diff --git a/common/include/Utilities/FixedPointTypes.inl b/common/include/Utilities/FixedPointTypes.inl
index 06403f9558..248d2d2838 100644
--- a/common/include/Utilities/FixedPointTypes.inl
+++ b/common/include/Utilities/FixedPointTypes.inl
@@ -1,240 +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 .
- */
-
-#pragma once
-
-#include "FixedPointTypes.h"
-#include // for pow!
-
-template< int Precision >
-FixedInt::FixedInt()
-{
- Raw = 0;
-}
-
-template< int Precision >
-FixedInt::FixedInt( int signedval )
-{
- Raw = signedval * Precision;
-}
-
-template< int Precision >
-FixedInt::FixedInt( double doubval )
-{
- Raw = (int)(doubval * (double)Precision);
-}
-
-template< int Precision >
-FixedInt::FixedInt( float floval )
-{
- Raw = (int)(floval * (float)Precision);
-}
-
-template< int Precision >
-FixedInt FixedInt::operator+( const FixedInt& right ) const
-{
- return FixedInt().SetRaw( Raw + right.Raw );
-}
-
-template< int Precision >
-FixedInt FixedInt::operator-( const FixedInt& right ) const
-{
- return FixedInt().SetRaw( Raw + right.Raw );
-}
-
-template< int Precision >
-FixedInt& FixedInt::operator+=( const FixedInt& right )
-{
- return SetRaw( Raw + right.Raw );
-}
-
-template< int Precision >
-FixedInt& FixedInt::operator-=( const FixedInt& right )
-{
- return SetRaw( Raw + right.Raw );
-}
-
-template< int Precision >
-FixedInt& FixedInt::ConfineTo( const FixedInt& low, const FixedInt& 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 FixedInt::operator*( const FixedInt& right ) const
-{
- s64 mulres = (s64)Raw * right.Raw;
- return FixedInt().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 FixedInt::operator/( const FixedInt& right ) const
-{
- s64 divres = Raw * Precision;
- return FixedInt().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& FixedInt::operator*=( const FixedInt& 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& FixedInt::operator/=( const FixedInt& 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::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::OverflowCheck( double signedval )
-{
- return ( signedval >= (INT_MAX / Precision) );
-}
-
-template< int Precision > int FixedInt::GetWhole() const { return Raw / Precision; }
-template< int Precision > int FixedInt::GetFraction() const { return Raw % Precision; }
-
-template< int Precision >
-FixedInt& FixedInt::SetRaw( s32 rawsrc )
-{
- Raw = rawsrc;
- return *this;
-}
-
-template< int Precision >
-FixedInt& FixedInt::Round()
-{
- Raw = ToIntRounded();
- return *this;
-}
-
-template< int Precision >
-FixedInt& FixedInt::SetWhole( s32 wholepart )
-{
- pxAssert( wholepart < (INT_MAX / Precision) );
- Raw = GetFraction() + (wholepart * Precision);
- return *this;
-}
-
-template< int Precision >
-FixedInt& FixedInt::SetFraction( u32 fracpart )
-{
- Raw = (GetWhole() * Precision) + fracpart;
- return *this;
-}
-
-template< int Precision >
-wxString FixedInt::ToString() const
-{
- return wxsFormat( L"%d.%d", GetWhole(), (GetFraction() * 100) / Precision );
-}
-
-template< int Precision >
-wxString FixedInt::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::ToDouble() const
-{
- return ((double)Raw / (double)Precision);
-}
-
-template< int Precision >
-float FixedInt::ToFloat() const
-{
- return ((float)Raw / (float)Precision);
-}
-
-template< int Precision >
-int FixedInt::ToIntTruncated() const
-{
- return Raw / Precision;
-}
-
-template< int Precision >
-int FixedInt::ToIntRounded() const
-{
- return (Raw + (Precision/2)) / Precision;
-}
-
-template< int Precision >
-bool FixedInt::TryFromString( FixedInt& 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 FixedInt::FromString( const wxString& parseFrom, const FixedInt& defval )
-{
- FixedInt 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 FixedInt::FromString( const wxString parseFrom )
-{
- FixedInt dest;
- if( !TryFromString( dest, parseFrom ) ) throw Exception::ParseError()
- .SetDiagMsg(wxsFormat(L"Parse error on FixedInt<%d>::FromString", Precision));
-
- return dest;
-}
+/* 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 .
+ */
+
+#pragma once
+
+#include "FixedPointTypes.h"
+#include // for pow!
+
+template< int Precision >
+FixedInt::FixedInt()
+{
+ Raw = 0;
+}
+
+template< int Precision >
+FixedInt::FixedInt( int signedval )
+{
+ Raw = signedval * Precision;
+}
+
+template< int Precision >
+FixedInt::FixedInt( double doubval )
+{
+ Raw = (int)(doubval * (double)Precision);
+}
+
+template< int Precision >
+FixedInt::FixedInt( float floval )
+{
+ Raw = (int)(floval * (float)Precision);
+}
+
+template< int Precision >
+FixedInt FixedInt::operator+( const FixedInt& right ) const
+{
+ return FixedInt().SetRaw( Raw + right.Raw );
+}
+
+template< int Precision >
+FixedInt FixedInt::operator-( const FixedInt& right ) const
+{
+ return FixedInt().SetRaw( Raw + right.Raw );
+}
+
+template< int Precision >
+FixedInt& FixedInt::operator+=( const FixedInt& right )
+{
+ return SetRaw( Raw + right.Raw );
+}
+
+template< int Precision >
+FixedInt& FixedInt::operator-=( const FixedInt& right )
+{
+ return SetRaw( Raw + right.Raw );
+}
+
+template< int Precision >
+FixedInt& FixedInt::ConfineTo( const FixedInt& low, const FixedInt& 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 FixedInt::operator*( const FixedInt& right ) const
+{
+ s64 mulres = (s64)Raw * right.Raw;
+ return FixedInt().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 FixedInt::operator/( const FixedInt& right ) const
+{
+ s64 divres = Raw * Precision;
+ return FixedInt().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& FixedInt::operator*=( const FixedInt& 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& FixedInt::operator/=( const FixedInt& 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::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::OverflowCheck( double signedval )
+{
+ return ( signedval >= (INT_MAX / Precision) );
+}
+
+template< int Precision > int FixedInt::GetWhole() const { return Raw / Precision; }
+template< int Precision > int FixedInt::GetFraction() const { return Raw % Precision; }
+
+template< int Precision >
+FixedInt& FixedInt::SetRaw( s32 rawsrc )
+{
+ Raw = rawsrc;
+ return *this;
+}
+
+template< int Precision >
+FixedInt& FixedInt::Round()
+{
+ Raw = ToIntRounded();
+ return *this;
+}
+
+template< int Precision >
+FixedInt& FixedInt::SetWhole( s32 wholepart )
+{
+ pxAssert( wholepart < (INT_MAX / Precision) );
+ Raw = GetFraction() + (wholepart * Precision);
+ return *this;
+}
+
+template< int Precision >
+FixedInt& FixedInt::SetFraction( u32 fracpart )
+{
+ Raw = (GetWhole() * Precision) + fracpart;
+ return *this;
+}
+
+template< int Precision >
+wxString FixedInt::ToString() const
+{
+ return wxsFormat( L"%d.%d", GetWhole(), (GetFraction() * 100) / Precision );
+}
+
+template< int Precision >
+wxString FixedInt::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::ToDouble() const
+{
+ return ((double)Raw / (double)Precision);
+}
+
+template< int Precision >
+float FixedInt::ToFloat() const
+{
+ return ((float)Raw / (float)Precision);
+}
+
+template< int Precision >
+int FixedInt::ToIntTruncated() const
+{
+ return Raw / Precision;
+}
+
+template< int Precision >
+int FixedInt::ToIntRounded() const
+{
+ return (Raw + (Precision/2)) / Precision;
+}
+
+template< int Precision >
+bool FixedInt::TryFromString( FixedInt& 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 FixedInt::FromString( const wxString& parseFrom, const FixedInt& defval )
+{
+ FixedInt 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 FixedInt::FromString( const wxString parseFrom )
+{
+ FixedInt dest;
+ if( !TryFromString( dest, parseFrom ) ) throw Exception::ParseError()
+ .SetDiagMsg(wxsFormat(L"Parse error on FixedInt<%d>::FromString", Precision));
+
+ return dest;
+}
diff --git a/common/include/Utilities/RwMutex.h b/common/include/Utilities/RwMutex.h
index 334df921a8..444040e9ed 100644
--- a/common/include/Utilities/RwMutex.h
+++ b/common/include/Utilities/RwMutex.h
@@ -1,90 +1,90 @@
-/* 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 .
- */
-
-#pragma once
-
-#include "Threading.h"
-
-namespace Threading
-{
-// --------------------------------------------------------------------------------------
-// RwMutex
-// --------------------------------------------------------------------------------------
- class RwMutex
- {
- DeclareNoncopyableObject(RwMutex);
-
- protected:
- pthread_rwlock_t m_rwlock;
-
- public:
- RwMutex();
- virtual ~RwMutex() throw();
-
- virtual void AcquireRead();
- virtual void AcquireWrite();
- virtual bool TryAcquireRead();
- virtual bool TryAcquireWrite();
-
- virtual void Release();
- };
-
-// --------------------------------------------------------------------------------------
-// BaseScopedReadWriteLock
-// --------------------------------------------------------------------------------------
- class BaseScopedReadWriteLock
- {
- DeclareNoncopyableObject(BaseScopedReadWriteLock);
-
- protected:
- RwMutex& m_lock;
- bool m_IsLocked;
-
- public:
- BaseScopedReadWriteLock( RwMutex& locker )
- : m_lock( locker )
- {
- }
-
- virtual ~BaseScopedReadWriteLock() throw();
-
- void Release();
- bool IsLocked() const { return m_IsLocked; }
- };
-
-// --------------------------------------------------------------------------------------
-// ScopedReadLock / ScopedWriteLock
-// --------------------------------------------------------------------------------------
- class ScopedReadLock : public BaseScopedReadWriteLock
- {
- public:
- ScopedReadLock( RwMutex& locker );
- virtual ~ScopedReadLock() throw() {}
-
- void Acquire();
- };
-
- class ScopedWriteLock : public BaseScopedReadWriteLock
- {
- public:
- ScopedWriteLock( RwMutex& locker );
- virtual ~ScopedWriteLock() throw() {}
-
- void Acquire();
-
- protected:
- ScopedWriteLock( RwMutex& locker, bool isTryLock );
- };
-}
+/* 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 .
+ */
+
+#pragma once
+
+#include "Threading.h"
+
+namespace Threading
+{
+// --------------------------------------------------------------------------------------
+// RwMutex
+// --------------------------------------------------------------------------------------
+ class RwMutex
+ {
+ DeclareNoncopyableObject(RwMutex);
+
+ protected:
+ pthread_rwlock_t m_rwlock;
+
+ public:
+ RwMutex();
+ virtual ~RwMutex() throw();
+
+ virtual void AcquireRead();
+ virtual void AcquireWrite();
+ virtual bool TryAcquireRead();
+ virtual bool TryAcquireWrite();
+
+ virtual void Release();
+ };
+
+// --------------------------------------------------------------------------------------
+// BaseScopedReadWriteLock
+// --------------------------------------------------------------------------------------
+ class BaseScopedReadWriteLock
+ {
+ DeclareNoncopyableObject(BaseScopedReadWriteLock);
+
+ protected:
+ RwMutex& m_lock;
+ bool m_IsLocked;
+
+ public:
+ BaseScopedReadWriteLock( RwMutex& locker )
+ : m_lock( locker )
+ {
+ }
+
+ virtual ~BaseScopedReadWriteLock() throw();
+
+ void Release();
+ bool IsLocked() const { return m_IsLocked; }
+ };
+
+// --------------------------------------------------------------------------------------
+// ScopedReadLock / ScopedWriteLock
+// --------------------------------------------------------------------------------------
+ class ScopedReadLock : public BaseScopedReadWriteLock
+ {
+ public:
+ ScopedReadLock( RwMutex& locker );
+ virtual ~ScopedReadLock() throw() {}
+
+ void Acquire();
+ };
+
+ class ScopedWriteLock : public BaseScopedReadWriteLock
+ {
+ public:
+ ScopedWriteLock( RwMutex& locker );
+ virtual ~ScopedWriteLock() throw() {}
+
+ void Acquire();
+
+ protected:
+ ScopedWriteLock( RwMutex& locker, bool isTryLock );
+ };
+}
diff --git a/common/include/Utilities/ThreadingDialogs.h b/common/include/Utilities/ThreadingDialogs.h
index 37776c87fd..478462080f 100644
--- a/common/include/Utilities/ThreadingDialogs.h
+++ b/common/include/Utilities/ThreadingDialogs.h
@@ -1,55 +1,55 @@
-/* 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 .
- */
-
-#pragma once
-
-#include "Threading.h"
-#include "wxAppWithHelpers.h"
-
-BEGIN_DECLARE_EVENT_TYPES()
- DECLARE_EVENT_TYPE(pxEvt_ThreadedTaskComplete, -1)
-END_DECLARE_EVENT_TYPES()
-
-namespace Threading
-{
- // --------------------------------------------------------------------------------------
- // WaitForTaskDialog
- // --------------------------------------------------------------------------------------
- // This dialog is displayed whenever the main thread is recursively waiting on multiple
- // mutexes or semaphores. wxwidgets does not support recursive yielding to pending events
- // but it *does* support opening a modal dialog, which disables the interface (preventing
- // the user from starting additional actions), and processes messages (allowing the system
- // to continue to manage threads and process logging).
- //
- class WaitForTaskDialog : public wxDialogWithHelpers
- {
- DECLARE_DYNAMIC_CLASS_NO_COPY(WaitForTaskDialog)
-
- typedef wxDialogWithHelpers _parent;
-
- protected:
- SynchronousActionState m_sync;
-
- public:
- WaitForTaskDialog( const wxString& title=wxEmptyString, const wxString& heading=wxEmptyString );
- virtual ~WaitForTaskDialog() throw() {}
- virtual int ShowModal();
-
- protected:
- void OnTaskComplete( wxCommandEvent& evt );
- //void OnTimer( wxTimerEvent& evt );
- };
-
-}
+/* 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 .
+ */
+
+#pragma once
+
+#include "Threading.h"
+#include "wxAppWithHelpers.h"
+
+BEGIN_DECLARE_EVENT_TYPES()
+ DECLARE_EVENT_TYPE(pxEvt_ThreadedTaskComplete, -1)
+END_DECLARE_EVENT_TYPES()
+
+namespace Threading
+{
+ // --------------------------------------------------------------------------------------
+ // WaitForTaskDialog
+ // --------------------------------------------------------------------------------------
+ // This dialog is displayed whenever the main thread is recursively waiting on multiple
+ // mutexes or semaphores. wxwidgets does not support recursive yielding to pending events
+ // but it *does* support opening a modal dialog, which disables the interface (preventing
+ // the user from starting additional actions), and processes messages (allowing the system
+ // to continue to manage threads and process logging).
+ //
+ class WaitForTaskDialog : public wxDialogWithHelpers
+ {
+ DECLARE_DYNAMIC_CLASS_NO_COPY(WaitForTaskDialog)
+
+ typedef wxDialogWithHelpers _parent;
+
+ protected:
+ SynchronousActionState m_sync;
+
+ public:
+ WaitForTaskDialog( const wxString& title=wxEmptyString, const wxString& heading=wxEmptyString );
+ virtual ~WaitForTaskDialog() throw() {}
+ virtual int ShowModal();
+
+ protected:
+ void OnTaskComplete( wxCommandEvent& evt );
+ //void OnTimer( wxTimerEvent& evt );
+ };
+
+}
diff --git a/common/include/Utilities/pxEvents.h b/common/include/Utilities/pxEvents.h
index d07894e609..4582f46170 100644
--- a/common/include/Utilities/pxEvents.h
+++ b/common/include/Utilities/pxEvents.h
@@ -1,368 +1,368 @@
-/* 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 .
- */
-
-#pragma once
-
-BEGIN_DECLARE_EVENT_TYPES()
- DECLARE_EVENT_TYPE( pxEvt_StartIdleEventTimer, -1 )
- DECLARE_EVENT_TYPE( pxEvt_DeleteObject, -1 )
- DECLARE_EVENT_TYPE( pxEvt_DeleteThread, -1 )
- DECLARE_EVENT_TYPE( pxEvt_InvokeAction, -1 )
- DECLARE_EVENT_TYPE( pxEvt_SynchronousCommand, -1 )
-END_DECLARE_EVENT_TYPES()
-
-typedef void FnType_Void();
-
-// --------------------------------------------------------------------------------------
-// SynchronousActionState
-// --------------------------------------------------------------------------------------
-class SynchronousActionState
-{
- DeclareNoncopyableObject( SynchronousActionState );
-
-protected:
- bool m_posted;
- Threading::Semaphore m_sema;
- ScopedExcept m_exception;
-
-public:
- sptr return_value;
-
- SynchronousActionState()
- {
- m_posted = false;
- return_value = 0;
- }
-
- virtual ~SynchronousActionState() throw() {}
-
- void SetException( const BaseException& ex );
- void SetException( BaseException* ex );
-
- Threading::Semaphore& GetSemaphore() { return m_sema; }
- const Threading::Semaphore& GetSemaphore() const { return m_sema; }
-
- void RethrowException() const;
- int WaitForResult();
- int WaitForResult_NoExceptions();
- void PostResult( int res );
- void ClearResult();
- void PostResult();
-};
-
-
-// --------------------------------------------------------------------------------------
-// pxSimpleEvent - non-abstract implementation of wxEvent
-// --------------------------------------------------------------------------------------
-// Why? I mean, why is wxEvent abstract? Over-designed OO is such a bad habit. And while
-// I'm on my high horse (and it's so very high!), why use 'private'? Ever? Seriously, it
-// sucks. Stop using it, people.
-//
-class pxSimpleEvent : public wxEvent
-{
- DECLARE_DYNAMIC_CLASS_NO_ASSIGN(pxSimpleEvent)
-
-public:
- explicit pxSimpleEvent( int evtid=0 )
- : wxEvent(0, evtid)
- { }
-
- pxSimpleEvent( wxWindowID winId, int evtid )
- : wxEvent(winId, evtid)
- { }
-
- virtual wxEvent *Clone() const { return new pxSimpleEvent(*this); }
-};
-
-// --------------------------------------------------------------------------------------
-// pxActionEvent
-// --------------------------------------------------------------------------------------
-class pxActionEvent : public wxEvent
-{
- DECLARE_DYNAMIC_CLASS_NO_ASSIGN(pxActionEvent)
-
-protected:
- SynchronousActionState* m_state;
-
-public:
- virtual ~pxActionEvent() throw() { }
- virtual pxActionEvent *Clone() const { return new pxActionEvent(*this); }
-
- explicit pxActionEvent( SynchronousActionState* sema=NULL, int msgtype=pxEvt_InvokeAction );
- explicit pxActionEvent( SynchronousActionState& sema, int msgtype=pxEvt_InvokeAction );
- pxActionEvent( const pxActionEvent& src );
-
- Threading::Semaphore* GetSemaphore() const { return m_state ? &m_state->GetSemaphore() : NULL; }
-
- const SynchronousActionState* GetSyncState() const { return m_state; }
- SynchronousActionState* GetSyncState() { return m_state; }
-
- void SetSyncState( SynchronousActionState* obj ) { m_state = obj; }
- void SetSyncState( SynchronousActionState& obj ) { m_state = &obj; }
-
- virtual void SetException( BaseException* ex );
- void SetException( const BaseException& ex );
-
- virtual void _DoInvokeEvent();
-
-protected:
- // Extending classes should implement this method to perfoem whatever action it is
- // the event is supposed to do. :) Thread affinity is garaunteed to be the Main/UI
- // thread, and exceptions will be handled automatically.
- //
- // Exception note: exceptions are passed back to the thread that posted the event
- // to the queue, when possible. If the calling thread is not blocking for a result
- // from this event, then the exception will be posted to the Main/UI thread instead.
- virtual void InvokeEvent() {}
-};
-
-
-// --------------------------------------------------------------------------------------
-// pxExceptionEvent
-// --------------------------------------------------------------------------------------
-class pxExceptionEvent : public pxActionEvent
-{
- typedef pxActionEvent _parent;
-
-protected:
- BaseException* m_except;
-
-public:
- pxExceptionEvent( BaseException* ex=NULL )
- {
- m_except = ex;
- }
-
- pxExceptionEvent( const BaseException& ex );
-
- virtual ~pxExceptionEvent() throw()
- {
- }
-
- virtual pxExceptionEvent *Clone() const { return new pxExceptionEvent(*this); }
-
-protected:
- void InvokeEvent();
-};
-
-// --------------------------------------------------------------------------------------
-// pxSynchronousCommandEvent
-// --------------------------------------------------------------------------------------
-
-class pxSynchronousCommandEvent : public wxCommandEvent
-{
- DECLARE_DYNAMIC_CLASS_NO_ASSIGN(pxSynchronousCommandEvent)
-
-protected:
- SynchronousActionState* m_sync;
- wxEventType m_realEvent;
-
-public:
- virtual ~pxSynchronousCommandEvent() throw() { }
- virtual pxSynchronousCommandEvent *Clone() const { return new pxSynchronousCommandEvent(*this); }
-
- pxSynchronousCommandEvent(SynchronousActionState* sema=NULL, wxEventType commandType = wxEVT_NULL, int winid = 0);
- pxSynchronousCommandEvent(SynchronousActionState& sema, wxEventType commandType = wxEVT_NULL, int winid = 0);
-
- pxSynchronousCommandEvent(SynchronousActionState* sema, const wxCommandEvent& evt);
- pxSynchronousCommandEvent(SynchronousActionState& sema, const wxCommandEvent& evt);
-
- pxSynchronousCommandEvent(const pxSynchronousCommandEvent& src);
-
- Threading::Semaphore* GetSemaphore() { return m_sync ? &m_sync->GetSemaphore() : NULL; }
- wxEventType GetRealEventType() const { return m_realEvent; }
-
- void SetException( BaseException* ex );
- void SetException( const BaseException& ex );
-};
-
-// --------------------------------------------------------------------------------------
-// BaseMessageBoxEvent
-// --------------------------------------------------------------------------------------
-class BaseMessageBoxEvent : public pxActionEvent
-{
- typedef pxActionEvent _parent;
- DECLARE_DYNAMIC_CLASS_NO_ASSIGN(BaseMessageBoxEvent)
-
-protected:
- wxString m_Content;
-
-public:
- virtual ~BaseMessageBoxEvent() throw() { }
- virtual BaseMessageBoxEvent *Clone() const { return new BaseMessageBoxEvent(*this); }
-
- explicit BaseMessageBoxEvent( const wxString& content=wxEmptyString, SynchronousActionState* instdata=NULL );
- BaseMessageBoxEvent( const wxString& content, SynchronousActionState& instdata );
- BaseMessageBoxEvent( const BaseMessageBoxEvent& event );
-
-protected:
- virtual void InvokeEvent();
- virtual int _DoDialog() const;
-};
-
-// --------------------------------------------------------------------------------------
-// MsgButtons
-// --------------------------------------------------------------------------------------
-class MsgButtons
-{
-protected:
- BITFIELD32()
- bool
- m_OK :1,
- m_Cancel :1,
- m_Yes :1,
- m_No :1,
- m_AllowToAll:1,
- m_Apply :1,
- m_Abort :1,
- m_Retry :1,
- m_Ignore :1,
- m_Reset :1,
- m_Close :1;
- BITFIELD_END
-
- wxString m_CustomLabel;
- wxString m_CustomLabelId;
-
-public:
- MsgButtons() { bitset = 0; }
-
- MsgButtons& OK() { m_OK = true; return *this; }
- MsgButtons& Cancel() { m_Cancel = true; return *this; }
- MsgButtons& Apply() { m_Apply = true; return *this; }
- MsgButtons& Yes() { m_Yes = true; return *this; }
- MsgButtons& No() { m_No = true; return *this; }
- MsgButtons& ToAll() { m_AllowToAll = true; return *this; }
-
- MsgButtons& Abort() { m_Abort = true; return *this; }
- MsgButtons& Retry() { m_Retry = true; return *this; }
- MsgButtons& Ignore() { m_Ignore = true; return *this; }
- MsgButtons& Reset() { m_Reset = true; return *this; }
- MsgButtons& Close() { m_Close = true; return *this; }
-
- // label - native language label displayed to user
- // id - raw ASCII identifier used in the config file (do not translate, hence char*)
- MsgButtons& Custom( const wxString& label, const char* id )
- {
- m_CustomLabel = label;
- m_CustomLabelId = fromUTF8(id);
- return *this;
- }
-
- MsgButtons& OKCancel() { m_OK = m_Cancel = true; return *this; }
- MsgButtons& YesNo() { m_Yes = m_No = true; return *this; }
-
- bool HasOK() const { return m_OK; }
- bool HasCancel() const { return m_Cancel; }
- bool HasApply() const { return m_Apply; }
- bool HasYes() const { return m_Yes; }
- bool HasNo() const { return m_No; }
- bool AllowsToAll() const{ return m_AllowToAll; }
-
- bool HasAbort() const { return m_Abort; }
- bool HasRetry() const { return m_Retry; }
- bool HasIgnore() const { return m_Ignore; }
- bool HasReset() const { return m_Reset; }
- bool HasClose() const { return m_Close; }
-
- bool HasCustom() const { return !m_CustomLabel.IsEmpty(); }
- const wxString& GetCustomLabel() const { return m_CustomLabel; }
- const wxString& GetCustomLabelId() const { return m_CustomLabelId; }
-
- bool Allows( wxWindowID id ) const;
- void SetBestFocus( wxWindow* dialog ) const;
- void SetBestFocus( wxWindow& dialog ) const;
-
- bool operator ==( const MsgButtons& right ) const
- {
- return OpEqu( bitset );
- }
-
- bool operator !=( const MsgButtons& right ) const
- {
- return !OpEqu( bitset );
- }
-};
-
-// --------------------------------------------------------------------------------------
-// pxMessageBoxEvent
-// --------------------------------------------------------------------------------------
-// This event type is used to transfer message boxes to the main UI thread, and return the
-// result of the box. It's the only way a message box can be issued from non-main threads
-// with complete safety in wx2.8.
-//
-// For simplicity sake this message box only supports two basic designs. The main design
-// is a generic message box with confirmation buttons of your choosing. Additionally you
-// can specify a "scrollableContent" text string, which is added into a read-only richtext
-// control similar to the console logs and such.
-//
-// Future consideration: If wxWidgets 3.0 has improved thread safety, then it should probably
-// be reasonable for it to work with a more flexable model where the dialog can be created
-// on a child thread, passed to the main thread, where ShowModal() is run (keeping the nested
-// message pumps on the main thread where they belong). But so far this is not possible,
-// because of various subtle issues in wx2.8 design.
-//
-class pxMessageBoxEvent : public BaseMessageBoxEvent
-{
- typedef BaseMessageBoxEvent _parent;
- DECLARE_DYNAMIC_CLASS_NO_ASSIGN(pxMessageBoxEvent)
-
-protected:
- wxString m_Title;
- MsgButtons m_Buttons;
-
-public:
- virtual ~pxMessageBoxEvent() throw() { }
- virtual pxMessageBoxEvent *Clone() const { return new pxMessageBoxEvent(*this); }
-
- pxMessageBoxEvent() {}
- pxMessageBoxEvent( const wxString& title, const wxString& content, const MsgButtons& buttons, SynchronousActionState& instdata );
- pxMessageBoxEvent( const wxString& title, const wxString& content, const MsgButtons& buttons, SynchronousActionState* instdata=NULL );
- pxMessageBoxEvent( const pxMessageBoxEvent& event );
-
-protected:
- int _DoDialog() const;
-};
-
-// --------------------------------------------------------------------------------------
-// pxAssertionEvent
-// --------------------------------------------------------------------------------------
-class pxAssertionEvent : public BaseMessageBoxEvent
-{
- typedef BaseMessageBoxEvent _parent;
- DECLARE_DYNAMIC_CLASS_NO_ASSIGN( pxAssertionEvent )
-
-protected:
- wxString m_Stacktrace;
-
-public:
- virtual ~pxAssertionEvent() throw() { }
- virtual pxAssertionEvent *Clone() const { return new pxAssertionEvent(*this); }
-
- pxAssertionEvent( const wxString& content=wxEmptyString, const wxString& trace=wxEmptyString, SynchronousActionState* instdata=NULL );
- pxAssertionEvent( const wxString& content, const wxString& trace, SynchronousActionState& instdata );
- pxAssertionEvent( const pxAssertionEvent& event );
-
- pxAssertionEvent& SetStacktrace( const wxString& trace );
-
-protected:
- int _DoDialog() const;
-};
-
-
-typedef void (wxEvtHandler::*pxSyncronousEventFunction)(pxSynchronousCommandEvent&);
-
-#define pxSynchronousEventHandler(func) \
- (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(pxSyncronousEventFunction, &func )
+/* 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 .
+ */
+
+#pragma once
+
+BEGIN_DECLARE_EVENT_TYPES()
+ DECLARE_EVENT_TYPE( pxEvt_StartIdleEventTimer, -1 )
+ DECLARE_EVENT_TYPE( pxEvt_DeleteObject, -1 )
+ DECLARE_EVENT_TYPE( pxEvt_DeleteThread, -1 )
+ DECLARE_EVENT_TYPE( pxEvt_InvokeAction, -1 )
+ DECLARE_EVENT_TYPE( pxEvt_SynchronousCommand, -1 )
+END_DECLARE_EVENT_TYPES()
+
+typedef void FnType_Void();
+
+// --------------------------------------------------------------------------------------
+// SynchronousActionState
+// --------------------------------------------------------------------------------------
+class SynchronousActionState
+{
+ DeclareNoncopyableObject( SynchronousActionState );
+
+protected:
+ bool m_posted;
+ Threading::Semaphore m_sema;
+ ScopedExcept m_exception;
+
+public:
+ sptr return_value;
+
+ SynchronousActionState()
+ {
+ m_posted = false;
+ return_value = 0;
+ }
+
+ virtual ~SynchronousActionState() throw() {}
+
+ void SetException( const BaseException& ex );
+ void SetException( BaseException* ex );
+
+ Threading::Semaphore& GetSemaphore() { return m_sema; }
+ const Threading::Semaphore& GetSemaphore() const { return m_sema; }
+
+ void RethrowException() const;
+ int WaitForResult();
+ int WaitForResult_NoExceptions();
+ void PostResult( int res );
+ void ClearResult();
+ void PostResult();
+};
+
+
+// --------------------------------------------------------------------------------------
+// pxSimpleEvent - non-abstract implementation of wxEvent
+// --------------------------------------------------------------------------------------
+// Why? I mean, why is wxEvent abstract? Over-designed OO is such a bad habit. And while
+// I'm on my high horse (and it's so very high!), why use 'private'? Ever? Seriously, it
+// sucks. Stop using it, people.
+//
+class pxSimpleEvent : public wxEvent
+{
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(pxSimpleEvent)
+
+public:
+ explicit pxSimpleEvent( int evtid=0 )
+ : wxEvent(0, evtid)
+ { }
+
+ pxSimpleEvent( wxWindowID winId, int evtid )
+ : wxEvent(winId, evtid)
+ { }
+
+ virtual wxEvent *Clone() const { return new pxSimpleEvent(*this); }
+};
+
+// --------------------------------------------------------------------------------------
+// pxActionEvent
+// --------------------------------------------------------------------------------------
+class pxActionEvent : public wxEvent
+{
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(pxActionEvent)
+
+protected:
+ SynchronousActionState* m_state;
+
+public:
+ virtual ~pxActionEvent() throw() { }
+ virtual pxActionEvent *Clone() const { return new pxActionEvent(*this); }
+
+ explicit pxActionEvent( SynchronousActionState* sema=NULL, int msgtype=pxEvt_InvokeAction );
+ explicit pxActionEvent( SynchronousActionState& sema, int msgtype=pxEvt_InvokeAction );
+ pxActionEvent( const pxActionEvent& src );
+
+ Threading::Semaphore* GetSemaphore() const { return m_state ? &m_state->GetSemaphore() : NULL; }
+
+ const SynchronousActionState* GetSyncState() const { return m_state; }
+ SynchronousActionState* GetSyncState() { return m_state; }
+
+ void SetSyncState( SynchronousActionState* obj ) { m_state = obj; }
+ void SetSyncState( SynchronousActionState& obj ) { m_state = &obj; }
+
+ virtual void SetException( BaseException* ex );
+ void SetException( const BaseException& ex );
+
+ virtual void _DoInvokeEvent();
+
+protected:
+ // Extending classes should implement this method to perfoem whatever action it is
+ // the event is supposed to do. :) Thread affinity is garaunteed to be the Main/UI
+ // thread, and exceptions will be handled automatically.
+ //
+ // Exception note: exceptions are passed back to the thread that posted the event
+ // to the queue, when possible. If the calling thread is not blocking for a result
+ // from this event, then the exception will be posted to the Main/UI thread instead.
+ virtual void InvokeEvent() {}
+};
+
+
+// --------------------------------------------------------------------------------------
+// pxExceptionEvent
+// --------------------------------------------------------------------------------------
+class pxExceptionEvent : public pxActionEvent
+{
+ typedef pxActionEvent _parent;
+
+protected:
+ BaseException* m_except;
+
+public:
+ pxExceptionEvent( BaseException* ex=NULL )
+ {
+ m_except = ex;
+ }
+
+ pxExceptionEvent( const BaseException& ex );
+
+ virtual ~pxExceptionEvent() throw()
+ {
+ }
+
+ virtual pxExceptionEvent *Clone() const { return new pxExceptionEvent(*this); }
+
+protected:
+ void InvokeEvent();
+};
+
+// --------------------------------------------------------------------------------------
+// pxSynchronousCommandEvent
+// --------------------------------------------------------------------------------------
+
+class pxSynchronousCommandEvent : public wxCommandEvent
+{
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(pxSynchronousCommandEvent)
+
+protected:
+ SynchronousActionState* m_sync;
+ wxEventType m_realEvent;
+
+public:
+ virtual ~pxSynchronousCommandEvent() throw() { }
+ virtual pxSynchronousCommandEvent *Clone() const { return new pxSynchronousCommandEvent(*this); }
+
+ pxSynchronousCommandEvent(SynchronousActionState* sema=NULL, wxEventType commandType = wxEVT_NULL, int winid = 0);
+ pxSynchronousCommandEvent(SynchronousActionState& sema, wxEventType commandType = wxEVT_NULL, int winid = 0);
+
+ pxSynchronousCommandEvent(SynchronousActionState* sema, const wxCommandEvent& evt);
+ pxSynchronousCommandEvent(SynchronousActionState& sema, const wxCommandEvent& evt);
+
+ pxSynchronousCommandEvent(const pxSynchronousCommandEvent& src);
+
+ Threading::Semaphore* GetSemaphore() { return m_sync ? &m_sync->GetSemaphore() : NULL; }
+ wxEventType GetRealEventType() const { return m_realEvent; }
+
+ void SetException( BaseException* ex );
+ void SetException( const BaseException& ex );
+};
+
+// --------------------------------------------------------------------------------------
+// BaseMessageBoxEvent
+// --------------------------------------------------------------------------------------
+class BaseMessageBoxEvent : public pxActionEvent
+{
+ typedef pxActionEvent _parent;
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(BaseMessageBoxEvent)
+
+protected:
+ wxString m_Content;
+
+public:
+ virtual ~BaseMessageBoxEvent() throw() { }
+ virtual BaseMessageBoxEvent *Clone() const { return new BaseMessageBoxEvent(*this); }
+
+ explicit BaseMessageBoxEvent( const wxString& content=wxEmptyString, SynchronousActionState* instdata=NULL );
+ BaseMessageBoxEvent( const wxString& content, SynchronousActionState& instdata );
+ BaseMessageBoxEvent( const BaseMessageBoxEvent& event );
+
+protected:
+ virtual void InvokeEvent();
+ virtual int _DoDialog() const;
+};
+
+// --------------------------------------------------------------------------------------
+// MsgButtons
+// --------------------------------------------------------------------------------------
+class MsgButtons
+{
+protected:
+ BITFIELD32()
+ bool
+ m_OK :1,
+ m_Cancel :1,
+ m_Yes :1,
+ m_No :1,
+ m_AllowToAll:1,
+ m_Apply :1,
+ m_Abort :1,
+ m_Retry :1,
+ m_Ignore :1,
+ m_Reset :1,
+ m_Close :1;
+ BITFIELD_END
+
+ wxString m_CustomLabel;
+ wxString m_CustomLabelId;
+
+public:
+ MsgButtons() { bitset = 0; }
+
+ MsgButtons& OK() { m_OK = true; return *this; }
+ MsgButtons& Cancel() { m_Cancel = true; return *this; }
+ MsgButtons& Apply() { m_Apply = true; return *this; }
+ MsgButtons& Yes() { m_Yes = true; return *this; }
+ MsgButtons& No() { m_No = true; return *this; }
+ MsgButtons& ToAll() { m_AllowToAll = true; return *this; }
+
+ MsgButtons& Abort() { m_Abort = true; return *this; }
+ MsgButtons& Retry() { m_Retry = true; return *this; }
+ MsgButtons& Ignore() { m_Ignore = true; return *this; }
+ MsgButtons& Reset() { m_Reset = true; return *this; }
+ MsgButtons& Close() { m_Close = true; return *this; }
+
+ // label - native language label displayed to user
+ // id - raw ASCII identifier used in the config file (do not translate, hence char*)
+ MsgButtons& Custom( const wxString& label, const char* id )
+ {
+ m_CustomLabel = label;
+ m_CustomLabelId = fromUTF8(id);
+ return *this;
+ }
+
+ MsgButtons& OKCancel() { m_OK = m_Cancel = true; return *this; }
+ MsgButtons& YesNo() { m_Yes = m_No = true; return *this; }
+
+ bool HasOK() const { return m_OK; }
+ bool HasCancel() const { return m_Cancel; }
+ bool HasApply() const { return m_Apply; }
+ bool HasYes() const { return m_Yes; }
+ bool HasNo() const { return m_No; }
+ bool AllowsToAll() const{ return m_AllowToAll; }
+
+ bool HasAbort() const { return m_Abort; }
+ bool HasRetry() const { return m_Retry; }
+ bool HasIgnore() const { return m_Ignore; }
+ bool HasReset() const { return m_Reset; }
+ bool HasClose() const { return m_Close; }
+
+ bool HasCustom() const { return !m_CustomLabel.IsEmpty(); }
+ const wxString& GetCustomLabel() const { return m_CustomLabel; }
+ const wxString& GetCustomLabelId() const { return m_CustomLabelId; }
+
+ bool Allows( wxWindowID id ) const;
+ void SetBestFocus( wxWindow* dialog ) const;
+ void SetBestFocus( wxWindow& dialog ) const;
+
+ bool operator ==( const MsgButtons& right ) const
+ {
+ return OpEqu( bitset );
+ }
+
+ bool operator !=( const MsgButtons& right ) const
+ {
+ return !OpEqu( bitset );
+ }
+};
+
+// --------------------------------------------------------------------------------------
+// pxMessageBoxEvent
+// --------------------------------------------------------------------------------------
+// This event type is used to transfer message boxes to the main UI thread, and return the
+// result of the box. It's the only way a message box can be issued from non-main threads
+// with complete safety in wx2.8.
+//
+// For simplicity sake this message box only supports two basic designs. The main design
+// is a generic message box with confirmation buttons of your choosing. Additionally you
+// can specify a "scrollableContent" text string, which is added into a read-only richtext
+// control similar to the console logs and such.
+//
+// Future consideration: If wxWidgets 3.0 has improved thread safety, then it should probably
+// be reasonable for it to work with a more flexable model where the dialog can be created
+// on a child thread, passed to the main thread, where ShowModal() is run (keeping the nested
+// message pumps on the main thread where they belong). But so far this is not possible,
+// because of various subtle issues in wx2.8 design.
+//
+class pxMessageBoxEvent : public BaseMessageBoxEvent
+{
+ typedef BaseMessageBoxEvent _parent;
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(pxMessageBoxEvent)
+
+protected:
+ wxString m_Title;
+ MsgButtons m_Buttons;
+
+public:
+ virtual ~pxMessageBoxEvent() throw() { }
+ virtual pxMessageBoxEvent *Clone() const { return new pxMessageBoxEvent(*this); }
+
+ pxMessageBoxEvent() {}
+ pxMessageBoxEvent( const wxString& title, const wxString& content, const MsgButtons& buttons, SynchronousActionState& instdata );
+ pxMessageBoxEvent( const wxString& title, const wxString& content, const MsgButtons& buttons, SynchronousActionState* instdata=NULL );
+ pxMessageBoxEvent( const pxMessageBoxEvent& event );
+
+protected:
+ int _DoDialog() const;
+};
+
+// --------------------------------------------------------------------------------------
+// pxAssertionEvent
+// --------------------------------------------------------------------------------------
+class pxAssertionEvent : public BaseMessageBoxEvent
+{
+ typedef BaseMessageBoxEvent _parent;
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN( pxAssertionEvent )
+
+protected:
+ wxString m_Stacktrace;
+
+public:
+ virtual ~pxAssertionEvent() throw() { }
+ virtual pxAssertionEvent *Clone() const { return new pxAssertionEvent(*this); }
+
+ pxAssertionEvent( const wxString& content=wxEmptyString, const wxString& trace=wxEmptyString, SynchronousActionState* instdata=NULL );
+ pxAssertionEvent( const wxString& content, const wxString& trace, SynchronousActionState& instdata );
+ pxAssertionEvent( const pxAssertionEvent& event );
+
+ pxAssertionEvent& SetStacktrace( const wxString& trace );
+
+protected:
+ int _DoDialog() const;
+};
+
+
+typedef void (wxEvtHandler::*pxSyncronousEventFunction)(pxSynchronousCommandEvent&);
+
+#define pxSynchronousEventHandler(func) \
+ (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(pxSyncronousEventFunction, &func )
diff --git a/common/include/Utilities/pxForwardDefs.h b/common/include/Utilities/pxForwardDefs.h
index e2e11be3e0..72904a695c 100644
--- a/common/include/Utilities/pxForwardDefs.h
+++ b/common/include/Utilities/pxForwardDefs.h
@@ -1,51 +1,51 @@
-/* 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 .
- */
-
-#pragma once
-
-// --------------------------------------------------------------------------------------
-// Forward Declarations Section
-// --------------------------------------------------------------------------------------
-
-class wxOutputStream;
-class wxFileOutputStream;
-class wxFFileOutputStream;
-
-class wxStreamBase;
-class wxInputStream;
-class wxFileInputStream;
-class wxFFileInputStream;
-
-class wxPoint;
-class wxRect;
-class wxSize;
-
-class pxInputStream;
-class pxOutputStream;
-
-extern const wxSize wxDefaultSize;
-extern const wxPoint wxDefaultPosition;
-
-namespace Threading
-{
- class Mutex;
- class Semaphore;
- class pxThread;
-}
-
-namespace Exception
-{
- class BaseException;
-}
+/* 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 .
+ */
+
+#pragma once
+
+// --------------------------------------------------------------------------------------
+// Forward Declarations Section
+// --------------------------------------------------------------------------------------
+
+class wxOutputStream;
+class wxFileOutputStream;
+class wxFFileOutputStream;
+
+class wxStreamBase;
+class wxInputStream;
+class wxFileInputStream;
+class wxFFileInputStream;
+
+class wxPoint;
+class wxRect;
+class wxSize;
+
+class pxInputStream;
+class pxOutputStream;
+
+extern const wxSize wxDefaultSize;
+extern const wxPoint wxDefaultPosition;
+
+namespace Threading
+{
+ class Mutex;
+ class Semaphore;
+ class pxThread;
+}
+
+namespace Exception
+{
+ class BaseException;
+}
diff --git a/common/include/Utilities/pxStreams.h b/common/include/Utilities/pxStreams.h
index d4a8117586..4d99b7eb56 100644
--- a/common/include/Utilities/pxStreams.h
+++ b/common/include/Utilities/pxStreams.h
@@ -1,116 +1,116 @@
-/* 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 .
- */
-
-#pragma once
-
-#include "wx/filefn.h"
-
-// --------------------------------------------------------------------------------------
-// pxStreamBase
-// --------------------------------------------------------------------------------------
-class pxStreamBase
-{
- DeclareNoncopyableObject(pxStreamBase);
-
-protected:
- // Filename of the stream, provided by the creator/caller. This is typically used *only*
- // for generating comprehensive error messages when an error occurs (the stream name is
- // passed to the exception handlers).
- wxString m_filename;
-
-public:
- pxStreamBase(const wxString& filename);
- virtual ~pxStreamBase() throw() {}
-
- // Implementing classes should return the base wxStream object (usually either a wxInputStream
- // or wxOputStream derivative).
- virtual wxStreamBase* GetWxStreamBase() const=0;
- virtual void Close()=0;
- virtual wxFileOffset Tell() const=0;
- virtual wxFileOffset Seek( wxFileOffset ofs, wxSeekMode mode = wxFromStart )=0;
-
- virtual wxFileOffset Length() const;
- bool IsOk() const;
- wxString GetStreamName() const { return m_filename; }
-};
-
-
-// --------------------------------------------------------------------------------------
-// pxOutputStream
-// --------------------------------------------------------------------------------------
-class pxOutputStream : public pxStreamBase
-{
- DeclareNoncopyableObject(pxOutputStream);
-
-protected:
- ScopedPtr m_stream_out;
-
-public:
- pxOutputStream(const wxString& filename, ScopedPtr& output);
- pxOutputStream(const wxString& filename, wxOutputStream* output);
-
- virtual ~pxOutputStream() throw() {}
- virtual void Write( const void* data, size_t size );
-
- void SetStream( const wxString& filename, ScopedPtr& stream );
- void SetStream( const wxString& filename, wxOutputStream* stream );
-
- void Close() { m_stream_out.Delete(); }
-
- virtual wxStreamBase* GetWxStreamBase() const;
-
- template< typename T >
- void Write( const T& data )
- {
- Write( &data, sizeof(data) );
- }
-
- wxFileOffset Tell() const;
- wxFileOffset Seek( wxFileOffset ofs, wxSeekMode mode = wxFromStart );
-};
-
-// --------------------------------------------------------------------------------------
-// pxInputStream
-// --------------------------------------------------------------------------------------
-class pxInputStream : public pxStreamBase
-{
- DeclareNoncopyableObject(pxInputStream);
-
-protected:
- ScopedPtr m_stream_in;
-
-public:
- pxInputStream(const wxString& filename, ScopedPtr& input);
- pxInputStream(const wxString& filename, wxInputStream* input);
-
- virtual ~pxInputStream() throw() {}
- virtual void Read( void* dest, size_t size );
-
- void SetStream( const wxString& filename, ScopedPtr& stream );
- void SetStream( const wxString& filename, wxInputStream* stream );
-
- void Close() { m_stream_in.Delete(); }
-
- virtual wxStreamBase* GetWxStreamBase() const;
-
- template< typename T >
- void Read( T& dest )
- {
- Read( &dest, sizeof(dest) );
- }
-
- wxFileOffset Tell() const;
- wxFileOffset Seek( wxFileOffset ofs, wxSeekMode mode = wxFromStart );
-};
+/* 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 .
+ */
+
+#pragma once
+
+#include "wx/filefn.h"
+
+// --------------------------------------------------------------------------------------
+// pxStreamBase
+// --------------------------------------------------------------------------------------
+class pxStreamBase
+{
+ DeclareNoncopyableObject(pxStreamBase);
+
+protected:
+ // Filename of the stream, provided by the creator/caller. This is typically used *only*
+ // for generating comprehensive error messages when an error occurs (the stream name is
+ // passed to the exception handlers).
+ wxString m_filename;
+
+public:
+ pxStreamBase(const wxString& filename);
+ virtual ~pxStreamBase() throw() {}
+
+ // Implementing classes should return the base wxStream object (usually either a wxInputStream
+ // or wxOputStream derivative).
+ virtual wxStreamBase* GetWxStreamBase() const=0;
+ virtual void Close()=0;
+ virtual wxFileOffset Tell() const=0;
+ virtual wxFileOffset Seek( wxFileOffset ofs, wxSeekMode mode = wxFromStart )=0;
+
+ virtual wxFileOffset Length() const;
+ bool IsOk() const;
+ wxString GetStreamName() const { return m_filename; }
+};
+
+
+// --------------------------------------------------------------------------------------
+// pxOutputStream
+// --------------------------------------------------------------------------------------
+class pxOutputStream : public pxStreamBase
+{
+ DeclareNoncopyableObject(pxOutputStream);
+
+protected:
+ ScopedPtr m_stream_out;
+
+public:
+ pxOutputStream(const wxString& filename, ScopedPtr& output);
+ pxOutputStream(const wxString& filename, wxOutputStream* output);
+
+ virtual ~pxOutputStream() throw() {}
+ virtual void Write( const void* data, size_t size );
+
+ void SetStream( const wxString& filename, ScopedPtr& stream );
+ void SetStream( const wxString& filename, wxOutputStream* stream );
+
+ void Close() { m_stream_out.Delete(); }
+
+ virtual wxStreamBase* GetWxStreamBase() const;
+
+ template< typename T >
+ void Write( const T& data )
+ {
+ Write( &data, sizeof(data) );
+ }
+
+ wxFileOffset Tell() const;
+ wxFileOffset Seek( wxFileOffset ofs, wxSeekMode mode = wxFromStart );
+};
+
+// --------------------------------------------------------------------------------------
+// pxInputStream
+// --------------------------------------------------------------------------------------
+class pxInputStream : public pxStreamBase
+{
+ DeclareNoncopyableObject(pxInputStream);
+
+protected:
+ ScopedPtr m_stream_in;
+
+public:
+ pxInputStream(const wxString& filename, ScopedPtr& input);
+ pxInputStream(const wxString& filename, wxInputStream* input);
+
+ virtual ~pxInputStream() throw() {}
+ virtual void Read( void* dest, size_t size );
+
+ void SetStream( const wxString& filename, ScopedPtr& stream );
+ void SetStream( const wxString& filename, wxInputStream* stream );
+
+ void Close() { m_stream_in.Delete(); }
+
+ virtual wxStreamBase* GetWxStreamBase() const;
+
+ template< typename T >
+ void Read( T& dest )
+ {
+ Read( &dest, sizeof(dest) );
+ }
+
+ wxFileOffset Tell() const;
+ wxFileOffset Seek( wxFileOffset ofs, wxSeekMode mode = wxFromStart );
+};
diff --git a/common/src/Utilities/RwMutex.cpp b/common/src/Utilities/RwMutex.cpp
index 95a9396097..bab4f7ff03 100644
--- a/common/src/Utilities/RwMutex.cpp
+++ b/common/src/Utilities/RwMutex.cpp
@@ -1,112 +1,112 @@
-/* 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 .
- */
-
-#include "PrecompiledHeader.h"
-#include "RwMutex.h"
-
-// --------------------------------------------------------------------------------------
-// RwMutex
-// --------------------------------------------------------------------------------------
-Threading::RwMutex::RwMutex()
-{
- pthread_rwlock_init( &m_rwlock, NULL );
-}
-
-Threading::RwMutex::~RwMutex() throw()
-{
- pthread_rwlock_destroy( &m_rwlock );
-}
-
-void Threading::RwMutex::AcquireRead()
-{
- pthread_rwlock_rdlock( &m_rwlock );
-}
-
-void Threading::RwMutex::AcquireWrite()
-{
- pthread_rwlock_wrlock( &m_rwlock );
-}
-
-bool Threading::RwMutex::TryAcquireRead()
-{
- return pthread_rwlock_tryrdlock( &m_rwlock ) != EBUSY;
-}
-
-bool Threading::RwMutex::TryAcquireWrite()
-{
- return pthread_rwlock_trywrlock( &m_rwlock ) != EBUSY;
-}
-
-void Threading::RwMutex::Release()
-{
- pthread_rwlock_unlock( &m_rwlock );
-}
-
-// --------------------------------------------------------------------------------------
-//
-// --------------------------------------------------------------------------------------
-Threading::BaseScopedReadWriteLock::~BaseScopedReadWriteLock() throw()
-{
- if( m_IsLocked )
- m_lock.Release();
-}
-
-// Provides manual unlocking of a scoped lock prior to object destruction.
-void Threading::BaseScopedReadWriteLock::Release()
-{
- if( !m_IsLocked ) return;
- m_IsLocked = false;
- m_lock.Release();
-}
-
-// --------------------------------------------------------------------------------------
-// ScopedReadLock / ScopedWriteLock
-// --------------------------------------------------------------------------------------
-Threading::ScopedReadLock::ScopedReadLock( RwMutex& locker )
- : BaseScopedReadWriteLock( locker )
-{
- m_IsLocked = true;
- m_lock.AcquireRead();
-}
-
-// provides manual locking of a scoped lock, to re-lock after a manual unlocking.
-void Threading::ScopedReadLock::Acquire()
-{
- if( m_IsLocked ) return;
- m_lock.AcquireRead();
- m_IsLocked = true;
-}
-
-Threading::ScopedWriteLock::ScopedWriteLock( RwMutex& locker )
- : BaseScopedReadWriteLock( locker )
-{
- m_IsLocked = true;
- m_lock.AcquireWrite();
-}
-
-// provides manual locking of a scoped lock, to re-lock after a manual unlocking.
-void Threading::ScopedWriteLock::Acquire()
-{
- if( m_IsLocked ) return;
- m_lock.AcquireWrite();
- m_IsLocked = true;
-}
-
-// Special constructor used by ScopedTryLock
-Threading::ScopedWriteLock::ScopedWriteLock( RwMutex& locker, bool isTryLock )
- : BaseScopedReadWriteLock( locker )
-{
- //m_IsLocked = isTryLock ? m_lock.TryAcquireWrite() : false;
-}
+/* 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 .
+ */
+
+#include "PrecompiledHeader.h"
+#include "RwMutex.h"
+
+// --------------------------------------------------------------------------------------
+// RwMutex
+// --------------------------------------------------------------------------------------
+Threading::RwMutex::RwMutex()
+{
+ pthread_rwlock_init( &m_rwlock, NULL );
+}
+
+Threading::RwMutex::~RwMutex() throw()
+{
+ pthread_rwlock_destroy( &m_rwlock );
+}
+
+void Threading::RwMutex::AcquireRead()
+{
+ pthread_rwlock_rdlock( &m_rwlock );
+}
+
+void Threading::RwMutex::AcquireWrite()
+{
+ pthread_rwlock_wrlock( &m_rwlock );
+}
+
+bool Threading::RwMutex::TryAcquireRead()
+{
+ return pthread_rwlock_tryrdlock( &m_rwlock ) != EBUSY;
+}
+
+bool Threading::RwMutex::TryAcquireWrite()
+{
+ return pthread_rwlock_trywrlock( &m_rwlock ) != EBUSY;
+}
+
+void Threading::RwMutex::Release()
+{
+ pthread_rwlock_unlock( &m_rwlock );
+}
+
+// --------------------------------------------------------------------------------------
+//
+// --------------------------------------------------------------------------------------
+Threading::BaseScopedReadWriteLock::~BaseScopedReadWriteLock() throw()
+{
+ if( m_IsLocked )
+ m_lock.Release();
+}
+
+// Provides manual unlocking of a scoped lock prior to object destruction.
+void Threading::BaseScopedReadWriteLock::Release()
+{
+ if( !m_IsLocked ) return;
+ m_IsLocked = false;
+ m_lock.Release();
+}
+
+// --------------------------------------------------------------------------------------
+// ScopedReadLock / ScopedWriteLock
+// --------------------------------------------------------------------------------------
+Threading::ScopedReadLock::ScopedReadLock( RwMutex& locker )
+ : BaseScopedReadWriteLock( locker )
+{
+ m_IsLocked = true;
+ m_lock.AcquireRead();
+}
+
+// provides manual locking of a scoped lock, to re-lock after a manual unlocking.
+void Threading::ScopedReadLock::Acquire()
+{
+ if( m_IsLocked ) return;
+ m_lock.AcquireRead();
+ m_IsLocked = true;
+}
+
+Threading::ScopedWriteLock::ScopedWriteLock( RwMutex& locker )
+ : BaseScopedReadWriteLock( locker )
+{
+ m_IsLocked = true;
+ m_lock.AcquireWrite();
+}
+
+// provides manual locking of a scoped lock, to re-lock after a manual unlocking.
+void Threading::ScopedWriteLock::Acquire()
+{
+ if( m_IsLocked ) return;
+ m_lock.AcquireWrite();
+ m_IsLocked = true;
+}
+
+// Special constructor used by ScopedTryLock
+Threading::ScopedWriteLock::ScopedWriteLock( RwMutex& locker, bool isTryLock )
+ : BaseScopedReadWriteLock( locker )
+{
+ //m_IsLocked = isTryLock ? m_lock.TryAcquireWrite() : false;
+}
diff --git a/common/src/Utilities/ThreadingDialogs.cpp b/common/src/Utilities/ThreadingDialogs.cpp
index 198dc2a303..0601dc066d 100644
--- a/common/src/Utilities/ThreadingDialogs.cpp
+++ b/common/src/Utilities/ThreadingDialogs.cpp
@@ -1,83 +1,83 @@
-/* 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 .
- */
-
-#include "PrecompiledHeader.h"
-#include "ThreadingDialogs.h"
-#include "pxStaticText.h"
-
-using namespace pxSizerFlags;
-
-DEFINE_EVENT_TYPE(pxEvt_ThreadedTaskComplete);
-
-// --------------------------------------------------------------------------------------
-// WaitForTaskDialog Implementations
-// --------------------------------------------------------------------------------------
-IMPLEMENT_DYNAMIC_CLASS(WaitForTaskDialog, wxDialogWithHelpers)
-
-Threading::WaitForTaskDialog::WaitForTaskDialog( const wxString& title, const wxString& heading )
- : wxDialogWithHelpers( NULL, _("Waiting for tasks...") )
- //, m_Timer(this)
-{
- SetMinWidth( 300 );
-
- //m_sem = sem;
- //m_mutex = mutex;
-
- wxString m_title( title );
- wxString m_heading( heading );
-
- if( m_title.IsEmpty() ) m_title = _("Waiting for task...");
- if( m_heading.IsEmpty() ) m_heading = m_title;
-
- Connect( pxEvt_ThreadedTaskComplete, wxCommandEventHandler(WaitForTaskDialog::OnTaskComplete) );
-
- *this += 12;
- *this += Heading(m_heading).Unwrapped() | StdExpand();
- *this += 12;
-
- // TODO : Implement a cancel button. Not quite sure the best way to do
- // that, since it requires a thread or event handler context, or something.
-
- //applyDlg += new wxButton( &applyDlg, wxID_CANCEL ) | pxCenter;
- //applyDlg += 6;
-
- //Connect( m_Timer.GetId(), wxEVT_TIMER, wxTimerEventHandler(WaitForTaskDialog::OnTimer) );
- //m_Timer.Start( 200 );
- //GetSysExecutorThread().PostEvent( new SysExecEvent_ApplyPlugins( this, m_sync ) );
-}
-
-void Threading::WaitForTaskDialog::OnTaskComplete( wxCommandEvent& evt )
-{
- evt.Skip();
-
- // Note: we don't throw exceptions from the pending task here.
- // Instead we wait until we exit the modal loop below -- this gives
- // the caller a chance to handle the exception themselves, and if
- // not the exception will still fall back on the standard app-level
- // exception handler.
-
- // (this also avoids any sticky business with the modal dialog not getting
- // closed out right due to stack unwinding skipping dialog closure crap)
-
- m_sync.WaitForResult_NoExceptions();
- EndModal( wxID_OK );
-}
-
-int Threading::WaitForTaskDialog::ShowModal()
-{
- int result = _parent::ShowModal();
- m_sync.RethrowException();
- return result;
-}
+/* 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 .
+ */
+
+#include "PrecompiledHeader.h"
+#include "ThreadingDialogs.h"
+#include "pxStaticText.h"
+
+using namespace pxSizerFlags;
+
+DEFINE_EVENT_TYPE(pxEvt_ThreadedTaskComplete);
+
+// --------------------------------------------------------------------------------------
+// WaitForTaskDialog Implementations
+// --------------------------------------------------------------------------------------
+IMPLEMENT_DYNAMIC_CLASS(WaitForTaskDialog, wxDialogWithHelpers)
+
+Threading::WaitForTaskDialog::WaitForTaskDialog( const wxString& title, const wxString& heading )
+ : wxDialogWithHelpers( NULL, _("Waiting for tasks...") )
+ //, m_Timer(this)
+{
+ SetMinWidth( 300 );
+
+ //m_sem = sem;
+ //m_mutex = mutex;
+
+ wxString m_title( title );
+ wxString m_heading( heading );
+
+ if( m_title.IsEmpty() ) m_title = _("Waiting for task...");
+ if( m_heading.IsEmpty() ) m_heading = m_title;
+
+ Connect( pxEvt_ThreadedTaskComplete, wxCommandEventHandler(WaitForTaskDialog::OnTaskComplete) );
+
+ *this += 12;
+ *this += Heading(m_heading).Unwrapped() | StdExpand();
+ *this += 12;
+
+ // TODO : Implement a cancel button. Not quite sure the best way to do
+ // that, since it requires a thread or event handler context, or something.
+
+ //applyDlg += new wxButton( &applyDlg, wxID_CANCEL ) | pxCenter;
+ //applyDlg += 6;
+
+ //Connect( m_Timer.GetId(), wxEVT_TIMER, wxTimerEventHandler(WaitForTaskDialog::OnTimer) );
+ //m_Timer.Start( 200 );
+ //GetSysExecutorThread().PostEvent( new SysExecEvent_ApplyPlugins( this, m_sync ) );
+}
+
+void Threading::WaitForTaskDialog::OnTaskComplete( wxCommandEvent& evt )
+{
+ evt.Skip();
+
+ // Note: we don't throw exceptions from the pending task here.
+ // Instead we wait until we exit the modal loop below -- this gives
+ // the caller a chance to handle the exception themselves, and if
+ // not the exception will still fall back on the standard app-level
+ // exception handler.
+
+ // (this also avoids any sticky business with the modal dialog not getting
+ // closed out right due to stack unwinding skipping dialog closure crap)
+
+ m_sync.WaitForResult_NoExceptions();
+ EndModal( wxID_OK );
+}
+
+int Threading::WaitForTaskDialog::ShowModal()
+{
+ int result = _parent::ShowModal();
+ m_sync.RethrowException();
+ return result;
+}
diff --git a/common/src/Utilities/x86/MemcpyVibes.cpp b/common/src/Utilities/x86/MemcpyVibes.cpp
index e3b99b63af..d6a29f466d 100644
--- a/common/src/Utilities/x86/MemcpyVibes.cpp
+++ b/common/src/Utilities/x86/MemcpyVibes.cpp
@@ -1,250 +1,250 @@
-/* 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 .
- */
-
-#include "PrecompiledHeader.h"
-#include "x86emitter/x86emitter.h"
-#include
-
-using namespace x86Emitter;
-
-// Max Number of qwc supported
-#define _maxSize 0x400
-
-typedef void (__fastcall *_memCpyCall)(void*, void*);
-__aligned16 _memCpyCall _memcpy_vibes[_maxSize+1];
-
-#if 1
-
-// this version uses SSE intrinsics to perform an inline copy. MSVC disasm shows pretty
-// decent code generation on whole, but it hasn't been benchmarked at all yet --air
-__fi void memcpy_vibes(void * dest, const void * src, int size) {
-
- float (*destxmm)[4] = (float(*)[4])dest, (*srcxmm)[4] = (float(*)[4])src;
- size_t count = size & ~15, extra = size & 15;
-
- destxmm -= 8 - extra, srcxmm -= 8 - extra;
- switch (extra) {
- do {
- destxmm += 16, srcxmm += 16, count -= 16;
- _mm_store_ps(&destxmm[-8][0], _mm_load_ps(&srcxmm[-8][0]));
- case 15:
- _mm_store_ps(&destxmm[-7][0], _mm_load_ps(&srcxmm[-7][0]));
- case 14:
- _mm_store_ps(&destxmm[-6][0], _mm_load_ps(&srcxmm[-6][0]));
- case 13:
- _mm_store_ps(&destxmm[-5][0], _mm_load_ps(&srcxmm[-5][0]));
- case 12:
- _mm_store_ps(&destxmm[-4][0], _mm_load_ps(&srcxmm[-4][0]));
- case 11:
- _mm_store_ps(&destxmm[-3][0], _mm_load_ps(&srcxmm[-3][0]));
- case 10:
- _mm_store_ps(&destxmm[-2][0], _mm_load_ps(&srcxmm[-2][0]));
- case 9:
- _mm_store_ps(&destxmm[-1][0], _mm_load_ps(&srcxmm[-1][0]));
- case 8:
- _mm_store_ps(&destxmm[ 0][0], _mm_load_ps(&srcxmm[ 0][0]));
- case 7:
- _mm_store_ps(&destxmm[ 1][0], _mm_load_ps(&srcxmm[ 1][0]));
- case 6:
- _mm_store_ps(&destxmm[ 2][0], _mm_load_ps(&srcxmm[ 2][0]));
- case 5:
- _mm_store_ps(&destxmm[ 3][0], _mm_load_ps(&srcxmm[ 3][0]));
- case 4:
- _mm_store_ps(&destxmm[ 4][0], _mm_load_ps(&srcxmm[ 4][0]));
- case 3:
- _mm_store_ps(&destxmm[ 5][0], _mm_load_ps(&srcxmm[ 5][0]));
- case 2:
- _mm_store_ps(&destxmm[ 6][0], _mm_load_ps(&srcxmm[ 6][0]));
- case 1:
- _mm_store_ps(&destxmm[ 7][0], _mm_load_ps(&srcxmm[ 7][0]));
- case 0: NULL;
- } while (count);
- }
-}
-
-#else
-#if 1
-// This version creates one function with a lot of movaps
-// It jumps to the correct movaps entry-point while adding
-// the proper offset for adjustment...
-
-static __pagealigned u8 _memCpyExec[__pagesize*16];
-
-void gen_memcpy_vibes() {
- HostSys::MemProtectStatic(_memCpyExec, Protect_ReadWrite, false);
- memset (_memCpyExec, 0xcc, sizeof(_memCpyExec));
- xSetPtr(_memCpyExec);
-
- int off =-(((_maxSize & 0xf) - 7) << 4);
- for (int i = _maxSize, x = 0; i > 0; i--, x=(x+1)&7, off+=16) {
-
- _memcpy_vibes[i] = (_memCpyCall)xGetPtr();
-
- if (off >= 128) {
- off = -128;
- xADD(edx, 256);
- xADD(ecx, 256);
- }
- const xRegisterSSE xmm_t(x);
- xMOVAPS (xmm_t, ptr32[edx+off]);
- xMOVNTPS(ptr32[ecx+off], xmm_t);
- }
-
- _memcpy_vibes[0] = (_memCpyCall)xGetPtr();
-
- xRET();
- pxAssert(((uptr)xGetPtr() - (uptr)_memCpyExec) < sizeof(_memCpyExec));
-
- HostSys::MemProtectStatic(_memCpyExec, Protect_ReadOnly, true);
-}
-
-__fi void memcpy_vibes(void * dest, const void * src, int size) {
- int offset = ((size & 0xf) - 7) << 4;
- _memcpy_vibes[size]((void*)((uptr)dest + offset), (void*)((uptr)src + offset));
-}
-
-#else
-
-// This version creates '_maxSize' number of different functions,
-// and calls the appropriate one...
-
-static __pagealigned u8 _memCpyExec[__pagesize*_maxSize*2];
-
-void gen_memcpy_vibes() {
- HostSys::MemProtectStatic(_memCpyExec, Protect_ReadWrite, false);
- memset (_memCpyExec, 0xcc, sizeof(_memCpyExec));
- xSetPtr(_memCpyExec);
-
- for (int i = 0; i < _maxSize+1; i++)
- {
- int off = 0;
- _memcpy_vibes[i] = (_memCpyCall)xGetAlignedCallTarget();
-
- for (int j = 0, x = 0; j < i; j++, x=(x+1)&7, off+=16) {
- if (off >= 128) {
- off = -128;
- xADD(edx, 256);
- xADD(ecx, 256);
- }
- const xRegisterSSE xmm_t(x);
- xMOVAPS(xmm_t, ptr32[edx+off]);
- xMOVAPS(ptr32[ecx+off], xmm_t);
- }
-
- xRET();
- pxAssert(((uptr)xGetPtr() - (uptr)_memCpyExec) < sizeof(_memCpyExec));
- }
-
- HostSys::MemProtectStatic(_memCpyExec, Protect_ReadOnly, true);
-}
-
-__fi void memcpy_vibes(void * dest, const void * src, int size) {
- _memcpy_vibes[size](dest, src);
-}
-
-#endif
-#endif
-
-// Since MemcpyVibes is already in the project, I'll just tuck the Linux version of memcpy_amd_qwc here for the moment,
-// to get around compilation issues with having it in the headers.
-#ifdef __LINUX__
-
- // This can be moved later, but Linux doesn't even compile memcpyFast.cpp, so I figured I'd stick it here for now.
- // Quadword Copy! Count is in QWCs (128 bits). Neither source nor dest need to be aligned.
- __fi void memcpy_amd_qwc(void *dest, const void *src, size_t qwc)
- {
- // Optimization Analysis: This code is *nearly* optimal. Do not think that using XMM
- // registers will improve copy performance, because they won't. Use of XMMs is only
- // warranted in situations where both source and dest are guaranteed aligned to 16 bytes,
- // and even then the benefits are typically minimal (sometimes slower depending on the
- // amount of data being copied).
- //
- // Thus: MMX are alignment safe, fast, and widely available. Lets just stick with them.
- // --air
-
- // Linux Conversion note:
- // This code would benefit nicely from having inline-able GAS syntax, since it should
- // allow GCC to optimize the first 3 instructions out of existence in many scenarios.
- // And its called enough times to probably merit the extra effort to ensure proper
- // optimization. --air
-
- __asm__ __volatile__
- (
- ".intel_syntax noprefix\n"
- "sub %[qwc], 1\n" // dec the counter to ease the count of 16bytes block later (optimization)
- // Note after this line, real value of the counter is %[qwc] + 1
- "jle memcpy_qwc_1_%=\n" // only one 16 byte block to copy? Or nothing.
-
- "cmp %[qwc], 127\n" // "IN_CACHE_COPY/16"
- "jb memcpy_qwc_loop1_%=\n" // small copies should be cached (definite speedup --air)
-
- "memcpy_qwc_loop2_%=:\n" // 32-byte blocks, uncached copy
- "prefetchnta [%[src] + 568]\n" // start reading ahead (tested: it helps! --air)
-
- "movq mm0,[%[src]+0]\n" // read 64 bits
- "movq mm1,[%[src]+8]\n"
- "movq mm2,[%[src]+16]\n"
- "movntq [%[dest]+0], mm0\n" // write 64 bits, bypassing the cache
- "movntq [%[dest]+8], mm1\n"
- "movq mm3,[%[src]+24]\n"
- "movntq [%[dest]+16], mm2\n"
- "movntq [%[dest]+24], mm3\n"
-
- "add %[src],32\n" // update source pointer
- "add %[dest],32\n" // update destination pointer
- "sub %[qwc],2\n"
- "jg memcpy_qwc_loop2_%=\n" // last 64-byte block?
- "sfence\n" // flush the write buffer
- "jmp memcpy_qwc_1_%=\n"
-
- // 32-byte blocks, cached!
- // This *is* important. Removing this and using exclusively non-temporal stores
- // results in noticeable speed loss!
-
- "memcpy_qwc_loop1_%=:\n"
- "prefetchnta [%[src] + 568]\n" // start reading ahead (tested: it helps! --air)
-
- "movq mm0,[%[src]+0]\n" // read 64 bits
- "movq mm1,[%[src]+8]\n"
- "movq mm2,[%[src]+16]\n"
- "movq [%[dest]+0], mm0\n" // write 64 bits, bypassing the cache
- "movq [%[dest]+8], mm1\n"
- "movq mm3,[%[src]+24]\n"
- "movq [%[dest]+16], mm2\n"
- "movq [%[dest]+24], mm3\n"
-
- "add %[src],32\n" // update source pointer
- "add %[dest],32\n" // update destination pointer
- "sub %[qwc],2\n"
- "jg memcpy_qwc_loop2_%=\n" // last 64-byte block?
-
- "memcpy_qwc_1_%=:\n"
- "cmp %[qwc],0\n"
- "jne memcpy_qwc_final_%=\n"
- "movq mm0,[%[src]]\n"
- "movq mm1,[%[src]+8]\n"
- "movq [%[dest]], mm0\n"
- "movq [%[dest]+8], mm1\n"
-
- "memcpy_qwc_final_%=:\n"
- "emms\n" // clean up the MMX state
- ".att_syntax\n"
- : "=&r"(dest), "=&r"(src), "=&r"(qwc)
- : [dest]"0"(dest), [src]"1"(src), [qwc]"2"(qwc)
- : "memory", "mm0", "mm1", "mm2", "mm3"
- );
- }
-#endif
-
+/* 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 .
+ */
+
+#include "PrecompiledHeader.h"
+#include "x86emitter/x86emitter.h"
+#include
+
+using namespace x86Emitter;
+
+// Max Number of qwc supported
+#define _maxSize 0x400
+
+typedef void (__fastcall *_memCpyCall)(void*, void*);
+__aligned16 _memCpyCall _memcpy_vibes[_maxSize+1];
+
+#if 1
+
+// this version uses SSE intrinsics to perform an inline copy. MSVC disasm shows pretty
+// decent code generation on whole, but it hasn't been benchmarked at all yet --air
+__fi void memcpy_vibes(void * dest, const void * src, int size) {
+
+ float (*destxmm)[4] = (float(*)[4])dest, (*srcxmm)[4] = (float(*)[4])src;
+ size_t count = size & ~15, extra = size & 15;
+
+ destxmm -= 8 - extra, srcxmm -= 8 - extra;
+ switch (extra) {
+ do {
+ destxmm += 16, srcxmm += 16, count -= 16;
+ _mm_store_ps(&destxmm[-8][0], _mm_load_ps(&srcxmm[-8][0]));
+ case 15:
+ _mm_store_ps(&destxmm[-7][0], _mm_load_ps(&srcxmm[-7][0]));
+ case 14:
+ _mm_store_ps(&destxmm[-6][0], _mm_load_ps(&srcxmm[-6][0]));
+ case 13:
+ _mm_store_ps(&destxmm[-5][0], _mm_load_ps(&srcxmm[-5][0]));
+ case 12:
+ _mm_store_ps(&destxmm[-4][0], _mm_load_ps(&srcxmm[-4][0]));
+ case 11:
+ _mm_store_ps(&destxmm[-3][0], _mm_load_ps(&srcxmm[-3][0]));
+ case 10:
+ _mm_store_ps(&destxmm[-2][0], _mm_load_ps(&srcxmm[-2][0]));
+ case 9:
+ _mm_store_ps(&destxmm[-1][0], _mm_load_ps(&srcxmm[-1][0]));
+ case 8:
+ _mm_store_ps(&destxmm[ 0][0], _mm_load_ps(&srcxmm[ 0][0]));
+ case 7:
+ _mm_store_ps(&destxmm[ 1][0], _mm_load_ps(&srcxmm[ 1][0]));
+ case 6:
+ _mm_store_ps(&destxmm[ 2][0], _mm_load_ps(&srcxmm[ 2][0]));
+ case 5:
+ _mm_store_ps(&destxmm[ 3][0], _mm_load_ps(&srcxmm[ 3][0]));
+ case 4:
+ _mm_store_ps(&destxmm[ 4][0], _mm_load_ps(&srcxmm[ 4][0]));
+ case 3:
+ _mm_store_ps(&destxmm[ 5][0], _mm_load_ps(&srcxmm[ 5][0]));
+ case 2:
+ _mm_store_ps(&destxmm[ 6][0], _mm_load_ps(&srcxmm[ 6][0]));
+ case 1:
+ _mm_store_ps(&destxmm[ 7][0], _mm_load_ps(&srcxmm[ 7][0]));
+ case 0: NULL;
+ } while (count);
+ }
+}
+
+#else
+#if 1
+// This version creates one function with a lot of movaps
+// It jumps to the correct movaps entry-point while adding
+// the proper offset for adjustment...
+
+static __pagealigned u8 _memCpyExec[__pagesize*16];
+
+void gen_memcpy_vibes() {
+ HostSys::MemProtectStatic(_memCpyExec, Protect_ReadWrite, false);
+ memset (_memCpyExec, 0xcc, sizeof(_memCpyExec));
+ xSetPtr(_memCpyExec);
+
+ int off =-(((_maxSize & 0xf) - 7) << 4);
+ for (int i = _maxSize, x = 0; i > 0; i--, x=(x+1)&7, off+=16) {
+
+ _memcpy_vibes[i] = (_memCpyCall)xGetPtr();
+
+ if (off >= 128) {
+ off = -128;
+ xADD(edx, 256);
+ xADD(ecx, 256);
+ }
+ const xRegisterSSE xmm_t(x);
+ xMOVAPS (xmm_t, ptr32[edx+off]);
+ xMOVNTPS(ptr32[ecx+off], xmm_t);
+ }
+
+ _memcpy_vibes[0] = (_memCpyCall)xGetPtr();
+
+ xRET();
+ pxAssert(((uptr)xGetPtr() - (uptr)_memCpyExec) < sizeof(_memCpyExec));
+
+ HostSys::MemProtectStatic(_memCpyExec, Protect_ReadOnly, true);
+}
+
+__fi void memcpy_vibes(void * dest, const void * src, int size) {
+ int offset = ((size & 0xf) - 7) << 4;
+ _memcpy_vibes[size]((void*)((uptr)dest + offset), (void*)((uptr)src + offset));
+}
+
+#else
+
+// This version creates '_maxSize' number of different functions,
+// and calls the appropriate one...
+
+static __pagealigned u8 _memCpyExec[__pagesize*_maxSize*2];
+
+void gen_memcpy_vibes() {
+ HostSys::MemProtectStatic(_memCpyExec, Protect_ReadWrite, false);
+ memset (_memCpyExec, 0xcc, sizeof(_memCpyExec));
+ xSetPtr(_memCpyExec);
+
+ for (int i = 0; i < _maxSize+1; i++)
+ {
+ int off = 0;
+ _memcpy_vibes[i] = (_memCpyCall)xGetAlignedCallTarget();
+
+ for (int j = 0, x = 0; j < i; j++, x=(x+1)&7, off+=16) {
+ if (off >= 128) {
+ off = -128;
+ xADD(edx, 256);
+ xADD(ecx, 256);
+ }
+ const xRegisterSSE xmm_t(x);
+ xMOVAPS(xmm_t, ptr32[edx+off]);
+ xMOVAPS(ptr32[ecx+off], xmm_t);
+ }
+
+ xRET();
+ pxAssert(((uptr)xGetPtr() - (uptr)_memCpyExec) < sizeof(_memCpyExec));
+ }
+
+ HostSys::MemProtectStatic(_memCpyExec, Protect_ReadOnly, true);
+}
+
+__fi void memcpy_vibes(void * dest, const void * src, int size) {
+ _memcpy_vibes[size](dest, src);
+}
+
+#endif
+#endif
+
+// Since MemcpyVibes is already in the project, I'll just tuck the Linux version of memcpy_amd_qwc here for the moment,
+// to get around compilation issues with having it in the headers.
+#ifdef __LINUX__
+
+ // This can be moved later, but Linux doesn't even compile memcpyFast.cpp, so I figured I'd stick it here for now.
+ // Quadword Copy! Count is in QWCs (128 bits). Neither source nor dest need to be aligned.
+ __fi void memcpy_amd_qwc(void *dest, const void *src, size_t qwc)
+ {
+ // Optimization Analysis: This code is *nearly* optimal. Do not think that using XMM
+ // registers will improve copy performance, because they won't. Use of XMMs is only
+ // warranted in situations where both source and dest are guaranteed aligned to 16 bytes,
+ // and even then the benefits are typically minimal (sometimes slower depending on the
+ // amount of data being copied).
+ //
+ // Thus: MMX are alignment safe, fast, and widely available. Lets just stick with them.
+ // --air
+
+ // Linux Conversion note:
+ // This code would benefit nicely from having inline-able GAS syntax, since it should
+ // allow GCC to optimize the first 3 instructions out of existence in many scenarios.
+ // And its called enough times to probably merit the extra effort to ensure proper
+ // optimization. --air
+
+ __asm__ __volatile__
+ (
+ ".intel_syntax noprefix\n"
+ "sub %[qwc], 1\n" // dec the counter to ease the count of 16bytes block later (optimization)
+ // Note after this line, real value of the counter is %[qwc] + 1
+ "jle memcpy_qwc_1_%=\n" // only one 16 byte block to copy? Or nothing.
+
+ "cmp %[qwc], 127\n" // "IN_CACHE_COPY/16"
+ "jb memcpy_qwc_loop1_%=\n" // small copies should be cached (definite speedup --air)
+
+ "memcpy_qwc_loop2_%=:\n" // 32-byte blocks, uncached copy
+ "prefetchnta [%[src] + 568]\n" // start reading ahead (tested: it helps! --air)
+
+ "movq mm0,[%[src]+0]\n" // read 64 bits
+ "movq mm1,[%[src]+8]\n"
+ "movq mm2,[%[src]+16]\n"
+ "movntq [%[dest]+0], mm0\n" // write 64 bits, bypassing the cache
+ "movntq [%[dest]+8], mm1\n"
+ "movq mm3,[%[src]+24]\n"
+ "movntq [%[dest]+16], mm2\n"
+ "movntq [%[dest]+24], mm3\n"
+
+ "add %[src],32\n" // update source pointer
+ "add %[dest],32\n" // update destination pointer
+ "sub %[qwc],2\n"
+ "jg memcpy_qwc_loop2_%=\n" // last 64-byte block?
+ "sfence\n" // flush the write buffer
+ "jmp memcpy_qwc_1_%=\n"
+
+ // 32-byte blocks, cached!
+ // This *is* important. Removing this and using exclusively non-temporal stores
+ // results in noticeable speed loss!
+
+ "memcpy_qwc_loop1_%=:\n"
+ "prefetchnta [%[src] + 568]\n" // start reading ahead (tested: it helps! --air)
+
+ "movq mm0,[%[src]+0]\n" // read 64 bits
+ "movq mm1,[%[src]+8]\n"
+ "movq mm2,[%[src]+16]\n"
+ "movq [%[dest]+0], mm0\n" // write 64 bits, bypassing the cache
+ "movq [%[dest]+8], mm1\n"
+ "movq mm3,[%[src]+24]\n"
+ "movq [%[dest]+16], mm2\n"
+ "movq [%[dest]+24], mm3\n"
+
+ "add %[src],32\n" // update source pointer
+ "add %[dest],32\n" // update destination pointer
+ "sub %[qwc],2\n"
+ "jg memcpy_qwc_loop2_%=\n" // last 64-byte block?
+
+ "memcpy_qwc_1_%=:\n"
+ "cmp %[qwc],0\n"
+ "jne memcpy_qwc_final_%=\n"
+ "movq mm0,[%[src]]\n"
+ "movq mm1,[%[src]+8]\n"
+ "movq [%[dest]], mm0\n"
+ "movq [%[dest]+8], mm1\n"
+
+ "memcpy_qwc_final_%=:\n"
+ "emms\n" // clean up the MMX state
+ ".att_syntax\n"
+ : "=&r"(dest), "=&r"(src), "=&r"(qwc)
+ : [dest]"0"(dest), [src]"1"(src), [qwc]"2"(qwc)
+ : "memory", "mm0", "mm1", "mm2", "mm3"
+ );
+ }
+#endif
+
diff --git a/locales/locales.txt b/locales/locales.txt
index 525115fe0e..05f1a4d435 100644
--- a/locales/locales.txt
+++ b/locales/locales.txt
@@ -1,13 +1,13 @@
-Folder: /trunk/locales
-Contains: PO files for gettext language translations
-
-
-The PO files in this folder are the most current/up-to-date translations for any given revision
-of PCSX2. When checking out trunk, for example, these files are usually chasing a "moving
-target" that may have a number of language string changes from PO file contents. When checking
-out a stable release branch (such as 0.9.8) the PO files should be fairly stable and unchanging.
-
-In general it is recommended that translators focus time on perfecting stable releases, and
-contribute to trunk/dev-branch languages only if you're feeling eagar, or if PCSX2 devs have
-announced a scheduled stable release in the future (ie, requested translators to update and
-submit new PO files).
+Folder: /trunk/locales
+Contains: PO files for gettext language translations
+
+
+The PO files in this folder are the most current/up-to-date translations for any given revision
+of PCSX2. When checking out trunk, for example, these files are usually chasing a "moving
+target" that may have a number of language string changes from PO file contents. When checking
+out a stable release branch (such as 0.9.8) the PO files should be fairly stable and unchanging.
+
+In general it is recommended that translators focus time on perfecting stable releases, and
+contribute to trunk/dev-branch languages only if you're feeling eagar, or if PCSX2 devs have
+announced a scheduled stable release in the future (ie, requested translators to update and
+submit new PO files).
diff --git a/locales/templates/readme.txt b/locales/templates/readme.txt
index 9fddd86083..a2c1f1d67a 100644
--- a/locales/templates/readme.txt
+++ b/locales/templates/readme.txt
@@ -1,19 +1,19 @@
-
-PCSX2 Language Translation Templates (POT format)
--------------------------------------------------
-
-Quick overview of using POT files:
-
-POT files are essentially identical to PO files, except that they have no translated
-text strings filled in yet. Your job as a translator is to make copies of these files,
-give then .PO extensions, fill in the properly translated text for each string in the
-files, test, and then submit the new PO file to the PCSX2 Team.
-
-The PCSX2 Team recommends using Poedit to help make your life easier.
-
-Details on PCSX2's use of gettext, translation, and tesing/submitting new translations,
-visit our wiki at googlecode: https://code.google.com/p/pcsx2/wiki/TranslationGuide
-
-
-Jake Stine (Air)
+
+PCSX2 Language Translation Templates (POT format)
+-------------------------------------------------
+
+Quick overview of using POT files:
+
+POT files are essentially identical to PO files, except that they have no translated
+text strings filled in yet. Your job as a translator is to make copies of these files,
+give then .PO extensions, fill in the properly translated text for each string in the
+files, test, and then submit the new PO file to the PCSX2 Team.
+
+The PCSX2 Team recommends using Poedit to help make your life easier.
+
+Details on PCSX2's use of gettext, translation, and tesing/submitting new translations,
+visit our wiki at googlecode: https://code.google.com/p/pcsx2/wiki/TranslationGuide
+
+
+Jake Stine (Air)
PCSX2 Development Team
\ No newline at end of file
diff --git a/pcsx2/GameDatabase.cpp b/pcsx2/GameDatabase.cpp
index d69ab7e5d1..6e996918f4 100644
--- a/pcsx2/GameDatabase.cpp
+++ b/pcsx2/GameDatabase.cpp
@@ -1,149 +1,149 @@
-/* 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 .
- */
-
-#include "PrecompiledHeader.h"
-#include "GameDatabase.h"
-
-BaseGameDatabaseImpl::BaseGameDatabaseImpl()
- : gHash( 9400 )
- , m_baseKey( L"Serial" )
-{
- m_BlockTable.reserve(48);
-
- m_CurBlockWritePos = 0;
- m_BlockTableWritePos = 0;
-
- m_GamesPerBlock = 256;
-
- m_BlockTable.push_back(NULL);
-}
-
-BaseGameDatabaseImpl::~BaseGameDatabaseImpl() throw()
-{
- for(uint blockidx=0; blockidx<=m_BlockTableWritePos; ++blockidx)
- {
- if( !m_BlockTable[blockidx] ) continue;
-
- const uint endidx = (blockidx == m_BlockTableWritePos) ? m_CurBlockWritePos : m_GamesPerBlock;
-
- for( uint gameidx=0; gameidxsecond;
- return true;
-}
-
-Game_Data* BaseGameDatabaseImpl::createNewGame( const wxString& id )
-{
- if(!m_BlockTable[m_BlockTableWritePos])
- m_BlockTable[m_BlockTableWritePos] = (Game_Data*)malloc(m_GamesPerBlock * sizeof(Game_Data));
-
- Game_Data* block = m_BlockTable[m_BlockTableWritePos];
- Game_Data* retval = &block[m_CurBlockWritePos];
-
- gHash[id] = retval;
-
- new (retval) Game_Data(id);
-
- if( ++m_CurBlockWritePos >= m_GamesPerBlock )
- {
- ++m_BlockTableWritePos;
- m_CurBlockWritePos = 0;
- m_BlockTable.push_back(NULL);
- }
-
- return retval;
-}
-
-void BaseGameDatabaseImpl::updateGame(const Game_Data& game)
-{
- GameDataHash::const_iterator iter( gHash.find(game.id) );
-
- if( iter == gHash.end() ) {
- *(createNewGame( game.id )) = game;
- }
- else
- {
- // Re-assign existing vector/array entry!
- *gHash[game.id] = game;
- }
-}
-
-// Searches the current game's data to see if the given key exists
-bool Game_Data::keyExists(const wxChar* key) const {
- KeyPairArray::const_iterator it( kList.begin() );
- for ( ; it != kList.end(); ++it) {
- if (it->CompareKey(key)) {
- return true;
- }
- }
- return false;
-}
-
-// Totally Deletes the specified key/pair value from the current game's data
-void Game_Data::deleteKey(const wxChar* key) {
- KeyPairArray::iterator it( kList.begin() );
- for ( ; it != kList.end(); ++it) {
- if (it->CompareKey(key)) {
- kList.erase(it);
- return;
- }
- }
-}
-
-// Gets a string representation of the 'value' for the given key
-wxString Game_Data::getString(const wxChar* key) const {
- KeyPairArray::const_iterator it( kList.begin() );
- for ( ; it != kList.end(); ++it) {
- if (it->CompareKey(key)) {
- return it->value;
- }
- }
- return wxString();
-}
-
-void Game_Data::writeString(const wxString& key, const wxString& value) {
- KeyPairArray::iterator it( kList.begin() );
- for ( ; it != kList.end(); ++it) {
- if (it->CompareKey(key)) {
- if( value.IsEmpty() )
- kList.erase(it);
- else
- it->value = value;
- return;
- }
- }
- if( !value.IsEmpty() ) {
- kList.push_back(key_pair(key, value));
- }
-}
-
-// Write a bool value to the specified key
-void Game_Data::writeBool(const wxString& key, bool value) {
- writeString(key, value ? L"1" : L"0");
+/* 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 .
+ */
+
+#include "PrecompiledHeader.h"
+#include "GameDatabase.h"
+
+BaseGameDatabaseImpl::BaseGameDatabaseImpl()
+ : gHash( 9400 )
+ , m_baseKey( L"Serial" )
+{
+ m_BlockTable.reserve(48);
+
+ m_CurBlockWritePos = 0;
+ m_BlockTableWritePos = 0;
+
+ m_GamesPerBlock = 256;
+
+ m_BlockTable.push_back(NULL);
+}
+
+BaseGameDatabaseImpl::~BaseGameDatabaseImpl() throw()
+{
+ for(uint blockidx=0; blockidx<=m_BlockTableWritePos; ++blockidx)
+ {
+ if( !m_BlockTable[blockidx] ) continue;
+
+ const uint endidx = (blockidx == m_BlockTableWritePos) ? m_CurBlockWritePos : m_GamesPerBlock;
+
+ for( uint gameidx=0; gameidxsecond;
+ return true;
+}
+
+Game_Data* BaseGameDatabaseImpl::createNewGame( const wxString& id )
+{
+ if(!m_BlockTable[m_BlockTableWritePos])
+ m_BlockTable[m_BlockTableWritePos] = (Game_Data*)malloc(m_GamesPerBlock * sizeof(Game_Data));
+
+ Game_Data* block = m_BlockTable[m_BlockTableWritePos];
+ Game_Data* retval = &block[m_CurBlockWritePos];
+
+ gHash[id] = retval;
+
+ new (retval) Game_Data(id);
+
+ if( ++m_CurBlockWritePos >= m_GamesPerBlock )
+ {
+ ++m_BlockTableWritePos;
+ m_CurBlockWritePos = 0;
+ m_BlockTable.push_back(NULL);
+ }
+
+ return retval;
+}
+
+void BaseGameDatabaseImpl::updateGame(const Game_Data& game)
+{
+ GameDataHash::const_iterator iter( gHash.find(game.id) );
+
+ if( iter == gHash.end() ) {
+ *(createNewGame( game.id )) = game;
+ }
+ else
+ {
+ // Re-assign existing vector/array entry!
+ *gHash[game.id] = game;
+ }
+}
+
+// Searches the current game's data to see if the given key exists
+bool Game_Data::keyExists(const wxChar* key) const {
+ KeyPairArray::const_iterator it( kList.begin() );
+ for ( ; it != kList.end(); ++it) {
+ if (it->CompareKey(key)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+// Totally Deletes the specified key/pair value from the current game's data
+void Game_Data::deleteKey(const wxChar* key) {
+ KeyPairArray::iterator it( kList.begin() );
+ for ( ; it != kList.end(); ++it) {
+ if (it->CompareKey(key)) {
+ kList.erase(it);
+ return;
+ }
+ }
+}
+
+// Gets a string representation of the 'value' for the given key
+wxString Game_Data::getString(const wxChar* key) const {
+ KeyPairArray::const_iterator it( kList.begin() );
+ for ( ; it != kList.end(); ++it) {
+ if (it->CompareKey(key)) {
+ return it->value;
+ }
+ }
+ return wxString();
+}
+
+void Game_Data::writeString(const wxString& key, const wxString& value) {
+ KeyPairArray::iterator it( kList.begin() );
+ for ( ; it != kList.end(); ++it) {
+ if (it->CompareKey(key)) {
+ if( value.IsEmpty() )
+ kList.erase(it);
+ else
+ it->value = value;
+ return;
+ }
+ }
+ if( !value.IsEmpty() ) {
+ kList.push_back(key_pair(key, value));
+ }
+}
+
+// Write a bool value to the specified key
+void Game_Data::writeBool(const wxString& key, bool value) {
+ writeString(key, value ? L"1" : L"0");
}
\ No newline at end of file
diff --git a/pcsx2/IPU/yuv2rgb.asm b/pcsx2/IPU/yuv2rgb.asm
index c5714205ea..7b0bd7dbeb 100644
--- a/pcsx2/IPU/yuv2rgb.asm
+++ b/pcsx2/IPU/yuv2rgb.asm
@@ -1,242 +1,242 @@
-;/********************************************************
-; * Some code. Copyright (C) 2003 by Pascal Massimino. *
-; * All Rights Reserved. (http://skal.planet-d.net) *
-; * For Educational/Academic use ONLY. See 'LICENSE.TXT'.*
-; ********************************************************/
-;//////////////////////////////////////////////////////////
-;// NASM macros
-;//////////////////////////////////////////////////////////
-
-%ifdef LINUX
-
-;//////////////////////////////////////////////////////////
-; LINUX / egcs / macros
-;//////////////////////////////////////////////////////////
-
-%macro extrn 1
- extern %1
- %define %1 %1
-%endmacro
-%macro globl 1
- global %1
- %define %1 %1
-%endmacro
-
-%macro DATA 0
-[section data align=16 write alloc USE32]
-%endmacro
-%macro TEXT 0
-[section text align=16 nowrite alloc exec USE32]
-%endmacro
-
-%endif ; LINUX
-
-;//////////////////////////////////////////////////////////
-
-%ifdef WIN32
-
-%macro extrn 1
- extern _%1
- %define %1 _%1
-%endmacro
-
-%macro globl 1
- global _%1
- %define %1 _%1
-%endmacro
-
-%macro DATA 0
-[section .data align=16 write alloc USE32]
-%endmacro
-%macro TEXT 0
-[section .text align=16 nowrite alloc exec USE32]
-%endmacro
-
-%endif ; WIN32
-
-;//////////////////////////////////////////////////////////
-;
-; MACRO for timing. NASM.
-; Total additional code size is 0xb0.
-; this keep code alignment right.
-
-extrn Skl_Cur_Count_
-extrn Skl_Print_Tics
-
-%macro SKL_USE_RDSTC 0
-extrn SKL_RDTSC_0_ASM
-extrn SKL_RDTSC_1_ASM
-extrn SKL_RDTSC_2_ASM
-%endmacro
-%define SKL_RDTSC_OFFSET 15 ; check value with skl_rdtsc.h...
-
-%macro SKL_RDTSC_IN 0
- SKL_USE_RDSTC
- call SKL_RDTSC_0_ASM
-.Skl_RDTSC_Loop_:
- call SKL_RDTSC_1_ASM
-%endmacro
-
-%macro SKL_RDTSC_OUT 0
- call SKL_RDTSC_2_ASM
- dec dword [Skl_Cur_Count_]
- jge near .Skl_RDTSC_Loop_
- push dword 53
- call Skl_Print_Tics
-%endmacro
-
-;//////////////////////////////////////////////////////////
-
-globl Skl_YUV_To_RGB32_MMX
-
-;//////////////////////////////////////////////////////////////////////
-
- ; eax: *U
- ; ebx: *V
- ; esi: *Y
- ; edx: Src_BpS
- ; edi: *Dst
- ; ebx: Dst_BpS
- ; ecx: Counter
-
-%define RGBp esp+20
-%define Yp esp+16
-%define Up esp+12
-%define Vp esp+8
-%define xCnt esp+4
-%define yCnt esp+0
-
-Skl_YUV_To_RGB32_MMX:
-
- push ebx
- push esi
- push edi
- push ebp
-
- mov edi, [esp+4 +16] ; RGB
- mov ebp, [esp+12 +16] ; Y
- mov eax, [esp+16 +16] ; U
- mov ebx, [esp+20 +16] ; V
- mov edx, [esp+24 +16] ; Src_BpS
- mov ecx, [esp+28 +16] ; Width
-
- lea edi, [edi+4*ecx] ; RGB += Width*sizeof(32b)
- lea ebp, [ebp+ecx] ; ebp: Y1 = Y + Width
- add edx, ebp ; edx: Y2 = Y1+ BpS
- push edi ; [RGBp]
- push ebp ; [Yp]
- shr ecx, 1 ; Width/=2
- lea eax, [eax+ecx] ; U += W/2
- lea ebx, [ebx+ecx] ; V += W/2
- push eax ; [Up]
- push ebx ; [Vp]
-
- neg ecx ; ecx = -Width/2
- push ecx ; save [xCnt]
- push eax ; fake ([yCnt])
-
- mov ecx, [esp+32 +40] ; Height
- shr ecx, 1 ; /2
-
- mov esi, [Up]
- mov edi, [Vp]
-
- jmp .Go
-
-align 16
-.Loop_y
- dec ecx
- jg .Add
-
- add esp, 24 ; rid of all tmp
- pop ebp
- pop edi
- pop esi
- pop ebx
-
- ret
-
-align 16
-.Add
- mov edi, [esp+8 +40] ; Dst_BpS
- mov esi, [esp+24 +40] ; Src_BpS
- mov edx, [RGBp]
- mov ebp, [Yp]
- lea edx, [edx+2*edi] ; RGB += 2*Dst_BpS
- lea ebp, [ebp+2*esi] ; Y += 2*Src_BpS
- mov [RGBp], edx
- mov edi, [Vp]
- mov [Yp], ebp ; Y1
- lea edx, [ebp+esi] ; Y2
-
- lea edi, [edi+esi] ; V += Src_BpS
- add esi, [Up] ; U += Src_BpS
- mov [Vp], edi
- mov [Up], esi
-
-.Go
- mov [yCnt], ecx
- mov ecx, [xCnt]
-
- ; 5210c@640x480
-
-.Loop_x ; edi,esi: U,V; ebp,edx: Y1, Y2; ecx: xCnt
-
- ; R = Y + a.U
- ; G = Y + c.V + b.U
- ; B = Y + d.V
-
- movzx eax, byte [edi+ecx+0]
- movzx ebx, byte [esi+ecx+0]
- movq mm0, [Skl_YUV_Tab32_MMX+0*2048 + eax*8]
- movzx eax, byte [edi+ecx+1]
- paddw mm0, [Skl_YUV_Tab32_MMX+1*2048 + ebx*8]
- movzx ebx, byte [esi+ecx+1]
- movq mm4, [Skl_YUV_Tab32_MMX+0*2048 + eax*8]
- movzx eax, byte [ebp + 2*ecx+0]
- paddw mm4, [Skl_YUV_Tab32_MMX+1*2048 + ebx*8]
- movzx ebx, byte [ebp + 2*ecx+1]
-
- movq mm1, mm0
- movq mm2, mm0
- movq mm3, mm0
- movq mm5, mm4
- movq mm6, mm4
- movq mm7, mm4
-
- paddw mm0, [Skl_YUV_Tab32_MMX+2*2048 + eax*8]
- movzx eax, byte [ebp + 2*ecx+2]
- paddw mm1, [Skl_YUV_Tab32_MMX+2*2048 + ebx*8]
- movzx ebx, byte [ebp + 2*ecx+3]
- packuswb mm0, mm1
- paddw mm4, [Skl_YUV_Tab32_MMX+2*2048 + eax*8]
- movzx eax, byte [edx + 2*ecx+0]
- paddw mm5, [Skl_YUV_Tab32_MMX+2*2048 + ebx*8]
-
- packuswb mm4, mm5
- mov esi, [RGBp]
- movzx ebx, byte [edx + 2*ecx+1]
- movq [esi+8*ecx+0], mm0 ; 2x32b
- movq [esi+8*ecx+8], mm4 ; 2x32b
-
- paddw mm2, [Skl_YUV_Tab32_MMX+2*2048 + eax*8]
- movzx eax, byte [edx + 2*ecx+2]
- paddw mm3, [Skl_YUV_Tab32_MMX+2*2048 + ebx*8]
- movzx ebx, byte [edx + 2*ecx+3]
- packuswb mm2, mm3
- paddw mm6, [Skl_YUV_Tab32_MMX+2*2048 + eax*8]
- add esi, [esp+8 +40]
- paddw mm7, [Skl_YUV_Tab32_MMX+2*2048 + ebx*8]
-
- mov edi, [Vp]
- packuswb mm6, mm7
- movq [esi+8*ecx+0], mm2 ; 2x32b
- movq [esi+8*ecx+8], mm6 ; 2x32b
-
- add ecx, 2
- mov esi, [Up]
-
- jl near .Loop_x
-
- mov ecx, [yCnt]
- jmp .Loop_y
+;/********************************************************
+; * Some code. Copyright (C) 2003 by Pascal Massimino. *
+; * All Rights Reserved. (http://skal.planet-d.net) *
+; * For Educational/Academic use ONLY. See 'LICENSE.TXT'.*
+; ********************************************************/
+;//////////////////////////////////////////////////////////
+;// NASM macros
+;//////////////////////////////////////////////////////////
+
+%ifdef LINUX
+
+;//////////////////////////////////////////////////////////
+; LINUX / egcs / macros
+;//////////////////////////////////////////////////////////
+
+%macro extrn 1
+ extern %1
+ %define %1 %1
+%endmacro
+%macro globl 1
+ global %1
+ %define %1 %1
+%endmacro
+
+%macro DATA 0
+[section data align=16 write alloc USE32]
+%endmacro
+%macro TEXT 0
+[section text align=16 nowrite alloc exec USE32]
+%endmacro
+
+%endif ; LINUX
+
+;//////////////////////////////////////////////////////////
+
+%ifdef WIN32
+
+%macro extrn 1
+ extern _%1
+ %define %1 _%1
+%endmacro
+
+%macro globl 1
+ global _%1
+ %define %1 _%1
+%endmacro
+
+%macro DATA 0
+[section .data align=16 write alloc USE32]
+%endmacro
+%macro TEXT 0
+[section .text align=16 nowrite alloc exec USE32]
+%endmacro
+
+%endif ; WIN32
+
+;//////////////////////////////////////////////////////////
+;
+; MACRO for timing. NASM.
+; Total additional code size is 0xb0.
+; this keep code alignment right.
+
+extrn Skl_Cur_Count_
+extrn Skl_Print_Tics
+
+%macro SKL_USE_RDSTC 0
+extrn SKL_RDTSC_0_ASM
+extrn SKL_RDTSC_1_ASM
+extrn SKL_RDTSC_2_ASM
+%endmacro
+%define SKL_RDTSC_OFFSET 15 ; check value with skl_rdtsc.h...
+
+%macro SKL_RDTSC_IN 0
+ SKL_USE_RDSTC
+ call SKL_RDTSC_0_ASM
+.Skl_RDTSC_Loop_:
+ call SKL_RDTSC_1_ASM
+%endmacro
+
+%macro SKL_RDTSC_OUT 0
+ call SKL_RDTSC_2_ASM
+ dec dword [Skl_Cur_Count_]
+ jge near .Skl_RDTSC_Loop_
+ push dword 53
+ call Skl_Print_Tics
+%endmacro
+
+;//////////////////////////////////////////////////////////
+
+globl Skl_YUV_To_RGB32_MMX
+
+;//////////////////////////////////////////////////////////////////////
+
+ ; eax: *U
+ ; ebx: *V
+ ; esi: *Y
+ ; edx: Src_BpS
+ ; edi: *Dst
+ ; ebx: Dst_BpS
+ ; ecx: Counter
+
+%define RGBp esp+20
+%define Yp esp+16
+%define Up esp+12
+%define Vp esp+8
+%define xCnt esp+4
+%define yCnt esp+0
+
+Skl_YUV_To_RGB32_MMX:
+
+ push ebx
+ push esi
+ push edi
+ push ebp
+
+ mov edi, [esp+4 +16] ; RGB
+ mov ebp, [esp+12 +16] ; Y
+ mov eax, [esp+16 +16] ; U
+ mov ebx, [esp+20 +16] ; V
+ mov edx, [esp+24 +16] ; Src_BpS
+ mov ecx, [esp+28 +16] ; Width
+
+ lea edi, [edi+4*ecx] ; RGB += Width*sizeof(32b)
+ lea ebp, [ebp+ecx] ; ebp: Y1 = Y + Width
+ add edx, ebp ; edx: Y2 = Y1+ BpS
+ push edi ; [RGBp]
+ push ebp ; [Yp]
+ shr ecx, 1 ; Width/=2
+ lea eax, [eax+ecx] ; U += W/2
+ lea ebx, [ebx+ecx] ; V += W/2
+ push eax ; [Up]
+ push ebx ; [Vp]
+
+ neg ecx ; ecx = -Width/2
+ push ecx ; save [xCnt]
+ push eax ; fake ([yCnt])
+
+ mov ecx, [esp+32 +40] ; Height
+ shr ecx, 1 ; /2
+
+ mov esi, [Up]
+ mov edi, [Vp]
+
+ jmp .Go
+
+align 16
+.Loop_y
+ dec ecx
+ jg .Add
+
+ add esp, 24 ; rid of all tmp
+ pop ebp
+ pop edi
+ pop esi
+ pop ebx
+
+ ret
+
+align 16
+.Add
+ mov edi, [esp+8 +40] ; Dst_BpS
+ mov esi, [esp+24 +40] ; Src_BpS
+ mov edx, [RGBp]
+ mov ebp, [Yp]
+ lea edx, [edx+2*edi] ; RGB += 2*Dst_BpS
+ lea ebp, [ebp+2*esi] ; Y += 2*Src_BpS
+ mov [RGBp], edx
+ mov edi, [Vp]
+ mov [Yp], ebp ; Y1
+ lea edx, [ebp+esi] ; Y2
+
+ lea edi, [edi+esi] ; V += Src_BpS
+ add esi, [Up] ; U += Src_BpS
+ mov [Vp], edi
+ mov [Up], esi
+
+.Go
+ mov [yCnt], ecx
+ mov ecx, [xCnt]
+
+ ; 5210c@640x480
+
+.Loop_x ; edi,esi: U,V; ebp,edx: Y1, Y2; ecx: xCnt
+
+ ; R = Y + a.U
+ ; G = Y + c.V + b.U
+ ; B = Y + d.V
+
+ movzx eax, byte [edi+ecx+0]
+ movzx ebx, byte [esi+ecx+0]
+ movq mm0, [Skl_YUV_Tab32_MMX+0*2048 + eax*8]
+ movzx eax, byte [edi+ecx+1]
+ paddw mm0, [Skl_YUV_Tab32_MMX+1*2048 + ebx*8]
+ movzx ebx, byte [esi+ecx+1]
+ movq mm4, [Skl_YUV_Tab32_MMX+0*2048 + eax*8]
+ movzx eax, byte [ebp + 2*ecx+0]
+ paddw mm4, [Skl_YUV_Tab32_MMX+1*2048 + ebx*8]
+ movzx ebx, byte [ebp + 2*ecx+1]
+
+ movq mm1, mm0
+ movq mm2, mm0
+ movq mm3, mm0
+ movq mm5, mm4
+ movq mm6, mm4
+ movq mm7, mm4
+
+ paddw mm0, [Skl_YUV_Tab32_MMX+2*2048 + eax*8]
+ movzx eax, byte [ebp + 2*ecx+2]
+ paddw mm1, [Skl_YUV_Tab32_MMX+2*2048 + ebx*8]
+ movzx ebx, byte [ebp + 2*ecx+3]
+ packuswb mm0, mm1
+ paddw mm4, [Skl_YUV_Tab32_MMX+2*2048 + eax*8]
+ movzx eax, byte [edx + 2*ecx+0]
+ paddw mm5, [Skl_YUV_Tab32_MMX+2*2048 + ebx*8]
+
+ packuswb mm4, mm5
+ mov esi, [RGBp]
+ movzx ebx, byte [edx + 2*ecx+1]
+ movq [esi+8*ecx+0], mm0 ; 2x32b
+ movq [esi+8*ecx+8], mm4 ; 2x32b
+
+ paddw mm2, [Skl_YUV_Tab32_MMX+2*2048 + eax*8]
+ movzx eax, byte [edx + 2*ecx+2]
+ paddw mm3, [Skl_YUV_Tab32_MMX+2*2048 + ebx*8]
+ movzx ebx, byte [edx + 2*ecx+3]
+ packuswb mm2, mm3
+ paddw mm6, [Skl_YUV_Tab32_MMX+2*2048 + eax*8]
+ add esi, [esp+8 +40]
+ paddw mm7, [Skl_YUV_Tab32_MMX+2*2048 + ebx*8]
+
+ mov edi, [Vp]
+ packuswb mm6, mm7
+ movq [esi+8*ecx+0], mm2 ; 2x32b
+ movq [esi+8*ecx+8], mm6 ; 2x32b
+
+ add ecx, 2
+ mov esi, [Up]
+
+ jl near .Loop_x
+
+ mov ecx, [yCnt]
+ jmp .Loop_y
diff --git a/pcsx2/IopModuleNames.cpp b/pcsx2/IopModuleNames.cpp
index 5d81460bf3..eb30785d89 100644
--- a/pcsx2/IopModuleNames.cpp
+++ b/pcsx2/IopModuleNames.cpp
@@ -1,995 +1,995 @@
-/* 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 .
- */
-
-#define MODULE(n) if (!strncmp(libname, #n, 8)) switch (index) {
-#define END_MODULE }
-#define EXPORT(i, n) case (i): return #n;
-
-// machine generated
-MODULE(cdvdman)
- EXPORT( 4, sceCdInit)
- EXPORT( 5, sceCdStandby)
- EXPORT( 6, sceCdRead)
- EXPORT( 7, sceCdSeek)
- EXPORT( 8, sceCdGetError)
- EXPORT( 9, sceCdGetToc)
- EXPORT( 10, sceCdSearchFile)
- EXPORT( 11, sceCdSync)
- EXPORT( 12, sceCdGetDiskType)
- EXPORT( 13, sceCdDiskReady)
- EXPORT( 14, sceCdTrayReq)
- EXPORT( 15, sceCdStop)
- EXPORT( 16, sceCdPosToInt)
- EXPORT( 17, sceCdIntToPos)
- EXPORT( 21, sceCdCheckCmd)
- EXPORT( 22, _sceCdRI)
- EXPORT( 24, sceCdReadClock)
- EXPORT( 28, sceCdStatus)
- EXPORT( 29, sceCdApplySCmd)
- EXPORT( 37, sceCdCallback)
- EXPORT( 38, sceCdPause)
- EXPORT( 39, sceCdBreak)
- EXPORT( 40, sceCdReadCDDA)
- EXPORT( 44, sceCdGetReadPos)
- EXPORT( 45, sceCdCtrlADout)
- EXPORT( 46, sceCdNop)
- EXPORT( 47, _sceGetFsvRbuf)
- EXPORT( 48, _sceCdstm0Cb)
- EXPORT( 49, _sceCdstm1Cb)
- EXPORT( 50, _sceCdSC)
- EXPORT( 51, _sceCdRC)
- EXPORT( 54, sceCdApplyNCmd)
- EXPORT( 56, sceCdStInit)
- EXPORT( 57, sceCdStRead)
- EXPORT( 58, sceCdStSeek)
- EXPORT( 59, sceCdStStart)
- EXPORT( 60, sceCdStStat)
- EXPORT( 61, sceCdStStop)
- EXPORT( 62, sceCdRead0)
- EXPORT( 63, _sceCdRV)
- EXPORT( 64, _sceCdRM)
- EXPORT( 66, sceCdReadChain)
- EXPORT( 67, sceCdStPause)
- EXPORT( 68, sceCdStResume)
- EXPORT( 74, sceCdPowerOff)
- EXPORT( 75, sceCdMmode)
- EXPORT( 77, sceCdStSeekF)
- EXPORT( 78, sceCdPOffCallback)
- EXPORT( 81, _sceCdSetTimeout)
- EXPORT( 83, sceCdReadDvdDualInfo)
- EXPORT( 84, sceCdLayerSearchFile)
- EXPORT(112, sceCdApplySCmd2)
- EXPORT(114, _sceCdRE)
-END_MODULE
-MODULE(deci2api)
- EXPORT( 4, sceDeci2Open)
- EXPORT( 5, sceDeci2Close)
- EXPORT( 6, sceDeci2ExRecv)
- EXPORT( 7, sceDeci2ExSend)
- EXPORT( 8, sceDeci2ReqSend)
- EXPORT( 9, sceDeci2ExReqSend)
- EXPORT( 10, sceDeci2ExLock)
- EXPORT( 11, sceDeci2ExUnLock)
- EXPORT( 12, sceDeci2ExPanic)
- EXPORT( 13, sceDeci2Poll)
- EXPORT( 14, sceDeci2ExPoll)
- EXPORT( 15, sceDeci2ExRecvSuspend)
- EXPORT( 16, sceDeci2ExRecvUnSuspend)
- EXPORT( 17, sceDeci2ExWakeupThread)
- EXPORT( 18, sceDeci2ExSignalSema)
- EXPORT( 19, sceDeci2ExSetEventFlag)
-END_MODULE
-MODULE(eenetctl)
- EXPORT( 4, sceEENetCtlSetConfiguration)
- EXPORT( 5, sceEENetCtlRegisterDialCnf)
- EXPORT( 6, sceEENetCtlUnRegisterDialCnf)
- EXPORT( 7, sceEENetCtlSetDialingData)
- EXPORT( 8, sceEENetCtlClearDialingData)
-END_MODULE
-MODULE(ent_devm)
- EXPORT( 4, sceEENetDevAttach)
- EXPORT( 5, sceEENetDevReady)
- EXPORT( 6, sceEENetDevDetach)
- EXPORT( 7, sceEENetSifAddCmdHandler)
- EXPORT( 8, sceEENetSifRemoveCmdHandler)
- EXPORT( 9, sceEENetSifSendCmd)
- EXPORT( 10, sceEENetSifBindRpc)
- EXPORT( 11, sceEENetSifCallRpc)
- EXPORT( 12, sceEENetCheckWaitingDriverList)
- EXPORT( 13, sceEENetCheckTerminatedDriverList)
-END_MODULE
-MODULE(excepman)
- EXPORT( 4, RegisterExceptionHandler)
- EXPORT( 5, RegisterPriorityExceptionHandler)
- EXPORT( 6, RegisterDefaultExceptionHandler)
- EXPORT( 7, ReleaseExceptionHandler)
- EXPORT( 8, ReleaseDefaultExceptionHandler)
-END_MODULE
-MODULE(heaplib)
- EXPORT( 4, CreateHeap)
- EXPORT( 5, DeleteHeap)
- EXPORT( 6, AllocHeapMemory)
- EXPORT( 7, FreeHeapMemory)
- EXPORT( 8, HeapTotalFreeSize)
-END_MODULE
-MODULE(ilink)
- EXPORT( 0, sce1394SetupModule)
- EXPORT( 2, sce1394ReleaseModule)
- EXPORT( 4, sce1394Initialize)
- EXPORT( 5, sce1394Destroy)
- EXPORT( 6, sce1394Debug)
- EXPORT( 7, sce1394ConfGet)
- EXPORT( 8, sce1394ConfSet)
- EXPORT( 9, sce1394ChangeThreadPriority)
- EXPORT( 12, sce1394UnitAdd)
- EXPORT( 13, sce1394UnitDelete)
- EXPORT( 17, sce1394GenerateCrc32)
- EXPORT( 18, sce1394GenerateCrc16)
- EXPORT( 19, sce1394ValidateCrc16)
- EXPORT( 23, sce1394SbControl)
- EXPORT( 24, sce1394SbEnable)
- EXPORT( 25, sce1394SbDisable)
- EXPORT( 26, sce1394SbReset)
- EXPORT( 27, sce1394SbEui64)
- EXPORT( 28, sce1394SbNodeId)
- EXPORT( 29, sce1394SbNodeCount)
- EXPORT( 30, sce1394SbSelfId)
- EXPORT( 31, sce1394SbGenNumber)
- EXPORT( 32, sce1394SbPhyPacket)
- EXPORT( 33, sce1394SbCycleTime)
- EXPORT( 36, sce1394EvAlloc)
- EXPORT( 37, sce1394EvFree)
- EXPORT( 38, sce1394EvWait)
- EXPORT( 39, sce1394EvPoll)
- EXPORT( 43, sce1394PbAlloc)
- EXPORT( 44, sce1394PbFree)
- EXPORT( 45, sce1394PbGet)
- EXPORT( 46, sce1394PbSet)
- EXPORT( 50, sce1394TrDataInd)
- EXPORT( 51, sce1394TrDataUnInd)
- EXPORT( 55, sce1394TrAlloc)
- EXPORT( 56, sce1394TrFree)
- EXPORT( 57, sce1394TrGet)
- EXPORT( 58, sce1394TrSet)
- EXPORT( 59, sce1394TrWrite)
- EXPORT( 60, sce1394TrWriteV)
- EXPORT( 61, sce1394TrRead)
- EXPORT( 62, sce1394TrReadV)
- EXPORT( 63, sce1394TrLock)
- EXPORT( 67, sce1394CrEui64)
- EXPORT( 68, sce1394CrGenNumber)
- EXPORT( 69, sce1394CrMaxRec)
- EXPORT( 70, sce1394CrMaxSpeed)
- EXPORT( 71, sce1394CrRead)
- EXPORT( 72, sce1394CrCapability)
- EXPORT( 73, sce1394CrFindNode)
- EXPORT( 74, sce1394CrFindUnit)
- EXPORT( 75, sce1394CrInvalidate)
-END_MODULE
-MODULE(ilsocket)
- EXPORT( 0, sceILsockModuleInit)
- EXPORT( 2, sceILsockModuleReset)
- EXPORT( 4, sceILsockInit)
- EXPORT( 5, sceILsockReset)
- EXPORT( 8, sceILsockOpen)
- EXPORT( 9, sceILsockClose)
- EXPORT( 10, sceILsockBind)
- EXPORT( 11, sceILsockConnect)
- EXPORT( 12, sceILsockSend)
- EXPORT( 13, sceILsockSendTo)
- EXPORT( 14, sceILsockRecv)
- EXPORT( 15, sceILsockRecvFrom)
- EXPORT( 18, sceILsockHtoNl)
- EXPORT( 19, sceILsockHtoNs)
- EXPORT( 20, sceILsockNtoHl)
- EXPORT( 21, sceILsockNtoHs)
- EXPORT( 22, sce1394GetCycleTimeV)
-END_MODULE
-MODULE(inet)
- EXPORT( 4, sceInetName2Address)
- EXPORT( 5, sceInetAddress2String)
- EXPORT( 6, sceInetCreate)
- EXPORT( 7, sceInetOpen)
- EXPORT( 8, sceInetClose)
- EXPORT( 9, sceInetRecv)
- EXPORT( 10, sceInetSend)
- EXPORT( 11, sceInetAbort)
- EXPORT( 12, sceInetRecvFrom)
- EXPORT( 13, sceInetSendTo)
- EXPORT( 14, sceInetAddress2Name)
- EXPORT( 15, sceInetControl)
- EXPORT( 16, sceInetPoll)
- EXPORT( 17, sceInetNtohs)
- EXPORT( 18, sceInetHtons)
- EXPORT( 19, sceInetNtohl)
- EXPORT( 20, sceInetHtonl)
- EXPORT( 21, sceInetGet4u)
- EXPORT( 22, sceInetPut4u)
- EXPORT( 24, sceInetGetInterfaceList)
- EXPORT( 25, sceInetInterfaceControl)
- EXPORT( 27, sceInetGetRoutingTable)
- EXPORT( 28, sceInetAddRouting)
- EXPORT( 29, sceInetDelRouting)
- EXPORT( 30, sceInetGetNameServers)
- EXPORT( 31, sceInetAddNameServer)
- EXPORT( 32, sceInetDelNameServer)
- EXPORT( 36, sceInetChangeThreadPriority)
- EXPORT( 38, sceInetGetLog)
- EXPORT( 39, sceInetWaitInterfaceEvent)
- EXPORT( 40, sceInetSignalInterfaceEvent)
- EXPORT( 41, sceInetAbortLog)
-END_MODULE
-MODULE(inetctl)
- EXPORT( 4, sceInetCtlSetConfiguration)
- EXPORT( 5, sceInetCtlUpInterface)
- EXPORT( 6, sceInetCtlDownInterface)
- EXPORT( 7, sceInetCtlSetAutoMode)
- EXPORT( 8, sceInetCtlRegisterEventHandler)
- EXPORT( 9, sceInetCtlUnregisterEventHandler)
- EXPORT( 10, sceInetCtlGetState)
- EXPORT( 11, sceInetCtlGetConfiguration)
- EXPORT( 12, sceInetCtlSetDialingData)
- EXPORT( 13, sceInetCtlClearDialingData)
-END_MODULE
-MODULE(intrman)
- EXPORT( 4, RegisterIntrHandler)
- EXPORT( 5, ReleaseIntrHandler)
- EXPORT( 6, EnableIntr)
- EXPORT( 7, DisableIntr)
- EXPORT( 8, CpuDisableIntr)
- EXPORT( 9, CpuEnableIntr)
- EXPORT( 17, CpuSuspendIntr)
- EXPORT( 18, CpuResumeIntr)
- EXPORT( 23, QueryIntrContext)
- EXPORT( 24, QueryIntrStack)
- EXPORT( 25, iCatchMultiIntr)
-END_MODULE
-MODULE(ioman)
- EXPORT( 4, open)
- EXPORT( 5, close)
- EXPORT( 6, read)
- EXPORT( 7, write)
- EXPORT( 8, lseek)
- EXPORT( 9, ioctl)
- EXPORT( 10, remove)
- EXPORT( 11, mkdir)
- EXPORT( 12, rmdir)
- EXPORT( 13, dopen)
- EXPORT( 14, dclose)
- EXPORT( 15, dread)
- EXPORT( 16, getstat)
- EXPORT( 17, chstat)
- EXPORT( 18, format)
- EXPORT( 20, AddDrv)
- EXPORT( 21, DelDrv)
- EXPORT( 23, StdioInit)
- EXPORT( 25, rename)
- EXPORT( 26, chdir)
- EXPORT( 27, sync)
- EXPORT( 28, mount)
- EXPORT( 29, umount)
- EXPORT( 30, lseek64)
- EXPORT( 31, devctl)
- EXPORT( 32, symlink)
- EXPORT( 33, readlink)
- EXPORT( 34, ioctl2)
-END_MODULE
-MODULE(libsd)
- EXPORT( 2, sceSdQuit)
- EXPORT( 4, sceSdInit)
- EXPORT( 5, sceSdSetParam)
- EXPORT( 6, sceSdGetParam)
- EXPORT( 7, sceSdSetSwitch)
- EXPORT( 8, sceSdGetSwitch)
- EXPORT( 9, sceSdSetAddr)
- EXPORT( 10, sceSdGetAddr)
- EXPORT( 11, sceSdSetCoreAttr)
- EXPORT( 12, sceSdGetCoreAttr)
- EXPORT( 13, sceSdNote2Pitch)
- EXPORT( 14, sceSdPitch2Note)
- EXPORT( 15, sceSdProcBatch)
- EXPORT( 16, sceSdProcBatchEx)
- EXPORT( 17, sceSdVoiceTrans)
- EXPORT( 18, sceSdBlockTrans)
- EXPORT( 19, sceSdVoiceTransStatus)
- EXPORT( 20, sceSdBlockTransStatus)
- EXPORT( 21, sceSdSetTransCallback)
- EXPORT( 22, sceSdSetIRQCallback)
- EXPORT( 23, sceSdSetEffectAttr)
- EXPORT( 24, sceSdGetEffectAttr)
- EXPORT( 25, sceSdClearEffectWorkArea)
- EXPORT( 26, sceSdSetTransIntrHandler)
- EXPORT( 27, sceSdSetSpu2IntrHandler)
- EXPORT( 28, sceSdGetTransIntrHandlerArgument)
- EXPORT( 29, sceSdGetSpu2IntrHandlerArgument)
- EXPORT( 30, sceSdStopTrans)
- EXPORT( 31, sceSdCleanEffectWorkArea)
- EXPORT( 32, sceSdSetEffectMode)
- EXPORT( 33, sceSdSetEffectModeParams)
-END_MODULE
-MODULE(loadcore)
- EXPORT( 4, FlushIcache)
- EXPORT( 5, FlushDcache)
- EXPORT( 6, RegisterLibraryEntries)
- EXPORT( 7, ReleaseLibraryEntries)
- EXPORT( 10, RegisterNonAutoLinkEntries)
- EXPORT( 11, QueryLibraryEntryTable)
- EXPORT( 12, QueryBootMode)
- EXPORT( 13, RegisterBootMode)
- EXPORT( 27, SetRebootTimeLibraryHandlingMode)
-END_MODULE
-MODULE(moddelay)
- EXPORT( 4, sceMidiDelay_Init)
- EXPORT( 5, sceMidiDelay_ATick)
- EXPORT( 6, sceMidiDelay_Flush)
-END_MODULE
-MODULE(modem)
- EXPORT( 4, sceModemRegisterDevice)
- EXPORT( 5, sceModemUnregisterDevice)
-END_MODULE
-MODULE(modhsyn)
- EXPORT( 4, sceHSyn_Init)
- EXPORT( 5, sceHSyn_ATick)
- EXPORT( 6, sceHSyn_Load)
- EXPORT( 7, sceHSyn_VoiceTrans)
- EXPORT( 8, sceHSyn_SetReservVoice)
- EXPORT( 9, sceHSyn_SetEffectAttr)
- EXPORT( 10, sceHSyn_SetVolume)
- EXPORT( 11, sceHSyn_GetVolume)
- EXPORT( 12, sceHSyn_AllNoteOff)
- EXPORT( 13, sceHSyn_AllSoundOff)
- EXPORT( 14, sceHSyn_ResetAllControler)
- EXPORT( 15, sceHSyn_SetVoiceStatBuffer)
- EXPORT( 16, sceHSyn_SetDebugInfoBuffer)
- EXPORT( 17, sceHSyn_GetChStat)
- EXPORT( 18, sceHSyn_SetOutputMode)
- EXPORT( 19, sceHSyn_SESetMaxVoices)
- EXPORT( 20, sceHSyn_SEAllNoteOff)
- EXPORT( 21, sceHSyn_SEAllSoundOff)
- EXPORT( 22, sceHSyn_SERetrieveVoiceNumberByID)
- EXPORT( 23, sceHSyn_MSGetVoiceStateByID)
- EXPORT( 24, sceHSyn_MSGetVoiceEnvelopeByID)
- EXPORT( 25, sceHSyn_SERetrieveAllSEMsgIDs)
- EXPORT( 26, sceHSyn_GetReservVoice)
- EXPORT( 27, sceHSyn_GetOutputMode)
- EXPORT( 28, sceHSyn_Unload)
-END_MODULE
-MODULE(modload)
- EXPORT( 4, ReBootStart)
- EXPORT( 5, LoadModuleAddress)
- EXPORT( 6, LoadModule)
- EXPORT( 7, LoadStartModule)
- EXPORT( 8, StartModule)
- EXPORT( 9, LoadModuleBufferAddress)
- EXPORT( 10, LoadModuleBuffer)
- EXPORT( 16, GetModuleIdList)
- EXPORT( 17, ReferModuleStatus)
- EXPORT( 18, GetModuleIdListByName)
- EXPORT( 19, LoadModuleWithOption)
- EXPORT( 20, StopModule)
- EXPORT( 21, UnloadModule)
- EXPORT( 22, SearchModuleByName)
- EXPORT( 23, SearchModuleByAddress)
- EXPORT( 26, SelfStopModule)
- EXPORT( 27, SelfUnloadModule)
- EXPORT( 28, AllocLoadMemory)
- EXPORT( 29, FreeLoadMemory)
- EXPORT( 30, SetModuleFlags)
-END_MODULE
-MODULE(modmidi)
- EXPORT( 4, sceMidi_Init)
- EXPORT( 5, sceMidi_ATick)
- EXPORT( 6, sceMidi_Load)
- EXPORT( 7, sceMidi_SelectSong)
- EXPORT( 8, sceMidi_SongPlaySwitch)
- EXPORT( 9, sceMidi_SongSetVolume)
- EXPORT( 10, sceMidi_SongVolumeChange)
- EXPORT( 11, sceMidi_SongSetAbsoluteTempo)
- EXPORT( 12, sceMidi_SongSetRelativeTempo)
- EXPORT( 13, sceMidi_SongSetLocation)
- EXPORT( 14, sceMidi_SelectMidi)
- EXPORT( 15, sceMidi_MidiPlaySwitch)
- EXPORT( 16, sceMidi_MidiSetLocation)
- EXPORT( 17, sceMidi_MidiSetVolume)
- EXPORT( 18, sceMidi_MidiVolumeChange)
- EXPORT( 19, sceMidi_MidiSetAbsoluteTempo)
- EXPORT( 20, sceMidi_MidiGetAbsoluteTempo)
- EXPORT( 21, sceMidi_MidiSetRelativeTempo)
- EXPORT( 22, sceMidi_MidiGetRelativeTempo)
- EXPORT( 23, sceMidi_MidiSetUSecTempo)
- EXPORT( 24, sceMidi_MidiGetUSecTempo)
- EXPORT( 25, sceMidi_Unload)
-END_MODULE
-MODULE(modmono)
- EXPORT( 4, sceMidiMono_Init)
- EXPORT( 5, sceMidiMono_ATick)
- EXPORT( 6, sceMidiMono_SetMono)
-END_MODULE
-MODULE(modmsin)
- EXPORT( 4, sceMSIn_Init)
- EXPORT( 5, sceMSIn_ATick)
- EXPORT( 6, sceMSIn_Load)
- EXPORT( 7, sceMSIn_PutMsg)
- EXPORT( 8, sceMSIn_PutExcMsg)
- EXPORT( 9, sceMSIn_PutHsMsg)
-END_MODULE
-MODULE(modsein)
- EXPORT( 4, sceSEIn_Init)
- EXPORT( 5, sceSEIn_ATick)
- EXPORT( 6, sceSEIn_Load)
- EXPORT( 7, sceSEIn_PutMsg)
- EXPORT( 8, sceSEIn_PutSEMsg)
- EXPORT( 9, sceSEIn_MakeNoteOn)
- EXPORT( 10, sceSEIn_MakePitchOn)
- EXPORT( 11, sceSEIn_MakeTimeVolume)
- EXPORT( 12, sceSEIn_MakeTimePanpot)
- EXPORT( 13, sceSEIn_MakeTimePitch)
- EXPORT( 14, sceSEIn_MakePitchLFO)
- EXPORT( 15, sceSEIn_MakeAmpLFO)
- EXPORT( 16, sceSEIn_MakeAllNoteOff)
- EXPORT( 17, sceSEIn_MakeAllNoteOffMask)
- EXPORT( 18, sceSEIn_MakeNoteOnZero)
- EXPORT( 19, sceSEIn_MakePitchOnZero)
-END_MODULE
-MODULE(modsesq)
- EXPORT( 4, sceSESq_Init)
- EXPORT( 5, sceSESq_ATick)
- EXPORT( 6, sceSESq_Load)
- EXPORT( 7, sceSESq_SelectSeq)
- EXPORT( 8, sceSESq_UnselectSeq)
- EXPORT( 9, sceSESq_SeqPlaySwitch)
- EXPORT( 10, sceSESq_SeqGetStatus)
- EXPORT( 11, sceSESq_SeqIsInPlay)
- EXPORT( 12, sceSESq_SeqIsDataEnd)
- EXPORT( 13, sceSESq_SeqSetSEMsgID)
- EXPORT( 14, sceSESq_SeqTerminateVoice)
-END_MODULE
-MODULE(modssyn)
- EXPORT( 4, sceSSyn_Init)
- EXPORT( 5, sceSSyn_ATick)
- EXPORT( 6, sceSSyn_Load)
-END_MODULE
-MODULE(msifrpc)
- EXPORT( 4, sceSifMInitRpc)
- EXPORT( 16, sceSifMTermRpc)
- EXPORT( 17, sceSifMEntryLoop)
-END_MODULE
-MODULE(netcnf)
- EXPORT( 4, sceNetCnfGetCount)
- EXPORT( 5, sceNetCnfGetList)
- EXPORT( 6, sceNetCnfLoadEntry)
- EXPORT( 7, sceNetCnfAddEntry)
- EXPORT( 8, sceNetCnfDeleteEntry)
- EXPORT( 9, sceNetCnfSetLatestEntry)
- EXPORT( 10, sceNetCnfAllocMem)
- EXPORT( 11, sceNetCnfInitIFC)
- EXPORT( 12, sceNetCnfLoadConf)
- EXPORT( 13, sceNetCnfLoadDial)
- EXPORT( 14, sceNetCnfMergeConf)
- EXPORT( 15, sceNetCnfName2Address)
- EXPORT( 16, sceNetCnfAddress2String)
- EXPORT( 17, sceNetCnfEditEntry)
- EXPORT( 18, sceNetCnfDeleteAll)
- EXPORT( 19, sceNetCnfCheckCapacity)
- EXPORT( 20, sceNetCnfConvA2S)
- EXPORT( 21, sceNetCnfConvS2A)
- EXPORT( 22, sceNetCnfCheckSpecialProvider)
- EXPORT( 23, sceNetCnfSetCallback)
-END_MODULE
-MODULE(netdev)
- EXPORT( 4, sceInetRegisterNetDevice)
- EXPORT( 5, sceInetUnregisterNetDevice)
- EXPORT( 6, sceInetAllocMem)
- EXPORT( 7, sceInetFreeMem)
- EXPORT( 8, sceInetPktEnQ)
- EXPORT( 9, sceInetPktDeQ)
- EXPORT( 10, sceInetRand)
- EXPORT( 11, sceInetPrintf)
- EXPORT( 12, sceInetAllocPkt)
- EXPORT( 13, sceInetFreePkt)
- EXPORT( 14, sceInetRegisterPPPoE)
- EXPORT( 15, sceInetUnregisterPPPoE)
-END_MODULE
-MODULE(scrtpad)
- EXPORT( 4, AllocScratchPad)
- EXPORT( 5, FreeScratchPad)
-END_MODULE
-MODULE(sdhd)
- EXPORT( 4, sceSdHdGetMaxProgramNumber)
- EXPORT( 5, sceSdHdGetMaxSampleSetNumber)
- EXPORT( 6, sceSdHdGetMaxSampleNumber)
- EXPORT( 7, sceSdHdGetMaxVAGInfoNumber)
- EXPORT( 8, sceSdHdGetProgramParamAddr)
- EXPORT( 9, sceSdHdGetProgramParam)
- EXPORT( 10, sceSdHdGetSplitBlockAddr)
- EXPORT( 11, sceSdHdGetSplitBlock)
- EXPORT( 12, sceSdHdGetSampleSetParamAddr)
- EXPORT( 13, sceSdHdGetSampleSetParam)
- EXPORT( 14, sceSdHdGetSampleParamAddr)
- EXPORT( 15, sceSdHdGetSampleParam)
- EXPORT( 16, sceSdHdGetVAGInfoParamAddr)
- EXPORT( 17, sceSdHdGetVAGInfoParam)
- EXPORT( 18, sceSdHdCheckProgramNumber)
- EXPORT( 19, sceSdHdGetSplitBlockCountByNote)
- EXPORT( 20, sceSdHdGetSplitBlockAddrByNote)
- EXPORT( 21, sceSdHdGetSplitBlockByNote)
- EXPORT( 22, sceSdHdGetSampleSetParamCountByNote)
- EXPORT( 23, sceSdHdGetSampleSetParamAddrByNote)
- EXPORT( 24, sceSdHdGetSampleSetParamByNote)
- EXPORT( 25, sceSdHdGetSampleParamCountByNoteVelocity)
- EXPORT( 26, sceSdHdGetSampleParamAddrByNoteVelocity)
- EXPORT( 27, sceSdHdGetSampleParamByNoteVelocity)
- EXPORT( 28, sceSdHdGetVAGInfoParamCountByNoteVelocity)
- EXPORT( 29, sceSdHdGetVAGInfoParamAddrByNoteVelocity)
- EXPORT( 30, sceSdHdGetVAGInfoParamByNoteVelocity)
- EXPORT( 31, sceSdHdGetSampleParamCountByVelocity)
- EXPORT( 32, sceSdHdGetSampleParamAddrByVelocity)
- EXPORT( 33, sceSdHdGetSampleParamByVelocity)
- EXPORT( 34, sceSdHdGetVAGInfoParamCountByVelocity)
- EXPORT( 35, sceSdHdGetVAGInfoParamAddrByVelocity)
- EXPORT( 36, sceSdHdGetVAGInfoParamByVelocity)
- EXPORT( 37, sceSdHdGetVAGInfoParamAddrBySampleNumber)
- EXPORT( 38, sceSdHdGetVAGInfoParamBySampleNumber)
- EXPORT( 39, sceSdHdGetSplitBlockNumberBySplitNumber)
- EXPORT( 40, sceSdHdGetVAGSize)
- EXPORT( 41, sceSdHdGetSplitBlockCount)
- EXPORT( 42, sceSdHdGetMaxSplitBlockCount)
- EXPORT( 43, sceSdHdGetMaxSampleSetParamCount)
- EXPORT( 44, sceSdHdGetMaxSampleParamCount)
- EXPORT( 45, sceSdHdGetMaxVAGInfoParamCount)
- EXPORT( 46, sceSdHdModifyVelocity)
- EXPORT( 47, sceSdHdModifyVelocityLFO)
- EXPORT( 48, sceSdHdGetValidProgramNumberCount)
- EXPORT( 49, sceSdHdGetValidProgramNumber)
- EXPORT( 50, sceSdHdGetSampleNumberBySampleIndex)
-END_MODULE
-MODULE(sdrdrv)
- EXPORT( 4, sceSdrChangeThreadPriority)
- EXPORT( 5, sceSdrSetUserCommandFunction)
-END_MODULE
-MODULE(sdsq)
- EXPORT( 4, sceSdSqGetMaxMidiNumber)
- EXPORT( 5, sceSdSqGetMaxSongNumber)
- EXPORT( 6, sceSdSqInitMidiData)
- EXPORT( 7, sceSdSqReadMidiData)
- EXPORT( 8, sceSdSqInitSongData)
- EXPORT( 9, sceSdSqReadSongData)
- EXPORT( 10, sceSdSqGetMaxCompTableIndex)
- EXPORT( 11, sceSdSqGetCompTableOffset)
- EXPORT( 12, sceSdSqGetCompTableDataByIndex)
- EXPORT( 13, sceSdSqGetNoteOnEventByPolyKeyPress)
- EXPORT( 14, sceSdSqCopyMidiData)
- EXPORT( 15, sceSdSqCopySongData)
-END_MODULE
-MODULE(sifcmd)
- EXPORT( 4, sceSifInitCmd)
- EXPORT( 5, sceSifExitCmd)
- EXPORT( 6, sceSifGetSreg)
- EXPORT( 7, sceSifSetSreg)
- EXPORT( 8, sceSifSetCmdBuffer)
- EXPORT( 10, sceSifAddCmdHandler)
- EXPORT( 11, sceSifRemoveCmdHandler)
- EXPORT( 12, sceSifSendCmd)
- EXPORT( 13, isceSifSendCmd)
- EXPORT( 14, sceSifInitRpc)
- EXPORT( 15, sceSifBindRpc)
- EXPORT( 16, sceSifCallRpc)
- EXPORT( 17, sceSifRegisterRpc)
- EXPORT( 18, sceSifCheckStatRpc)
- EXPORT( 19, sceSifSetRpcQueue)
- EXPORT( 20, sceSifGetNextRequest)
- EXPORT( 21, sceSifExecRequest)
- EXPORT( 22, sceSifRpcLoop)
- EXPORT( 23, sceSifGetOtherData)
- EXPORT( 24, sceSifRemoveRpc)
- EXPORT( 25, sceSifRemoveRpcQueue)
- EXPORT( 28, sceSifSendCmdIntr)
- EXPORT( 29, isceSifSendCmdIntr)
-END_MODULE
-MODULE(sifman)
- EXPORT( 5, sceSifInit)
- EXPORT( 6, sceSifSetDChain)
- EXPORT( 7, sceSifSetDma)
- EXPORT( 8, sceSifDmaStat)
- EXPORT( 29, sceSifCheckInit)
- EXPORT( 32, sceSifSetDmaIntr)
-END_MODULE
-MODULE(spucodec)
- EXPORT( 4, sceSpuCodecEncode)
-END_MODULE
-MODULE(stdio)
- EXPORT( 4, printf)
- EXPORT( 5, getchar)
- EXPORT( 6, putchar)
- EXPORT( 7, puts)
- EXPORT( 8, gets)
- EXPORT( 9, fdprintf)
- EXPORT( 10, fdgetc)
- EXPORT( 11, fdputc)
- EXPORT( 12, fdputs)
- EXPORT( 13, fdgets)
- EXPORT( 14, vfdprintf)
-END_MODULE
-MODULE(sysclib)
- EXPORT( 4, setjmp)
- EXPORT( 5, longjmp)
- EXPORT( 6, toupper)
- EXPORT( 7, tolower)
- EXPORT( 8, look_ctype_table)
- EXPORT( 9, get_ctype_table)
- EXPORT( 10, memchr)
- EXPORT( 11, memcmp)
- EXPORT( 12, memcpy)
- EXPORT( 13, memmove)
- EXPORT( 14, memset)
- EXPORT( 15, bcmp)
- EXPORT( 16, bcopy)
- EXPORT( 17, bzero)
- EXPORT( 18, prnt)
- EXPORT( 19, sprintf)
- EXPORT( 20, strcat)
- EXPORT( 21, strchr)
- EXPORT( 22, strcmp)
- EXPORT( 23, strcpy)
- EXPORT( 24, strcspn)
- EXPORT( 25, index)
- EXPORT( 26, rindex)
- EXPORT( 27, strlen)
- EXPORT( 28, strncat)
- EXPORT( 29, strncmp)
- EXPORT( 30, strncpy)
- EXPORT( 31, strpbrk)
- EXPORT( 32, strrchr)
- EXPORT( 33, strspn)
- EXPORT( 34, strstr)
- EXPORT( 35, strtok)
- EXPORT( 36, strtol)
- EXPORT( 37, atob)
- EXPORT( 38, strtoul)
- EXPORT( 40, wmemcopy)
- EXPORT( 41, wmemset)
- EXPORT( 42, vsprintf)
- EXPORT( 43, strtok_r)
-END_MODULE
-MODULE(sysmem)
- EXPORT( 4, AllocSysMemory)
- EXPORT( 5, FreeSysMemory)
- EXPORT( 6, QueryMemSize)
- EXPORT( 7, QueryMaxFreeMemSize)
- EXPORT( 8, QueryTotalFreeMemSize)
- EXPORT( 9, QueryBlockTopAddress)
- EXPORT( 10, QueryBlockSize)
- EXPORT( 14, Kprintf)
-END_MODULE
-MODULE(thbase)
- EXPORT( 4, CreateThread)
- EXPORT( 5, DeleteThread)
- EXPORT( 6, StartThread)
- EXPORT( 7, StartThreadArgs)
- EXPORT( 8, ExitThread)
- EXPORT( 9, ExitDeleteThread)
- EXPORT( 10, TerminateThread)
- EXPORT( 11, iTerminateThread)
- EXPORT( 12, DisableDispatchThread)
- EXPORT( 13, EnableDispatchThread)
- EXPORT( 14, ChangeThreadPriority)
- EXPORT( 15, iChangeThreadPriority)
- EXPORT( 16, RotateThreadReadyQueue)
- EXPORT( 17, iRotateThreadReadyQueue)
- EXPORT( 18, ReleaseWaitThread)
- EXPORT( 19, iReleaseWaitThread)
- EXPORT( 20, GetThreadId)
- EXPORT( 21, CheckThreadStack)
- EXPORT( 22, ReferThreadStatus)
- EXPORT( 23, iReferThreadStatus)
- EXPORT( 24, SleepThread)
- EXPORT( 25, WakeupThread)
- EXPORT( 26, iWakeupThread)
- EXPORT( 27, CancelWakeupThread)
- EXPORT( 28, iCancelWakeupThread)
- EXPORT( 29, SuspendThread)
- EXPORT( 30, iSuspendThread)
- EXPORT( 31, ResumeThread)
- EXPORT( 32, iResumeThread)
- EXPORT( 33, DelayThread)
- EXPORT( 34, GetSystemTime)
- EXPORT( 35, SetAlarm)
- EXPORT( 36, iSetAlarm)
- EXPORT( 37, CancelAlarm)
- EXPORT( 38, iCancelAlarm)
- EXPORT( 39, USec2SysClock)
- EXPORT( 40, SysClock2USec)
- EXPORT( 41, GetSystemStatusFlag)
- EXPORT( 42, GetThreadCurrentPriority)
- EXPORT( 43, GetSystemTimeLow)
- EXPORT( 44, ReferSystemStatus)
- EXPORT( 45, ReferThreadRunStatus)
- EXPORT( 46, GetThreadStackFreeSize)
- EXPORT( 47, GetThreadmanIdList)
-END_MODULE
-MODULE(thevent)
- EXPORT( 4, CreateEventFlag)
- EXPORT( 5, DeleteEventFlag)
- EXPORT( 6, SetEventFlag)
- EXPORT( 7, iSetEventFlag)
- EXPORT( 8, ClearEventFlag)
- EXPORT( 9, iClearEventFlag)
- EXPORT( 10, WaitEventFlag)
- EXPORT( 11, PollEventFlag)
- EXPORT( 13, ReferEventFlagStatus)
- EXPORT( 14, iReferEventFlagStatus)
-END_MODULE
-MODULE(thfpool)
- EXPORT( 4, CreateFpl)
- EXPORT( 5, DeleteFpl)
- EXPORT( 6, AllocateFpl)
- EXPORT( 7, pAllocateFpl)
- EXPORT( 8, ipAllocateFpl)
- EXPORT( 9, FreeFpl)
- EXPORT( 11, ReferFplStatus)
- EXPORT( 12, iReferFplStatus)
-END_MODULE
-MODULE(thmsgbx)
- EXPORT( 4, CreateMbx)
- EXPORT( 5, DeleteMbx)
- EXPORT( 6, SendMbx)
- EXPORT( 7, iSendMbx)
- EXPORT( 8, ReceiveMbx)
- EXPORT( 9, PollMbx)
- EXPORT( 11, ReferMbxStatus)
- EXPORT( 12, iReferMbxStatus)
-END_MODULE
-MODULE(thsemap)
- EXPORT( 4, CreateSema)
- EXPORT( 5, DeleteSema)
- EXPORT( 6, SignalSema)
- EXPORT( 7, iSignalSema)
- EXPORT( 8, WaitSema)
- EXPORT( 9, PollSema)
- EXPORT( 11, ReferSemaStatus)
- EXPORT( 12, iReferSemaStatus)
-END_MODULE
-MODULE(thvpool)
- EXPORT( 4, CreateVpl)
- EXPORT( 5, DeleteVpl)
- EXPORT( 6, AllocateVpl)
- EXPORT( 7, pAllocateVpl)
- EXPORT( 8, ipAllocateVpl)
- EXPORT( 9, FreeVpl)
- EXPORT( 11, ReferVplStatus)
- EXPORT( 12, iReferVplStatus)
-END_MODULE
-MODULE(timrman)
- EXPORT( 4, AllocHardTimer)
- EXPORT( 5, ReferHardTimer)
- EXPORT( 6, FreeHardTimer)
- EXPORT( 7, SetTimerMode)
- EXPORT( 8, GetTimerStatus)
- EXPORT( 9, SetTimerCounter)
- EXPORT( 10, GetTimerCounter)
- EXPORT( 11, SetTimerCompare)
- EXPORT( 12, GetTimerCompare)
- EXPORT( 16, GetHardTimerIntrCode)
- EXPORT( 20, SetTimerHandler)
- EXPORT( 21, SetOverflowHandler)
- EXPORT( 22, SetupHardTimer)
- EXPORT( 23, StartHardTimer)
- EXPORT( 24, StopHardTimer)
-END_MODULE
-MODULE(usbd)
- EXPORT( 4, sceUsbdRegisterLdd)
- EXPORT( 5, sceUsbdUnregisterLdd)
- EXPORT( 6, sceUsbdScanStaticDescriptor)
- EXPORT( 7, sceUsbdSetPrivateData)
- EXPORT( 8, sceUsbdGetPrivateData)
- EXPORT( 9, sceUsbdOpenPipe)
- EXPORT( 10, sceUsbdClosePipe)
- EXPORT( 11, sceUsbdTransferPipe)
- EXPORT( 12, sceUsbdOpenPipeAligned)
- EXPORT( 13, sceUsbdGetDeviceLocation)
- EXPORT( 16, sceUsbdChangeThreadPriority)
- EXPORT( 17, sceUsbdGetReportDescriptor)
- EXPORT( 18, sceUsbdMultiIsochronousTransfer)
-END_MODULE
-MODULE(usbmload)
- EXPORT( 4, sceUsbmlDisable)
- EXPORT( 5, sceUsbmlEnable)
- EXPORT( 6, sceUsbmlActivateCategory)
- EXPORT( 7, sceUsbmlInactivateCategory)
- EXPORT( 8, sceUsbmlRegisterLoadFunc)
- EXPORT( 9, sceUsbmlUnregisterLoadFunc)
- EXPORT( 10, sceUsbmlLoadConffile)
- EXPORT( 11, sceUsbmlRegisterDevice)
- EXPORT( 12, sceUsbmlChangeThreadPriority)
-END_MODULE
-MODULE(vblank)
- EXPORT( 4, WaitVblankStart)
- EXPORT( 5, WaitVblankEnd)
- EXPORT( 6, WaitVblank)
- EXPORT( 7, WaitNonVblank)
- EXPORT( 8, RegisterVblankHandler)
- EXPORT( 9, ReleaseVblankHandler)
-END_MODULE
-
-// undocumented functions from old list
-#if 0
-MODULE(sysmem)
- EXPORT( 3, return_addr_of_memsize)
- EXPORT( 15, set_Kprintf)
-END_MODULE
-MODULE(loadcore)
- EXPORT( 3, return_LibraryEntryTable)
- EXPORT( 8, findFixImports)
- EXPORT( 9, restoreImports)
- EXPORT( 14, setFlag)
- EXPORT( 15, resetFlag)
- EXPORT( 16, linkModule)
- EXPORT( 17, unlinkModule)
- EXPORT( 20, registerFunc)
- EXPORT( 22, read_header)
- EXPORT( 23, load_module)
- EXPORT( 24, findImageInfo)
-END_MODULE
-MODULE(excepman)
- EXPORT( 3, getcommon)
-END_MODULE
-MODULE(intrman)
- EXPORT( 10, syscall04)
- EXPORT( 11, syscall08)
- EXPORT( 12, resetICTRL)
- EXPORT( 13, setICTRL)
- EXPORT( 14, syscall0C)
- EXPORT( 19, CpuSuspendIntr)
- EXPORT( 20, CpuResumeIntr)
- EXPORT( 21, syscall10)
- EXPORT( 22, syscall14)
- EXPORT( 28, set_h1)
- EXPORT( 29, reset_h1)
- EXPORT( 30, set_h2)
- EXPORT( 31, reset_h2)
-END_MODULE
-MODULE(ssbusc)
- EXPORT( 4, setTable1)
- EXPORT( 5, getTable1)
- EXPORT( 6, setTable2)
- EXPORT( 7, getTable2)
- EXPORT( 8, setCOM_DELAY_1st)
- EXPORT( 9, getCOM_DELAY_1st)
- EXPORT( 10, setCOM_DELAY_2nd)
- EXPORT( 11, getCOM_DELAY_2nd)
- EXPORT( 12, setCOM_DELAY_3rd)
- EXPORT( 13, getCOM_DELAY_3rd)
- EXPORT( 14, setCOM_DELAY_4th)
- EXPORT( 15, getCOM_DELAY_4th)
- EXPORT( 16, setCOM_DELAY)
- EXPORT( 16, getCOM_DELAY)
-END_MODULE
-MODULE(dmacman)
- EXPORT( 4, SetD_MADR)
- EXPORT( 5, GetD_MADR)
- EXPORT( 6, SetD_BCR)
- EXPORT( 7, GetD_BCR)
- EXPORT( 8, SetD_CHCR)
- EXPORT( 9, GetD_CHCR)
- EXPORT( 10, SetD_TADR)
- EXPORT( 11, GetD_TADR)
- EXPORT( 12, Set_4_9_A)
- EXPORT( 13, Get_4_9_A)
- EXPORT( 14, SetDPCR)
- EXPORT( 15, GetDPCR)
- EXPORT( 16, SetDPCR2)
- EXPORT( 17, GetDPCR2)
- EXPORT( 18, SetDPCR3)
- EXPORT( 19, GetDPCR3)
- EXPORT( 20, SetDICR)
- EXPORT( 21, GetDICR)
- EXPORT( 22, SetDICR2)
- EXPORT( 23, GetDICR2)
- EXPORT( 24, SetBF80157C)
- EXPORT( 25, GetBF80157C)
- EXPORT( 26, SetBF801578)
- EXPORT( 27, GetBF801578)
- EXPORT( 28, SetDMA)
- EXPORT( 29, SetDMA_chainedSPU_SIF0)
- EXPORT( 30, SetDMA_SIF0)
- EXPORT( 31, SetDMA_SIF1)
- EXPORT( 32, StartTransfer)
- EXPORT( 33, SetVal)
- EXPORT( 34, EnableDMAch)
- EXPORT( 35, DisableDMAch)
-END_MODULE
-MODULE(timrman)
- EXPORT( 13, SetHoldMode)
- EXPORT( 14, GetHoldMode)
- EXPORT( 15, GetHoldReg)
-END_MODULE
-MODULE(sifman)
- EXPORT( 4, sceSif2Init)
- EXPORT( 9, sceSifSend)
- EXPORT( 10, sceSifSendSync)
- EXPORT( 11, sceSifIsSending)
- EXPORT( 12, sceSifSetSIF0DMA)
- EXPORT( 13, sceSifSendSync0)
- EXPORT( 14, sceSifIsSending0)
- EXPORT( 15, sceSifSetSIF1DMA)
- EXPORT( 16, sceSifSendSync1)
- EXPORT( 17, sceSifIsSending1)
- EXPORT( 18, sceSifSetSIF2DMA)
- EXPORT( 19, sceSifSendSync2)
- EXPORT( 20, sceSifIsSending2)
- EXPORT( 21, getEEIOPflags)
- EXPORT( 22, setEEIOPflags)
- EXPORT( 23, getIOPEEflags)
- EXPORT( 24, setIOPEEflags)
- EXPORT( 25, getEErcvaddr)
- EXPORT( 26, getIOPrcvaddr)
- EXPORT( 27, setIOPrcvaddr)
- EXPORT( 30, setSif0CB)
- EXPORT( 31, resetSif0CB)
-END_MODULE
-MODULE(sifcmd)
- EXPORT( 9, sceSifSetSysCmdBuffer)
- EXPORT( 26, setSif1CB)
- EXPORT( 27, resetSif1CB)
-END_MODULE
-MODULE(cdvdman)
- EXPORT( 20, sceDvdRead)
- EXPORT( 23, sceCdWriteILinkID)
- EXPORT( 25, sceCdWriteRTC)
- EXPORT( 26, sceCdReadNVM)
- EXPORT( 27, sceCdWriteNVM)
- EXPORT( 30, setHDmode)
- EXPORT( 31, sceCdOpenConfig)
- EXPORT( 32, sceCdCloseConfig)
- EXPORT( 33, sceCdReadConfig)
- EXPORT( 34, sceCdWriteConfig)
- EXPORT( 35, sceCdReadKey)
- EXPORT( 36. sceCdDecSet)
- EXPORT( 41, sceCdReadConsoleID)
- EXPORT( 42, sceCdWriteConsoleID)
- EXPORT( 43, sceCdGetMecaconVersion)
- EXPORT( 52, sceCdForbidDVDP)
- EXPORT( 53, sceCdReadSubQ)
- EXPORT( 55, AutoAdjustCtrl)
-END_MODULE
-MODULE(sio2man)
- EXPORT( 4, set8268_ctrl)
- EXPORT( 5, get8268_ctrl)
- EXPORT( 6, get826C_recv1)
- EXPORT( 7, call7_send1)
- EXPORT( 8, call8_send1)
- EXPORT( 9, call9_send2)
- EXPORT( 10, call10_send2)
- EXPORT( 11, get8270_recv2)
- EXPORT( 12, call12_set_params)
- EXPORT( 13, call13_get_params)
- EXPORT( 14, get8274_recv3)
- EXPORT( 15, set8278)
- EXPORT( 16, get8278)
- EXPORT( 17, set827C)
- EXPORT( 18, get827C)
- EXPORT( 19, set8260_datain)
- EXPORT( 20, get8264_dataout)
- EXPORT( 21, set8280_intr)
- EXPORT( 22, get8280_intr)
- EXPORT( 23, signalExchange1)
- EXPORT( 24, signalExchange2)
- EXPORT( 25, packetExchange)
-END_MODULE
-#endif
-
-#undef MODULE
-#undef END_MODULE
-#undef EXPORT
+/* 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 .
+ */
+
+#define MODULE(n) if (!strncmp(libname, #n, 8)) switch (index) {
+#define END_MODULE }
+#define EXPORT(i, n) case (i): return #n;
+
+// machine generated
+MODULE(cdvdman)
+ EXPORT( 4, sceCdInit)
+ EXPORT( 5, sceCdStandby)
+ EXPORT( 6, sceCdRead)
+ EXPORT( 7, sceCdSeek)
+ EXPORT( 8, sceCdGetError)
+ EXPORT( 9, sceCdGetToc)
+ EXPORT( 10, sceCdSearchFile)
+ EXPORT( 11, sceCdSync)
+ EXPORT( 12, sceCdGetDiskType)
+ EXPORT( 13, sceCdDiskReady)
+ EXPORT( 14, sceCdTrayReq)
+ EXPORT( 15, sceCdStop)
+ EXPORT( 16, sceCdPosToInt)
+ EXPORT( 17, sceCdIntToPos)
+ EXPORT( 21, sceCdCheckCmd)
+ EXPORT( 22, _sceCdRI)
+ EXPORT( 24, sceCdReadClock)
+ EXPORT( 28, sceCdStatus)
+ EXPORT( 29, sceCdApplySCmd)
+ EXPORT( 37, sceCdCallback)
+ EXPORT( 38, sceCdPause)
+ EXPORT( 39, sceCdBreak)
+ EXPORT( 40, sceCdReadCDDA)
+ EXPORT( 44, sceCdGetReadPos)
+ EXPORT( 45, sceCdCtrlADout)
+ EXPORT( 46, sceCdNop)
+ EXPORT( 47, _sceGetFsvRbuf)
+ EXPORT( 48, _sceCdstm0Cb)
+ EXPORT( 49, _sceCdstm1Cb)
+ EXPORT( 50, _sceCdSC)
+ EXPORT( 51, _sceCdRC)
+ EXPORT( 54, sceCdApplyNCmd)
+ EXPORT( 56, sceCdStInit)
+ EXPORT( 57, sceCdStRead)
+ EXPORT( 58, sceCdStSeek)
+ EXPORT( 59, sceCdStStart)
+ EXPORT( 60, sceCdStStat)
+ EXPORT( 61, sceCdStStop)
+ EXPORT( 62, sceCdRead0)
+ EXPORT( 63, _sceCdRV)
+ EXPORT( 64, _sceCdRM)
+ EXPORT( 66, sceCdReadChain)
+ EXPORT( 67, sceCdStPause)
+ EXPORT( 68, sceCdStResume)
+ EXPORT( 74, sceCdPowerOff)
+ EXPORT( 75, sceCdMmode)
+ EXPORT( 77, sceCdStSeekF)
+ EXPORT( 78, sceCdPOffCallback)
+ EXPORT( 81, _sceCdSetTimeout)
+ EXPORT( 83, sceCdReadDvdDualInfo)
+ EXPORT( 84, sceCdLayerSearchFile)
+ EXPORT(112, sceCdApplySCmd2)
+ EXPORT(114, _sceCdRE)
+END_MODULE
+MODULE(deci2api)
+ EXPORT( 4, sceDeci2Open)
+ EXPORT( 5, sceDeci2Close)
+ EXPORT( 6, sceDeci2ExRecv)
+ EXPORT( 7, sceDeci2ExSend)
+ EXPORT( 8, sceDeci2ReqSend)
+ EXPORT( 9, sceDeci2ExReqSend)
+ EXPORT( 10, sceDeci2ExLock)
+ EXPORT( 11, sceDeci2ExUnLock)
+ EXPORT( 12, sceDeci2ExPanic)
+ EXPORT( 13, sceDeci2Poll)
+ EXPORT( 14, sceDeci2ExPoll)
+ EXPORT( 15, sceDeci2ExRecvSuspend)
+ EXPORT( 16, sceDeci2ExRecvUnSuspend)
+ EXPORT( 17, sceDeci2ExWakeupThread)
+ EXPORT( 18, sceDeci2ExSignalSema)
+ EXPORT( 19, sceDeci2ExSetEventFlag)
+END_MODULE
+MODULE(eenetctl)
+ EXPORT( 4, sceEENetCtlSetConfiguration)
+ EXPORT( 5, sceEENetCtlRegisterDialCnf)
+ EXPORT( 6, sceEENetCtlUnRegisterDialCnf)
+ EXPORT( 7, sceEENetCtlSetDialingData)
+ EXPORT( 8, sceEENetCtlClearDialingData)
+END_MODULE
+MODULE(ent_devm)
+ EXPORT( 4, sceEENetDevAttach)
+ EXPORT( 5, sceEENetDevReady)
+ EXPORT( 6, sceEENetDevDetach)
+ EXPORT( 7, sceEENetSifAddCmdHandler)
+ EXPORT( 8, sceEENetSifRemoveCmdHandler)
+ EXPORT( 9, sceEENetSifSendCmd)
+ EXPORT( 10, sceEENetSifBindRpc)
+ EXPORT( 11, sceEENetSifCallRpc)
+ EXPORT( 12, sceEENetCheckWaitingDriverList)
+ EXPORT( 13, sceEENetCheckTerminatedDriverList)
+END_MODULE
+MODULE(excepman)
+ EXPORT( 4, RegisterExceptionHandler)
+ EXPORT( 5, RegisterPriorityExceptionHandler)
+ EXPORT( 6, RegisterDefaultExceptionHandler)
+ EXPORT( 7, ReleaseExceptionHandler)
+ EXPORT( 8, ReleaseDefaultExceptionHandler)
+END_MODULE
+MODULE(heaplib)
+ EXPORT( 4, CreateHeap)
+ EXPORT( 5, DeleteHeap)
+ EXPORT( 6, AllocHeapMemory)
+ EXPORT( 7, FreeHeapMemory)
+ EXPORT( 8, HeapTotalFreeSize)
+END_MODULE
+MODULE(ilink)
+ EXPORT( 0, sce1394SetupModule)
+ EXPORT( 2, sce1394ReleaseModule)
+ EXPORT( 4, sce1394Initialize)
+ EXPORT( 5, sce1394Destroy)
+ EXPORT( 6, sce1394Debug)
+ EXPORT( 7, sce1394ConfGet)
+ EXPORT( 8, sce1394ConfSet)
+ EXPORT( 9, sce1394ChangeThreadPriority)
+ EXPORT( 12, sce1394UnitAdd)
+ EXPORT( 13, sce1394UnitDelete)
+ EXPORT( 17, sce1394GenerateCrc32)
+ EXPORT( 18, sce1394GenerateCrc16)
+ EXPORT( 19, sce1394ValidateCrc16)
+ EXPORT( 23, sce1394SbControl)
+ EXPORT( 24, sce1394SbEnable)
+ EXPORT( 25, sce1394SbDisable)
+ EXPORT( 26, sce1394SbReset)
+ EXPORT( 27, sce1394SbEui64)
+ EXPORT( 28, sce1394SbNodeId)
+ EXPORT( 29, sce1394SbNodeCount)
+ EXPORT( 30, sce1394SbSelfId)
+ EXPORT( 31, sce1394SbGenNumber)
+ EXPORT( 32, sce1394SbPhyPacket)
+ EXPORT( 33, sce1394SbCycleTime)
+ EXPORT( 36, sce1394EvAlloc)
+ EXPORT( 37, sce1394EvFree)
+ EXPORT( 38, sce1394EvWait)
+ EXPORT( 39, sce1394EvPoll)
+ EXPORT( 43, sce1394PbAlloc)
+ EXPORT( 44, sce1394PbFree)
+ EXPORT( 45, sce1394PbGet)
+ EXPORT( 46, sce1394PbSet)
+ EXPORT( 50, sce1394TrDataInd)
+ EXPORT( 51, sce1394TrDataUnInd)
+ EXPORT( 55, sce1394TrAlloc)
+ EXPORT( 56, sce1394TrFree)
+ EXPORT( 57, sce1394TrGet)
+ EXPORT( 58, sce1394TrSet)
+ EXPORT( 59, sce1394TrWrite)
+ EXPORT( 60, sce1394TrWriteV)
+ EXPORT( 61, sce1394TrRead)
+ EXPORT( 62, sce1394TrReadV)
+ EXPORT( 63, sce1394TrLock)
+ EXPORT( 67, sce1394CrEui64)
+ EXPORT( 68, sce1394CrGenNumber)
+ EXPORT( 69, sce1394CrMaxRec)
+ EXPORT( 70, sce1394CrMaxSpeed)
+ EXPORT( 71, sce1394CrRead)
+ EXPORT( 72, sce1394CrCapability)
+ EXPORT( 73, sce1394CrFindNode)
+ EXPORT( 74, sce1394CrFindUnit)
+ EXPORT( 75, sce1394CrInvalidate)
+END_MODULE
+MODULE(ilsocket)
+ EXPORT( 0, sceILsockModuleInit)
+ EXPORT( 2, sceILsockModuleReset)
+ EXPORT( 4, sceILsockInit)
+ EXPORT( 5, sceILsockReset)
+ EXPORT( 8, sceILsockOpen)
+ EXPORT( 9, sceILsockClose)
+ EXPORT( 10, sceILsockBind)
+ EXPORT( 11, sceILsockConnect)
+ EXPORT( 12, sceILsockSend)
+ EXPORT( 13, sceILsockSendTo)
+ EXPORT( 14, sceILsockRecv)
+ EXPORT( 15, sceILsockRecvFrom)
+ EXPORT( 18, sceILsockHtoNl)
+ EXPORT( 19, sceILsockHtoNs)
+ EXPORT( 20, sceILsockNtoHl)
+ EXPORT( 21, sceILsockNtoHs)
+ EXPORT( 22, sce1394GetCycleTimeV)
+END_MODULE
+MODULE(inet)
+ EXPORT( 4, sceInetName2Address)
+ EXPORT( 5, sceInetAddress2String)
+ EXPORT( 6, sceInetCreate)
+ EXPORT( 7, sceInetOpen)
+ EXPORT( 8, sceInetClose)
+ EXPORT( 9, sceInetRecv)
+ EXPORT( 10, sceInetSend)
+ EXPORT( 11, sceInetAbort)
+ EXPORT( 12, sceInetRecvFrom)
+ EXPORT( 13, sceInetSendTo)
+ EXPORT( 14, sceInetAddress2Name)
+ EXPORT( 15, sceInetControl)
+ EXPORT( 16, sceInetPoll)
+ EXPORT( 17, sceInetNtohs)
+ EXPORT( 18, sceInetHtons)
+ EXPORT( 19, sceInetNtohl)
+ EXPORT( 20, sceInetHtonl)
+ EXPORT( 21, sceInetGet4u)
+ EXPORT( 22, sceInetPut4u)
+ EXPORT( 24, sceInetGetInterfaceList)
+ EXPORT( 25, sceInetInterfaceControl)
+ EXPORT( 27, sceInetGetRoutingTable)
+ EXPORT( 28, sceInetAddRouting)
+ EXPORT( 29, sceInetDelRouting)
+ EXPORT( 30, sceInetGetNameServers)
+ EXPORT( 31, sceInetAddNameServer)
+ EXPORT( 32, sceInetDelNameServer)
+ EXPORT( 36, sceInetChangeThreadPriority)
+ EXPORT( 38, sceInetGetLog)
+ EXPORT( 39, sceInetWaitInterfaceEvent)
+ EXPORT( 40, sceInetSignalInterfaceEvent)
+ EXPORT( 41, sceInetAbortLog)
+END_MODULE
+MODULE(inetctl)
+ EXPORT( 4, sceInetCtlSetConfiguration)
+ EXPORT( 5, sceInetCtlUpInterface)
+ EXPORT( 6, sceInetCtlDownInterface)
+ EXPORT( 7, sceInetCtlSetAutoMode)
+ EXPORT( 8, sceInetCtlRegisterEventHandler)
+ EXPORT( 9, sceInetCtlUnregisterEventHandler)
+ EXPORT( 10, sceInetCtlGetState)
+ EXPORT( 11, sceInetCtlGetConfiguration)
+ EXPORT( 12, sceInetCtlSetDialingData)
+ EXPORT( 13, sceInetCtlClearDialingData)
+END_MODULE
+MODULE(intrman)
+ EXPORT( 4, RegisterIntrHandler)
+ EXPORT( 5, ReleaseIntrHandler)
+ EXPORT( 6, EnableIntr)
+ EXPORT( 7, DisableIntr)
+ EXPORT( 8, CpuDisableIntr)
+ EXPORT( 9, CpuEnableIntr)
+ EXPORT( 17, CpuSuspendIntr)
+ EXPORT( 18, CpuResumeIntr)
+ EXPORT( 23, QueryIntrContext)
+ EXPORT( 24, QueryIntrStack)
+ EXPORT( 25, iCatchMultiIntr)
+END_MODULE
+MODULE(ioman)
+ EXPORT( 4, open)
+ EXPORT( 5, close)
+ EXPORT( 6, read)
+ EXPORT( 7, write)
+ EXPORT( 8, lseek)
+ EXPORT( 9, ioctl)
+ EXPORT( 10, remove)
+ EXPORT( 11, mkdir)
+ EXPORT( 12, rmdir)
+ EXPORT( 13, dopen)
+ EXPORT( 14, dclose)
+ EXPORT( 15, dread)
+ EXPORT( 16, getstat)
+ EXPORT( 17, chstat)
+ EXPORT( 18, format)
+ EXPORT( 20, AddDrv)
+ EXPORT( 21, DelDrv)
+ EXPORT( 23, StdioInit)
+ EXPORT( 25, rename)
+ EXPORT( 26, chdir)
+ EXPORT( 27, sync)
+ EXPORT( 28, mount)
+ EXPORT( 29, umount)
+ EXPORT( 30, lseek64)
+ EXPORT( 31, devctl)
+ EXPORT( 32, symlink)
+ EXPORT( 33, readlink)
+ EXPORT( 34, ioctl2)
+END_MODULE
+MODULE(libsd)
+ EXPORT( 2, sceSdQuit)
+ EXPORT( 4, sceSdInit)
+ EXPORT( 5, sceSdSetParam)
+ EXPORT( 6, sceSdGetParam)
+ EXPORT( 7, sceSdSetSwitch)
+ EXPORT( 8, sceSdGetSwitch)
+ EXPORT( 9, sceSdSetAddr)
+ EXPORT( 10, sceSdGetAddr)
+ EXPORT( 11, sceSdSetCoreAttr)
+ EXPORT( 12, sceSdGetCoreAttr)
+ EXPORT( 13, sceSdNote2Pitch)
+ EXPORT( 14, sceSdPitch2Note)
+ EXPORT( 15, sceSdProcBatch)
+ EXPORT( 16, sceSdProcBatchEx)
+ EXPORT( 17, sceSdVoiceTrans)
+ EXPORT( 18, sceSdBlockTrans)
+ EXPORT( 19, sceSdVoiceTransStatus)
+ EXPORT( 20, sceSdBlockTransStatus)
+ EXPORT( 21, sceSdSetTransCallback)
+ EXPORT( 22, sceSdSetIRQCallback)
+ EXPORT( 23, sceSdSetEffectAttr)
+ EXPORT( 24, sceSdGetEffectAttr)
+ EXPORT( 25, sceSdClearEffectWorkArea)
+ EXPORT( 26, sceSdSetTransIntrHandler)
+ EXPORT( 27, sceSdSetSpu2IntrHandler)
+ EXPORT( 28, sceSdGetTransIntrHandlerArgument)
+ EXPORT( 29, sceSdGetSpu2IntrHandlerArgument)
+ EXPORT( 30, sceSdStopTrans)
+ EXPORT( 31, sceSdCleanEffectWorkArea)
+ EXPORT( 32, sceSdSetEffectMode)
+ EXPORT( 33, sceSdSetEffectModeParams)
+END_MODULE
+MODULE(loadcore)
+ EXPORT( 4, FlushIcache)
+ EXPORT( 5, FlushDcache)
+ EXPORT( 6, RegisterLibraryEntries)
+ EXPORT( 7, ReleaseLibraryEntries)
+ EXPORT( 10, RegisterNonAutoLinkEntries)
+ EXPORT( 11, QueryLibraryEntryTable)
+ EXPORT( 12, QueryBootMode)
+ EXPORT( 13, RegisterBootMode)
+ EXPORT( 27, SetRebootTimeLibraryHandlingMode)
+END_MODULE
+MODULE(moddelay)
+ EXPORT( 4, sceMidiDelay_Init)
+ EXPORT( 5, sceMidiDelay_ATick)
+ EXPORT( 6, sceMidiDelay_Flush)
+END_MODULE
+MODULE(modem)
+ EXPORT( 4, sceModemRegisterDevice)
+ EXPORT( 5, sceModemUnregisterDevice)
+END_MODULE
+MODULE(modhsyn)
+ EXPORT( 4, sceHSyn_Init)
+ EXPORT( 5, sceHSyn_ATick)
+ EXPORT( 6, sceHSyn_Load)
+ EXPORT( 7, sceHSyn_VoiceTrans)
+ EXPORT( 8, sceHSyn_SetReservVoice)
+ EXPORT( 9, sceHSyn_SetEffectAttr)
+ EXPORT( 10, sceHSyn_SetVolume)
+ EXPORT( 11, sceHSyn_GetVolume)
+ EXPORT( 12, sceHSyn_AllNoteOff)
+ EXPORT( 13, sceHSyn_AllSoundOff)
+ EXPORT( 14, sceHSyn_ResetAllControler)
+ EXPORT( 15, sceHSyn_SetVoiceStatBuffer)
+ EXPORT( 16, sceHSyn_SetDebugInfoBuffer)
+ EXPORT( 17, sceHSyn_GetChStat)
+ EXPORT( 18, sceHSyn_SetOutputMode)
+ EXPORT( 19, sceHSyn_SESetMaxVoices)
+ EXPORT( 20, sceHSyn_SEAllNoteOff)
+ EXPORT( 21, sceHSyn_SEAllSoundOff)
+ EXPORT( 22, sceHSyn_SERetrieveVoiceNumberByID)
+ EXPORT( 23, sceHSyn_MSGetVoiceStateByID)
+ EXPORT( 24, sceHSyn_MSGetVoiceEnvelopeByID)
+ EXPORT( 25, sceHSyn_SERetrieveAllSEMsgIDs)
+ EXPORT( 26, sceHSyn_GetReservVoice)
+ EXPORT( 27, sceHSyn_GetOutputMode)
+ EXPORT( 28, sceHSyn_Unload)
+END_MODULE
+MODULE(modload)
+ EXPORT( 4, ReBootStart)
+ EXPORT( 5, LoadModuleAddress)
+ EXPORT( 6, LoadModule)
+ EXPORT( 7, LoadStartModule)
+ EXPORT( 8, StartModule)
+ EXPORT( 9, LoadModuleBufferAddress)
+ EXPORT( 10, LoadModuleBuffer)
+ EXPORT( 16, GetModuleIdList)
+ EXPORT( 17, ReferModuleStatus)
+ EXPORT( 18, GetModuleIdListByName)
+ EXPORT( 19, LoadModuleWithOption)
+ EXPORT( 20, StopModule)
+ EXPORT( 21, UnloadModule)
+ EXPORT( 22, SearchModuleByName)
+ EXPORT( 23, SearchModuleByAddress)
+ EXPORT( 26, SelfStopModule)
+ EXPORT( 27, SelfUnloadModule)
+ EXPORT( 28, AllocLoadMemory)
+ EXPORT( 29, FreeLoadMemory)
+ EXPORT( 30, SetModuleFlags)
+END_MODULE
+MODULE(modmidi)
+ EXPORT( 4, sceMidi_Init)
+ EXPORT( 5, sceMidi_ATick)
+ EXPORT( 6, sceMidi_Load)
+ EXPORT( 7, sceMidi_SelectSong)
+ EXPORT( 8, sceMidi_SongPlaySwitch)
+ EXPORT( 9, sceMidi_SongSetVolume)
+ EXPORT( 10, sceMidi_SongVolumeChange)
+ EXPORT( 11, sceMidi_SongSetAbsoluteTempo)
+ EXPORT( 12, sceMidi_SongSetRelativeTempo)
+ EXPORT( 13, sceMidi_SongSetLocation)
+ EXPORT( 14, sceMidi_SelectMidi)
+ EXPORT( 15, sceMidi_MidiPlaySwitch)
+ EXPORT( 16, sceMidi_MidiSetLocation)
+ EXPORT( 17, sceMidi_MidiSetVolume)
+ EXPORT( 18, sceMidi_MidiVolumeChange)
+ EXPORT( 19, sceMidi_MidiSetAbsoluteTempo)
+ EXPORT( 20, sceMidi_MidiGetAbsoluteTempo)
+ EXPORT( 21, sceMidi_MidiSetRelativeTempo)
+ EXPORT( 22, sceMidi_MidiGetRelativeTempo)
+ EXPORT( 23, sceMidi_MidiSetUSecTempo)
+ EXPORT( 24, sceMidi_MidiGetUSecTempo)
+ EXPORT( 25, sceMidi_Unload)
+END_MODULE
+MODULE(modmono)
+ EXPORT( 4, sceMidiMono_Init)
+ EXPORT( 5, sceMidiMono_ATick)
+ EXPORT( 6, sceMidiMono_SetMono)
+END_MODULE
+MODULE(modmsin)
+ EXPORT( 4, sceMSIn_Init)
+ EXPORT( 5, sceMSIn_ATick)
+ EXPORT( 6, sceMSIn_Load)
+ EXPORT( 7, sceMSIn_PutMsg)
+ EXPORT( 8, sceMSIn_PutExcMsg)
+ EXPORT( 9, sceMSIn_PutHsMsg)
+END_MODULE
+MODULE(modsein)
+ EXPORT( 4, sceSEIn_Init)
+ EXPORT( 5, sceSEIn_ATick)
+ EXPORT( 6, sceSEIn_Load)
+ EXPORT( 7, sceSEIn_PutMsg)
+ EXPORT( 8, sceSEIn_PutSEMsg)
+ EXPORT( 9, sceSEIn_MakeNoteOn)
+ EXPORT( 10, sceSEIn_MakePitchOn)
+ EXPORT( 11, sceSEIn_MakeTimeVolume)
+ EXPORT( 12, sceSEIn_MakeTimePanpot)
+ EXPORT( 13, sceSEIn_MakeTimePitch)
+ EXPORT( 14, sceSEIn_MakePitchLFO)
+ EXPORT( 15, sceSEIn_MakeAmpLFO)
+ EXPORT( 16, sceSEIn_MakeAllNoteOff)
+ EXPORT( 17, sceSEIn_MakeAllNoteOffMask)
+ EXPORT( 18, sceSEIn_MakeNoteOnZero)
+ EXPORT( 19, sceSEIn_MakePitchOnZero)
+END_MODULE
+MODULE(modsesq)
+ EXPORT( 4, sceSESq_Init)
+ EXPORT( 5, sceSESq_ATick)
+ EXPORT( 6, sceSESq_Load)
+ EXPORT( 7, sceSESq_SelectSeq)
+ EXPORT( 8, sceSESq_UnselectSeq)
+ EXPORT( 9, sceSESq_SeqPlaySwitch)
+ EXPORT( 10, sceSESq_SeqGetStatus)
+ EXPORT( 11, sceSESq_SeqIsInPlay)
+ EXPORT( 12, sceSESq_SeqIsDataEnd)
+ EXPORT( 13, sceSESq_SeqSetSEMsgID)
+ EXPORT( 14, sceSESq_SeqTerminateVoice)
+END_MODULE
+MODULE(modssyn)
+ EXPORT( 4, sceSSyn_Init)
+ EXPORT( 5, sceSSyn_ATick)
+ EXPORT( 6, sceSSyn_Load)
+END_MODULE
+MODULE(msifrpc)
+ EXPORT( 4, sceSifMInitRpc)
+ EXPORT( 16, sceSifMTermRpc)
+ EXPORT( 17, sceSifMEntryLoop)
+END_MODULE
+MODULE(netcnf)
+ EXPORT( 4, sceNetCnfGetCount)
+ EXPORT( 5, sceNetCnfGetList)
+ EXPORT( 6, sceNetCnfLoadEntry)
+ EXPORT( 7, sceNetCnfAddEntry)
+ EXPORT( 8, sceNetCnfDeleteEntry)
+ EXPORT( 9, sceNetCnfSetLatestEntry)
+ EXPORT( 10, sceNetCnfAllocMem)
+ EXPORT( 11, sceNetCnfInitIFC)
+ EXPORT( 12, sceNetCnfLoadConf)
+ EXPORT( 13, sceNetCnfLoadDial)
+ EXPORT( 14, sceNetCnfMergeConf)
+ EXPORT( 15, sceNetCnfName2Address)
+ EXPORT( 16, sceNetCnfAddress2String)
+ EXPORT( 17, sceNetCnfEditEntry)
+ EXPORT( 18, sceNetCnfDeleteAll)
+ EXPORT( 19, sceNetCnfCheckCapacity)
+ EXPORT( 20, sceNetCnfConvA2S)
+ EXPORT( 21, sceNetCnfConvS2A)
+ EXPORT( 22, sceNetCnfCheckSpecialProvider)
+ EXPORT( 23, sceNetCnfSetCallback)
+END_MODULE
+MODULE(netdev)
+ EXPORT( 4, sceInetRegisterNetDevice)
+ EXPORT( 5, sceInetUnregisterNetDevice)
+ EXPORT( 6, sceInetAllocMem)
+ EXPORT( 7, sceInetFreeMem)
+ EXPORT( 8, sceInetPktEnQ)
+ EXPORT( 9, sceInetPktDeQ)
+ EXPORT( 10, sceInetRand)
+ EXPORT( 11, sceInetPrintf)
+ EXPORT( 12, sceInetAllocPkt)
+ EXPORT( 13, sceInetFreePkt)
+ EXPORT( 14, sceInetRegisterPPPoE)
+ EXPORT( 15, sceInetUnregisterPPPoE)
+END_MODULE
+MODULE(scrtpad)
+ EXPORT( 4, AllocScratchPad)
+ EXPORT( 5, FreeScratchPad)
+END_MODULE
+MODULE(sdhd)
+ EXPORT( 4, sceSdHdGetMaxProgramNumber)
+ EXPORT( 5, sceSdHdGetMaxSampleSetNumber)
+ EXPORT( 6, sceSdHdGetMaxSampleNumber)
+ EXPORT( 7, sceSdHdGetMaxVAGInfoNumber)
+ EXPORT( 8, sceSdHdGetProgramParamAddr)
+ EXPORT( 9, sceSdHdGetProgramParam)
+ EXPORT( 10, sceSdHdGetSplitBlockAddr)
+ EXPORT( 11, sceSdHdGetSplitBlock)
+ EXPORT( 12, sceSdHdGetSampleSetParamAddr)
+ EXPORT( 13, sceSdHdGetSampleSetParam)
+ EXPORT( 14, sceSdHdGetSampleParamAddr)
+ EXPORT( 15, sceSdHdGetSampleParam)
+ EXPORT( 16, sceSdHdGetVAGInfoParamAddr)
+ EXPORT( 17, sceSdHdGetVAGInfoParam)
+ EXPORT( 18, sceSdHdCheckProgramNumber)
+ EXPORT( 19, sceSdHdGetSplitBlockCountByNote)
+ EXPORT( 20, sceSdHdGetSplitBlockAddrByNote)
+ EXPORT( 21, sceSdHdGetSplitBlockByNote)
+ EXPORT( 22, sceSdHdGetSampleSetParamCountByNote)
+ EXPORT( 23, sceSdHdGetSampleSetParamAddrByNote)
+ EXPORT( 24, sceSdHdGetSampleSetParamByNote)
+ EXPORT( 25, sceSdHdGetSampleParamCountByNoteVelocity)
+ EXPORT( 26, sceSdHdGetSampleParamAddrByNoteVelocity)
+ EXPORT( 27, sceSdHdGetSampleParamByNoteVelocity)
+ EXPORT( 28, sceSdHdGetVAGInfoParamCountByNoteVelocity)
+ EXPORT( 29, sceSdHdGetVAGInfoParamAddrByNoteVelocity)
+ EXPORT( 30, sceSdHdGetVAGInfoParamByNoteVelocity)
+ EXPORT( 31, sceSdHdGetSampleParamCountByVelocity)
+ EXPORT( 32, sceSdHdGetSampleParamAddrByVelocity)
+ EXPORT( 33, sceSdHdGetSampleParamByVelocity)
+ EXPORT( 34, sceSdHdGetVAGInfoParamCountByVelocity)
+ EXPORT( 35, sceSdHdGetVAGInfoParamAddrByVelocity)
+ EXPORT( 36, sceSdHdGetVAGInfoParamByVelocity)
+ EXPORT( 37, sceSdHdGetVAGInfoParamAddrBySampleNumber)
+ EXPORT( 38, sceSdHdGetVAGInfoParamBySampleNumber)
+ EXPORT( 39, sceSdHdGetSplitBlockNumberBySplitNumber)
+ EXPORT( 40, sceSdHdGetVAGSize)
+ EXPORT( 41, sceSdHdGetSplitBlockCount)
+ EXPORT( 42, sceSdHdGetMaxSplitBlockCount)
+ EXPORT( 43, sceSdHdGetMaxSampleSetParamCount)
+ EXPORT( 44, sceSdHdGetMaxSampleParamCount)
+ EXPORT( 45, sceSdHdGetMaxVAGInfoParamCount)
+ EXPORT( 46, sceSdHdModifyVelocity)
+ EXPORT( 47, sceSdHdModifyVelocityLFO)
+ EXPORT( 48, sceSdHdGetValidProgramNumberCount)
+ EXPORT( 49, sceSdHdGetValidProgramNumber)
+ EXPORT( 50, sceSdHdGetSampleNumberBySampleIndex)
+END_MODULE
+MODULE(sdrdrv)
+ EXPORT( 4, sceSdrChangeThreadPriority)
+ EXPORT( 5, sceSdrSetUserCommandFunction)
+END_MODULE
+MODULE(sdsq)
+ EXPORT( 4, sceSdSqGetMaxMidiNumber)
+ EXPORT( 5, sceSdSqGetMaxSongNumber)
+ EXPORT( 6, sceSdSqInitMidiData)
+ EXPORT( 7, sceSdSqReadMidiData)
+ EXPORT( 8, sceSdSqInitSongData)
+ EXPORT( 9, sceSdSqReadSongData)
+ EXPORT( 10, sceSdSqGetMaxCompTableIndex)
+ EXPORT( 11, sceSdSqGetCompTableOffset)
+ EXPORT( 12, sceSdSqGetCompTableDataByIndex)
+ EXPORT( 13, sceSdSqGetNoteOnEventByPolyKeyPress)
+ EXPORT( 14, sceSdSqCopyMidiData)
+ EXPORT( 15, sceSdSqCopySongData)
+END_MODULE
+MODULE(sifcmd)
+ EXPORT( 4, sceSifInitCmd)
+ EXPORT( 5, sceSifExitCmd)
+ EXPORT( 6, sceSifGetSreg)
+ EXPORT( 7, sceSifSetSreg)
+ EXPORT( 8, sceSifSetCmdBuffer)
+ EXPORT( 10, sceSifAddCmdHandler)
+ EXPORT( 11, sceSifRemoveCmdHandler)
+ EXPORT( 12, sceSifSendCmd)
+ EXPORT( 13, isceSifSendCmd)
+ EXPORT( 14, sceSifInitRpc)
+ EXPORT( 15, sceSifBindRpc)
+ EXPORT( 16, sceSifCallRpc)
+ EXPORT( 17, sceSifRegisterRpc)
+ EXPORT( 18, sceSifCheckStatRpc)
+ EXPORT( 19, sceSifSetRpcQueue)
+ EXPORT( 20, sceSifGetNextRequest)
+ EXPORT( 21, sceSifExecRequest)
+ EXPORT( 22, sceSifRpcLoop)
+ EXPORT( 23, sceSifGetOtherData)
+ EXPORT( 24, sceSifRemoveRpc)
+ EXPORT( 25, sceSifRemoveRpcQueue)
+ EXPORT( 28, sceSifSendCmdIntr)
+ EXPORT( 29, isceSifSendCmdIntr)
+END_MODULE
+MODULE(sifman)
+ EXPORT( 5, sceSifInit)
+ EXPORT( 6, sceSifSetDChain)
+ EXPORT( 7, sceSifSetDma)
+ EXPORT( 8, sceSifDmaStat)
+ EXPORT( 29, sceSifCheckInit)
+ EXPORT( 32, sceSifSetDmaIntr)
+END_MODULE
+MODULE(spucodec)
+ EXPORT( 4, sceSpuCodecEncode)
+END_MODULE
+MODULE(stdio)
+ EXPORT( 4, printf)
+ EXPORT( 5, getchar)
+ EXPORT( 6, putchar)
+ EXPORT( 7, puts)
+ EXPORT( 8, gets)
+ EXPORT( 9, fdprintf)
+ EXPORT( 10, fdgetc)
+ EXPORT( 11, fdputc)
+ EXPORT( 12, fdputs)
+ EXPORT( 13, fdgets)
+ EXPORT( 14, vfdprintf)
+END_MODULE
+MODULE(sysclib)
+ EXPORT( 4, setjmp)
+ EXPORT( 5, longjmp)
+ EXPORT( 6, toupper)
+ EXPORT( 7, tolower)
+ EXPORT( 8, look_ctype_table)
+ EXPORT( 9, get_ctype_table)
+ EXPORT( 10, memchr)
+ EXPORT( 11, memcmp)
+ EXPORT( 12, memcpy)
+ EXPORT( 13, memmove)
+ EXPORT( 14, memset)
+ EXPORT( 15, bcmp)
+ EXPORT( 16, bcopy)
+ EXPORT( 17, bzero)
+ EXPORT( 18, prnt)
+ EXPORT( 19, sprintf)
+ EXPORT( 20, strcat)
+ EXPORT( 21, strchr)
+ EXPORT( 22, strcmp)
+ EXPORT( 23, strcpy)
+ EXPORT( 24, strcspn)
+ EXPORT( 25, index)
+ EXPORT( 26, rindex)
+ EXPORT( 27, strlen)
+ EXPORT( 28, strncat)
+ EXPORT( 29, strncmp)
+ EXPORT( 30, strncpy)
+ EXPORT( 31, strpbrk)
+ EXPORT( 32, strrchr)
+ EXPORT( 33, strspn)
+ EXPORT( 34, strstr)
+ EXPORT( 35, strtok)
+ EXPORT( 36, strtol)
+ EXPORT( 37, atob)
+ EXPORT( 38, strtoul)
+ EXPORT( 40, wmemcopy)
+ EXPORT( 41, wmemset)
+ EXPORT( 42, vsprintf)
+ EXPORT( 43, strtok_r)
+END_MODULE
+MODULE(sysmem)
+ EXPORT( 4, AllocSysMemory)
+ EXPORT( 5, FreeSysMemory)
+ EXPORT( 6, QueryMemSize)
+ EXPORT( 7, QueryMaxFreeMemSize)
+ EXPORT( 8, QueryTotalFreeMemSize)
+ EXPORT( 9, QueryBlockTopAddress)
+ EXPORT( 10, QueryBlockSize)
+ EXPORT( 14, Kprintf)
+END_MODULE
+MODULE(thbase)
+ EXPORT( 4, CreateThread)
+ EXPORT( 5, DeleteThread)
+ EXPORT( 6, StartThread)
+ EXPORT( 7, StartThreadArgs)
+ EXPORT( 8, ExitThread)
+ EXPORT( 9, ExitDeleteThread)
+ EXPORT( 10, TerminateThread)
+ EXPORT( 11, iTerminateThread)
+ EXPORT( 12, DisableDispatchThread)
+ EXPORT( 13, EnableDispatchThread)
+ EXPORT( 14, ChangeThreadPriority)
+ EXPORT( 15, iChangeThreadPriority)
+ EXPORT( 16, RotateThreadReadyQueue)
+ EXPORT( 17, iRotateThreadReadyQueue)
+ EXPORT( 18, ReleaseWaitThread)
+ EXPORT( 19, iReleaseWaitThread)
+ EXPORT( 20, GetThreadId)
+ EXPORT( 21, CheckThreadStack)
+ EXPORT( 22, ReferThreadStatus)
+ EXPORT( 23, iReferThreadStatus)
+ EXPORT( 24, SleepThread)
+ EXPORT( 25, WakeupThread)
+ EXPORT( 26, iWakeupThread)
+ EXPORT( 27, CancelWakeupThread)
+ EXPORT( 28, iCancelWakeupThread)
+ EXPORT( 29, SuspendThread)
+ EXPORT( 30, iSuspendThread)
+ EXPORT( 31, ResumeThread)
+ EXPORT( 32, iResumeThread)
+ EXPORT( 33, DelayThread)
+ EXPORT( 34, GetSystemTime)
+ EXPORT( 35, SetAlarm)
+ EXPORT( 36, iSetAlarm)
+ EXPORT( 37, CancelAlarm)
+ EXPORT( 38, iCancelAlarm)
+ EXPORT( 39, USec2SysClock)
+ EXPORT( 40, SysClock2USec)
+ EXPORT( 41, GetSystemStatusFlag)
+ EXPORT( 42, GetThreadCurrentPriority)
+ EXPORT( 43, GetSystemTimeLow)
+ EXPORT( 44, ReferSystemStatus)
+ EXPORT( 45, ReferThreadRunStatus)
+ EXPORT( 46, GetThreadStackFreeSize)
+ EXPORT( 47, GetThreadmanIdList)
+END_MODULE
+MODULE(thevent)
+ EXPORT( 4, CreateEventFlag)
+ EXPORT( 5, DeleteEventFlag)
+ EXPORT( 6, SetEventFlag)
+ EXPORT( 7, iSetEventFlag)
+ EXPORT( 8, ClearEventFlag)
+ EXPORT( 9, iClearEventFlag)
+ EXPORT( 10, WaitEventFlag)
+ EXPORT( 11, PollEventFlag)
+ EXPORT( 13, ReferEventFlagStatus)
+ EXPORT( 14, iReferEventFlagStatus)
+END_MODULE
+MODULE(thfpool)
+ EXPORT( 4, CreateFpl)
+ EXPORT( 5, DeleteFpl)
+ EXPORT( 6, AllocateFpl)
+ EXPORT( 7, pAllocateFpl)
+ EXPORT( 8, ipAllocateFpl)
+ EXPORT( 9, FreeFpl)
+ EXPORT( 11, ReferFplStatus)
+ EXPORT( 12, iReferFplStatus)
+END_MODULE
+MODULE(thmsgbx)
+ EXPORT( 4, CreateMbx)
+ EXPORT( 5, DeleteMbx)
+ EXPORT( 6, SendMbx)
+ EXPORT( 7, iSendMbx)
+ EXPORT( 8, ReceiveMbx)
+ EXPORT( 9, PollMbx)
+ EXPORT( 11, ReferMbxStatus)
+ EXPORT( 12, iReferMbxStatus)
+END_MODULE
+MODULE(thsemap)
+ EXPORT( 4, CreateSema)
+ EXPORT( 5, DeleteSema)
+ EXPORT( 6, SignalSema)
+ EXPORT( 7, iSignalSema)
+ EXPORT( 8, WaitSema)
+ EXPORT( 9, PollSema)
+ EXPORT( 11, ReferSemaStatus)
+ EXPORT( 12, iReferSemaStatus)
+END_MODULE
+MODULE(thvpool)
+ EXPORT( 4, CreateVpl)
+ EXPORT( 5, DeleteVpl)
+ EXPORT( 6, AllocateVpl)
+ EXPORT( 7, pAllocateVpl)
+ EXPORT( 8, ipAllocateVpl)
+ EXPORT( 9, FreeVpl)
+ EXPORT( 11, ReferVplStatus)
+ EXPORT( 12, iReferVplStatus)
+END_MODULE
+MODULE(timrman)
+ EXPORT( 4, AllocHardTimer)
+ EXPORT( 5, ReferHardTimer)
+ EXPORT( 6, FreeHardTimer)
+ EXPORT( 7, SetTimerMode)
+ EXPORT( 8, GetTimerStatus)
+ EXPORT( 9, SetTimerCounter)
+ EXPORT( 10, GetTimerCounter)
+ EXPORT( 11, SetTimerCompare)
+ EXPORT( 12, GetTimerCompare)
+ EXPORT( 16, GetHardTimerIntrCode)
+ EXPORT( 20, SetTimerHandler)
+ EXPORT( 21, SetOverflowHandler)
+ EXPORT( 22, SetupHardTimer)
+ EXPORT( 23, StartHardTimer)
+ EXPORT( 24, StopHardTimer)
+END_MODULE
+MODULE(usbd)
+ EXPORT( 4, sceUsbdRegisterLdd)
+ EXPORT( 5, sceUsbdUnregisterLdd)
+ EXPORT( 6, sceUsbdScanStaticDescriptor)
+ EXPORT( 7, sceUsbdSetPrivateData)
+ EXPORT( 8, sceUsbdGetPrivateData)
+ EXPORT( 9, sceUsbdOpenPipe)
+ EXPORT( 10, sceUsbdClosePipe)
+ EXPORT( 11, sceUsbdTransferPipe)
+ EXPORT( 12, sceUsbdOpenPipeAligned)
+ EXPORT( 13, sceUsbdGetDeviceLocation)
+ EXPORT( 16, sceUsbdChangeThreadPriority)
+ EXPORT( 17, sceUsbdGetReportDescriptor)
+ EXPORT( 18, sceUsbdMultiIsochronousTransfer)
+END_MODULE
+MODULE(usbmload)
+ EXPORT( 4, sceUsbmlDisable)
+ EXPORT( 5, sceUsbmlEnable)
+ EXPORT( 6, sceUsbmlActivateCategory)
+ EXPORT( 7, sceUsbmlInactivateCategory)
+ EXPORT( 8, sceUsbmlRegisterLoadFunc)
+ EXPORT( 9, sceUsbmlUnregisterLoadFunc)
+ EXPORT( 10, sceUsbmlLoadConffile)
+ EXPORT( 11, sceUsbmlRegisterDevice)
+ EXPORT( 12, sceUsbmlChangeThreadPriority)
+END_MODULE
+MODULE(vblank)
+ EXPORT( 4, WaitVblankStart)
+ EXPORT( 5, WaitVblankEnd)
+ EXPORT( 6, WaitVblank)
+ EXPORT( 7, WaitNonVblank)
+ EXPORT( 8, RegisterVblankHandler)
+ EXPORT( 9, ReleaseVblankHandler)
+END_MODULE
+
+// undocumented functions from old list
+#if 0
+MODULE(sysmem)
+ EXPORT( 3, return_addr_of_memsize)
+ EXPORT( 15, set_Kprintf)
+END_MODULE
+MODULE(loadcore)
+ EXPORT( 3, return_LibraryEntryTable)
+ EXPORT( 8, findFixImports)
+ EXPORT( 9, restoreImports)
+ EXPORT( 14, setFlag)
+ EXPORT( 15, resetFlag)
+ EXPORT( 16, linkModule)
+ EXPORT( 17, unlinkModule)
+ EXPORT( 20, registerFunc)
+ EXPORT( 22, read_header)
+ EXPORT( 23, load_module)
+ EXPORT( 24, findImageInfo)
+END_MODULE
+MODULE(excepman)
+ EXPORT( 3, getcommon)
+END_MODULE
+MODULE(intrman)
+ EXPORT( 10, syscall04)
+ EXPORT( 11, syscall08)
+ EXPORT( 12, resetICTRL)
+ EXPORT( 13, setICTRL)
+ EXPORT( 14, syscall0C)
+ EXPORT( 19, CpuSuspendIntr)
+ EXPORT( 20, CpuResumeIntr)
+ EXPORT( 21, syscall10)
+ EXPORT( 22, syscall14)
+ EXPORT( 28, set_h1)
+ EXPORT( 29, reset_h1)
+ EXPORT( 30, set_h2)
+ EXPORT( 31, reset_h2)
+END_MODULE
+MODULE(ssbusc)
+ EXPORT( 4, setTable1)
+ EXPORT( 5, getTable1)
+ EXPORT( 6, setTable2)
+ EXPORT( 7, getTable2)
+ EXPORT( 8, setCOM_DELAY_1st)
+ EXPORT( 9, getCOM_DELAY_1st)
+ EXPORT( 10, setCOM_DELAY_2nd)
+ EXPORT( 11, getCOM_DELAY_2nd)
+ EXPORT( 12, setCOM_DELAY_3rd)
+ EXPORT( 13, getCOM_DELAY_3rd)
+ EXPORT( 14, setCOM_DELAY_4th)
+ EXPORT( 15, getCOM_DELAY_4th)
+ EXPORT( 16, setCOM_DELAY)
+ EXPORT( 16, getCOM_DELAY)
+END_MODULE
+MODULE(dmacman)
+ EXPORT( 4, SetD_MADR)
+ EXPORT( 5, GetD_MADR)
+ EXPORT( 6, SetD_BCR)
+ EXPORT( 7, GetD_BCR)
+ EXPORT( 8, SetD_CHCR)
+ EXPORT( 9, GetD_CHCR)
+ EXPORT( 10, SetD_TADR)
+ EXPORT( 11, GetD_TADR)
+ EXPORT( 12, Set_4_9_A)
+ EXPORT( 13, Get_4_9_A)
+ EXPORT( 14, SetDPCR)
+ EXPORT( 15, GetDPCR)
+ EXPORT( 16, SetDPCR2)
+ EXPORT( 17, GetDPCR2)
+ EXPORT( 18, SetDPCR3)
+ EXPORT( 19, GetDPCR3)
+ EXPORT( 20, SetDICR)
+ EXPORT( 21, GetDICR)
+ EXPORT( 22, SetDICR2)
+ EXPORT( 23, GetDICR2)
+ EXPORT( 24, SetBF80157C)
+ EXPORT( 25, GetBF80157C)
+ EXPORT( 26, SetBF801578)
+ EXPORT( 27, GetBF801578)
+ EXPORT( 28, SetDMA)
+ EXPORT( 29, SetDMA_chainedSPU_SIF0)
+ EXPORT( 30, SetDMA_SIF0)
+ EXPORT( 31, SetDMA_SIF1)
+ EXPORT( 32, StartTransfer)
+ EXPORT( 33, SetVal)
+ EXPORT( 34, EnableDMAch)
+ EXPORT( 35, DisableDMAch)
+END_MODULE
+MODULE(timrman)
+ EXPORT( 13, SetHoldMode)
+ EXPORT( 14, GetHoldMode)
+ EXPORT( 15, GetHoldReg)
+END_MODULE
+MODULE(sifman)
+ EXPORT( 4, sceSif2Init)
+ EXPORT( 9, sceSifSend)
+ EXPORT( 10, sceSifSendSync)
+ EXPORT( 11, sceSifIsSending)
+ EXPORT( 12, sceSifSetSIF0DMA)
+ EXPORT( 13, sceSifSendSync0)
+ EXPORT( 14, sceSifIsSending0)
+ EXPORT( 15, sceSifSetSIF1DMA)
+ EXPORT( 16, sceSifSendSync1)
+ EXPORT( 17, sceSifIsSending1)
+ EXPORT( 18, sceSifSetSIF2DMA)
+ EXPORT( 19, sceSifSendSync2)
+ EXPORT( 20, sceSifIsSending2)
+ EXPORT( 21, getEEIOPflags)
+ EXPORT( 22, setEEIOPflags)
+ EXPORT( 23, getIOPEEflags)
+ EXPORT( 24, setIOPEEflags)
+ EXPORT( 25, getEErcvaddr)
+ EXPORT( 26, getIOPrcvaddr)
+ EXPORT( 27, setIOPrcvaddr)
+ EXPORT( 30, setSif0CB)
+ EXPORT( 31, resetSif0CB)
+END_MODULE
+MODULE(sifcmd)
+ EXPORT( 9, sceSifSetSysCmdBuffer)
+ EXPORT( 26, setSif1CB)
+ EXPORT( 27, resetSif1CB)
+END_MODULE
+MODULE(cdvdman)
+ EXPORT( 20, sceDvdRead)
+ EXPORT( 23, sceCdWriteILinkID)
+ EXPORT( 25, sceCdWriteRTC)
+ EXPORT( 26, sceCdReadNVM)
+ EXPORT( 27, sceCdWriteNVM)
+ EXPORT( 30, setHDmode)
+ EXPORT( 31, sceCdOpenConfig)
+ EXPORT( 32, sceCdCloseConfig)
+ EXPORT( 33, sceCdReadConfig)
+ EXPORT( 34, sceCdWriteConfig)
+ EXPORT( 35, sceCdReadKey)
+ EXPORT( 36. sceCdDecSet)
+ EXPORT( 41, sceCdReadConsoleID)
+ EXPORT( 42, sceCdWriteConsoleID)
+ EXPORT( 43, sceCdGetMecaconVersion)
+ EXPORT( 52, sceCdForbidDVDP)
+ EXPORT( 53, sceCdReadSubQ)
+ EXPORT( 55, AutoAdjustCtrl)
+END_MODULE
+MODULE(sio2man)
+ EXPORT( 4, set8268_ctrl)
+ EXPORT( 5, get8268_ctrl)
+ EXPORT( 6, get826C_recv1)
+ EXPORT( 7, call7_send1)
+ EXPORT( 8, call8_send1)
+ EXPORT( 9, call9_send2)
+ EXPORT( 10, call10_send2)
+ EXPORT( 11, get8270_recv2)
+ EXPORT( 12, call12_set_params)
+ EXPORT( 13, call13_get_params)
+ EXPORT( 14, get8274_recv3)
+ EXPORT( 15, set8278)
+ EXPORT( 16, get8278)
+ EXPORT( 17, set827C)
+ EXPORT( 18, get827C)
+ EXPORT( 19, set8260_datain)
+ EXPORT( 20, get8264_dataout)
+ EXPORT( 21, set8280_intr)
+ EXPORT( 22, get8280_intr)
+ EXPORT( 23, signalExchange1)
+ EXPORT( 24, signalExchange2)
+ EXPORT( 25, packetExchange)
+END_MODULE
+#endif
+
+#undef MODULE
+#undef END_MODULE
+#undef EXPORT
diff --git a/pcsx2/SysForwardDefs.h b/pcsx2/SysForwardDefs.h
index b2ddb35f97..0ea2a4b359 100644
--- a/pcsx2/SysForwardDefs.h
+++ b/pcsx2/SysForwardDefs.h
@@ -1,25 +1,25 @@
-/* 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 .
- */
-
-#pragma once
-
-static const int PCSX2_VersionHi = 0;
-static const int PCSX2_VersionMid = 9;
-static const int PCSX2_VersionLo = 7;
-
-class SysCoreThread;
-class CpuInitializerSet;
-
-struct Game_Data;
+/* 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 .
+ */
+
+#pragma once
+
+static const int PCSX2_VersionHi = 0;
+static const int PCSX2_VersionMid = 9;
+static const int PCSX2_VersionLo = 7;
+
+class SysCoreThread;
+class CpuInitializerSet;
+
+struct Game_Data;
diff --git a/pcsx2/ZipTools/FolderDesc.txt b/pcsx2/ZipTools/FolderDesc.txt
index 37469bfd3f..71d05a060b 100644
--- a/pcsx2/ZipTools/FolderDesc.txt
+++ b/pcsx2/ZipTools/FolderDesc.txt
@@ -1,10 +1,10 @@
-
--------------------
- ZipTools (folder)
--------------------
-
-Contains C++ interfaces for zipping to/from various formats
-(primarily gzip and 7zip).
-
-Notice: This folder is intended to be moved to a utility folder
+
+-------------------
+ ZipTools (folder)
+-------------------
+
+Contains C++ interfaces for zipping to/from various formats
+(primarily gzip and 7zip).
+
+Notice: This folder is intended to be moved to a utility folder
outside the main PCSX2 folders at a later date.
\ No newline at end of file
diff --git a/pcsx2/ZipTools/ThreadedZipTools.h b/pcsx2/ZipTools/ThreadedZipTools.h
index d27e93271d..01614ce22d 100644
--- a/pcsx2/ZipTools/ThreadedZipTools.h
+++ b/pcsx2/ZipTools/ThreadedZipTools.h
@@ -1,207 +1,207 @@
-/* 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 .
- */
-
-#pragma once
-
-#include "Utilities/PersistentThread.h"
-#include "Utilities/pxStreams.h"
-#include "wx/zipstrm.h"
-
-using namespace Threading;
-
-// --------------------------------------------------------------------------------------
-// ArchiveEntry
-// --------------------------------------------------------------------------------------
-class ArchiveEntry
-{
-protected:
- wxString m_filename;
- uptr m_dataidx;
- size_t m_datasize;
-
-public:
- ArchiveEntry( const wxString& filename=wxEmptyString )
- : m_filename( filename )
- {
- m_dataidx = 0;
- m_datasize = 0;
- }
-
- virtual ~ArchiveEntry() throw() {}
-
- ArchiveEntry& SetDataIndex( uptr idx )
- {
- m_dataidx = idx;
- return *this;
- }
-
- ArchiveEntry& SetDataSize( size_t size )
- {
- m_datasize = size;
- return *this;
- }
-
- wxString GetFilename() const
- {
- return m_filename;
- }
-
- uptr GetDataIndex() const
- {
- return m_dataidx;
- }
-
- uint GetDataSize() const
- {
- return m_datasize;
- }
-};
-
-typedef SafeArray< u8 > ArchiveDataBuffer;
-
-// --------------------------------------------------------------------------------------
-// ArchiveEntryList
-// --------------------------------------------------------------------------------------
-class ArchiveEntryList
-{
- DeclareNoncopyableObject( ArchiveEntryList );
-
-protected:
- std::vector m_list;
- ScopedPtr m_data;
-
-public:
- virtual ~ArchiveEntryList() throw() {}
-
- ArchiveEntryList() {}
-
- ArchiveEntryList( ArchiveDataBuffer* data )
- {
- m_data = data;
- }
-
- ArchiveEntryList( ArchiveDataBuffer& data )
- {
- m_data = &data;
- }
-
- const VmStateBuffer* GetBuffer() const
- {
- return m_data;
- }
-
- VmStateBuffer* GetBuffer()
- {
- return m_data;
- }
-
- u8* GetPtr( uint idx )
- {
- return &(*m_data)[idx];
- }
-
- const u8* GetPtr( uint idx ) const
- {
- return &(*m_data)[idx];
- }
-
- ArchiveEntryList& Add( const ArchiveEntry& src )
- {
- m_list.push_back( src );
- return *this;
- }
-
- size_t GetLength() const
- {
- return m_list.size();
- }
-
- ArchiveEntry& operator[](uint idx)
- {
- return m_list[idx];
- }
-
- const ArchiveEntry& operator[](uint idx) const
- {
- return m_list[idx];
- }
-};
-
-// --------------------------------------------------------------------------------------
-// BaseCompressThread
-// --------------------------------------------------------------------------------------
-class BaseCompressThread
- : public pxThread
-{
- typedef pxThread _parent;
-
-protected:
- pxOutputStream* m_gzfp;
- ArchiveEntryList* m_src_list;
- bool m_PendingSaveFlag;
-
- wxString m_final_filename;
-
-public:
- virtual ~BaseCompressThread() throw();
-
- BaseCompressThread& SetSource( ArchiveEntryList* srcdata )
- {
- m_src_list = srcdata;
- return *this;
- }
-
- BaseCompressThread& SetSource( ArchiveEntryList& srcdata )
- {
- m_src_list = &srcdata;
- return *this;
- }
-
- BaseCompressThread& SetOutStream( pxOutputStream* out )
- {
- m_gzfp = out;
- return *this;
- }
-
- BaseCompressThread& SetOutStream( pxOutputStream& out )
- {
- m_gzfp = &out;
- return *this;
- }
-
- BaseCompressThread& SetFinishedPath( const wxString& path )
- {
- m_final_filename = path;
- return *this;
- }
-
- wxString GetStreamName() const { return m_gzfp->GetStreamName(); }
-
- BaseCompressThread& SetTargetFilename(const wxString& filename)
- {
- m_final_filename = filename;
- return *this;
- }
-
-protected:
- BaseCompressThread()
- {
- m_PendingSaveFlag = false;
- }
-
- void SetPendingSave();
- void ExecuteTaskInThread();
- void OnCleanupInThread();
-};
+/* 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 .
+ */
+
+#pragma once
+
+#include "Utilities/PersistentThread.h"
+#include "Utilities/pxStreams.h"
+#include "wx/zipstrm.h"
+
+using namespace Threading;
+
+// --------------------------------------------------------------------------------------
+// ArchiveEntry
+// --------------------------------------------------------------------------------------
+class ArchiveEntry
+{
+protected:
+ wxString m_filename;
+ uptr m_dataidx;
+ size_t m_datasize;
+
+public:
+ ArchiveEntry( const wxString& filename=wxEmptyString )
+ : m_filename( filename )
+ {
+ m_dataidx = 0;
+ m_datasize = 0;
+ }
+
+ virtual ~ArchiveEntry() throw() {}
+
+ ArchiveEntry& SetDataIndex( uptr idx )
+ {
+ m_dataidx = idx;
+ return *this;
+ }
+
+ ArchiveEntry& SetDataSize( size_t size )
+ {
+ m_datasize = size;
+ return *this;
+ }
+
+ wxString GetFilename() const
+ {
+ return m_filename;
+ }
+
+ uptr GetDataIndex() const
+ {
+ return m_dataidx;
+ }
+
+ uint GetDataSize() const
+ {
+ return m_datasize;
+ }
+};
+
+typedef SafeArray< u8 > ArchiveDataBuffer;
+
+// --------------------------------------------------------------------------------------
+// ArchiveEntryList
+// --------------------------------------------------------------------------------------
+class ArchiveEntryList
+{
+ DeclareNoncopyableObject( ArchiveEntryList );
+
+protected:
+ std::vector m_list;
+ ScopedPtr m_data;
+
+public:
+ virtual ~ArchiveEntryList() throw() {}
+
+ ArchiveEntryList() {}
+
+ ArchiveEntryList( ArchiveDataBuffer* data )
+ {
+ m_data = data;
+ }
+
+ ArchiveEntryList( ArchiveDataBuffer& data )
+ {
+ m_data = &data;
+ }
+
+ const VmStateBuffer* GetBuffer() const
+ {
+ return m_data;
+ }
+
+ VmStateBuffer* GetBuffer()
+ {
+ return m_data;
+ }
+
+ u8* GetPtr( uint idx )
+ {
+ return &(*m_data)[idx];
+ }
+
+ const u8* GetPtr( uint idx ) const
+ {
+ return &(*m_data)[idx];
+ }
+
+ ArchiveEntryList& Add( const ArchiveEntry& src )
+ {
+ m_list.push_back( src );
+ return *this;
+ }
+
+ size_t GetLength() const
+ {
+ return m_list.size();
+ }
+
+ ArchiveEntry& operator[](uint idx)
+ {
+ return m_list[idx];
+ }
+
+ const ArchiveEntry& operator[](uint idx) const
+ {
+ return m_list[idx];
+ }
+};
+
+// --------------------------------------------------------------------------------------
+// BaseCompressThread
+// --------------------------------------------------------------------------------------
+class BaseCompressThread
+ : public pxThread
+{
+ typedef pxThread _parent;
+
+protected:
+ pxOutputStream* m_gzfp;
+ ArchiveEntryList* m_src_list;
+ bool m_PendingSaveFlag;
+
+ wxString m_final_filename;
+
+public:
+ virtual ~BaseCompressThread() throw();
+
+ BaseCompressThread& SetSource( ArchiveEntryList* srcdata )
+ {
+ m_src_list = srcdata;
+ return *this;
+ }
+
+ BaseCompressThread& SetSource( ArchiveEntryList& srcdata )
+ {
+ m_src_list = &srcdata;
+ return *this;
+ }
+
+ BaseCompressThread& SetOutStream( pxOutputStream* out )
+ {
+ m_gzfp = out;
+ return *this;
+ }
+
+ BaseCompressThread& SetOutStream( pxOutputStream& out )
+ {
+ m_gzfp = &out;
+ return *this;
+ }
+
+ BaseCompressThread& SetFinishedPath( const wxString& path )
+ {
+ m_final_filename = path;
+ return *this;
+ }
+
+ wxString GetStreamName() const { return m_gzfp->GetStreamName(); }
+
+ BaseCompressThread& SetTargetFilename(const wxString& filename)
+ {
+ m_final_filename = filename;
+ return *this;
+ }
+
+protected:
+ BaseCompressThread()
+ {
+ m_PendingSaveFlag = false;
+ }
+
+ void SetPendingSave();
+ void ExecuteTaskInThread();
+ void OnCleanupInThread();
+};
diff --git a/pcsx2/ZipTools/thread_gzip.cpp b/pcsx2/ZipTools/thread_gzip.cpp
index c1c51c36a8..ca437fda8d 100644
--- a/pcsx2/ZipTools/thread_gzip.cpp
+++ b/pcsx2/ZipTools/thread_gzip.cpp
@@ -1,95 +1,95 @@
-/* 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 te 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 .
- */
-
-#include "PrecompiledHeader.h"
-
-#include "App.h"
-#include "SaveState.h"
-#include "ThreadedZipTools.h"
-#include "Utilities/SafeArray.inl"
-#include "wx/wfstream.h"
-
-
-BaseCompressThread::~BaseCompressThread() throw()
-{
- _parent::Cancel();
- if( m_PendingSaveFlag )
- {
- wxGetApp().ClearPendingSave();
- m_PendingSaveFlag = false;
- }
-}
-
-void BaseCompressThread::SetPendingSave()
-{
- wxGetApp().StartPendingSave();
- m_PendingSaveFlag = true;
-}
-
-void BaseCompressThread::ExecuteTaskInThread()
-{
- // TODO : Add an API to PersistentThread for this! :) --air
- //SetThreadPriority( THREAD_PRIORITY_BELOW_NORMAL );
-
- // Notes:
- // * Safeguard against corruption by writing to a temp file, and then copying the final
- // result over the original.
-
- if( !m_src_list ) return;
- SetPendingSave();
-
- Yield( 3 );
-
- uint listlen = m_src_list->GetLength();
- for( uint i=0; iGetWxStreamBase();
- woot.PutNextEntry( entry.GetFilename() );
-
- static const uint BlockSize = 0x64000;
- uint curidx = 0;
-
- do {
- uint thisBlockSize = std::min( BlockSize, entry.GetDataSize() - curidx );
- m_gzfp->Write(m_src_list->GetPtr( entry.GetDataIndex() + curidx ), thisBlockSize);
- curidx += thisBlockSize;
- Yield( 2 );
- } while( curidx < entry.GetDataSize() );
-
- woot.CloseEntry();
- }
-
- m_gzfp->Close();
-
- if( !wxRenameFile( m_gzfp->GetStreamName(), m_final_filename, true ) )
- throw Exception::BadStream( m_final_filename )
- .SetDiagMsg(L"Failed to move or copy the temporary archive to the destination filename.")
- .SetUserMsg(_("The savestate was not properly saved. The temporary file was created successfully but could not be moved to its final resting place."));
-
- Console.WriteLn( "(gzipThread) Data saved to disk without error." );
-}
-
-void BaseCompressThread::OnCleanupInThread()
-{
- _parent::OnCleanupInThread();
- wxGetApp().DeleteThread( this );
-
- safe_delete(m_gzfp);
- safe_delete(m_src_list);
-}
-
+/* 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 te 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 .
+ */
+
+#include "PrecompiledHeader.h"
+
+#include "App.h"
+#include "SaveState.h"
+#include "ThreadedZipTools.h"
+#include "Utilities/SafeArray.inl"
+#include "wx/wfstream.h"
+
+
+BaseCompressThread::~BaseCompressThread() throw()
+{
+ _parent::Cancel();
+ if( m_PendingSaveFlag )
+ {
+ wxGetApp().ClearPendingSave();
+ m_PendingSaveFlag = false;
+ }
+}
+
+void BaseCompressThread::SetPendingSave()
+{
+ wxGetApp().StartPendingSave();
+ m_PendingSaveFlag = true;
+}
+
+void BaseCompressThread::ExecuteTaskInThread()
+{
+ // TODO : Add an API to PersistentThread for this! :) --air
+ //SetThreadPriority( THREAD_PRIORITY_BELOW_NORMAL );
+
+ // Notes:
+ // * Safeguard against corruption by writing to a temp file, and then copying the final
+ // result over the original.
+
+ if( !m_src_list ) return;
+ SetPendingSave();
+
+ Yield( 3 );
+
+ uint listlen = m_src_list->GetLength();
+ for( uint i=0; iGetWxStreamBase();
+ woot.PutNextEntry( entry.GetFilename() );
+
+ static const uint BlockSize = 0x64000;
+ uint curidx = 0;
+
+ do {
+ uint thisBlockSize = std::min( BlockSize, entry.GetDataSize() - curidx );
+ m_gzfp->Write(m_src_list->GetPtr( entry.GetDataIndex() + curidx ), thisBlockSize);
+ curidx += thisBlockSize;
+ Yield( 2 );
+ } while( curidx < entry.GetDataSize() );
+
+ woot.CloseEntry();
+ }
+
+ m_gzfp->Close();
+
+ if( !wxRenameFile( m_gzfp->GetStreamName(), m_final_filename, true ) )
+ throw Exception::BadStream( m_final_filename )
+ .SetDiagMsg(L"Failed to move or copy the temporary archive to the destination filename.")
+ .SetUserMsg(_("The savestate was not properly saved. The temporary file was created successfully but could not be moved to its final resting place."));
+
+ Console.WriteLn( "(gzipThread) Data saved to disk without error." );
+}
+
+void BaseCompressThread::OnCleanupInThread()
+{
+ _parent::OnCleanupInThread();
+ wxGetApp().DeleteThread( this );
+
+ safe_delete(m_gzfp);
+ safe_delete(m_src_list);
+}
+
diff --git a/pcsx2/ZipTools/thread_lzma.cpp b/pcsx2/ZipTools/thread_lzma.cpp
index 733b8f29c3..fd06a199fe 100644
--- a/pcsx2/ZipTools/thread_lzma.cpp
+++ b/pcsx2/ZipTools/thread_lzma.cpp
@@ -1,17 +1,17 @@
-/* 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 te 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 .
- */
-
-#include "PrecompiledHeader.h"
-
+/* 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 te 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 .
+ */
+
+#include "PrecompiledHeader.h"
+
diff --git a/pcsx2/gui/AppGameDatabase.cpp b/pcsx2/gui/AppGameDatabase.cpp
index 60adba79e0..d1e81f2685 100644
--- a/pcsx2/gui/AppGameDatabase.cpp
+++ b/pcsx2/gui/AppGameDatabase.cpp
@@ -1,225 +1,225 @@
-/* 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 .
- */
-
-#include "PrecompiledHeader.h"
-#include "App.h"
-#include "AppGameDatabase.h"
-
-class DBLoaderHelper
-{
- DeclareNoncopyableObject( DBLoaderHelper );
-
-protected:
- IGameDatabase& m_gamedb;
- wxInputStream& m_reader;
-
- // temp areas used as buffers for accelerated loading of database content. These strings are
- // allocated and grown only once, and then reused for the duration of the database loading
- // process; saving thousands of heapp allocation operations.
-
- wxString m_dest;
- std::string m_intermediate;
-
- key_pair m_keyPair;
-
-public:
- DBLoaderHelper( wxInputStream& reader, IGameDatabase& db )
- : m_gamedb(db)
- , m_reader(reader)
- {
- }
-
- wxString ReadHeader();
- void ReadGames();
-
-protected:
- void doError(bool doMsg = false);
- bool extractMultiLine();
- void extract();
-};
-
-void DBLoaderHelper::doError(bool doMsg) {
- if (doMsg) Console.Error("GameDatabase: Bad file data [%s]", m_dest.c_str());
- m_keyPair.Clear();
-}
-
-// Multiline Sections are in the form of:
-//
-// [section=value]
-// content
-// content
-// [/section]
-//
-// ... where the =value part is OPTIONAL.
-bool DBLoaderHelper::extractMultiLine() {
-
- if (m_dest[0] != L'[') return false; // All multiline sections begin with a '['!
-
- if (!m_dest.EndsWith(L"]")) {
- doError(true);
- return false;
- }
-
- m_keyPair.key = m_dest;
-
- // Use Mid() to strip off the left and right side brackets.
- wxString midLine(m_dest.Mid(1, m_dest.Length()-2));
- wxString lvalue(midLine.BeforeFirst(L'=').Trim(true).Trim(false));
- //wxString rvalue(midLine.AfterFirst(L'=').Trim(true).Trim(false));
-
- wxString endString;
- endString.Printf( L"[/%s]", lvalue.c_str() );
-
- while(!m_reader.Eof()) {
- pxReadLine( m_reader, m_dest, m_intermediate );
- if (m_dest.CmpNoCase(endString) == 0) break;
- m_keyPair.value += m_dest + L"\n";
- }
- return true;
-}
-
-void DBLoaderHelper::extract() {
-
- if( !pxParseAssignmentString( m_dest, m_keyPair.key, m_keyPair.value ) ) return;
- if( m_keyPair.value.IsEmpty() ) doError(true);
-}
-
-wxString DBLoaderHelper::ReadHeader()
-{
- wxString header;
- header.reserve(2048);
-
- while(!m_reader.Eof()) {
- pxReadLine(m_reader, m_dest, m_intermediate);
- m_dest.Trim(false).Trim(true);
- if( !(m_dest.IsEmpty() || m_dest.StartsWith(L"--") || m_dest.StartsWith( L"//" ) || m_dest.StartsWith( L";" )) ) break;
- header += m_dest + L'\n';
- }
-
- if( !m_dest.IsEmpty() )
- {
- m_keyPair.Clear();
- if( !extractMultiLine() ) extract();
- }
- return header;
-}
-
-void DBLoaderHelper::ReadGames()
-{
- Game_Data* game = NULL;
-
- if (m_keyPair.IsOk())
- {
- game = m_gamedb.createNewGame(m_keyPair.value);
- game->writeString(m_keyPair.key, m_keyPair.value);
- //if( m_keyPair.CompareKey(m_gamedb.getBaseKey()) )
- // game.id = m_keyPair.value;
- }
-
- while(!m_reader.Eof()) { // Fill game data, find new game, repeat...
- pthread_testcancel();
- pxReadLine(m_reader, m_dest, m_intermediate);
- m_dest.Trim(true).Trim(false);
- if( m_dest.IsEmpty() ) continue;
-
- m_keyPair.Clear();
- if (!extractMultiLine()) extract();
-
- if (!m_keyPair.IsOk()) continue;
- if (m_keyPair.CompareKey(m_gamedb.getBaseKey()))
- game = m_gamedb.createNewGame(m_keyPair.value);
-
- game->writeString( m_keyPair.key, m_keyPair.value );
- }
-}
-
-// --------------------------------------------------------------------------------------
-// AppGameDatabase (implementations)
-// --------------------------------------------------------------------------------------
-
-AppGameDatabase& AppGameDatabase::LoadFromFile(wxString file, const wxString& key )
-{
- if( wxFileName(file).IsRelative() )
- file = (InstallFolder + file).GetFullPath();
-
- if (!wxFileExists(file))
- {
- Console.Error(L"(GameDB) Database Not Found! [%s]", file.c_str());
- return *this;
- }
-
- wxFFileInputStream reader( file );
-
- if (!reader.IsOk())
- {
- //throw Exception::FileNotFound( file );
- Console.Error(L"(GameDB) Could not access file (permission denied?) [%s]", file.c_str());
- }
-
- DBLoaderHelper loader( reader, *this );
-
- u64 qpc_Start = GetCPUTicks();
- header = loader.ReadHeader();
- loader.ReadGames();
- u64 qpc_end = GetCPUTicks();
-
- Console.WriteLn( "(GameDB) %d games on record (loaded in %ums)",
- gHash.size(), (u32)(((qpc_end-qpc_Start)*1000) / GetTickFrequency()) );
-
- return *this;
-}
-
-// Saves changes to the database
-
-void AppGameDatabase::SaveToFile(const wxString& file) {
- wxFFileOutputStream writer( file );
- pxWriteMultiline(writer, header);
-
- for(uint blockidx=0; blockidx<=m_BlockTableWritePos; ++blockidx)
- {
- if( !m_BlockTable[blockidx] ) continue;
-
- const uint endidx = (blockidx == m_BlockTableWritePos) ? m_CurBlockWritePos : m_GamesPerBlock;
-
- for( uint gameidx=0; gameidx<=endidx; ++gameidx )
- {
- const Game_Data& game( m_BlockTable[blockidx][gameidx] );
- KeyPairArray::const_iterator i(game.kList.begin());
- for ( ; i != game.kList.end(); ++i) {
- pxWriteMultiline(writer, i->toString() );
- }
-
- pxWriteLine(writer, L"---------------------------------------------");
- }
- }
-}
-
-AppGameDatabase* Pcsx2App::GetGameDatabase()
-{
- pxAppResources& res( GetResourceCache() );
-
- ScopedLock lock( m_mtx_LoadingGameDB );
- if( !res.GameDB )
- {
- res.GameDB = new AppGameDatabase();
- res.GameDB->LoadFromFile();
- }
- return res.GameDB;
-}
-
-IGameDatabase* AppHost_GetGameDatabase()
-{
- return wxGetApp().GetGameDatabase();
-}
+/* 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 .
+ */
+
+#include "PrecompiledHeader.h"
+#include "App.h"
+#include "AppGameDatabase.h"
+
+class DBLoaderHelper
+{
+ DeclareNoncopyableObject( DBLoaderHelper );
+
+protected:
+ IGameDatabase& m_gamedb;
+ wxInputStream& m_reader;
+
+ // temp areas used as buffers for accelerated loading of database content. These strings are
+ // allocated and grown only once, and then reused for the duration of the database loading
+ // process; saving thousands of heapp allocation operations.
+
+ wxString m_dest;
+ std::string m_intermediate;
+
+ key_pair m_keyPair;
+
+public:
+ DBLoaderHelper( wxInputStream& reader, IGameDatabase& db )
+ : m_gamedb(db)
+ , m_reader(reader)
+ {
+ }
+
+ wxString ReadHeader();
+ void ReadGames();
+
+protected:
+ void doError(bool doMsg = false);
+ bool extractMultiLine();
+ void extract();
+};
+
+void DBLoaderHelper::doError(bool doMsg) {
+ if (doMsg) Console.Error("GameDatabase: Bad file data [%s]", m_dest.c_str());
+ m_keyPair.Clear();
+}
+
+// Multiline Sections are in the form of:
+//
+// [section=value]
+// content
+// content
+// [/section]
+//
+// ... where the =value part is OPTIONAL.
+bool DBLoaderHelper::extractMultiLine() {
+
+ if (m_dest[0] != L'[') return false; // All multiline sections begin with a '['!
+
+ if (!m_dest.EndsWith(L"]")) {
+ doError(true);
+ return false;
+ }
+
+ m_keyPair.key = m_dest;
+
+ // Use Mid() to strip off the left and right side brackets.
+ wxString midLine(m_dest.Mid(1, m_dest.Length()-2));
+ wxString lvalue(midLine.BeforeFirst(L'=').Trim(true).Trim(false));
+ //wxString rvalue(midLine.AfterFirst(L'=').Trim(true).Trim(false));
+
+ wxString endString;
+ endString.Printf( L"[/%s]", lvalue.c_str() );
+
+ while(!m_reader.Eof()) {
+ pxReadLine( m_reader, m_dest, m_intermediate );
+ if (m_dest.CmpNoCase(endString) == 0) break;
+ m_keyPair.value += m_dest + L"\n";
+ }
+ return true;
+}
+
+void DBLoaderHelper::extract() {
+
+ if( !pxParseAssignmentString( m_dest, m_keyPair.key, m_keyPair.value ) ) return;
+ if( m_keyPair.value.IsEmpty() ) doError(true);
+}
+
+wxString DBLoaderHelper::ReadHeader()
+{
+ wxString header;
+ header.reserve(2048);
+
+ while(!m_reader.Eof()) {
+ pxReadLine(m_reader, m_dest, m_intermediate);
+ m_dest.Trim(false).Trim(true);
+ if( !(m_dest.IsEmpty() || m_dest.StartsWith(L"--") || m_dest.StartsWith( L"//" ) || m_dest.StartsWith( L";" )) ) break;
+ header += m_dest + L'\n';
+ }
+
+ if( !m_dest.IsEmpty() )
+ {
+ m_keyPair.Clear();
+ if( !extractMultiLine() ) extract();
+ }
+ return header;
+}
+
+void DBLoaderHelper::ReadGames()
+{
+ Game_Data* game = NULL;
+
+ if (m_keyPair.IsOk())
+ {
+ game = m_gamedb.createNewGame(m_keyPair.value);
+ game->writeString(m_keyPair.key, m_keyPair.value);
+ //if( m_keyPair.CompareKey(m_gamedb.getBaseKey()) )
+ // game.id = m_keyPair.value;
+ }
+
+ while(!m_reader.Eof()) { // Fill game data, find new game, repeat...
+ pthread_testcancel();
+ pxReadLine(m_reader, m_dest, m_intermediate);
+ m_dest.Trim(true).Trim(false);
+ if( m_dest.IsEmpty() ) continue;
+
+ m_keyPair.Clear();
+ if (!extractMultiLine()) extract();
+
+ if (!m_keyPair.IsOk()) continue;
+ if (m_keyPair.CompareKey(m_gamedb.getBaseKey()))
+ game = m_gamedb.createNewGame(m_keyPair.value);
+
+ game->writeString( m_keyPair.key, m_keyPair.value );
+ }
+}
+
+// --------------------------------------------------------------------------------------
+// AppGameDatabase (implementations)
+// --------------------------------------------------------------------------------------
+
+AppGameDatabase& AppGameDatabase::LoadFromFile(wxString file, const wxString& key )
+{
+ if( wxFileName(file).IsRelative() )
+ file = (InstallFolder + file).GetFullPath();
+
+ if (!wxFileExists(file))
+ {
+ Console.Error(L"(GameDB) Database Not Found! [%s]", file.c_str());
+ return *this;
+ }
+
+ wxFFileInputStream reader( file );
+
+ if (!reader.IsOk())
+ {
+ //throw Exception::FileNotFound( file );
+ Console.Error(L"(GameDB) Could not access file (permission denied?) [%s]", file.c_str());
+ }
+
+ DBLoaderHelper loader( reader, *this );
+
+ u64 qpc_Start = GetCPUTicks();
+ header = loader.ReadHeader();
+ loader.ReadGames();
+ u64 qpc_end = GetCPUTicks();
+
+ Console.WriteLn( "(GameDB) %d games on record (loaded in %ums)",
+ gHash.size(), (u32)(((qpc_end-qpc_Start)*1000) / GetTickFrequency()) );
+
+ return *this;
+}
+
+// Saves changes to the database
+
+void AppGameDatabase::SaveToFile(const wxString& file) {
+ wxFFileOutputStream writer( file );
+ pxWriteMultiline(writer, header);
+
+ for(uint blockidx=0; blockidx<=m_BlockTableWritePos; ++blockidx)
+ {
+ if( !m_BlockTable[blockidx] ) continue;
+
+ const uint endidx = (blockidx == m_BlockTableWritePos) ? m_CurBlockWritePos : m_GamesPerBlock;
+
+ for( uint gameidx=0; gameidx<=endidx; ++gameidx )
+ {
+ const Game_Data& game( m_BlockTable[blockidx][gameidx] );
+ KeyPairArray::const_iterator i(game.kList.begin());
+ for ( ; i != game.kList.end(); ++i) {
+ pxWriteMultiline(writer, i->toString() );
+ }
+
+ pxWriteLine(writer, L"---------------------------------------------");
+ }
+ }
+}
+
+AppGameDatabase* Pcsx2App::GetGameDatabase()
+{
+ pxAppResources& res( GetResourceCache() );
+
+ ScopedLock lock( m_mtx_LoadingGameDB );
+ if( !res.GameDB )
+ {
+ res.GameDB = new AppGameDatabase();
+ res.GameDB->LoadFromFile();
+ }
+ return res.GameDB;
+}
+
+IGameDatabase* AppHost_GetGameDatabase()
+{
+ return wxGetApp().GetGameDatabase();
+}
diff --git a/pcsx2/gui/AppGameDatabase.h b/pcsx2/gui/AppGameDatabase.h
index 8788a51f8b..19bf67ceff 100644
--- a/pcsx2/gui/AppGameDatabase.h
+++ b/pcsx2/gui/AppGameDatabase.h
@@ -1,68 +1,68 @@
-/* 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 .
- */
-
-#pragma once
-
-#include "GameDatabase.h"
-
-// --------------------------------------------------------------------------------------
-// AppGameDatabase
-// --------------------------------------------------------------------------------------
-// This class extends BaseGameDatabase_Impl and provides interfaces for loading and saving
-// the text-formatted game database.
-//
-// Example:
-// ---------------------------------------------
-// Serial = SLUS-20486
-// Name = Marvel vs. Capcom 2
-// Region = NTSC-U
-// ---------------------------------------------
-//
-// [-- separators are a standard part of the formatting]
-//
-
-// To Load this game data, use "Serial" as the initial Key
-// then specify "SLUS-20486" as the value in the constructor.
-// After the constructor loads the game data, you can use the
-// GameDatabase class's methods to get the other key's values.
-// Such as dbLoader.getString("Region") returns "NTSC-U"
-
-class AppGameDatabase : public BaseGameDatabaseImpl
-{
-protected:
- wxString header; // Header of the database
- wxString baseKey; // Key to separate games by ("Serial")
-
-public:
- AppGameDatabase() {}
- virtual ~AppGameDatabase() throw() {
- Console.WriteLn( "(GameDB) Unloading..." );
- }
-
- AppGameDatabase& LoadFromFile(wxString file = L"GameIndex.dbf", const wxString& key = L"Serial" );
- void SaveToFile(const wxString& file = L"GameIndex.dbf");
-};
-
-static wxString compatToStringWX(int compat) {
- switch (compat) {
- case 6: return L"Perfect";
- case 5: return L"Playable";
- case 4: return L"In-Game";
- case 3: return L"Menu";
- case 2: return L"Intro";
- case 1: return L"Nothing";
- default: return L"Unknown";
- }
-}
+/* 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 .
+ */
+
+#pragma once
+
+#include "GameDatabase.h"
+
+// --------------------------------------------------------------------------------------
+// AppGameDatabase
+// --------------------------------------------------------------------------------------
+// This class extends BaseGameDatabase_Impl and provides interfaces for loading and saving
+// the text-formatted game database.
+//
+// Example:
+// ---------------------------------------------
+// Serial = SLUS-20486
+// Name = Marvel vs. Capcom 2
+// Region = NTSC-U
+// ---------------------------------------------
+//
+// [-- separators are a standard part of the formatting]
+//
+
+// To Load this game data, use "Serial" as the initial Key
+// then specify "SLUS-20486" as the value in the constructor.
+// After the constructor loads the game data, you can use the
+// GameDatabase class's methods to get the other key's values.
+// Such as dbLoader.getString("Region") returns "NTSC-U"
+
+class AppGameDatabase : public BaseGameDatabaseImpl
+{
+protected:
+ wxString header; // Header of the database
+ wxString baseKey; // Key to separate games by ("Serial")
+
+public:
+ AppGameDatabase() {}
+ virtual ~AppGameDatabase() throw() {
+ Console.WriteLn( "(GameDB) Unloading..." );
+ }
+
+ AppGameDatabase& LoadFromFile(wxString file = L"GameIndex.dbf", const wxString& key = L"Serial" );
+ void SaveToFile(const wxString& file = L"GameIndex.dbf");
+};
+
+static wxString compatToStringWX(int compat) {
+ switch (compat) {
+ case 6: return L"Perfect";
+ case 5: return L"Playable";
+ case 4: return L"In-Game";
+ case 3: return L"Menu";
+ case 2: return L"Intro";
+ case 1: return L"Nothing";
+ default: return L"Unknown";
+ }
+}
diff --git a/pcsx2/gui/AppUserMode.cpp b/pcsx2/gui/AppUserMode.cpp
index 274139e5ca..6d21f1b836 100644
--- a/pcsx2/gui/AppUserMode.cpp
+++ b/pcsx2/gui/AppUserMode.cpp
@@ -1,307 +1,307 @@
-/* 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 .
- */
-
-#include "PrecompiledHeader.h"
-#include "MainFrame.h"
-#include "Utilities/IniInterface.h"
-#include "Utilities/HashMap.h"
-#include "Dialogs/ModalPopups.h"
-
-#include
-
-#ifdef __WXMSW__
-#include "wx/msw/regconf.h"
-#endif
-
-DocsModeType DocsFolderMode = DocsFolder_User;
-bool UseDefaultSettingsFolder = true;
-bool UseDefaultPluginsFolder = true;
-bool UseDefaultThemesFolder = true;
-
-
-wxDirName CustomDocumentsFolder;
-wxDirName SettingsFolder;
-
-wxDirName InstallFolder;
-wxDirName PluginsFolder;
-wxDirName ThemesFolder;
-
-// The UserLocalData folder can be redefined depending on whether or not PCSX2 is in
-// "portable install" mode or not. when PCSX2 has been configured for portable install, the
-// UserLocalData folder is the current working directory.
-//
-InstallationModeType InstallationMode;
-
-static wxFileName GetPortableIniPath()
-{
- wxString programFullPath = wxStandardPaths::Get().GetExecutablePath();
- wxDirName programDir( wxFileName(programFullPath).GetPath() );
-
- return programDir + "portable.ini";
-}
-
-static wxString GetMsg_PortableModeRights()
-{
- return pxE( "!Notice:PortableModeRights",
- L"Please ensure that these folders are created and that your user account is granted "
- L"write permissions to them -- or re-run PCSX2 with elevated (administrator) rights, which "
- L"should grant PCSX2 the ability to create the necessary folders itself. If you "
- L"do not have elevated rights on this computer, then you will need to switch to User "
- L"Documents mode (click button below)."
- );
-};
-
-bool Pcsx2App::TestUserPermissionsRights( const wxDirName& testFolder, wxString& createFailedStr, wxString& accessFailedStr )
-{
- // We need to individually verify read/write permission for each PCSX2 user documents folder.
- // If any of the folders are not writable, then the user should be informed asap via
- // friendly and courteous dialog box!
-
- const wxDirName PermissionFolders[] =
- {
- PathDefs::Base::Settings(),
- PathDefs::Base::MemoryCards(),
- PathDefs::Base::Savestates(),
- PathDefs::Base::Snapshots(),
- PathDefs::Base::Logs(),
- #ifdef PCSX2_DEVBUILD
- PathDefs::Base::Dumps(),
- #endif
- };
-
- FastFormatUnicode createme, accessme;
-
- for (uint i=0; i conf_portable( OpenFileConfig( portableIniFile.GetFullPath() ) );
- conf_portable->SetRecordDefaults(false);
-
- while( true )
- {
- wxString accessFailedStr, createFailedStr;
- if (TestUserPermissionsRights( portableDocsFolder, createFailedStr, accessFailedStr )) break;
-
- wxDialogWithHelpers dialog( NULL, AddAppName(_("Portable mode error - %s")) );
-
- wxTextCtrl* scrollText = new wxTextCtrl(
- &dialog, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize,
- wxTE_READONLY | wxTE_MULTILINE | wxTE_WORDWRAP
- );
-
- if (!createFailedStr.IsEmpty())
- scrollText->AppendText( createFailedStr + L"\n" );
-
- if (!accessFailedStr.IsEmpty())
- scrollText->AppendText( accessFailedStr + L"\n" );
-
- dialog += dialog.Heading( _("PCSX2 has been installed as a portable application but cannot run due to the following errors:" ) );
- dialog += scrollText | pxExpand.Border(wxALL, 16);
- dialog += 6;
- dialog += dialog.Text( GetMsg_PortableModeRights() );
-
- // [TODO] : Add url for platform-relevant user permissions tutorials? (low priority)
-
- wxWindowID result = pxIssueConfirmation( dialog,
- MsgButtons().Retry().Cancel().Custom(_("Switch to User Documents Mode"), "switchmode")
- );
-
- switch (result)
- {
- case wxID_CANCEL:
- throw Exception::StartupAborted( L"User canceled portable mode due to insufficient user access/permissions." );
-
- case wxID_RETRY:
- // do nothing (continues while loop)
- break;
-
- case pxID_CUSTOM:
- wxDialogWithHelpers dialog2( NULL, AddAppName(_("%s is switching to local install mode.")) );
- dialog2 += dialog2.Heading( _("Try to remove the file called \"portable.ini\" from your installation directory manually." ) );
- dialog2 += 6;
- pxIssueConfirmation( dialog2, MsgButtons().OK() );
- conf_portable.DetachPtr(); // Not sure but can't hurt
-
- return NULL;
- }
-
- }
-
- // Success -- all user-based folders have write access. PCSX2 should be able to run error-free!
- // Force-set the custom documents mode, and set the
-
- InstallationMode = InstallMode_Portable;
- DocsFolderMode = DocsFolder_Custom;
- CustomDocumentsFolder = portableDocsFolder;
- return conf_portable.DetachPtr();
- }
-
- return NULL;
-}
-
-// Reset RunWizard so the FTWizard is run again on next PCSX2 start.
-void Pcsx2App::WipeUserModeSettings()
-{
- if (InstallationMode == InstallMode_Portable)
- {
- // Remove the portable.ini entry "RunWizard" conforming to this instance of PCSX2.
- wxFileName portableIniFile( GetPortableIniPath() );
- ScopedPtr conf_portable( OpenFileConfig( portableIniFile.GetFullPath() ) );
- conf_portable->DeleteEntry(L"RunWizard");
- }
- else
- {
- // Remove the registry entry "RunWizard" conforming to this instance of PCSX2.
- ScopedPtr conf_install( OpenInstallSettingsFile() );
- conf_install->DeleteEntry(L"RunWizard");
- }
-}
-
-static void DoFirstTimeWizard()
-{
- // first time startup, so give the user the choice of user mode:
- while(true)
- {
- // PCSX2's FTWizard allows improptu restarting of the wizard without cancellation.
- // This is typically used to change the user's language selection.
-
- FirstTimeWizard wiz( NULL );
- if( wiz.RunWizard( wiz.GetFirstPage() ) ) break;
- if (wiz.GetReturnCode() != pxID_RestartWizard)
- throw Exception::StartupAborted( L"User canceled FirstTime Wizard." );
-
- Console.WriteLn( Color_StrongBlack, "Restarting First Time Wizard!" );
- }
-}
-
-wxConfigBase* Pcsx2App::OpenInstallSettingsFile()
-{
- // Implementation Notes:
- //
- // As of 0.9.8 and beyond, PCSX2's versioning should be strong enough to base ini and
- // plugin compatibility on version information alone. This in turn allows us to ditch
- // the old system (CWD-based ini file mess) in favor of a system that simply stores
- // most core application-level settings in the registry.
-
- ScopedPtr conf_install;
-
-#ifdef __WXMSW__
- conf_install = new wxRegConfig();
-#else
- // FIXME!! Linux / Mac
- // Where the heck should this information be stored?
-
- wxDirName usrlocaldir( PathDefs::GetUserLocalDataDir() );
- //wxDirName usrlocaldir( wxStandardPaths::Get().GetDataDir() );
- if( !usrlocaldir.Exists() )
- {
- Console.WriteLn( L"Creating UserLocalData folder: " + usrlocaldir.ToString() );
- usrlocaldir.Mkdir();
- }
-
- wxFileName usermodefile( GetAppName() + L"-reg.ini" );
- usermodefile.SetPath( usrlocaldir.ToString() );
- conf_install = OpenFileConfig( usermodefile.GetFullPath() );
-#endif
-
- return conf_install.DetachPtr();
-}
-
-
-void Pcsx2App::EstablishAppUserMode()
-{
- ScopedPtr conf_install;
-
- conf_install = TestForPortableInstall();
- if (!conf_install)
- conf_install = OpenInstallSettingsFile();
-
- conf_install->SetRecordDefaults(false);
-
- // Run the First Time Wizard!
- // ----------------------------
- // Wizard is only run once. The status of the wizard having been run is stored in
- // the installation ini file, which can be either the portable install (useful for admins)
- // or the registry/user local documents position.
-
- bool runWiz;
- conf_install->Read( L"RunWizard", &runWiz, true );
-
- App_LoadInstallSettings( conf_install );
-
- if( !Startup.ForceWizard && !runWiz )
- {
- AppConfig_OnChangedSettingsFolder( false );
- return;
- }
-
- DoFirstTimeWizard();
-
- // Save user's new settings
- App_SaveInstallSettings( conf_install );
- AppConfig_OnChangedSettingsFolder( true );
- AppSaveSettings();
-
- // Wizard completed successfully, so let's not torture the user with this crap again!
- conf_install->Write( L"RunWizard", false );
-}
-
+/* 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 .
+ */
+
+#include "PrecompiledHeader.h"
+#include "MainFrame.h"
+#include "Utilities/IniInterface.h"
+#include "Utilities/HashMap.h"
+#include "Dialogs/ModalPopups.h"
+
+#include
+
+#ifdef __WXMSW__
+#include "wx/msw/regconf.h"
+#endif
+
+DocsModeType DocsFolderMode = DocsFolder_User;
+bool UseDefaultSettingsFolder = true;
+bool UseDefaultPluginsFolder = true;
+bool UseDefaultThemesFolder = true;
+
+
+wxDirName CustomDocumentsFolder;
+wxDirName SettingsFolder;
+
+wxDirName InstallFolder;
+wxDirName PluginsFolder;
+wxDirName ThemesFolder;
+
+// The UserLocalData folder can be redefined depending on whether or not PCSX2 is in
+// "portable install" mode or not. when PCSX2 has been configured for portable install, the
+// UserLocalData folder is the current working directory.
+//
+InstallationModeType InstallationMode;
+
+static wxFileName GetPortableIniPath()
+{
+ wxString programFullPath = wxStandardPaths::Get().GetExecutablePath();
+ wxDirName programDir( wxFileName(programFullPath).GetPath() );
+
+ return programDir + "portable.ini";
+}
+
+static wxString GetMsg_PortableModeRights()
+{
+ return pxE( "!Notice:PortableModeRights",
+ L"Please ensure that these folders are created and that your user account is granted "
+ L"write permissions to them -- or re-run PCSX2 with elevated (administrator) rights, which "
+ L"should grant PCSX2 the ability to create the necessary folders itself. If you "
+ L"do not have elevated rights on this computer, then you will need to switch to User "
+ L"Documents mode (click button below)."
+ );
+};
+
+bool Pcsx2App::TestUserPermissionsRights( const wxDirName& testFolder, wxString& createFailedStr, wxString& accessFailedStr )
+{
+ // We need to individually verify read/write permission for each PCSX2 user documents folder.
+ // If any of the folders are not writable, then the user should be informed asap via
+ // friendly and courteous dialog box!
+
+ const wxDirName PermissionFolders[] =
+ {
+ PathDefs::Base::Settings(),
+ PathDefs::Base::MemoryCards(),
+ PathDefs::Base::Savestates(),
+ PathDefs::Base::Snapshots(),
+ PathDefs::Base::Logs(),
+ #ifdef PCSX2_DEVBUILD
+ PathDefs::Base::Dumps(),
+ #endif
+ };
+
+ FastFormatUnicode createme, accessme;
+
+ for (uint i=0; i conf_portable( OpenFileConfig( portableIniFile.GetFullPath() ) );
+ conf_portable->SetRecordDefaults(false);
+
+ while( true )
+ {
+ wxString accessFailedStr, createFailedStr;
+ if (TestUserPermissionsRights( portableDocsFolder, createFailedStr, accessFailedStr )) break;
+
+ wxDialogWithHelpers dialog( NULL, AddAppName(_("Portable mode error - %s")) );
+
+ wxTextCtrl* scrollText = new wxTextCtrl(
+ &dialog, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize,
+ wxTE_READONLY | wxTE_MULTILINE | wxTE_WORDWRAP
+ );
+
+ if (!createFailedStr.IsEmpty())
+ scrollText->AppendText( createFailedStr + L"\n" );
+
+ if (!accessFailedStr.IsEmpty())
+ scrollText->AppendText( accessFailedStr + L"\n" );
+
+ dialog += dialog.Heading( _("PCSX2 has been installed as a portable application but cannot run due to the following errors:" ) );
+ dialog += scrollText | pxExpand.Border(wxALL, 16);
+ dialog += 6;
+ dialog += dialog.Text( GetMsg_PortableModeRights() );
+
+ // [TODO] : Add url for platform-relevant user permissions tutorials? (low priority)
+
+ wxWindowID result = pxIssueConfirmation( dialog,
+ MsgButtons().Retry().Cancel().Custom(_("Switch to User Documents Mode"), "switchmode")
+ );
+
+ switch (result)
+ {
+ case wxID_CANCEL:
+ throw Exception::StartupAborted( L"User canceled portable mode due to insufficient user access/permissions." );
+
+ case wxID_RETRY:
+ // do nothing (continues while loop)
+ break;
+
+ case pxID_CUSTOM:
+ wxDialogWithHelpers dialog2( NULL, AddAppName(_("%s is switching to local install mode.")) );
+ dialog2 += dialog2.Heading( _("Try to remove the file called \"portable.ini\" from your installation directory manually." ) );
+ dialog2 += 6;
+ pxIssueConfirmation( dialog2, MsgButtons().OK() );
+ conf_portable.DetachPtr(); // Not sure but can't hurt
+
+ return NULL;
+ }
+
+ }
+
+ // Success -- all user-based folders have write access. PCSX2 should be able to run error-free!
+ // Force-set the custom documents mode, and set the
+
+ InstallationMode = InstallMode_Portable;
+ DocsFolderMode = DocsFolder_Custom;
+ CustomDocumentsFolder = portableDocsFolder;
+ return conf_portable.DetachPtr();
+ }
+
+ return NULL;
+}
+
+// Reset RunWizard so the FTWizard is run again on next PCSX2 start.
+void Pcsx2App::WipeUserModeSettings()
+{
+ if (InstallationMode == InstallMode_Portable)
+ {
+ // Remove the portable.ini entry "RunWizard" conforming to this instance of PCSX2.
+ wxFileName portableIniFile( GetPortableIniPath() );
+ ScopedPtr conf_portable( OpenFileConfig( portableIniFile.GetFullPath() ) );
+ conf_portable->DeleteEntry(L"RunWizard");
+ }
+ else
+ {
+ // Remove the registry entry "RunWizard" conforming to this instance of PCSX2.
+ ScopedPtr conf_install( OpenInstallSettingsFile() );
+ conf_install->DeleteEntry(L"RunWizard");
+ }
+}
+
+static void DoFirstTimeWizard()
+{
+ // first time startup, so give the user the choice of user mode:
+ while(true)
+ {
+ // PCSX2's FTWizard allows improptu restarting of the wizard without cancellation.
+ // This is typically used to change the user's language selection.
+
+ FirstTimeWizard wiz( NULL );
+ if( wiz.RunWizard( wiz.GetFirstPage() ) ) break;
+ if (wiz.GetReturnCode() != pxID_RestartWizard)
+ throw Exception::StartupAborted( L"User canceled FirstTime Wizard." );
+
+ Console.WriteLn( Color_StrongBlack, "Restarting First Time Wizard!" );
+ }
+}
+
+wxConfigBase* Pcsx2App::OpenInstallSettingsFile()
+{
+ // Implementation Notes:
+ //
+ // As of 0.9.8 and beyond, PCSX2's versioning should be strong enough to base ini and
+ // plugin compatibility on version information alone. This in turn allows us to ditch
+ // the old system (CWD-based ini file mess) in favor of a system that simply stores
+ // most core application-level settings in the registry.
+
+ ScopedPtr conf_install;
+
+#ifdef __WXMSW__
+ conf_install = new wxRegConfig();
+#else
+ // FIXME!! Linux / Mac
+ // Where the heck should this information be stored?
+
+ wxDirName usrlocaldir( PathDefs::GetUserLocalDataDir() );
+ //wxDirName usrlocaldir( wxStandardPaths::Get().GetDataDir() );
+ if( !usrlocaldir.Exists() )
+ {
+ Console.WriteLn( L"Creating UserLocalData folder: " + usrlocaldir.ToString() );
+ usrlocaldir.Mkdir();
+ }
+
+ wxFileName usermodefile( GetAppName() + L"-reg.ini" );
+ usermodefile.SetPath( usrlocaldir.ToString() );
+ conf_install = OpenFileConfig( usermodefile.GetFullPath() );
+#endif
+
+ return conf_install.DetachPtr();
+}
+
+
+void Pcsx2App::EstablishAppUserMode()
+{
+ ScopedPtr conf_install;
+
+ conf_install = TestForPortableInstall();
+ if (!conf_install)
+ conf_install = OpenInstallSettingsFile();
+
+ conf_install->SetRecordDefaults(false);
+
+ // Run the First Time Wizard!
+ // ----------------------------
+ // Wizard is only run once. The status of the wizard having been run is stored in
+ // the installation ini file, which can be either the portable install (useful for admins)
+ // or the registry/user local documents position.
+
+ bool runWiz;
+ conf_install->Read( L"RunWizard", &runWiz, true );
+
+ App_LoadInstallSettings( conf_install );
+
+ if( !Startup.ForceWizard && !runWiz )
+ {
+ AppConfig_OnChangedSettingsFolder( false );
+ return;
+ }
+
+ DoFirstTimeWizard();
+
+ // Save user's new settings
+ App_SaveInstallSettings( conf_install );
+ AppConfig_OnChangedSettingsFolder( true );
+ AppSaveSettings();
+
+ // Wizard completed successfully, so let's not torture the user with this crap again!
+ conf_install->Write( L"RunWizard", false );
+}
+
diff --git a/pcsx2/gui/Dialogs/GameDatabaseDialog.cpp b/pcsx2/gui/Dialogs/GameDatabaseDialog.cpp
index 1b8740c2a0..1231180496 100644
--- a/pcsx2/gui/Dialogs/GameDatabaseDialog.cpp
+++ b/pcsx2/gui/Dialogs/GameDatabaseDialog.cpp
@@ -1,29 +1,29 @@
-/* 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 .
- */
-
-#include "PrecompiledHeader.h"
-#include "ConfigurationDialog.h"
-#include "Panels/ConfigurationPanels.h"
-
-using namespace Panels;
-using namespace pxSizerFlags;
-
-Dialogs::GameDatabaseDialog::GameDatabaseDialog(wxWindow* parent)
- : BaseConfigurationDialog( parent, AddAppName(_("Game database - %s")), 580 )
-{
- ScopedBusyCursor busy( Cursor_ReallyBusy );
- *this += new GameDatabasePanel(this) | StdExpand();
- AddOkCancel();
-}
+/* 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 .
+ */
+
+#include "PrecompiledHeader.h"
+#include "ConfigurationDialog.h"
+#include "Panels/ConfigurationPanels.h"
+
+using namespace Panels;
+using namespace pxSizerFlags;
+
+Dialogs::GameDatabaseDialog::GameDatabaseDialog(wxWindow* parent)
+ : BaseConfigurationDialog( parent, AddAppName(_("Game database - %s")), 580 )
+{
+ ScopedBusyCursor busy( Cursor_ReallyBusy );
+ *this += new GameDatabasePanel(this) | StdExpand();
+ AddOkCancel();
+}
diff --git a/pcsx2/gui/MemoryCardFile.h b/pcsx2/gui/MemoryCardFile.h
index e85fd2ad6b..9f27c3f93d 100644
--- a/pcsx2/gui/MemoryCardFile.h
+++ b/pcsx2/gui/MemoryCardFile.h
@@ -1,30 +1,30 @@
-/* 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 .
- */
-
-#pragma once
-
-// NOTICE! This file is intended as a temporary placebo only, until such time that the
-// memorycard system is properly extracted into a plugin system (which would make it a
-// separate project file).
-//
-// Please do not move contents from MemoryCardfile.cpp, such as class definitions, into
-// this file. I'd prefer they stay in MemoryCardFile.cpp for now. --air
-
-extern uint FileMcd_GetMtapPort(uint slot);
-extern uint FileMcd_GetMtapSlot(uint slot);
-extern bool FileMcd_IsMultitapSlot( uint slot );
-//extern wxFileName FileMcd_GetSimpleName(uint slot);
-extern wxString FileMcd_GetDefaultName(uint slot);
-extern bool isValidNewFilename( wxString filenameStringToTest, wxDirName atBasePath, wxString& out_errorMessage, uint minNumCharacters=5 );
+/* 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 .
+ */
+
+#pragma once
+
+// NOTICE! This file is intended as a temporary placebo only, until such time that the
+// memorycard system is properly extracted into a plugin system (which would make it a
+// separate project file).
+//
+// Please do not move contents from MemoryCardfile.cpp, such as class definitions, into
+// this file. I'd prefer they stay in MemoryCardFile.cpp for now. --air
+
+extern uint FileMcd_GetMtapPort(uint slot);
+extern uint FileMcd_GetMtapSlot(uint slot);
+extern bool FileMcd_IsMultitapSlot( uint slot );
+//extern wxFileName FileMcd_GetSimpleName(uint slot);
+extern wxString FileMcd_GetDefaultName(uint slot);
+extern bool isValidNewFilename( wxString filenameStringToTest, wxDirName atBasePath, wxString& out_errorMessage, uint minNumCharacters=5 );
diff --git a/pcsx2/gui/Readme-MemoryCardFile.txt b/pcsx2/gui/Readme-MemoryCardFile.txt
index 5193bcc964..c3f26c6542 100644
--- a/pcsx2/gui/Readme-MemoryCardFile.txt
+++ b/pcsx2/gui/Readme-MemoryCardFile.txt
@@ -1,12 +1,12 @@
-
--/- MemoryCardFile SVN Status -/-
-
-Currently the MemoryCardFile "plugin" is integrated into the main UI of PCSX2. It provides
-standard raw/block emulation of a memorycard device. The plugin-ification of the MemoryCard
-system has not yet been completed, which is why the plugin as of right now is "integrated"
-into the UI. As the new PS2E.v2 plugin API is completed, the MemoryCardFile provider will
-be moved into an external DLL.
-
-Due to these future plans, and due to the number of files involved in implementing the
-user interface for memorycard management, I have arranged the MemoryCardFile plugin files
+
+-/- MemoryCardFile SVN Status -/-
+
+Currently the MemoryCardFile "plugin" is integrated into the main UI of PCSX2. It provides
+standard raw/block emulation of a memorycard device. The plugin-ification of the MemoryCard
+system has not yet been completed, which is why the plugin as of right now is "integrated"
+into the UI. As the new PS2E.v2 plugin API is completed, the MemoryCardFile provider will
+be moved into an external DLL.
+
+Due to these future plans, and due to the number of files involved in implementing the
+user interface for memorycard management, I have arranged the MemoryCardFile plugin files
in their own sub-folder inside the Visual Studio project.
\ No newline at end of file
diff --git a/pcsx2/x86/aVUzerorec.S b/pcsx2/x86/aVUzerorec.S
index 4df7eadf25..472eeacb3b 100644
--- a/pcsx2/x86/aVUzerorec.S
+++ b/pcsx2/x86/aVUzerorec.S
@@ -1,51 +1,51 @@
-// iVUzerorec.cpp assembly routines
-// zerofrog(@gmail.com)
-.intel_syntax noprefix
-
-.extern s_TotalVUCycles
-.extern s_callstack
-.extern s_vu1esp
-.extern s_writeQ
-.extern s_writeP
-.extern g_curdebugvu
-.extern SuperVUGetProgram
-.extern SuperVUCleanupProgram
-.extern g_sseVUMXCSR
-.extern g_sseMXCSR
-
-// SuperVUExecuteProgram(u32 startpc, int vuindex)
-.globl SuperVUExecuteProgram
-SuperVUExecuteProgram:
- mov eax, [esp]
- mov dword ptr s_TotalVUCycles, 0
- add esp, 4
- mov dword ptr [s_callstack], eax
- call SuperVUGetProgram
- mov s_vu1esi, esi
- mov s_vuedi, edi
- mov s_vuebx, ebx
-
- mov s_vu1esp, esp
- and esp, -16 // align stack for GCC compilance
-
- ldmxcsr g_sseVUMXCSR
- mov dword ptr s_writeQ, 0xffffffff
- mov dword ptr s_writeP, 0xffffffff
- jmp eax
-
-.globl SuperVUEndProgram
-SuperVUEndProgram:
- // restore cpu state
- ldmxcsr g_sseMXCSR
- mov esi, s_vu1esi
- mov edi, s_vuedi
- mov ebx, s_vuebx
-
- mov esp, s_vu1esp
-
- call SuperVUCleanupProgram
- jmp [s_callstack] // so returns correctly
-
-#if defined(__linux__) && defined(__ELF__)
-.section .note.GNU-stack,"",%progbits
-#endif
+// iVUzerorec.cpp assembly routines
+// zerofrog(@gmail.com)
+.intel_syntax noprefix
+
+.extern s_TotalVUCycles
+.extern s_callstack
+.extern s_vu1esp
+.extern s_writeQ
+.extern s_writeP
+.extern g_curdebugvu
+.extern SuperVUGetProgram
+.extern SuperVUCleanupProgram
+.extern g_sseVUMXCSR
+.extern g_sseMXCSR
+
+// SuperVUExecuteProgram(u32 startpc, int vuindex)
+.globl SuperVUExecuteProgram
+SuperVUExecuteProgram:
+ mov eax, [esp]
+ mov dword ptr s_TotalVUCycles, 0
+ add esp, 4
+ mov dword ptr [s_callstack], eax
+ call SuperVUGetProgram
+ mov s_vu1esi, esi
+ mov s_vuedi, edi
+ mov s_vuebx, ebx
+
+ mov s_vu1esp, esp
+ and esp, -16 // align stack for GCC compilance
+
+ ldmxcsr g_sseVUMXCSR
+ mov dword ptr s_writeQ, 0xffffffff
+ mov dword ptr s_writeP, 0xffffffff
+ jmp eax
+
+.globl SuperVUEndProgram
+SuperVUEndProgram:
+ // restore cpu state
+ ldmxcsr g_sseMXCSR
+ mov esi, s_vu1esi
+ mov edi, s_vuedi
+ mov ebx, s_vuebx
+
+ mov esp, s_vu1esp
+
+ call SuperVUCleanupProgram
+ jmp [s_callstack] // so returns correctly
+
+#if defined(__linux__) && defined(__ELF__)
+.section .note.GNU-stack,"",%progbits
+#endif
diff --git a/pcsx2/x86/ix86-32/aVif_proc-32.asm b/pcsx2/x86/ix86-32/aVif_proc-32.asm
index 62fd377795..ecaf3fbe5f 100644
--- a/pcsx2/x86/ix86-32/aVif_proc-32.asm
+++ b/pcsx2/x86/ix86-32/aVif_proc-32.asm
@@ -1,1839 +1,1839 @@
-
-.686
-.model flat, c
-.mmx
-.xmm
-
-
-extern vifRegs:ptr
-extern vifMaskRegs:ptr
-extern vifRow:ptr
-extern s_TempDecompress:ptr
-
-
-.code
-
-UNPACK_Write0_Regular macro r0, CL, DEST_OFFSET, MOVDQA
- MOVDQA [edi+DEST_OFFSET], r0
- endm
-
-UNPACK_Write1_Regular macro r0, CL, DEST_OFFSET, MOVDQA
- MOVDQA [edi], r0
- add edi, ecx
- endm
-
-UNPACK_Write0_Mask macro r0, CL, DEST_OFFSET, MOVDQA
- UNPACK_Write0_Regular r0, CL, DEST_OFFSET, MOVDQA
- endm
-
-UNPACK_Write1_Mask macro r0, CL, DEST_OFFSET, MOVDQA
- UNPACK_Write1_Regular r0, CL, DEST_OFFSET, MOVDQA
- endm
-
-
-UNPACK_Write0_WriteMask macro r0, CL, DEST_OFFSET, MOVDQA
-
- movdqa xmm3, [eax + 64*(CL) + 48]
- pand r0, xmm3
- pandn xmm3, [edi]
- por r0, xmm3
- MOVDQA [edi], r0
- add edi, 16
- endm
-
-
-UNPACK_Write1_WriteMask macro r0, CL, DEST_OFFSET, MOVDQA
-
- movdqa xmm3, [eax + 64*(0) + 48]
- pand r0, xmm3
- pandn xmm3, [edi]
- por r0, xmm3
- MOVDQA [edi], r0
- add edi, ecx
- endm
-
-UNPACK_Mask_SSE_0 macro r0
- pand r0, xmm3
- por r0, xmm5
- endm
-
-
-
-
-UNPACK_Mask_SSE_1 macro r0
-
- pand r0, xmm3
- por r0, xmm5
- pand xmm3, xmm6
- paddd r0, xmm3
- endm
-
-
-
-UNPACK_Mask_SSE_2 macro r0
-
-
- pand r0, xmm3
- pand xmm3, xmm6
- paddd xmm6, r0
- por r0, xmm5
- paddd r0, xmm3
- endm
-
-UNPACK_WriteMask_SSE_0 macro r0
- UNPACK_Mask_SSE_0 r0
- endm
-UNPACK_WriteMask_SSE_1 macro r0
- UNPACK_Mask_SSE_1 r0
- endm
-UNPACK_WriteMask_SSE_2 macro r0
- UNPACK_Mask_SSE_2 r0
- endm
-
-UNPACK_Regular_SSE_0 macro r0
- endm
-
-UNPACK_Regular_SSE_1 macro r0
- paddd r0, xmm6
- endm
-
-UNPACK_Regular_SSE_2 macro r0
- paddd r0, xmm6
- movdqa xmm6, r0
- endm
-
-
-UNPACK_Setup_Mask_SSE macro CL
- mov eax, [vifMaskRegs]
- movdqa xmm4, [eax + 64*(CL) + 16]
- movdqa xmm5, [eax + 64*(CL) + 32]
- movdqa xmm3, [eax + 64*(CL)]
- pand xmm4, xmm6
- pand xmm5, xmm7
- por xmm5, xmm4
- endm
-
-UNPACK_Start_Setup_Mask_SSE_0 macro CL
- UNPACK_Setup_Mask_SSE CL
- endm
-
-UNPACK_Start_Setup_Mask_SSE_1 macro CL
- mov eax, [vifMaskRegs]
- movdqa xmm4, [eax + 64*(CL) + 16]
- movdqa xmm5, [eax + 64*(CL) + 32]
- pand xmm4, xmm6
- pand xmm5, xmm7
- por xmm5, xmm4
- endm
-
-UNPACK_Start_Setup_Mask_SSE_2 macro CL
- endm
-
-UNPACK_Setup_Mask_SSE_0_1 macro CL
- endm
-UNPACK_Setup_Mask_SSE_1_1 macro CL
- mov eax, [vifMaskRegs]
- movdqa xmm3, [eax + 64*(0)]
- endm
-
-
-UNPACK_Setup_Mask_SSE_2_1 macro CL
-
- mov eax, [vifMaskRegs]
- movdqa xmm4, [eax + 64*(0) + 16]
- movdqa xmm5, [eax + 64*(0) + 32]
- movdqa xmm3, [eax + 64*(0)]
- pand xmm4, xmm6
- pand xmm5, xmm7
- por xmm5, xmm4
- endm
-
-UNPACK_Setup_Mask_SSE_0_0 macro CL
- UNPACK_Setup_Mask_SSE CL
- endm
-UNPACK_Setup_Mask_SSE_1_0 macro CL
- UNPACK_Setup_Mask_SSE CL
- endm
-UNPACK_Setup_Mask_SSE_2_0 macro CL
- UNPACK_Setup_Mask_SSE CL
- endm
-
-
-UNPACK_Setup_WriteMask_SSE_0_0 macro CL
- UNPACK_Setup_Mask_SSE CL
- endm
-UNPACK_Setup_WriteMask_SSE_1_0 macro CL
- UNPACK_Setup_Mask_SSE CL
- endm
-UNPACK_Setup_WriteMask_SSE_2_0 macro CL
- UNPACK_Setup_Mask_SSE CL
- endm
-UNPACK_Setup_WriteMask_SSE_0_1 macro CL
- UNPACK_Setup_Mask_SSE_1_1 CL
- endm
-
-UNPACK_Setup_WriteMask_SSE_1_1 macro CL
- UNPACK_Setup_Mask_SSE_1_1 CL
- endm
-
-UNPACK_Setup_WriteMask_SSE_2_1 macro CL
- UNPACK_Setup_Mask_SSE_2_1 CL
- endm
-
-UNPACK_Start_Setup_WriteMask_SSE_0 macro CL
- UNPACK_Start_Setup_Mask_SSE_1 CL
- endm
-UNPACK_Start_Setup_WriteMask_SSE_1 macro CL
- UNPACK_Start_Setup_Mask_SSE_1 CL
- endm
-UNPACK_Start_Setup_WriteMask_SSE_2 macro CL
- UNPACK_Start_Setup_Mask_SSE_2 CL
- endm
-
-UNPACK_Start_Setup_Regular_SSE_0 macro CL
- endm
-UNPACK_Start_Setup_Regular_SSE_1 macro CL
- endm
-UNPACK_Start_Setup_Regular_SSE_2 macro CL
- endm
-UNPACK_Setup_Regular_SSE_0_0 macro CL
- endm
-UNPACK_Setup_Regular_SSE_1_0 macro CL
- endm
-UNPACK_Setup_Regular_SSE_2_0 macro CL
- endm
-UNPACK_Setup_Regular_SSE_0_1 macro CL
- endm
-UNPACK_Setup_Regular_SSE_1_1 macro CL
- endm
-UNPACK_Setup_Regular_SSE_2_1 macro CL
- endm
-
-UNPACK_INC_DST_0_Regular macro qw
- add edi, (16*qw)
- endm
-UNPACK_INC_DST_1_Regular macro qw
- endm
-UNPACK_INC_DST_0_Mask macro qw
- add edi, (16*qw)
- endm
-UNPACK_INC_DST_1_Mask macro qw
- endm
-UNPACK_INC_DST_0_WriteMask macro qw
- endm
-UNPACK_INC_DST_1_WriteMask macro qw
- endm
-
-
-UNPACK4_SSE macro CL, TOTALCL, MaskType, ModeType
- @CatStr(UNPACK_Setup_, MaskType, _SSE_, ModeType, _, TOTALCL) CL+0
- @CatStr(UNPACK_, MaskType, _SSE_, ModeType) xmm0
- @CatStr(UNPACK_Write, TOTALCL, _, MaskType) xmm0, CL, 0, movdqa
-
- @CatStr(UNPACK_Setup_, MaskType, _SSE_, ModeType, _, TOTALCL) CL+1
- @CatStr(UNPACK_, MaskType, _SSE_, ModeType) xmm1
- @CatStr(UNPACK_Write, TOTALCL, _, MaskType) xmm1, CL+1, 16, movdqa
-
- @CatStr(UNPACK_Setup_, MaskType, _SSE_, ModeType, _, TOTALCL) CL+2
- @CatStr(UNPACK_, MaskType, _SSE_, ModeType) xmm2
- @CatStr(UNPACK_Write, TOTALCL, _, MaskType) xmm2, CL+2, 32, movdqa
-
- @CatStr(UNPACK_Setup_, MaskType, _SSE_, ModeType, _, TOTALCL) CL+3
- @CatStr(UNPACK_, MaskType, _SSE_, ModeType) xmm7
- @CatStr(UNPACK_Write, TOTALCL, _, MaskType) xmm7, CL+3, 48, movdqa
-
- @CatStr(UNPACK_INC_DST_, TOTALCL, _, MaskType) 4
- endm
-
-
-UNPACK3_SSE macro CL, TOTALCL, MaskType, ModeType
- @CatStr(UNPACK_Setup_, MaskType, _SSE_, ModeType, _, TOTALCL) CL
- @CatStr(UNPACK_, MaskType, _SSE_, ModeType) xmm0
- @CatStr(UNPACK_Write, TOTALCL, _, MaskType) xmm0, CL, 0, movdqa
-
- @CatStr(UNPACK_Setup_, MaskType, _SSE_, ModeType, _, TOTALCL) CL+1
- @CatStr(UNPACK_, MaskType, _SSE_, ModeType) xmm1
- @CatStr(UNPACK_Write, TOTALCL, _, MaskType) xmm1, CL+1, 16, movdqa
-
- @CatStr(UNPACK_Setup_, MaskType, _SSE_, ModeType, _, TOTALCL) CL+2
- @CatStr(UNPACK_, MaskType, _SSE_, ModeType) xmm2
- @CatStr(UNPACK_Write, TOTALCL, _, MaskType) xmm2, CL+2, 32, movdqa
-
- @CatStr(UNPACK_INC_DST_, TOTALCL, _, MaskType) 3
- endm
-
-UNPACK2_SSE macro CL, TOTALCL, MaskType, ModeType
- @CatStr(UNPACK_Setup_, MaskType, _SSE_, ModeType, _, TOTALCL) CL
- @CatStr(UNPACK_, MaskType, _SSE_, ModeType) xmm0
- @CatStr(UNPACK_Write, TOTALCL, _, MaskType) xmm0, CL, 0, movdqa
-
- @CatStr(UNPACK_Setup_, MaskType, _SSE_, ModeType, _, TOTALCL) CL+1
- @CatStr(UNPACK_, MaskType, _SSE_, ModeType) xmm1
- @CatStr(UNPACK_Write, TOTALCL, _, MaskType) xmm1, CL+1, 16, movdqa
-
- @CatStr(UNPACK_INC_DST_, TOTALCL, _, MaskType) 2
- endm
-
-UNPACK1_SSE macro CL, TOTALCL, MaskType, ModeType
- @CatStr(UNPACK_Setup_, MaskType, _SSE_, ModeType, _, TOTALCL) CL
- @CatStr(UNPACK_, MaskType, _SSE_, ModeType) xmm0
- @CatStr(UNPACK_Write, TOTALCL, _, MaskType) xmm0, CL, 0, movdqa
-
- @CatStr(UNPACK_INC_DST_, TOTALCL, _, MaskType) 1
- endm
-
-
-
-UNPACK_S_32SSE_4x macro CL, TOTALCL, MaskType, ModeType, MOVDQA
- MOVDQA xmm7, [esi]
-
- pshufd xmm0, xmm7, 0
- pshufd xmm1, xmm7, 055h
- pshufd xmm2, xmm7, 0aah
- pshufd xmm7, xmm7, 0ffh
-
- UNPACK4_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 16
- endm
-
-UNPACK_S_32SSE_4A macro CL, TOTALCL, MaskType, ModeType
- UNPACK_S_32SSE_4x CL, TOTALCL, MaskType, ModeType, movdqa
- endm
-UNPACK_S_32SSE_4 macro CL, TOTALCL, MaskType, ModeType
- UNPACK_S_32SSE_4x CL, TOTALCL, MaskType, ModeType, movdqu
- endm
-
-UNPACK_S_32SSE_3x macro CL, TOTALCL, MaskType, ModeType, MOVDQA
- MOVDQA xmm2, [esi]
-
- pshufd xmm0, xmm2, 0
- pshufd xmm1, xmm2, 055h
- pshufd xmm2, xmm2, 0aah
-
- UNPACK3_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 12
- endm
-
-UNPACK_S_32SSE_3A macro CL, TOTALCL, MaskType, ModeType
- UNPACK_S_32SSE_3x CL, TOTALCL, MaskType, ModeType, movdqa
- endm
-UNPACK_S_32SSE_3 macro CL, TOTALCL, MaskType, ModeType
- UNPACK_S_32SSE_3x CL, TOTALCL, MaskType, ModeType, movdqu
- endm
-
-UNPACK_S_32SSE_2 macro CL, TOTALCL, MaskType, ModeType
- movq xmm1, QWORD PTR [esi]
-
- pshufd xmm0, xmm1, 0
- pshufd xmm1, xmm1, 055h
-
- UNPACK2_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 8
- endm
-
-UNPACK_S_32SSE_2A macro CL, TOTALCL, MaskType, ModeType
- UNPACK_S_32SSE_2 CL, TOTALCL, MaskType, ModeType
- endm
-
-UNPACK_S_32SSE_1 macro CL, TOTALCL, MaskType, ModeType
- movd xmm0, dword ptr [esi]
- pshufd xmm0, xmm0, 0
-
- UNPACK1_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 4
- endm
-
-UNPACK_S_32SSE_1A macro CL, TOTALCL, MaskType, ModeType
- UNPACK_S_32SSE_1 CL, TOTALCL, MaskType, ModeType
- endm
-
-
-UNPACK_S_16SSE_4 macro CL, TOTALCL, MaskType, ModeType
- movq xmm7, QWORD PTR [esi]
- punpcklwd xmm7, xmm7
- UNPACK_RIGHTSHIFT xmm7, 16
-
- pshufd xmm0, xmm7, 0
- pshufd xmm1, xmm7, 055h
- pshufd xmm2, xmm7, 0aah
- pshufd xmm7, xmm7, 0ffh
-
- UNPACK4_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 8
- endm
-
-UNPACK_S_16SSE_4A macro CL, TOTALCL, MaskType, ModeType
- UNPACK_S_16SSE_4 CL, TOTALCL, MaskType, ModeType
- endm
-
-UNPACK_S_16SSE_3 macro CL, TOTALCL, MaskType, ModeType
- movq xmm2, QWORD PTR [esi]
- punpcklwd xmm2, xmm2
- UNPACK_RIGHTSHIFT xmm2, 16
-
- pshufd xmm0, xmm2, 0
- pshufd xmm1, xmm2, 055h
- pshufd xmm2, xmm2, 0aah
-
- UNPACK3_SSE CL, TOTALCL, MaskType, ModeType
- add esi, 6
- endm
-
-UNPACK_S_16SSE_3A macro CL, TOTALCL, MaskType, ModeType
- UNPACK_S_16SSE_3 CL, TOTALCL, MaskType, ModeType
- endm
-
-UNPACK_S_16SSE_2 macro CL, TOTALCL, MaskType, ModeType
- movd xmm1, dword ptr [esi]
- punpcklwd xmm1, xmm1
- UNPACK_RIGHTSHIFT xmm1, 16
-
- pshufd xmm0, xmm1, 0
- pshufd xmm1, xmm1, 055h
-
- UNPACK2_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 4
- endm
-
-UNPACK_S_16SSE_2A macro CL, TOTALCL, MaskType, ModeType
- UNPACK_S_16SSE_2 CL, TOTALCL, MaskType, ModeType
- endm
-
-UNPACK_S_16SSE_1 macro CL, TOTALCL, MaskType, ModeType
- movd xmm0, dword ptr [esi]
- punpcklwd xmm0, xmm0
- UNPACK_RIGHTSHIFT xmm0, 16
- pshufd xmm0, xmm0, 0
-
- UNPACK1_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 2
- endm
-
-UNPACK_S_16SSE_1A macro CL, TOTALCL, MaskType, ModeType
- UNPACK_S_16SSE_1 CL, TOTALCL, MaskType, ModeType
- endm
-
-
-UNPACK_S_8SSE_4 macro CL, TOTALCL, MaskType, ModeType
- movd xmm7, dword ptr [esi]
- punpcklbw xmm7, xmm7
- punpcklwd xmm7, xmm7
- UNPACK_RIGHTSHIFT xmm7, 24
-
- pshufd xmm0, xmm7, 0
- pshufd xmm1, xmm7, 055h
- pshufd xmm2, xmm7, 0aah
- pshufd xmm7, xmm7, 0ffh
-
- UNPACK4_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 4
- endm
-
-UNPACK_S_8SSE_4A macro CL, TOTALCL, MaskType, ModeType
- UNPACK_S_8SSE_4 CL, TOTALCL, MaskType, ModeType
- endm
-
-UNPACK_S_8SSE_3 macro CL, TOTALCL, MaskType, ModeType
- movd xmm2, dword ptr [esi]
- punpcklbw xmm2, xmm2
- punpcklwd xmm2, xmm2
- UNPACK_RIGHTSHIFT xmm2, 24
-
- pshufd xmm0, xmm2, 0
- pshufd xmm1, xmm2, 055h
- pshufd xmm2, xmm2, 0aah
-
- UNPACK3_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 3
- endm
-
-UNPACK_S_8SSE_3A macro CL, TOTALCL, MaskType, ModeType
- UNPACK_S_8SSE_3 CL, TOTALCL, MaskType, ModeType
- endm
-
-UNPACK_S_8SSE_2 macro CL, TOTALCL, MaskType, ModeType
- movd xmm1, dword ptr [esi]
- punpcklbw xmm1, xmm1
- punpcklwd xmm1, xmm1
- UNPACK_RIGHTSHIFT xmm1, 24
-
- pshufd xmm0, xmm1, 0
- pshufd xmm1, xmm1, 055h
-
- UNPACK2_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 2
- endm
-
-UNPACK_S_8SSE_2A macro CL, TOTALCL, MaskType, ModeType
- UNPACK_S_8SSE_2 CL, TOTALCL, MaskType, ModeType
- endm
-
-UNPACK_S_8SSE_1 macro CL, TOTALCL, MaskType, ModeType
- movd xmm0, dword ptr [esi]
- punpcklbw xmm0, xmm0
- punpcklwd xmm0, xmm0
- UNPACK_RIGHTSHIFT xmm0, 24
- pshufd xmm0, xmm0, 0
-
- UNPACK1_SSE CL, TOTALCL, MaskType, ModeType
-
- inc esi
- endm
-
-UNPACK_S_8SSE_1A macro CL, TOTALCL, MaskType, ModeType
- UNPACK_S_8SSE_1 CL, TOTALCL, MaskType, ModeType
- endm
-
-
-UNPACK_V2_32SSE_4A macro CL, TOTALCL, MaskType, ModeType
- MOVDQA xmm0, [esi]
- MOVDQA xmm2, [esi+16]
-
- pshufd xmm1, xmm0, 0eeh
- pshufd xmm7, xmm2, 0eeh
-
- UNPACK4_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 32
- endm
-
-UNPACK_V2_32SSE_4 macro CL, TOTALCL, MaskType, ModeType
- movq xmm0, QWORD PTR [esi]
- movq xmm1, QWORD PTR [esi+8]
- movq xmm2, QWORD PTR [esi+16]
- movq xmm7, QWORD PTR [esi+24]
-
- UNPACK4_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 32
- endm
-
-UNPACK_V2_32SSE_3A macro CL, TOTALCL, MaskType, ModeType
- MOVDQA xmm0, [esi]
- movq xmm2, QWORD PTR [esi+16]
- pshufd xmm1, xmm0, 0eeh
-
- UNPACK3_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 24
- endm
-
-UNPACK_V2_32SSE_3 macro CL, TOTALCL, MaskType, ModeType
- movq xmm0, QWORD PTR [esi]
- movq xmm1, QWORD PTR [esi+8]
- movq xmm2, QWORD PTR [esi+16]
-
- UNPACK3_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 24
- endm
-
-UNPACK_V2_32SSE_2 macro CL, TOTALCL, MaskType, ModeType
- movq xmm0, QWORD PTR [esi]
- movq xmm1, QWORD PTR [esi+8]
-
- UNPACK2_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 16
- endm
-
-UNPACK_V2_32SSE_2A macro CL, TOTALCL, MaskType, ModeType
- UNPACK_V2_32SSE_2 CL, TOTALCL, MaskType, ModeType
- endm
-
-UNPACK_V2_32SSE_1 macro CL, TOTALCL, MaskType, ModeType
- movq xmm0, QWORD PTR [esi]
-
- UNPACK1_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 8
- endm
-
-UNPACK_V2_32SSE_1A macro CL, TOTALCL, MaskType, ModeType
- UNPACK_V2_32SSE_1 CL, TOTALCL, MaskType, ModeType
- endm
-
-
-UNPACK_V2_16SSE_4A macro CL, TOTALCL, MaskType, ModeType
- punpcklwd xmm0, [esi]
- punpckhwd xmm2, [esi]
-
- UNPACK_RIGHTSHIFT xmm0, 16
- UNPACK_RIGHTSHIFT xmm2, 16
-
- punpckhqdq xmm1, xmm0
- punpckhqdq xmm7, xmm2
-
- punpcklqdq xmm0, xmm0
- punpcklqdq xmm2, xmm2
- punpckhqdq xmm1, xmm1
- punpckhqdq xmm7, xmm7
-
- UNPACK4_SSE CL, TOTALCL, MaskType, ModeType
- add esi, 16
- endm
-
-UNPACK_V2_16SSE_4 macro CL, TOTALCL, MaskType, ModeType
- pxor xmm0, xmm0
- pxor xmm2, xmm2
- movdqu xmm0, [esi]
-
- punpckhwd xmm2, xmm0
- punpcklwd xmm0, xmm0
-
- UNPACK_RIGHTSHIFT xmm0, 16
- UNPACK_RIGHTSHIFT xmm2, 16
-
- punpckhqdq xmm1, xmm0
- punpckhqdq xmm7, xmm2
-
- punpcklqdq xmm0, xmm0
- punpcklqdq xmm2, xmm2
- punpckhqdq xmm1, xmm1
- punpckhqdq xmm7, xmm7
-
- UNPACK4_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 16
- endm
-
-UNPACK_V2_16SSE_3A macro CL, TOTALCL, MaskType, ModeType
- punpcklwd xmm0, [esi]
- punpckhwd xmm2, [esi]
-
- UNPACK_RIGHTSHIFT xmm0, 16
- UNPACK_RIGHTSHIFT xmm2, 16
-
-
- punpckhqdq xmm1, xmm0
-
- punpcklqdq xmm0, xmm0
- punpcklqdq xmm2, xmm2
- punpckhqdq xmm1, xmm1
-
- UNPACK3_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 12
- endm
-
-UNPACK_V2_16SSE_3 macro CL, TOTALCL, MaskType, ModeType
- movdqu xmm0, [esi]
-
- punpckhwd xmm2, xmm0
- punpcklwd xmm0, xmm0
-
- UNPACK_RIGHTSHIFT xmm0, 16
- UNPACK_RIGHTSHIFT xmm2, 16
-
-
- punpckhqdq xmm1, xmm0
-
- punpcklqdq xmm0, xmm0
- punpcklqdq xmm2, xmm2
- punpckhqdq xmm1, xmm1
-
- UNPACK3_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 12
- endm
-
-UNPACK_V2_16SSE_2A macro CL, TOTALCL, MaskType, ModeType
- punpcklwd xmm0, [esi]
- UNPACK_RIGHTSHIFT xmm0, 16
-
-
- punpckhqdq xmm1, xmm0
-
- punpcklqdq xmm0, xmm0
- punpckhqdq xmm1, xmm1
-
- UNPACK2_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 8
- endm
-
-UNPACK_V2_16SSE_2 macro CL, TOTALCL, MaskType, ModeType
- movq xmm0, QWORD PTR [esi]
- punpcklwd xmm0, xmm0
- UNPACK_RIGHTSHIFT xmm0, 16
-
-
- punpckhqdq xmm1, xmm0
-
- punpcklqdq xmm0, xmm0
- punpckhqdq xmm1, xmm1
-
- UNPACK2_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 8
- endm
-
-UNPACK_V2_16SSE_1A macro CL, TOTALCL, MaskType, ModeType
- punpcklwd xmm0, [esi]
- UNPACK_RIGHTSHIFT xmm0, 16
-
- punpcklqdq xmm0, xmm0
-
- UNPACK1_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 4
- endm
-
-UNPACK_V2_16SSE_1 macro CL, TOTALCL, MaskType, ModeType
- movd xmm0, dword ptr [esi]
- punpcklwd xmm0, xmm0
- UNPACK_RIGHTSHIFT xmm0, 16
-
- punpcklqdq xmm0, xmm0
-
- UNPACK1_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 4
- endm
-
-
-UNPACK_V2_8SSE_4 macro CL, TOTALCL, MaskType, ModeType
- movq xmm0, QWORD PTR [esi]
-
- punpcklbw xmm0, xmm0
- punpckhwd xmm2, xmm0
- punpcklwd xmm0, xmm0
-
- UNPACK_RIGHTSHIFT xmm0, 24
- UNPACK_RIGHTSHIFT xmm2, 24
-
- punpckhqdq xmm1, xmm0
- punpckhqdq xmm7, xmm2
-
- punpcklqdq xmm0, xmm0
- punpcklqdq xmm2, xmm2
- punpckhqdq xmm1, xmm1
- punpckhqdq xmm7, xmm7
-
- UNPACK4_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 8
- endm
-
-UNPACK_V2_8SSE_4A macro CL, TOTALCL, MaskType, ModeType
- UNPACK_V2_8SSE_4 CL, TOTALCL, MaskType, ModeType
- endm
-
-UNPACK_V2_8SSE_3 macro CL, TOTALCL, MaskType, ModeType
- movq xmm0, QWORD PTR [esi]
-
- punpcklbw xmm0, xmm0
- punpckhwd xmm2, xmm0
- punpcklwd xmm0, xmm0
-
- UNPACK_RIGHTSHIFT xmm0, 24
- UNPACK_RIGHTSHIFT xmm2, 24
-
- punpckhqdq xmm1, xmm0
-
- punpcklqdq xmm0, xmm0
- punpcklqdq xmm2, xmm2
- punpckhqdq xmm1, xmm1
-
- UNPACK3_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 6
- endm
-
-UNPACK_V2_8SSE_3A macro CL, TOTALCL, MaskType, ModeType
- UNPACK_V2_8SSE_3 CL, TOTALCL, MaskType, ModeType
- endm
-
-UNPACK_V2_8SSE_2 macro CL, TOTALCL, MaskType, ModeType
- movd xmm0, dword ptr [esi]
- punpcklbw xmm0, xmm0
- punpcklwd xmm0, xmm0
- UNPACK_RIGHTSHIFT xmm0, 24
-
- punpckhqdq xmm1, xmm0
-
- punpcklqdq xmm0, xmm0
- punpckhqdq xmm1, xmm1
-
- UNPACK2_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 4
- endm
-
-UNPACK_V2_8SSE_2A macro CL, TOTALCL, MaskType, ModeType
- UNPACK_V2_8SSE_2 CL, TOTALCL, MaskType, ModeType
- endm
-
-UNPACK_V2_8SSE_1 macro CL, TOTALCL, MaskType, ModeType
- movd xmm0, dword ptr [esi]
- punpcklbw xmm0, xmm0
- punpcklwd xmm0, xmm0
- UNPACK_RIGHTSHIFT xmm0, 24
- punpcklqdq xmm0, xmm0
-
- UNPACK1_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 2
- endm
-
-UNPACK_V2_8SSE_1A macro CL, TOTALCL, MaskType, ModeType
- UNPACK_V2_8SSE_1 CL, TOTALCL, MaskType, ModeType
- endm
-
-
-UNPACK_V3_32SSE_4x macro CL, TOTALCL, MaskType, ModeType, MOVDQA
- MOVDQA xmm0, [esi]
- movdqu xmm1, [esi+12]
-
- @CatStr(UNPACK_Setup_, MaskType, _SSE_, ModeType, _, TOTALCL) CL+0
- @CatStr(UNPACK_, MaskType, _SSE_, ModeType) xmm0
- @CatStr(UNPACK_Write, TOTALCL, _, MaskType) xmm0, CL, 0, movdqa
-
- @CatStr(UNPACK_Setup_, MaskType, _SSE_, ModeType, _, TOTALCL) CL+1
- @CatStr(UNPACK_, MaskType, _SSE_, ModeType) xmm1
- @CatStr(UNPACK_Write, TOTALCL, _, MaskType) xmm1, CL+1, 16, movdqa
-
-
- MOVDQA xmm7, [esi+32]
- movdqu xmm2, [esi+24]
- psrldq xmm7, 4
-
- @CatStr(UNPACK_Setup_, MaskType, _SSE_, ModeType, _, TOTALCL) CL+2
- @CatStr(UNPACK_, MaskType, _SSE_, ModeType) xmm2
- @CatStr(UNPACK_Write, TOTALCL, _, MaskType) xmm2, CL+2, 32, movdqa
-
- @CatStr(UNPACK_Setup_, MaskType, _SSE_, ModeType, _, TOTALCL) CL+3
- @CatStr(UNPACK_, MaskType, _SSE_, ModeType) xmm7
- @CatStr(UNPACK_Write, TOTALCL, _, MaskType) xmm7, CL+3, 48, movdqa
-
- @CatStr(UNPACK_INC_DST_, TOTALCL, _, MaskType) 4
-
- add esi, 48
- endm
-
-UNPACK_V3_32SSE_4A macro CL, TOTALCL, MaskType, ModeType
- UNPACK_V3_32SSE_4x CL, TOTALCL, MaskType, ModeType, movdqa
- endm
-UNPACK_V3_32SSE_4 macro CL, TOTALCL, MaskType, ModeType
- UNPACK_V3_32SSE_4x CL, TOTALCL, MaskType, ModeType, movdqu
- endm
-
-UNPACK_V3_32SSE_3x macro CL, TOTALCL, MaskType, ModeType, MOVDQA
- MOVDQA xmm0, [esi]
- movdqu xmm1, [esi+12]
-
- @CatStr(UNPACK_Setup_, MaskType, _SSE_, ModeType, _, TOTALCL) CL
- @CatStr(UNPACK_, MaskType, _SSE_, ModeType) xmm0
- @CatStr(UNPACK_Write, TOTALCL, _, MaskType) xmm0, CL, 0, movdqa
-
- @CatStr(UNPACK_Setup_, MaskType, _SSE_, ModeType, _, TOTALCL) CL+1
- @CatStr(UNPACK_, MaskType, _SSE_, ModeType) xmm1
- @CatStr(UNPACK_Write, TOTALCL, _, MaskType) xmm1, CL+1, 16, movdqa
-
- movdqu xmm2, [esi+24]
-
- @CatStr(UNPACK_Setup_, MaskType, _SSE_, ModeType, _, TOTALCL) CL+2
- @CatStr(UNPACK_, MaskType, _SSE_, ModeType) xmm2
- @CatStr(UNPACK_Write, TOTALCL, _, MaskType) xmm2, CL+2, 32, movdqa
-
- @CatStr(UNPACK_INC_DST_, TOTALCL, _, MaskType) 3
-
- add esi, 36
- endm
-
-UNPACK_V3_32SSE_3A macro CL, TOTALCL, MaskType, ModeType
- UNPACK_V3_32SSE_3x CL, TOTALCL, MaskType, ModeType, movdqa
- endm
-UNPACK_V3_32SSE_3 macro CL, TOTALCL, MaskType, ModeType
- UNPACK_V3_32SSE_3x CL, TOTALCL, MaskType, ModeType, movdqu
- endm
-
-UNPACK_V3_32SSE_2x macro CL, TOTALCL, MaskType, ModeType, MOVDQA
- MOVDQA xmm0, [esi]
- movdqu xmm1, [esi+12]
-
- UNPACK2_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 24
- endm
-
-UNPACK_V3_32SSE_2A macro CL, TOTALCL, MaskType, ModeType
- UNPACK_V3_32SSE_2x CL, TOTALCL, MaskType, ModeType, movdqa
- endm
-UNPACK_V3_32SSE_2 macro CL, TOTALCL, MaskType, ModeType
- UNPACK_V3_32SSE_2x CL, TOTALCL, MaskType, ModeType, movdqu
- endm
-
-UNPACK_V3_32SSE_1x macro CL, TOTALCL, MaskType, ModeType, MOVDQA
- MOVDQA xmm0, [esi]
-
- UNPACK1_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 12
- endm
-
-UNPACK_V3_32SSE_1A macro CL, TOTALCL, MaskType, ModeType
- UNPACK_V3_32SSE_1x CL, TOTALCL, MaskType, ModeType, movdqa
- endm
-UNPACK_V3_32SSE_1 macro CL, TOTALCL, MaskType, ModeType
- UNPACK_V3_32SSE_1x CL, TOTALCL, MaskType, ModeType, movdqu
- endm
-
-
-UNPACK_V3_16SSE_4 macro CL, TOTALCL, MaskType, ModeType
- movq xmm0, QWORD PTR [esi]
- movq xmm1, QWORD PTR [esi+6]
-
- punpcklwd xmm0, xmm0
- movq xmm2, QWORD PTR [esi+12]
- punpcklwd xmm1, xmm1
- UNPACK_RIGHTSHIFT xmm0, 16
- movq xmm7, QWORD PTR [esi+18]
- UNPACK_RIGHTSHIFT xmm1, 16
- punpcklwd xmm2, xmm2
- punpcklwd xmm7, xmm7
-
- UNPACK_RIGHTSHIFT xmm2, 16
- UNPACK_RIGHTSHIFT xmm7, 16
-
- UNPACK4_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 24
- endm
-
-UNPACK_V3_16SSE_4A macro CL, TOTALCL, MaskType, ModeType
- UNPACK_V3_16SSE_4 CL, TOTALCL, MaskType, ModeType
- endm
-
-UNPACK_V3_16SSE_3 macro CL, TOTALCL, MaskType, ModeType
- movq xmm0, QWORD PTR [esi]
- movq xmm1, QWORD PTR [esi+6]
-
- punpcklwd xmm0, xmm0
- movq xmm2, QWORD PTR [esi+12]
- punpcklwd xmm1, xmm1
- UNPACK_RIGHTSHIFT xmm0, 16
- punpcklwd xmm2, xmm2
-
- UNPACK_RIGHTSHIFT xmm1, 16
- UNPACK_RIGHTSHIFT xmm2, 16
-
- UNPACK3_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 18
- endm
-
-UNPACK_V3_16SSE_3A macro CL, TOTALCL, MaskType, ModeType
- UNPACK_V3_16SSE_3 CL, TOTALCL, MaskType, ModeType
- endm
-
-UNPACK_V3_16SSE_2 macro CL, TOTALCL, MaskType, ModeType
- movq xmm0, QWORD PTR [esi]
- movq xmm1, QWORD PTR [esi+6]
-
- punpcklwd xmm0, xmm0
- punpcklwd xmm1, xmm1
-
- UNPACK_RIGHTSHIFT xmm0, 16
- UNPACK_RIGHTSHIFT xmm1, 16
-
- UNPACK2_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 12
- endm
-
-UNPACK_V3_16SSE_2A macro CL, TOTALCL, MaskType, ModeType
- UNPACK_V3_16SSE_2 CL, TOTALCL, MaskType, ModeType
- endm
-
-UNPACK_V3_16SSE_1 macro CL, TOTALCL, MaskType, ModeType
- movq xmm0, QWORD PTR [esi]
- punpcklwd xmm0, xmm0
- UNPACK_RIGHTSHIFT xmm0, 16
-
- UNPACK1_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 6
- endm
-
-UNPACK_V3_16SSE_1A macro CL, TOTALCL, MaskType, ModeType
- UNPACK_V3_16SSE_1 CL, TOTALCL, MaskType, ModeType
- endm
-
-
-UNPACK_V3_8SSE_4 macro CL, TOTALCL, MaskType, ModeType
- movq xmm1, QWORD PTR [esi]
- movq xmm7, QWORD PTR [esi+6]
-
- punpcklbw xmm1, xmm1
- punpcklbw xmm7, xmm7
- punpcklwd xmm0, xmm1
- psrldq xmm1, 6
- punpcklwd xmm2, xmm7
- psrldq xmm7, 6
- punpcklwd xmm1, xmm1
- UNPACK_RIGHTSHIFT xmm0, 24
- punpcklwd xmm7, xmm7
-
- UNPACK_RIGHTSHIFT xmm2, 24
- UNPACK_RIGHTSHIFT xmm1, 24
- UNPACK_RIGHTSHIFT xmm7, 24
-
- UNPACK4_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 12
- endm
-
-UNPACK_V3_8SSE_4A macro CL, TOTALCL, MaskType, ModeType
- UNPACK_V3_8SSE_4 CL, TOTALCL, MaskType, ModeType
- endm
-
-UNPACK_V3_8SSE_3 macro CL, TOTALCL, MaskType, ModeType
- movd xmm0, dword ptr [esi]
- movd xmm1, dword ptr [esi+3]
-
- punpcklbw xmm0, xmm0
- movd xmm2, dword ptr [esi+6]
- punpcklbw xmm1, xmm1
- punpcklwd xmm0, xmm0
- punpcklbw xmm2, xmm2
-
- punpcklwd xmm1, xmm1
- punpcklwd xmm2, xmm2
-
- UNPACK_RIGHTSHIFT xmm0, 24
- UNPACK_RIGHTSHIFT xmm1, 24
- UNPACK_RIGHTSHIFT xmm2, 24
-
- UNPACK3_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 9
- endm
-
-UNPACK_V3_8SSE_3A macro CL, TOTALCL, MaskType, ModeType
- UNPACK_V3_8SSE_3 CL, TOTALCL, MaskType, ModeType
- endm
-
-UNPACK_V3_8SSE_2 macro CL, TOTALCL, MaskType, ModeType
- movd xmm0, dword ptr [esi]
- movd xmm1, dword ptr [esi+3]
-
- punpcklbw xmm0, xmm0
- punpcklbw xmm1, xmm1
-
- punpcklwd xmm0, xmm0
- punpcklwd xmm1, xmm1
-
- UNPACK_RIGHTSHIFT xmm0, 24
- UNPACK_RIGHTSHIFT xmm1, 24
-
- UNPACK2_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 6
- endm
-
-UNPACK_V3_8SSE_2A macro CL, TOTALCL, MaskType, ModeType
- UNPACK_V3_8SSE_2 CL, TOTALCL, MaskType, ModeType
- endm
-
-UNPACK_V3_8SSE_1 macro CL, TOTALCL, MaskType, ModeType
- movd xmm0, dword ptr [esi]
- punpcklbw xmm0, xmm0
- punpcklwd xmm0, xmm0
- UNPACK_RIGHTSHIFT xmm0, 24
-
- UNPACK1_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 3
- endm
-
-UNPACK_V3_8SSE_1A macro CL, TOTALCL, MaskType, ModeType
- UNPACK_V3_8SSE_1 CL, TOTALCL, MaskType, ModeType
- endm
-
-
-UNPACK_V4_32SSE_4A macro CL, TOTALCL, MaskType, ModeType
- movdqa xmm0, [esi]
- movdqa xmm1, [esi+16]
- movdqa xmm2, [esi+32]
- movdqa xmm7, [esi+48]
-
- UNPACK4_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 64
- endm
-
-UNPACK_V4_32SSE_4 macro CL, TOTALCL, MaskType, ModeType
- movdqu xmm0, [esi]
- movdqu xmm1, [esi+16]
- movdqu xmm2, [esi+32]
- movdqu xmm7, [esi+48]
-
- UNPACK4_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 64
- endm
-
-UNPACK_V4_32SSE_3A macro CL, TOTALCL, MaskType, ModeType
- movdqa xmm0, [esi]
- movdqa xmm1, [esi+16]
- movdqa xmm2, [esi+32]
-
- UNPACK3_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 48
- endm
-
-UNPACK_V4_32SSE_3 macro CL, TOTALCL, MaskType, ModeType
- movdqu xmm0, [esi]
- movdqu xmm1, [esi+16]
- movdqu xmm2, [esi+32]
-
- UNPACK3_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 48
- endm
-
-UNPACK_V4_32SSE_2A macro CL, TOTALCL, MaskType, ModeType
- movdqa xmm0, [esi]
- movdqa xmm1, [esi+16]
-
- UNPACK2_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 32
- endm
-
-UNPACK_V4_32SSE_2 macro CL, TOTALCL, MaskType, ModeType
- movdqu xmm0, [esi]
- movdqu xmm1, [esi+16]
-
- UNPACK2_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 32
- endm
-
-UNPACK_V4_32SSE_1A macro CL, TOTALCL, MaskType, ModeType
- movdqa xmm0, [esi]
-
- UNPACK1_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 16
- endm
-
-UNPACK_V4_32SSE_1 macro CL, TOTALCL, MaskType, ModeType
- movdqu xmm0, [esi]
-
- UNPACK1_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 16
- endm
-
-
-UNPACK_V4_16SSE_4A macro CL, TOTALCL, MaskType, ModeType
-
- punpcklwd xmm0, [esi]
- punpckhwd xmm1, [esi]
- punpcklwd xmm2, [esi+16]
- punpckhwd xmm7, [esi+16]
-
- UNPACK_RIGHTSHIFT xmm1, 16
- UNPACK_RIGHTSHIFT xmm7, 16
- UNPACK_RIGHTSHIFT xmm0, 16
- UNPACK_RIGHTSHIFT xmm2, 16
-
- UNPACK4_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 32
- endm
-
-UNPACK_V4_16SSE_4 macro CL, TOTALCL, MaskType, ModeType
- movdqu xmm0, [esi]
- movdqu xmm2, [esi+16]
-
- punpckhwd xmm1, xmm0
- punpckhwd xmm7, xmm2
- punpcklwd xmm0, xmm0
- punpcklwd xmm2, xmm2
-
- UNPACK_RIGHTSHIFT xmm1, 16
- UNPACK_RIGHTSHIFT xmm7, 16
- UNPACK_RIGHTSHIFT xmm0, 16
- UNPACK_RIGHTSHIFT xmm2, 16
-
- UNPACK4_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 32
- endm
-
-UNPACK_V4_16SSE_3A macro CL, TOTALCL, MaskType, ModeType
- punpcklwd xmm0, [esi]
- punpckhwd xmm1, [esi]
- punpcklwd xmm2, [esi+16]
-
- UNPACK_RIGHTSHIFT xmm0, 16
- UNPACK_RIGHTSHIFT xmm1, 16
- UNPACK_RIGHTSHIFT xmm2, 16
-
- UNPACK3_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 24
- endm
-
-UNPACK_V4_16SSE_3 macro CL, TOTALCL, MaskType, ModeType
- movdqu xmm0, [esi]
- movq xmm2, QWORD PTR [esi+16]
-
- punpckhwd xmm1, xmm0
- punpcklwd xmm0, xmm0
- punpcklwd xmm2, xmm2
-
- UNPACK_RIGHTSHIFT xmm0, 16
- UNPACK_RIGHTSHIFT xmm1, 16
- UNPACK_RIGHTSHIFT xmm2, 16
-
- UNPACK3_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 24
- endm
-
-UNPACK_V4_16SSE_2A macro CL, TOTALCL, MaskType, ModeType
- punpcklwd xmm0, [esi]
- punpckhwd xmm1, [esi]
-
- UNPACK_RIGHTSHIFT xmm0, 16
- UNPACK_RIGHTSHIFT xmm1, 16
-
- UNPACK2_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 16
- endm
-
-UNPACK_V4_16SSE_2 macro CL, TOTALCL, MaskType, ModeType
- movq xmm0, QWORD PTR [esi]
- movq xmm1, QWORD PTR [esi+8]
-
- punpcklwd xmm0, xmm0
- punpcklwd xmm1, xmm1
-
- UNPACK_RIGHTSHIFT xmm0, 16
- UNPACK_RIGHTSHIFT xmm1, 16
-
- UNPACK2_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 16
- endm
-
-UNPACK_V4_16SSE_1A macro CL, TOTALCL, MaskType, ModeType
- punpcklwd xmm0, [esi]
- UNPACK_RIGHTSHIFT xmm0, 16
-
- UNPACK1_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 8
- endm
-
-UNPACK_V4_16SSE_1 macro CL, TOTALCL, MaskType, ModeType
- movq xmm0, QWORD PTR [esi]
- punpcklwd xmm0, xmm0
- UNPACK_RIGHTSHIFT xmm0, 16
-
- UNPACK1_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 8
- endm
-
-
-UNPACK_V4_8SSE_4A macro CL, TOTALCL, MaskType, ModeType
- punpcklbw xmm0, [esi]
- punpckhbw xmm2, [esi]
-
- punpckhwd xmm1, xmm0
- punpckhwd xmm7, xmm2
- punpcklwd xmm0, xmm0
- punpcklwd xmm2, xmm2
-
- UNPACK_RIGHTSHIFT xmm1, 24
- UNPACK_RIGHTSHIFT xmm7, 24
- UNPACK_RIGHTSHIFT xmm0, 24
- UNPACK_RIGHTSHIFT xmm2, 24
-
- UNPACK4_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 16
- endm
-
-UNPACK_V4_8SSE_4 macro CL, TOTALCL, MaskType, ModeType
- movdqu xmm0, [esi]
-
- punpckhbw xmm2, xmm0
- punpcklbw xmm0, xmm0
-
- punpckhwd xmm7, xmm2
- punpckhwd xmm1, xmm0
- punpcklwd xmm2, xmm2
- punpcklwd xmm0, xmm0
-
- UNPACK_RIGHTSHIFT xmm7, 24
- UNPACK_RIGHTSHIFT xmm2, 24
-
- UNPACK_RIGHTSHIFT xmm0, 24
- UNPACK_RIGHTSHIFT xmm1, 24
-
- UNPACK4_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 16
- endm
-
-UNPACK_V4_8SSE_3A macro CL, TOTALCL, MaskType, ModeType
- punpcklbw xmm0, [esi]
- punpckhbw xmm2, [esi]
-
- punpckhwd xmm1, xmm0
- punpcklwd xmm0, xmm0
- punpcklwd xmm2, xmm2
-
- UNPACK_RIGHTSHIFT xmm1, 24
- UNPACK_RIGHTSHIFT xmm0, 24
- UNPACK_RIGHTSHIFT xmm2, 24
-
- UNPACK3_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 12
- endm
-
-UNPACK_V4_8SSE_3 macro CL, TOTALCL, MaskType, ModeType
- movq xmm0, QWORD PTR [esi]
- movd xmm2, dword ptr [esi+8]
-
- punpcklbw xmm0, xmm0
- punpcklbw xmm2, xmm2
-
- punpckhwd xmm1, xmm0
- punpcklwd xmm2, xmm2
- punpcklwd xmm0, xmm0
-
- UNPACK_RIGHTSHIFT xmm1, 24
- UNPACK_RIGHTSHIFT xmm0, 24
- UNPACK_RIGHTSHIFT xmm2, 24
-
- UNPACK3_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 12
- endm
-
-UNPACK_V4_8SSE_2A macro CL, TOTALCL, MaskType, ModeType
- punpcklbw xmm0, [esi]
-
- punpckhwd xmm1, xmm0
- punpcklwd xmm0, xmm0
-
- UNPACK_RIGHTSHIFT xmm1, 24
- UNPACK_RIGHTSHIFT xmm0, 24
-
- UNPACK2_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 8
- endm
-
-UNPACK_V4_8SSE_2 macro CL, TOTALCL, MaskType, ModeType
- movq xmm0, QWORD PTR [esi]
-
- punpcklbw xmm0, xmm0
-
- punpckhwd xmm1, xmm0
- punpcklwd xmm0, xmm0
-
- UNPACK_RIGHTSHIFT xmm1, 24
- UNPACK_RIGHTSHIFT xmm0, 24
-
- UNPACK2_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 8
- endm
-
-UNPACK_V4_8SSE_1A macro CL, TOTALCL, MaskType, ModeType
- punpcklbw xmm0, [esi]
- punpcklwd xmm0, xmm0
- UNPACK_RIGHTSHIFT xmm0, 24
-
- UNPACK1_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 4
- endm
-
-UNPACK_V4_8SSE_1 macro CL, TOTALCL, MaskType, ModeType
- movd xmm0, dword ptr [esi]
- punpcklbw xmm0, xmm0
- punpcklwd xmm0, xmm0
- UNPACK_RIGHTSHIFT xmm0, 24
-
- UNPACK1_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 4
- endm
-
-
-DECOMPRESS_RGBA macro OFFSET
- mov bl, al
- shl bl, 3
- mov byte ptr [s_TempDecompress+OFFSET], bl
-
- mov bx, ax
- shr bx, 2
- and bx, 0f8h
- mov byte ptr [s_TempDecompress+OFFSET+1], bl
-
- mov bx, ax
- shr bx, 7
- and bx, 0f8h
- mov byte ptr [s_TempDecompress+OFFSET+2], bl
- mov bx, ax
- shr bx, 8
- and bx, 080h
- mov byte ptr [s_TempDecompress+OFFSET+3], bl
- endm
-
-UNPACK_V4_5SSE_4 macro CL, TOTALCL, MaskType, ModeType
- mov eax, dword ptr [esi]
- DECOMPRESS_RGBA 0
-
- shr eax, 16
- DECOMPRESS_RGBA 4
-
- mov eax, dword ptr [esi+4]
- DECOMPRESS_RGBA 8
-
- shr eax, 16
- DECOMPRESS_RGBA 12
-
- ;; have to use movaps instead of movdqa
- movaps xmm0, [s_TempDecompress]
-
- punpckhbw xmm2, xmm0
- punpcklbw xmm0, xmm0
-
- punpckhwd xmm7, xmm2
- punpckhwd xmm1, xmm0
- punpcklwd xmm0, xmm0
- punpcklwd xmm2, xmm2
-
- psrld xmm0, 24
- psrld xmm1, 24
- psrld xmm2, 24
- psrld xmm7, 24
-
- UNPACK4_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 8
- endm
-
-UNPACK_V4_5SSE_4A macro CL, TOTALCL, MaskType, ModeType
- UNPACK_V4_5SSE_4 CL, TOTALCL, MaskType, ModeType
- endm
-
-UNPACK_V4_5SSE_3 macro CL, TOTALCL, MaskType, ModeType
- mov eax, dword ptr [esi]
- DECOMPRESS_RGBA 0
-
- shr eax, 16
- DECOMPRESS_RGBA 4
-
- mov eax, dword ptr [esi]
- DECOMPRESS_RGBA 8
-
- ;; have to use movaps instead of movdqa
- movaps xmm0, [s_TempDecompress]
-
- punpckhbw xmm2, xmm0
- punpcklbw xmm0, xmm0
-
- punpckhwd xmm1, xmm0
- punpcklwd xmm0, xmm0
- punpcklwd xmm2, xmm2
-
- psrld xmm0, 24
- psrld xmm1, 24
- psrld xmm2, 24
-
- UNPACK3_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 6
- endm
-
-UNPACK_V4_5SSE_3A macro CL, TOTALCL, MaskType, ModeType
- UNPACK_V4_5SSE_3 CL, TOTALCL, MaskType, ModeType
- endm
-
-UNPACK_V4_5SSE_2 macro CL, TOTALCL, MaskType, ModeType
- mov eax, dword ptr [esi]
- DECOMPRESS_RGBA 0
-
- shr eax, 16
- DECOMPRESS_RGBA 4
-
- movq xmm0, QWORD PTR [s_TempDecompress]
-
- punpcklbw xmm0, xmm0
-
- punpckhwd xmm1, xmm0
- punpcklwd xmm0, xmm0
-
- psrld xmm0, 24
- psrld xmm1, 24
-
- UNPACK2_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 4
- endm
-
-UNPACK_V4_5SSE_2A macro CL, TOTALCL, MaskType, ModeType
- UNPACK_V4_5SSE_2 CL, TOTALCL, MaskType, ModeType
- endm
-
-UNPACK_V4_5SSE_1 macro CL, TOTALCL, MaskType, ModeType
- mov ax, word ptr [esi]
- DECOMPRESS_RGBA 0
-
- movd xmm0, DWORD PTR [s_TempDecompress]
- punpcklbw xmm0, xmm0
- punpcklwd xmm0, xmm0
-
- psrld xmm0, 24
-
- UNPACK1_SSE CL, TOTALCL, MaskType, ModeType
-
- add esi, 2
- endm
-
-UNPACK_V4_5SSE_1A macro CL, TOTALCL, MaskType, ModeType
- UNPACK_V4_5SSE_1 CL, TOTALCL, MaskType, ModeType
- endm
-
-
-SAVE_ROW_REG_BASE macro
- mov eax, [vifRow]
- movdqa [eax], xmm6
- mov eax, [vifRegs]
- movss dword ptr [eax+0100h], xmm6
- psrldq xmm6, 4
- movss dword ptr [eax+0110h], xmm6
- psrldq xmm6, 4
- movss dword ptr [eax+0120h], xmm6
- psrldq xmm6, 4
- movss dword ptr [eax+0130h], xmm6
- endm
-
-SAVE_NO_REG macro
- endm
-
-INIT_ARGS macro
- mov edi, dword ptr [esp+4+12]
- mov esi, dword ptr [esp+8+12]
- mov edx, dword ptr [esp+12+12]
- endm
-
-INC_STACK macro reg
- add esp, 4
- endm
-
-
-
-
-
-defUNPACK_SkippingWrite macro name, MaskType, ModeType, qsize, sign, SAVE_ROW_REG
-@CatStr(UNPACK_SkippingWrite_, name, _, sign, _, MaskType, _, ModeType) proc public
- push edi
- push esi
- push ebx
-
- INIT_ARGS
- mov eax, [vifRegs]
- movzx ecx, byte ptr [eax + 040h]
- movzx ebx, byte ptr [eax + 041h]
- sub ecx, ebx
- shl ecx, 4
-
- cmp ebx, 1
- je @CatStr(name, _, sign, _, MaskType, _, ModeType, _WL1)
- cmp ebx, 2
- je @CatStr(name, _, sign, _, MaskType, _, ModeType, _WL2)
- cmp ebx, 3
- je @CatStr(name, _, sign, _, MaskType, _, ModeType, _WL3)
- jmp @CatStr(name, _, sign, _, MaskType, _, ModeType, _WL4)
-
-@CatStr(name, _, sign, _, MaskType, _, ModeType, _WL1):
- @CatStr(UNPACK_Start_Setup_, MaskType, _SSE_, ModeType) 0
-
- cmp edx, qsize
- jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_Done3)
-
- add ecx, 16
-
-
-@CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_Align16):
-
- test esi, 15
- jz @CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_UnpackAligned)
-
- @CatStr(UNPACK_, name, SSE_1) 0, 1, MaskType, ModeType
-
- cmp edx, (2*qsize)
- jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_DoneWithDec)
- sub edx, qsize
- jmp @CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_Align16)
-
-@CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_UnpackAligned):
-
- cmp edx, (2*qsize)
- jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_Unpack1)
- cmp edx, (3*qsize)
- jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_Unpack2)
- cmp edx, (4*qsize)
- jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_Unpack3)
- prefetchnta [esi + 64]
-
-@CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_Unpack4):
- @CatStr(UNPACK_, name, SSE_4A) 0, 1, MaskType, ModeType
-
- cmp edx, (8*qsize)
- jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_DoneUnpack4)
- sub edx, (4*qsize)
- jmp @CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_Unpack4)
-
-@CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_DoneUnpack4):
-
- sub edx, (4*qsize)
- cmp edx, qsize
- jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_Done3)
- cmp edx, (2*qsize)
- jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_Unpack1)
- cmp edx, (3*qsize)
- jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_Unpack2)
-
-
-@CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_Unpack3):
- @CatStr(UNPACK_, name, SSE_3A) 0, 1, MaskType, ModeType
-
- sub edx, (3*qsize)
- jmp @CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_Done3)
-
-@CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_Unpack2):
- @CatStr(UNPACK_, name, SSE_2A) 0, 1, MaskType, ModeType
-
- sub edx, (2*qsize)
- jmp @CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_Done3)
-
-@CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_Unpack1):
- @CatStr(UNPACK_, name, SSE_1A) 0, 1, MaskType, ModeType
-@CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_DoneWithDec):
- sub edx, qsize
-@CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_Done3):
- SAVE_ROW_REG
- mov eax, edx
- pop ebx
- pop esi
- pop edi
-
- ret
-
-@CatStr(name, _, sign, _, MaskType, _, ModeType, _WL2):
- cmp edx, (2*qsize)
-
- jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C2_Done3)
-@CatStr(name, _, sign, _, MaskType, _, ModeType, _C2_Unpack):
- @CatStr(UNPACK_, name, SSE_2) 0, 0, MaskType, ModeType
-
-
- add edi, ecx
- cmp edx, (4*qsize)
- jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C2_Done2)
- sub edx, (2*qsize)
-
- jmp @CatStr(name, _, sign, _, MaskType, _, ModeType, _C2_Unpack)
-
-@CatStr(name, _, sign, _, MaskType, _, ModeType, _C2_Done2):
- sub edx, (2*qsize)
-@CatStr(name, _, sign, _, MaskType, _, ModeType, _C2_Done3):
- cmp edx, qsize
-
- jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C2_Done4)
-
-
- @CatStr(UNPACK_, name, SSE_1) 0, 0, MaskType, ModeType
-
- sub edx, qsize
-@CatStr(name, _, sign, _, MaskType, _, ModeType, _C2_Done4):
-
- SAVE_ROW_REG
- mov eax, edx
- pop ebx
- pop esi
- pop edi
-
- ret
-
-@CatStr(name, _, sign, _, MaskType, _, ModeType, _WL3):
- cmp edx, (3*qsize)
-
- jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C3_Done5)
-@CatStr(name, _, sign, _, MaskType, _, ModeType, _C3_Unpack):
- @CatStr(UNPACK_, name, SSE_3) 0, 0, MaskType, ModeType
-
- add edi, ecx
- cmp edx, (6*qsize)
- jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C3_Done2)
- sub edx, (3*qsize)
- jmp @CatStr(name, _, sign, _, MaskType, _, ModeType, _C3_Unpack)
-@CatStr(name, _, sign, _, MaskType, _, ModeType, _C3_Done2):
- sub edx, (3*qsize)
-@CatStr(name, _, sign, _, MaskType, _, ModeType, _C3_Done5):
- cmp edx, qsize
- jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C3_Done4)
-
- cmp edx, (2*qsize)
- jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C3_Done3)
-
- @CatStr(UNPACK_, name, SSE_2) 0, 0, MaskType, ModeType
-
- sub edx, (2*qsize)
- jmp @CatStr(name, _, sign, _, MaskType, _, ModeType, _C3_Done4)
-@CatStr(name, _, sign, _, MaskType, _, ModeType, _C3_Done3):
- sub edx, qsize
- @CatStr(UNPACK_, name, SSE_1) 0, 0, MaskType, ModeType
-@CatStr(name, _, sign, _, MaskType, _, ModeType, _C3_Done4):
- SAVE_ROW_REG
- mov eax, edx
- pop ebx
- pop esi
- pop edi
-
- ret
-
-@CatStr(name, _, sign, _, MaskType, _, ModeType, _WL4):
- sub ebx, 3
- push ecx
- cmp edx, qsize
- jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C4_Done)
-
-@CatStr(name, _, sign, _, MaskType, _, ModeType, _C4_Unpack):
- cmp edx, (3*qsize)
- jge @CatStr(name, _, sign, _, MaskType, _, ModeType, _C4_Unpack3)
- cmp edx, (2*qsize)
- jge @CatStr(name, _, sign, _, MaskType, _, ModeType, _C4_Unpack2)
-
- @CatStr(UNPACK_, name, SSE_1) 0, 0, MaskType, ModeType
-
-
- sub edx, qsize
- jmp @CatStr(name, _, sign, _, MaskType, _, ModeType, _C4_Done)
-@CatStr(name, _, sign, _, MaskType, _, ModeType, _C4_Unpack2):
- @CatStr(UNPACK_, name, SSE_2) 0, 0, MaskType, ModeType
-
-
- sub edx, (2*qsize)
- jmp @CatStr(name, _, sign, _, MaskType, _, ModeType, _C4_Done)
-@CatStr(name, _, sign, _, MaskType, _, ModeType, _C4_Unpack3):
- @CatStr(UNPACK_, name, SSE_3) 0, 0, MaskType, ModeType
-
-
- sub edx, (3*qsize)
- mov ecx, ebx
-
-@CatStr(name, _, sign, _, MaskType, _, ModeType, _C4_UnpackX):
-
-
- cmp edx, qsize
- jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C4_Done)
-
- @CatStr(UNPACK_, name, SSE_1) 3, 0, MaskType, ModeType
-
- sub edx, qsize
- cmp ecx, 1
- je @CatStr(name, _, sign, _, MaskType, _, ModeType, _C4_DoneLoop)
- sub ecx, 1
- jmp @CatStr(name, _, sign, _, MaskType, _, ModeType, _C4_UnpackX)
-@CatStr(name, _, sign, _, MaskType, _, ModeType, _C4_DoneLoop):
- add edi, [esp]
- cmp edx, qsize
- jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C4_Done)
- jmp @CatStr(name, _, sign, _, MaskType, _, ModeType, _C4_Unpack)
-@CatStr(name, _, sign, _, MaskType, _, ModeType, _C4_Done):
-
- SAVE_ROW_REG
- INC_STACK()
- mov eax, edx
- pop ebx
- pop esi
- pop edi
-
- ret
-@CatStr(UNPACK_SkippingWrite_, name, _, sign, _, MaskType, _, ModeType endp)
-endm
-
-UNPACK_RIGHTSHIFT macro reg, shift
- psrld reg, shift
- endm
-
-defUNPACK_SkippingWrite2 macro name, qsize
- defUNPACK_SkippingWrite name, Regular, 0, qsize, u, SAVE_NO_REG
- defUNPACK_SkippingWrite name, Regular, 1, qsize, u, SAVE_NO_REG
- defUNPACK_SkippingWrite name, Regular, 2, qsize, u, SAVE_ROW_REG_BASE
- defUNPACK_SkippingWrite name, Mask, 0, qsize, u, SAVE_NO_REG
- defUNPACK_SkippingWrite name, Mask, 1, qsize, u, SAVE_NO_REG
- defUNPACK_SkippingWrite name, Mask, 2, qsize, u, SAVE_ROW_REG_BASE
- defUNPACK_SkippingWrite name, WriteMask, 0, qsize, u, SAVE_NO_REG
- defUNPACK_SkippingWrite name, WriteMask, 1, qsize, u, SAVE_NO_REG
- defUNPACK_SkippingWrite name, WriteMask, 2, qsize, u, SAVE_ROW_REG_BASE
- endm
-
-defUNPACK_SkippingWrite2 S_32, 4
-defUNPACK_SkippingWrite2 S_16, 2
-defUNPACK_SkippingWrite2 S_8, 1
-defUNPACK_SkippingWrite2 V2_32, 8
-defUNPACK_SkippingWrite2 V2_16, 4
-defUNPACK_SkippingWrite2 V2_8, 2
-defUNPACK_SkippingWrite2 V3_32, 12
-defUNPACK_SkippingWrite2 V3_16, 6
-defUNPACK_SkippingWrite2 V3_8, 3
-defUNPACK_SkippingWrite2 V4_32, 16
-defUNPACK_SkippingWrite2 V4_16, 8
-defUNPACK_SkippingWrite2 V4_8, 4
-defUNPACK_SkippingWrite2 V4_5, 2
-
-UNPACK_RIGHTSHIFT macro reg, shift
- psrad reg, shift
- endm
-
-
-defUNPACK_SkippingWrite2a macro name, qsize
- defUNPACK_SkippingWrite name, Mask, 0, qsize, s, SAVE_NO_REG
- defUNPACK_SkippingWrite name, Regular, 0, qsize, s, SAVE_NO_REG
- defUNPACK_SkippingWrite name, Regular, 1, qsize, s, SAVE_NO_REG
- defUNPACK_SkippingWrite name, Regular, 2, qsize, s, SAVE_ROW_REG_BASE
- defUNPACK_SkippingWrite name, Mask, 1, qsize, s, SAVE_NO_REG
- defUNPACK_SkippingWrite name, Mask, 2, qsize, s, SAVE_ROW_REG_BASE
- defUNPACK_SkippingWrite name, WriteMask, 0, qsize, s, SAVE_NO_REG
- defUNPACK_SkippingWrite name, WriteMask, 1, qsize, s, SAVE_NO_REG
- defUNPACK_SkippingWrite name, WriteMask, 2, qsize, s, SAVE_ROW_REG_BASE
- endm
-
-defUNPACK_SkippingWrite2a S_16, 2
-defUNPACK_SkippingWrite2a S_8, 1
-defUNPACK_SkippingWrite2a V2_16, 4
-defUNPACK_SkippingWrite2a V2_8, 2
-defUNPACK_SkippingWrite2a V3_16, 6
-defUNPACK_SkippingWrite2a V3_8, 3
-defUNPACK_SkippingWrite2a V4_16, 8
-defUNPACK_SkippingWrite2a V4_8, 4
-
-end
+
+.686
+.model flat, c
+.mmx
+.xmm
+
+
+extern vifRegs:ptr
+extern vifMaskRegs:ptr
+extern vifRow:ptr
+extern s_TempDecompress:ptr
+
+
+.code
+
+UNPACK_Write0_Regular macro r0, CL, DEST_OFFSET, MOVDQA
+ MOVDQA [edi+DEST_OFFSET], r0
+ endm
+
+UNPACK_Write1_Regular macro r0, CL, DEST_OFFSET, MOVDQA
+ MOVDQA [edi], r0
+ add edi, ecx
+ endm
+
+UNPACK_Write0_Mask macro r0, CL, DEST_OFFSET, MOVDQA
+ UNPACK_Write0_Regular r0, CL, DEST_OFFSET, MOVDQA
+ endm
+
+UNPACK_Write1_Mask macro r0, CL, DEST_OFFSET, MOVDQA
+ UNPACK_Write1_Regular r0, CL, DEST_OFFSET, MOVDQA
+ endm
+
+
+UNPACK_Write0_WriteMask macro r0, CL, DEST_OFFSET, MOVDQA
+
+ movdqa xmm3, [eax + 64*(CL) + 48]
+ pand r0, xmm3
+ pandn xmm3, [edi]
+ por r0, xmm3
+ MOVDQA [edi], r0
+ add edi, 16
+ endm
+
+
+UNPACK_Write1_WriteMask macro r0, CL, DEST_OFFSET, MOVDQA
+
+ movdqa xmm3, [eax + 64*(0) + 48]
+ pand r0, xmm3
+ pandn xmm3, [edi]
+ por r0, xmm3
+ MOVDQA [edi], r0
+ add edi, ecx
+ endm
+
+UNPACK_Mask_SSE_0 macro r0
+ pand r0, xmm3
+ por r0, xmm5
+ endm
+
+
+
+
+UNPACK_Mask_SSE_1 macro r0
+
+ pand r0, xmm3
+ por r0, xmm5
+ pand xmm3, xmm6
+ paddd r0, xmm3
+ endm
+
+
+
+UNPACK_Mask_SSE_2 macro r0
+
+
+ pand r0, xmm3
+ pand xmm3, xmm6
+ paddd xmm6, r0
+ por r0, xmm5
+ paddd r0, xmm3
+ endm
+
+UNPACK_WriteMask_SSE_0 macro r0
+ UNPACK_Mask_SSE_0 r0
+ endm
+UNPACK_WriteMask_SSE_1 macro r0
+ UNPACK_Mask_SSE_1 r0
+ endm
+UNPACK_WriteMask_SSE_2 macro r0
+ UNPACK_Mask_SSE_2 r0
+ endm
+
+UNPACK_Regular_SSE_0 macro r0
+ endm
+
+UNPACK_Regular_SSE_1 macro r0
+ paddd r0, xmm6
+ endm
+
+UNPACK_Regular_SSE_2 macro r0
+ paddd r0, xmm6
+ movdqa xmm6, r0
+ endm
+
+
+UNPACK_Setup_Mask_SSE macro CL
+ mov eax, [vifMaskRegs]
+ movdqa xmm4, [eax + 64*(CL) + 16]
+ movdqa xmm5, [eax + 64*(CL) + 32]
+ movdqa xmm3, [eax + 64*(CL)]
+ pand xmm4, xmm6
+ pand xmm5, xmm7
+ por xmm5, xmm4
+ endm
+
+UNPACK_Start_Setup_Mask_SSE_0 macro CL
+ UNPACK_Setup_Mask_SSE CL
+ endm
+
+UNPACK_Start_Setup_Mask_SSE_1 macro CL
+ mov eax, [vifMaskRegs]
+ movdqa xmm4, [eax + 64*(CL) + 16]
+ movdqa xmm5, [eax + 64*(CL) + 32]
+ pand xmm4, xmm6
+ pand xmm5, xmm7
+ por xmm5, xmm4
+ endm
+
+UNPACK_Start_Setup_Mask_SSE_2 macro CL
+ endm
+
+UNPACK_Setup_Mask_SSE_0_1 macro CL
+ endm
+UNPACK_Setup_Mask_SSE_1_1 macro CL
+ mov eax, [vifMaskRegs]
+ movdqa xmm3, [eax + 64*(0)]
+ endm
+
+
+UNPACK_Setup_Mask_SSE_2_1 macro CL
+
+ mov eax, [vifMaskRegs]
+ movdqa xmm4, [eax + 64*(0) + 16]
+ movdqa xmm5, [eax + 64*(0) + 32]
+ movdqa xmm3, [eax + 64*(0)]
+ pand xmm4, xmm6
+ pand xmm5, xmm7
+ por xmm5, xmm4
+ endm
+
+UNPACK_Setup_Mask_SSE_0_0 macro CL
+ UNPACK_Setup_Mask_SSE CL
+ endm
+UNPACK_Setup_Mask_SSE_1_0 macro CL
+ UNPACK_Setup_Mask_SSE CL
+ endm
+UNPACK_Setup_Mask_SSE_2_0 macro CL
+ UNPACK_Setup_Mask_SSE CL
+ endm
+
+
+UNPACK_Setup_WriteMask_SSE_0_0 macro CL
+ UNPACK_Setup_Mask_SSE CL
+ endm
+UNPACK_Setup_WriteMask_SSE_1_0 macro CL
+ UNPACK_Setup_Mask_SSE CL
+ endm
+UNPACK_Setup_WriteMask_SSE_2_0 macro CL
+ UNPACK_Setup_Mask_SSE CL
+ endm
+UNPACK_Setup_WriteMask_SSE_0_1 macro CL
+ UNPACK_Setup_Mask_SSE_1_1 CL
+ endm
+
+UNPACK_Setup_WriteMask_SSE_1_1 macro CL
+ UNPACK_Setup_Mask_SSE_1_1 CL
+ endm
+
+UNPACK_Setup_WriteMask_SSE_2_1 macro CL
+ UNPACK_Setup_Mask_SSE_2_1 CL
+ endm
+
+UNPACK_Start_Setup_WriteMask_SSE_0 macro CL
+ UNPACK_Start_Setup_Mask_SSE_1 CL
+ endm
+UNPACK_Start_Setup_WriteMask_SSE_1 macro CL
+ UNPACK_Start_Setup_Mask_SSE_1 CL
+ endm
+UNPACK_Start_Setup_WriteMask_SSE_2 macro CL
+ UNPACK_Start_Setup_Mask_SSE_2 CL
+ endm
+
+UNPACK_Start_Setup_Regular_SSE_0 macro CL
+ endm
+UNPACK_Start_Setup_Regular_SSE_1 macro CL
+ endm
+UNPACK_Start_Setup_Regular_SSE_2 macro CL
+ endm
+UNPACK_Setup_Regular_SSE_0_0 macro CL
+ endm
+UNPACK_Setup_Regular_SSE_1_0 macro CL
+ endm
+UNPACK_Setup_Regular_SSE_2_0 macro CL
+ endm
+UNPACK_Setup_Regular_SSE_0_1 macro CL
+ endm
+UNPACK_Setup_Regular_SSE_1_1 macro CL
+ endm
+UNPACK_Setup_Regular_SSE_2_1 macro CL
+ endm
+
+UNPACK_INC_DST_0_Regular macro qw
+ add edi, (16*qw)
+ endm
+UNPACK_INC_DST_1_Regular macro qw
+ endm
+UNPACK_INC_DST_0_Mask macro qw
+ add edi, (16*qw)
+ endm
+UNPACK_INC_DST_1_Mask macro qw
+ endm
+UNPACK_INC_DST_0_WriteMask macro qw
+ endm
+UNPACK_INC_DST_1_WriteMask macro qw
+ endm
+
+
+UNPACK4_SSE macro CL, TOTALCL, MaskType, ModeType
+ @CatStr(UNPACK_Setup_, MaskType, _SSE_, ModeType, _, TOTALCL) CL+0
+ @CatStr(UNPACK_, MaskType, _SSE_, ModeType) xmm0
+ @CatStr(UNPACK_Write, TOTALCL, _, MaskType) xmm0, CL, 0, movdqa
+
+ @CatStr(UNPACK_Setup_, MaskType, _SSE_, ModeType, _, TOTALCL) CL+1
+ @CatStr(UNPACK_, MaskType, _SSE_, ModeType) xmm1
+ @CatStr(UNPACK_Write, TOTALCL, _, MaskType) xmm1, CL+1, 16, movdqa
+
+ @CatStr(UNPACK_Setup_, MaskType, _SSE_, ModeType, _, TOTALCL) CL+2
+ @CatStr(UNPACK_, MaskType, _SSE_, ModeType) xmm2
+ @CatStr(UNPACK_Write, TOTALCL, _, MaskType) xmm2, CL+2, 32, movdqa
+
+ @CatStr(UNPACK_Setup_, MaskType, _SSE_, ModeType, _, TOTALCL) CL+3
+ @CatStr(UNPACK_, MaskType, _SSE_, ModeType) xmm7
+ @CatStr(UNPACK_Write, TOTALCL, _, MaskType) xmm7, CL+3, 48, movdqa
+
+ @CatStr(UNPACK_INC_DST_, TOTALCL, _, MaskType) 4
+ endm
+
+
+UNPACK3_SSE macro CL, TOTALCL, MaskType, ModeType
+ @CatStr(UNPACK_Setup_, MaskType, _SSE_, ModeType, _, TOTALCL) CL
+ @CatStr(UNPACK_, MaskType, _SSE_, ModeType) xmm0
+ @CatStr(UNPACK_Write, TOTALCL, _, MaskType) xmm0, CL, 0, movdqa
+
+ @CatStr(UNPACK_Setup_, MaskType, _SSE_, ModeType, _, TOTALCL) CL+1
+ @CatStr(UNPACK_, MaskType, _SSE_, ModeType) xmm1
+ @CatStr(UNPACK_Write, TOTALCL, _, MaskType) xmm1, CL+1, 16, movdqa
+
+ @CatStr(UNPACK_Setup_, MaskType, _SSE_, ModeType, _, TOTALCL) CL+2
+ @CatStr(UNPACK_, MaskType, _SSE_, ModeType) xmm2
+ @CatStr(UNPACK_Write, TOTALCL, _, MaskType) xmm2, CL+2, 32, movdqa
+
+ @CatStr(UNPACK_INC_DST_, TOTALCL, _, MaskType) 3
+ endm
+
+UNPACK2_SSE macro CL, TOTALCL, MaskType, ModeType
+ @CatStr(UNPACK_Setup_, MaskType, _SSE_, ModeType, _, TOTALCL) CL
+ @CatStr(UNPACK_, MaskType, _SSE_, ModeType) xmm0
+ @CatStr(UNPACK_Write, TOTALCL, _, MaskType) xmm0, CL, 0, movdqa
+
+ @CatStr(UNPACK_Setup_, MaskType, _SSE_, ModeType, _, TOTALCL) CL+1
+ @CatStr(UNPACK_, MaskType, _SSE_, ModeType) xmm1
+ @CatStr(UNPACK_Write, TOTALCL, _, MaskType) xmm1, CL+1, 16, movdqa
+
+ @CatStr(UNPACK_INC_DST_, TOTALCL, _, MaskType) 2
+ endm
+
+UNPACK1_SSE macro CL, TOTALCL, MaskType, ModeType
+ @CatStr(UNPACK_Setup_, MaskType, _SSE_, ModeType, _, TOTALCL) CL
+ @CatStr(UNPACK_, MaskType, _SSE_, ModeType) xmm0
+ @CatStr(UNPACK_Write, TOTALCL, _, MaskType) xmm0, CL, 0, movdqa
+
+ @CatStr(UNPACK_INC_DST_, TOTALCL, _, MaskType) 1
+ endm
+
+
+
+UNPACK_S_32SSE_4x macro CL, TOTALCL, MaskType, ModeType, MOVDQA
+ MOVDQA xmm7, [esi]
+
+ pshufd xmm0, xmm7, 0
+ pshufd xmm1, xmm7, 055h
+ pshufd xmm2, xmm7, 0aah
+ pshufd xmm7, xmm7, 0ffh
+
+ UNPACK4_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 16
+ endm
+
+UNPACK_S_32SSE_4A macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_S_32SSE_4x CL, TOTALCL, MaskType, ModeType, movdqa
+ endm
+UNPACK_S_32SSE_4 macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_S_32SSE_4x CL, TOTALCL, MaskType, ModeType, movdqu
+ endm
+
+UNPACK_S_32SSE_3x macro CL, TOTALCL, MaskType, ModeType, MOVDQA
+ MOVDQA xmm2, [esi]
+
+ pshufd xmm0, xmm2, 0
+ pshufd xmm1, xmm2, 055h
+ pshufd xmm2, xmm2, 0aah
+
+ UNPACK3_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 12
+ endm
+
+UNPACK_S_32SSE_3A macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_S_32SSE_3x CL, TOTALCL, MaskType, ModeType, movdqa
+ endm
+UNPACK_S_32SSE_3 macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_S_32SSE_3x CL, TOTALCL, MaskType, ModeType, movdqu
+ endm
+
+UNPACK_S_32SSE_2 macro CL, TOTALCL, MaskType, ModeType
+ movq xmm1, QWORD PTR [esi]
+
+ pshufd xmm0, xmm1, 0
+ pshufd xmm1, xmm1, 055h
+
+ UNPACK2_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 8
+ endm
+
+UNPACK_S_32SSE_2A macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_S_32SSE_2 CL, TOTALCL, MaskType, ModeType
+ endm
+
+UNPACK_S_32SSE_1 macro CL, TOTALCL, MaskType, ModeType
+ movd xmm0, dword ptr [esi]
+ pshufd xmm0, xmm0, 0
+
+ UNPACK1_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 4
+ endm
+
+UNPACK_S_32SSE_1A macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_S_32SSE_1 CL, TOTALCL, MaskType, ModeType
+ endm
+
+
+UNPACK_S_16SSE_4 macro CL, TOTALCL, MaskType, ModeType
+ movq xmm7, QWORD PTR [esi]
+ punpcklwd xmm7, xmm7
+ UNPACK_RIGHTSHIFT xmm7, 16
+
+ pshufd xmm0, xmm7, 0
+ pshufd xmm1, xmm7, 055h
+ pshufd xmm2, xmm7, 0aah
+ pshufd xmm7, xmm7, 0ffh
+
+ UNPACK4_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 8
+ endm
+
+UNPACK_S_16SSE_4A macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_S_16SSE_4 CL, TOTALCL, MaskType, ModeType
+ endm
+
+UNPACK_S_16SSE_3 macro CL, TOTALCL, MaskType, ModeType
+ movq xmm2, QWORD PTR [esi]
+ punpcklwd xmm2, xmm2
+ UNPACK_RIGHTSHIFT xmm2, 16
+
+ pshufd xmm0, xmm2, 0
+ pshufd xmm1, xmm2, 055h
+ pshufd xmm2, xmm2, 0aah
+
+ UNPACK3_SSE CL, TOTALCL, MaskType, ModeType
+ add esi, 6
+ endm
+
+UNPACK_S_16SSE_3A macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_S_16SSE_3 CL, TOTALCL, MaskType, ModeType
+ endm
+
+UNPACK_S_16SSE_2 macro CL, TOTALCL, MaskType, ModeType
+ movd xmm1, dword ptr [esi]
+ punpcklwd xmm1, xmm1
+ UNPACK_RIGHTSHIFT xmm1, 16
+
+ pshufd xmm0, xmm1, 0
+ pshufd xmm1, xmm1, 055h
+
+ UNPACK2_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 4
+ endm
+
+UNPACK_S_16SSE_2A macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_S_16SSE_2 CL, TOTALCL, MaskType, ModeType
+ endm
+
+UNPACK_S_16SSE_1 macro CL, TOTALCL, MaskType, ModeType
+ movd xmm0, dword ptr [esi]
+ punpcklwd xmm0, xmm0
+ UNPACK_RIGHTSHIFT xmm0, 16
+ pshufd xmm0, xmm0, 0
+
+ UNPACK1_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 2
+ endm
+
+UNPACK_S_16SSE_1A macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_S_16SSE_1 CL, TOTALCL, MaskType, ModeType
+ endm
+
+
+UNPACK_S_8SSE_4 macro CL, TOTALCL, MaskType, ModeType
+ movd xmm7, dword ptr [esi]
+ punpcklbw xmm7, xmm7
+ punpcklwd xmm7, xmm7
+ UNPACK_RIGHTSHIFT xmm7, 24
+
+ pshufd xmm0, xmm7, 0
+ pshufd xmm1, xmm7, 055h
+ pshufd xmm2, xmm7, 0aah
+ pshufd xmm7, xmm7, 0ffh
+
+ UNPACK4_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 4
+ endm
+
+UNPACK_S_8SSE_4A macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_S_8SSE_4 CL, TOTALCL, MaskType, ModeType
+ endm
+
+UNPACK_S_8SSE_3 macro CL, TOTALCL, MaskType, ModeType
+ movd xmm2, dword ptr [esi]
+ punpcklbw xmm2, xmm2
+ punpcklwd xmm2, xmm2
+ UNPACK_RIGHTSHIFT xmm2, 24
+
+ pshufd xmm0, xmm2, 0
+ pshufd xmm1, xmm2, 055h
+ pshufd xmm2, xmm2, 0aah
+
+ UNPACK3_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 3
+ endm
+
+UNPACK_S_8SSE_3A macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_S_8SSE_3 CL, TOTALCL, MaskType, ModeType
+ endm
+
+UNPACK_S_8SSE_2 macro CL, TOTALCL, MaskType, ModeType
+ movd xmm1, dword ptr [esi]
+ punpcklbw xmm1, xmm1
+ punpcklwd xmm1, xmm1
+ UNPACK_RIGHTSHIFT xmm1, 24
+
+ pshufd xmm0, xmm1, 0
+ pshufd xmm1, xmm1, 055h
+
+ UNPACK2_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 2
+ endm
+
+UNPACK_S_8SSE_2A macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_S_8SSE_2 CL, TOTALCL, MaskType, ModeType
+ endm
+
+UNPACK_S_8SSE_1 macro CL, TOTALCL, MaskType, ModeType
+ movd xmm0, dword ptr [esi]
+ punpcklbw xmm0, xmm0
+ punpcklwd xmm0, xmm0
+ UNPACK_RIGHTSHIFT xmm0, 24
+ pshufd xmm0, xmm0, 0
+
+ UNPACK1_SSE CL, TOTALCL, MaskType, ModeType
+
+ inc esi
+ endm
+
+UNPACK_S_8SSE_1A macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_S_8SSE_1 CL, TOTALCL, MaskType, ModeType
+ endm
+
+
+UNPACK_V2_32SSE_4A macro CL, TOTALCL, MaskType, ModeType
+ MOVDQA xmm0, [esi]
+ MOVDQA xmm2, [esi+16]
+
+ pshufd xmm1, xmm0, 0eeh
+ pshufd xmm7, xmm2, 0eeh
+
+ UNPACK4_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 32
+ endm
+
+UNPACK_V2_32SSE_4 macro CL, TOTALCL, MaskType, ModeType
+ movq xmm0, QWORD PTR [esi]
+ movq xmm1, QWORD PTR [esi+8]
+ movq xmm2, QWORD PTR [esi+16]
+ movq xmm7, QWORD PTR [esi+24]
+
+ UNPACK4_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 32
+ endm
+
+UNPACK_V2_32SSE_3A macro CL, TOTALCL, MaskType, ModeType
+ MOVDQA xmm0, [esi]
+ movq xmm2, QWORD PTR [esi+16]
+ pshufd xmm1, xmm0, 0eeh
+
+ UNPACK3_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 24
+ endm
+
+UNPACK_V2_32SSE_3 macro CL, TOTALCL, MaskType, ModeType
+ movq xmm0, QWORD PTR [esi]
+ movq xmm1, QWORD PTR [esi+8]
+ movq xmm2, QWORD PTR [esi+16]
+
+ UNPACK3_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 24
+ endm
+
+UNPACK_V2_32SSE_2 macro CL, TOTALCL, MaskType, ModeType
+ movq xmm0, QWORD PTR [esi]
+ movq xmm1, QWORD PTR [esi+8]
+
+ UNPACK2_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 16
+ endm
+
+UNPACK_V2_32SSE_2A macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_V2_32SSE_2 CL, TOTALCL, MaskType, ModeType
+ endm
+
+UNPACK_V2_32SSE_1 macro CL, TOTALCL, MaskType, ModeType
+ movq xmm0, QWORD PTR [esi]
+
+ UNPACK1_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 8
+ endm
+
+UNPACK_V2_32SSE_1A macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_V2_32SSE_1 CL, TOTALCL, MaskType, ModeType
+ endm
+
+
+UNPACK_V2_16SSE_4A macro CL, TOTALCL, MaskType, ModeType
+ punpcklwd xmm0, [esi]
+ punpckhwd xmm2, [esi]
+
+ UNPACK_RIGHTSHIFT xmm0, 16
+ UNPACK_RIGHTSHIFT xmm2, 16
+
+ punpckhqdq xmm1, xmm0
+ punpckhqdq xmm7, xmm2
+
+ punpcklqdq xmm0, xmm0
+ punpcklqdq xmm2, xmm2
+ punpckhqdq xmm1, xmm1
+ punpckhqdq xmm7, xmm7
+
+ UNPACK4_SSE CL, TOTALCL, MaskType, ModeType
+ add esi, 16
+ endm
+
+UNPACK_V2_16SSE_4 macro CL, TOTALCL, MaskType, ModeType
+ pxor xmm0, xmm0
+ pxor xmm2, xmm2
+ movdqu xmm0, [esi]
+
+ punpckhwd xmm2, xmm0
+ punpcklwd xmm0, xmm0
+
+ UNPACK_RIGHTSHIFT xmm0, 16
+ UNPACK_RIGHTSHIFT xmm2, 16
+
+ punpckhqdq xmm1, xmm0
+ punpckhqdq xmm7, xmm2
+
+ punpcklqdq xmm0, xmm0
+ punpcklqdq xmm2, xmm2
+ punpckhqdq xmm1, xmm1
+ punpckhqdq xmm7, xmm7
+
+ UNPACK4_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 16
+ endm
+
+UNPACK_V2_16SSE_3A macro CL, TOTALCL, MaskType, ModeType
+ punpcklwd xmm0, [esi]
+ punpckhwd xmm2, [esi]
+
+ UNPACK_RIGHTSHIFT xmm0, 16
+ UNPACK_RIGHTSHIFT xmm2, 16
+
+
+ punpckhqdq xmm1, xmm0
+
+ punpcklqdq xmm0, xmm0
+ punpcklqdq xmm2, xmm2
+ punpckhqdq xmm1, xmm1
+
+ UNPACK3_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 12
+ endm
+
+UNPACK_V2_16SSE_3 macro CL, TOTALCL, MaskType, ModeType
+ movdqu xmm0, [esi]
+
+ punpckhwd xmm2, xmm0
+ punpcklwd xmm0, xmm0
+
+ UNPACK_RIGHTSHIFT xmm0, 16
+ UNPACK_RIGHTSHIFT xmm2, 16
+
+
+ punpckhqdq xmm1, xmm0
+
+ punpcklqdq xmm0, xmm0
+ punpcklqdq xmm2, xmm2
+ punpckhqdq xmm1, xmm1
+
+ UNPACK3_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 12
+ endm
+
+UNPACK_V2_16SSE_2A macro CL, TOTALCL, MaskType, ModeType
+ punpcklwd xmm0, [esi]
+ UNPACK_RIGHTSHIFT xmm0, 16
+
+
+ punpckhqdq xmm1, xmm0
+
+ punpcklqdq xmm0, xmm0
+ punpckhqdq xmm1, xmm1
+
+ UNPACK2_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 8
+ endm
+
+UNPACK_V2_16SSE_2 macro CL, TOTALCL, MaskType, ModeType
+ movq xmm0, QWORD PTR [esi]
+ punpcklwd xmm0, xmm0
+ UNPACK_RIGHTSHIFT xmm0, 16
+
+
+ punpckhqdq xmm1, xmm0
+
+ punpcklqdq xmm0, xmm0
+ punpckhqdq xmm1, xmm1
+
+ UNPACK2_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 8
+ endm
+
+UNPACK_V2_16SSE_1A macro CL, TOTALCL, MaskType, ModeType
+ punpcklwd xmm0, [esi]
+ UNPACK_RIGHTSHIFT xmm0, 16
+
+ punpcklqdq xmm0, xmm0
+
+ UNPACK1_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 4
+ endm
+
+UNPACK_V2_16SSE_1 macro CL, TOTALCL, MaskType, ModeType
+ movd xmm0, dword ptr [esi]
+ punpcklwd xmm0, xmm0
+ UNPACK_RIGHTSHIFT xmm0, 16
+
+ punpcklqdq xmm0, xmm0
+
+ UNPACK1_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 4
+ endm
+
+
+UNPACK_V2_8SSE_4 macro CL, TOTALCL, MaskType, ModeType
+ movq xmm0, QWORD PTR [esi]
+
+ punpcklbw xmm0, xmm0
+ punpckhwd xmm2, xmm0
+ punpcklwd xmm0, xmm0
+
+ UNPACK_RIGHTSHIFT xmm0, 24
+ UNPACK_RIGHTSHIFT xmm2, 24
+
+ punpckhqdq xmm1, xmm0
+ punpckhqdq xmm7, xmm2
+
+ punpcklqdq xmm0, xmm0
+ punpcklqdq xmm2, xmm2
+ punpckhqdq xmm1, xmm1
+ punpckhqdq xmm7, xmm7
+
+ UNPACK4_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 8
+ endm
+
+UNPACK_V2_8SSE_4A macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_V2_8SSE_4 CL, TOTALCL, MaskType, ModeType
+ endm
+
+UNPACK_V2_8SSE_3 macro CL, TOTALCL, MaskType, ModeType
+ movq xmm0, QWORD PTR [esi]
+
+ punpcklbw xmm0, xmm0
+ punpckhwd xmm2, xmm0
+ punpcklwd xmm0, xmm0
+
+ UNPACK_RIGHTSHIFT xmm0, 24
+ UNPACK_RIGHTSHIFT xmm2, 24
+
+ punpckhqdq xmm1, xmm0
+
+ punpcklqdq xmm0, xmm0
+ punpcklqdq xmm2, xmm2
+ punpckhqdq xmm1, xmm1
+
+ UNPACK3_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 6
+ endm
+
+UNPACK_V2_8SSE_3A macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_V2_8SSE_3 CL, TOTALCL, MaskType, ModeType
+ endm
+
+UNPACK_V2_8SSE_2 macro CL, TOTALCL, MaskType, ModeType
+ movd xmm0, dword ptr [esi]
+ punpcklbw xmm0, xmm0
+ punpcklwd xmm0, xmm0
+ UNPACK_RIGHTSHIFT xmm0, 24
+
+ punpckhqdq xmm1, xmm0
+
+ punpcklqdq xmm0, xmm0
+ punpckhqdq xmm1, xmm1
+
+ UNPACK2_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 4
+ endm
+
+UNPACK_V2_8SSE_2A macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_V2_8SSE_2 CL, TOTALCL, MaskType, ModeType
+ endm
+
+UNPACK_V2_8SSE_1 macro CL, TOTALCL, MaskType, ModeType
+ movd xmm0, dword ptr [esi]
+ punpcklbw xmm0, xmm0
+ punpcklwd xmm0, xmm0
+ UNPACK_RIGHTSHIFT xmm0, 24
+ punpcklqdq xmm0, xmm0
+
+ UNPACK1_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 2
+ endm
+
+UNPACK_V2_8SSE_1A macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_V2_8SSE_1 CL, TOTALCL, MaskType, ModeType
+ endm
+
+
+UNPACK_V3_32SSE_4x macro CL, TOTALCL, MaskType, ModeType, MOVDQA
+ MOVDQA xmm0, [esi]
+ movdqu xmm1, [esi+12]
+
+ @CatStr(UNPACK_Setup_, MaskType, _SSE_, ModeType, _, TOTALCL) CL+0
+ @CatStr(UNPACK_, MaskType, _SSE_, ModeType) xmm0
+ @CatStr(UNPACK_Write, TOTALCL, _, MaskType) xmm0, CL, 0, movdqa
+
+ @CatStr(UNPACK_Setup_, MaskType, _SSE_, ModeType, _, TOTALCL) CL+1
+ @CatStr(UNPACK_, MaskType, _SSE_, ModeType) xmm1
+ @CatStr(UNPACK_Write, TOTALCL, _, MaskType) xmm1, CL+1, 16, movdqa
+
+
+ MOVDQA xmm7, [esi+32]
+ movdqu xmm2, [esi+24]
+ psrldq xmm7, 4
+
+ @CatStr(UNPACK_Setup_, MaskType, _SSE_, ModeType, _, TOTALCL) CL+2
+ @CatStr(UNPACK_, MaskType, _SSE_, ModeType) xmm2
+ @CatStr(UNPACK_Write, TOTALCL, _, MaskType) xmm2, CL+2, 32, movdqa
+
+ @CatStr(UNPACK_Setup_, MaskType, _SSE_, ModeType, _, TOTALCL) CL+3
+ @CatStr(UNPACK_, MaskType, _SSE_, ModeType) xmm7
+ @CatStr(UNPACK_Write, TOTALCL, _, MaskType) xmm7, CL+3, 48, movdqa
+
+ @CatStr(UNPACK_INC_DST_, TOTALCL, _, MaskType) 4
+
+ add esi, 48
+ endm
+
+UNPACK_V3_32SSE_4A macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_V3_32SSE_4x CL, TOTALCL, MaskType, ModeType, movdqa
+ endm
+UNPACK_V3_32SSE_4 macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_V3_32SSE_4x CL, TOTALCL, MaskType, ModeType, movdqu
+ endm
+
+UNPACK_V3_32SSE_3x macro CL, TOTALCL, MaskType, ModeType, MOVDQA
+ MOVDQA xmm0, [esi]
+ movdqu xmm1, [esi+12]
+
+ @CatStr(UNPACK_Setup_, MaskType, _SSE_, ModeType, _, TOTALCL) CL
+ @CatStr(UNPACK_, MaskType, _SSE_, ModeType) xmm0
+ @CatStr(UNPACK_Write, TOTALCL, _, MaskType) xmm0, CL, 0, movdqa
+
+ @CatStr(UNPACK_Setup_, MaskType, _SSE_, ModeType, _, TOTALCL) CL+1
+ @CatStr(UNPACK_, MaskType, _SSE_, ModeType) xmm1
+ @CatStr(UNPACK_Write, TOTALCL, _, MaskType) xmm1, CL+1, 16, movdqa
+
+ movdqu xmm2, [esi+24]
+
+ @CatStr(UNPACK_Setup_, MaskType, _SSE_, ModeType, _, TOTALCL) CL+2
+ @CatStr(UNPACK_, MaskType, _SSE_, ModeType) xmm2
+ @CatStr(UNPACK_Write, TOTALCL, _, MaskType) xmm2, CL+2, 32, movdqa
+
+ @CatStr(UNPACK_INC_DST_, TOTALCL, _, MaskType) 3
+
+ add esi, 36
+ endm
+
+UNPACK_V3_32SSE_3A macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_V3_32SSE_3x CL, TOTALCL, MaskType, ModeType, movdqa
+ endm
+UNPACK_V3_32SSE_3 macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_V3_32SSE_3x CL, TOTALCL, MaskType, ModeType, movdqu
+ endm
+
+UNPACK_V3_32SSE_2x macro CL, TOTALCL, MaskType, ModeType, MOVDQA
+ MOVDQA xmm0, [esi]
+ movdqu xmm1, [esi+12]
+
+ UNPACK2_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 24
+ endm
+
+UNPACK_V3_32SSE_2A macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_V3_32SSE_2x CL, TOTALCL, MaskType, ModeType, movdqa
+ endm
+UNPACK_V3_32SSE_2 macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_V3_32SSE_2x CL, TOTALCL, MaskType, ModeType, movdqu
+ endm
+
+UNPACK_V3_32SSE_1x macro CL, TOTALCL, MaskType, ModeType, MOVDQA
+ MOVDQA xmm0, [esi]
+
+ UNPACK1_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 12
+ endm
+
+UNPACK_V3_32SSE_1A macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_V3_32SSE_1x CL, TOTALCL, MaskType, ModeType, movdqa
+ endm
+UNPACK_V3_32SSE_1 macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_V3_32SSE_1x CL, TOTALCL, MaskType, ModeType, movdqu
+ endm
+
+
+UNPACK_V3_16SSE_4 macro CL, TOTALCL, MaskType, ModeType
+ movq xmm0, QWORD PTR [esi]
+ movq xmm1, QWORD PTR [esi+6]
+
+ punpcklwd xmm0, xmm0
+ movq xmm2, QWORD PTR [esi+12]
+ punpcklwd xmm1, xmm1
+ UNPACK_RIGHTSHIFT xmm0, 16
+ movq xmm7, QWORD PTR [esi+18]
+ UNPACK_RIGHTSHIFT xmm1, 16
+ punpcklwd xmm2, xmm2
+ punpcklwd xmm7, xmm7
+
+ UNPACK_RIGHTSHIFT xmm2, 16
+ UNPACK_RIGHTSHIFT xmm7, 16
+
+ UNPACK4_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 24
+ endm
+
+UNPACK_V3_16SSE_4A macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_V3_16SSE_4 CL, TOTALCL, MaskType, ModeType
+ endm
+
+UNPACK_V3_16SSE_3 macro CL, TOTALCL, MaskType, ModeType
+ movq xmm0, QWORD PTR [esi]
+ movq xmm1, QWORD PTR [esi+6]
+
+ punpcklwd xmm0, xmm0
+ movq xmm2, QWORD PTR [esi+12]
+ punpcklwd xmm1, xmm1
+ UNPACK_RIGHTSHIFT xmm0, 16
+ punpcklwd xmm2, xmm2
+
+ UNPACK_RIGHTSHIFT xmm1, 16
+ UNPACK_RIGHTSHIFT xmm2, 16
+
+ UNPACK3_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 18
+ endm
+
+UNPACK_V3_16SSE_3A macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_V3_16SSE_3 CL, TOTALCL, MaskType, ModeType
+ endm
+
+UNPACK_V3_16SSE_2 macro CL, TOTALCL, MaskType, ModeType
+ movq xmm0, QWORD PTR [esi]
+ movq xmm1, QWORD PTR [esi+6]
+
+ punpcklwd xmm0, xmm0
+ punpcklwd xmm1, xmm1
+
+ UNPACK_RIGHTSHIFT xmm0, 16
+ UNPACK_RIGHTSHIFT xmm1, 16
+
+ UNPACK2_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 12
+ endm
+
+UNPACK_V3_16SSE_2A macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_V3_16SSE_2 CL, TOTALCL, MaskType, ModeType
+ endm
+
+UNPACK_V3_16SSE_1 macro CL, TOTALCL, MaskType, ModeType
+ movq xmm0, QWORD PTR [esi]
+ punpcklwd xmm0, xmm0
+ UNPACK_RIGHTSHIFT xmm0, 16
+
+ UNPACK1_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 6
+ endm
+
+UNPACK_V3_16SSE_1A macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_V3_16SSE_1 CL, TOTALCL, MaskType, ModeType
+ endm
+
+
+UNPACK_V3_8SSE_4 macro CL, TOTALCL, MaskType, ModeType
+ movq xmm1, QWORD PTR [esi]
+ movq xmm7, QWORD PTR [esi+6]
+
+ punpcklbw xmm1, xmm1
+ punpcklbw xmm7, xmm7
+ punpcklwd xmm0, xmm1
+ psrldq xmm1, 6
+ punpcklwd xmm2, xmm7
+ psrldq xmm7, 6
+ punpcklwd xmm1, xmm1
+ UNPACK_RIGHTSHIFT xmm0, 24
+ punpcklwd xmm7, xmm7
+
+ UNPACK_RIGHTSHIFT xmm2, 24
+ UNPACK_RIGHTSHIFT xmm1, 24
+ UNPACK_RIGHTSHIFT xmm7, 24
+
+ UNPACK4_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 12
+ endm
+
+UNPACK_V3_8SSE_4A macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_V3_8SSE_4 CL, TOTALCL, MaskType, ModeType
+ endm
+
+UNPACK_V3_8SSE_3 macro CL, TOTALCL, MaskType, ModeType
+ movd xmm0, dword ptr [esi]
+ movd xmm1, dword ptr [esi+3]
+
+ punpcklbw xmm0, xmm0
+ movd xmm2, dword ptr [esi+6]
+ punpcklbw xmm1, xmm1
+ punpcklwd xmm0, xmm0
+ punpcklbw xmm2, xmm2
+
+ punpcklwd xmm1, xmm1
+ punpcklwd xmm2, xmm2
+
+ UNPACK_RIGHTSHIFT xmm0, 24
+ UNPACK_RIGHTSHIFT xmm1, 24
+ UNPACK_RIGHTSHIFT xmm2, 24
+
+ UNPACK3_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 9
+ endm
+
+UNPACK_V3_8SSE_3A macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_V3_8SSE_3 CL, TOTALCL, MaskType, ModeType
+ endm
+
+UNPACK_V3_8SSE_2 macro CL, TOTALCL, MaskType, ModeType
+ movd xmm0, dword ptr [esi]
+ movd xmm1, dword ptr [esi+3]
+
+ punpcklbw xmm0, xmm0
+ punpcklbw xmm1, xmm1
+
+ punpcklwd xmm0, xmm0
+ punpcklwd xmm1, xmm1
+
+ UNPACK_RIGHTSHIFT xmm0, 24
+ UNPACK_RIGHTSHIFT xmm1, 24
+
+ UNPACK2_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 6
+ endm
+
+UNPACK_V3_8SSE_2A macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_V3_8SSE_2 CL, TOTALCL, MaskType, ModeType
+ endm
+
+UNPACK_V3_8SSE_1 macro CL, TOTALCL, MaskType, ModeType
+ movd xmm0, dword ptr [esi]
+ punpcklbw xmm0, xmm0
+ punpcklwd xmm0, xmm0
+ UNPACK_RIGHTSHIFT xmm0, 24
+
+ UNPACK1_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 3
+ endm
+
+UNPACK_V3_8SSE_1A macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_V3_8SSE_1 CL, TOTALCL, MaskType, ModeType
+ endm
+
+
+UNPACK_V4_32SSE_4A macro CL, TOTALCL, MaskType, ModeType
+ movdqa xmm0, [esi]
+ movdqa xmm1, [esi+16]
+ movdqa xmm2, [esi+32]
+ movdqa xmm7, [esi+48]
+
+ UNPACK4_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 64
+ endm
+
+UNPACK_V4_32SSE_4 macro CL, TOTALCL, MaskType, ModeType
+ movdqu xmm0, [esi]
+ movdqu xmm1, [esi+16]
+ movdqu xmm2, [esi+32]
+ movdqu xmm7, [esi+48]
+
+ UNPACK4_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 64
+ endm
+
+UNPACK_V4_32SSE_3A macro CL, TOTALCL, MaskType, ModeType
+ movdqa xmm0, [esi]
+ movdqa xmm1, [esi+16]
+ movdqa xmm2, [esi+32]
+
+ UNPACK3_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 48
+ endm
+
+UNPACK_V4_32SSE_3 macro CL, TOTALCL, MaskType, ModeType
+ movdqu xmm0, [esi]
+ movdqu xmm1, [esi+16]
+ movdqu xmm2, [esi+32]
+
+ UNPACK3_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 48
+ endm
+
+UNPACK_V4_32SSE_2A macro CL, TOTALCL, MaskType, ModeType
+ movdqa xmm0, [esi]
+ movdqa xmm1, [esi+16]
+
+ UNPACK2_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 32
+ endm
+
+UNPACK_V4_32SSE_2 macro CL, TOTALCL, MaskType, ModeType
+ movdqu xmm0, [esi]
+ movdqu xmm1, [esi+16]
+
+ UNPACK2_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 32
+ endm
+
+UNPACK_V4_32SSE_1A macro CL, TOTALCL, MaskType, ModeType
+ movdqa xmm0, [esi]
+
+ UNPACK1_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 16
+ endm
+
+UNPACK_V4_32SSE_1 macro CL, TOTALCL, MaskType, ModeType
+ movdqu xmm0, [esi]
+
+ UNPACK1_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 16
+ endm
+
+
+UNPACK_V4_16SSE_4A macro CL, TOTALCL, MaskType, ModeType
+
+ punpcklwd xmm0, [esi]
+ punpckhwd xmm1, [esi]
+ punpcklwd xmm2, [esi+16]
+ punpckhwd xmm7, [esi+16]
+
+ UNPACK_RIGHTSHIFT xmm1, 16
+ UNPACK_RIGHTSHIFT xmm7, 16
+ UNPACK_RIGHTSHIFT xmm0, 16
+ UNPACK_RIGHTSHIFT xmm2, 16
+
+ UNPACK4_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 32
+ endm
+
+UNPACK_V4_16SSE_4 macro CL, TOTALCL, MaskType, ModeType
+ movdqu xmm0, [esi]
+ movdqu xmm2, [esi+16]
+
+ punpckhwd xmm1, xmm0
+ punpckhwd xmm7, xmm2
+ punpcklwd xmm0, xmm0
+ punpcklwd xmm2, xmm2
+
+ UNPACK_RIGHTSHIFT xmm1, 16
+ UNPACK_RIGHTSHIFT xmm7, 16
+ UNPACK_RIGHTSHIFT xmm0, 16
+ UNPACK_RIGHTSHIFT xmm2, 16
+
+ UNPACK4_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 32
+ endm
+
+UNPACK_V4_16SSE_3A macro CL, TOTALCL, MaskType, ModeType
+ punpcklwd xmm0, [esi]
+ punpckhwd xmm1, [esi]
+ punpcklwd xmm2, [esi+16]
+
+ UNPACK_RIGHTSHIFT xmm0, 16
+ UNPACK_RIGHTSHIFT xmm1, 16
+ UNPACK_RIGHTSHIFT xmm2, 16
+
+ UNPACK3_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 24
+ endm
+
+UNPACK_V4_16SSE_3 macro CL, TOTALCL, MaskType, ModeType
+ movdqu xmm0, [esi]
+ movq xmm2, QWORD PTR [esi+16]
+
+ punpckhwd xmm1, xmm0
+ punpcklwd xmm0, xmm0
+ punpcklwd xmm2, xmm2
+
+ UNPACK_RIGHTSHIFT xmm0, 16
+ UNPACK_RIGHTSHIFT xmm1, 16
+ UNPACK_RIGHTSHIFT xmm2, 16
+
+ UNPACK3_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 24
+ endm
+
+UNPACK_V4_16SSE_2A macro CL, TOTALCL, MaskType, ModeType
+ punpcklwd xmm0, [esi]
+ punpckhwd xmm1, [esi]
+
+ UNPACK_RIGHTSHIFT xmm0, 16
+ UNPACK_RIGHTSHIFT xmm1, 16
+
+ UNPACK2_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 16
+ endm
+
+UNPACK_V4_16SSE_2 macro CL, TOTALCL, MaskType, ModeType
+ movq xmm0, QWORD PTR [esi]
+ movq xmm1, QWORD PTR [esi+8]
+
+ punpcklwd xmm0, xmm0
+ punpcklwd xmm1, xmm1
+
+ UNPACK_RIGHTSHIFT xmm0, 16
+ UNPACK_RIGHTSHIFT xmm1, 16
+
+ UNPACK2_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 16
+ endm
+
+UNPACK_V4_16SSE_1A macro CL, TOTALCL, MaskType, ModeType
+ punpcklwd xmm0, [esi]
+ UNPACK_RIGHTSHIFT xmm0, 16
+
+ UNPACK1_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 8
+ endm
+
+UNPACK_V4_16SSE_1 macro CL, TOTALCL, MaskType, ModeType
+ movq xmm0, QWORD PTR [esi]
+ punpcklwd xmm0, xmm0
+ UNPACK_RIGHTSHIFT xmm0, 16
+
+ UNPACK1_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 8
+ endm
+
+
+UNPACK_V4_8SSE_4A macro CL, TOTALCL, MaskType, ModeType
+ punpcklbw xmm0, [esi]
+ punpckhbw xmm2, [esi]
+
+ punpckhwd xmm1, xmm0
+ punpckhwd xmm7, xmm2
+ punpcklwd xmm0, xmm0
+ punpcklwd xmm2, xmm2
+
+ UNPACK_RIGHTSHIFT xmm1, 24
+ UNPACK_RIGHTSHIFT xmm7, 24
+ UNPACK_RIGHTSHIFT xmm0, 24
+ UNPACK_RIGHTSHIFT xmm2, 24
+
+ UNPACK4_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 16
+ endm
+
+UNPACK_V4_8SSE_4 macro CL, TOTALCL, MaskType, ModeType
+ movdqu xmm0, [esi]
+
+ punpckhbw xmm2, xmm0
+ punpcklbw xmm0, xmm0
+
+ punpckhwd xmm7, xmm2
+ punpckhwd xmm1, xmm0
+ punpcklwd xmm2, xmm2
+ punpcklwd xmm0, xmm0
+
+ UNPACK_RIGHTSHIFT xmm7, 24
+ UNPACK_RIGHTSHIFT xmm2, 24
+
+ UNPACK_RIGHTSHIFT xmm0, 24
+ UNPACK_RIGHTSHIFT xmm1, 24
+
+ UNPACK4_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 16
+ endm
+
+UNPACK_V4_8SSE_3A macro CL, TOTALCL, MaskType, ModeType
+ punpcklbw xmm0, [esi]
+ punpckhbw xmm2, [esi]
+
+ punpckhwd xmm1, xmm0
+ punpcklwd xmm0, xmm0
+ punpcklwd xmm2, xmm2
+
+ UNPACK_RIGHTSHIFT xmm1, 24
+ UNPACK_RIGHTSHIFT xmm0, 24
+ UNPACK_RIGHTSHIFT xmm2, 24
+
+ UNPACK3_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 12
+ endm
+
+UNPACK_V4_8SSE_3 macro CL, TOTALCL, MaskType, ModeType
+ movq xmm0, QWORD PTR [esi]
+ movd xmm2, dword ptr [esi+8]
+
+ punpcklbw xmm0, xmm0
+ punpcklbw xmm2, xmm2
+
+ punpckhwd xmm1, xmm0
+ punpcklwd xmm2, xmm2
+ punpcklwd xmm0, xmm0
+
+ UNPACK_RIGHTSHIFT xmm1, 24
+ UNPACK_RIGHTSHIFT xmm0, 24
+ UNPACK_RIGHTSHIFT xmm2, 24
+
+ UNPACK3_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 12
+ endm
+
+UNPACK_V4_8SSE_2A macro CL, TOTALCL, MaskType, ModeType
+ punpcklbw xmm0, [esi]
+
+ punpckhwd xmm1, xmm0
+ punpcklwd xmm0, xmm0
+
+ UNPACK_RIGHTSHIFT xmm1, 24
+ UNPACK_RIGHTSHIFT xmm0, 24
+
+ UNPACK2_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 8
+ endm
+
+UNPACK_V4_8SSE_2 macro CL, TOTALCL, MaskType, ModeType
+ movq xmm0, QWORD PTR [esi]
+
+ punpcklbw xmm0, xmm0
+
+ punpckhwd xmm1, xmm0
+ punpcklwd xmm0, xmm0
+
+ UNPACK_RIGHTSHIFT xmm1, 24
+ UNPACK_RIGHTSHIFT xmm0, 24
+
+ UNPACK2_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 8
+ endm
+
+UNPACK_V4_8SSE_1A macro CL, TOTALCL, MaskType, ModeType
+ punpcklbw xmm0, [esi]
+ punpcklwd xmm0, xmm0
+ UNPACK_RIGHTSHIFT xmm0, 24
+
+ UNPACK1_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 4
+ endm
+
+UNPACK_V4_8SSE_1 macro CL, TOTALCL, MaskType, ModeType
+ movd xmm0, dword ptr [esi]
+ punpcklbw xmm0, xmm0
+ punpcklwd xmm0, xmm0
+ UNPACK_RIGHTSHIFT xmm0, 24
+
+ UNPACK1_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 4
+ endm
+
+
+DECOMPRESS_RGBA macro OFFSET
+ mov bl, al
+ shl bl, 3
+ mov byte ptr [s_TempDecompress+OFFSET], bl
+
+ mov bx, ax
+ shr bx, 2
+ and bx, 0f8h
+ mov byte ptr [s_TempDecompress+OFFSET+1], bl
+
+ mov bx, ax
+ shr bx, 7
+ and bx, 0f8h
+ mov byte ptr [s_TempDecompress+OFFSET+2], bl
+ mov bx, ax
+ shr bx, 8
+ and bx, 080h
+ mov byte ptr [s_TempDecompress+OFFSET+3], bl
+ endm
+
+UNPACK_V4_5SSE_4 macro CL, TOTALCL, MaskType, ModeType
+ mov eax, dword ptr [esi]
+ DECOMPRESS_RGBA 0
+
+ shr eax, 16
+ DECOMPRESS_RGBA 4
+
+ mov eax, dword ptr [esi+4]
+ DECOMPRESS_RGBA 8
+
+ shr eax, 16
+ DECOMPRESS_RGBA 12
+
+ ;; have to use movaps instead of movdqa
+ movaps xmm0, [s_TempDecompress]
+
+ punpckhbw xmm2, xmm0
+ punpcklbw xmm0, xmm0
+
+ punpckhwd xmm7, xmm2
+ punpckhwd xmm1, xmm0
+ punpcklwd xmm0, xmm0
+ punpcklwd xmm2, xmm2
+
+ psrld xmm0, 24
+ psrld xmm1, 24
+ psrld xmm2, 24
+ psrld xmm7, 24
+
+ UNPACK4_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 8
+ endm
+
+UNPACK_V4_5SSE_4A macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_V4_5SSE_4 CL, TOTALCL, MaskType, ModeType
+ endm
+
+UNPACK_V4_5SSE_3 macro CL, TOTALCL, MaskType, ModeType
+ mov eax, dword ptr [esi]
+ DECOMPRESS_RGBA 0
+
+ shr eax, 16
+ DECOMPRESS_RGBA 4
+
+ mov eax, dword ptr [esi]
+ DECOMPRESS_RGBA 8
+
+ ;; have to use movaps instead of movdqa
+ movaps xmm0, [s_TempDecompress]
+
+ punpckhbw xmm2, xmm0
+ punpcklbw xmm0, xmm0
+
+ punpckhwd xmm1, xmm0
+ punpcklwd xmm0, xmm0
+ punpcklwd xmm2, xmm2
+
+ psrld xmm0, 24
+ psrld xmm1, 24
+ psrld xmm2, 24
+
+ UNPACK3_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 6
+ endm
+
+UNPACK_V4_5SSE_3A macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_V4_5SSE_3 CL, TOTALCL, MaskType, ModeType
+ endm
+
+UNPACK_V4_5SSE_2 macro CL, TOTALCL, MaskType, ModeType
+ mov eax, dword ptr [esi]
+ DECOMPRESS_RGBA 0
+
+ shr eax, 16
+ DECOMPRESS_RGBA 4
+
+ movq xmm0, QWORD PTR [s_TempDecompress]
+
+ punpcklbw xmm0, xmm0
+
+ punpckhwd xmm1, xmm0
+ punpcklwd xmm0, xmm0
+
+ psrld xmm0, 24
+ psrld xmm1, 24
+
+ UNPACK2_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 4
+ endm
+
+UNPACK_V4_5SSE_2A macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_V4_5SSE_2 CL, TOTALCL, MaskType, ModeType
+ endm
+
+UNPACK_V4_5SSE_1 macro CL, TOTALCL, MaskType, ModeType
+ mov ax, word ptr [esi]
+ DECOMPRESS_RGBA 0
+
+ movd xmm0, DWORD PTR [s_TempDecompress]
+ punpcklbw xmm0, xmm0
+ punpcklwd xmm0, xmm0
+
+ psrld xmm0, 24
+
+ UNPACK1_SSE CL, TOTALCL, MaskType, ModeType
+
+ add esi, 2
+ endm
+
+UNPACK_V4_5SSE_1A macro CL, TOTALCL, MaskType, ModeType
+ UNPACK_V4_5SSE_1 CL, TOTALCL, MaskType, ModeType
+ endm
+
+
+SAVE_ROW_REG_BASE macro
+ mov eax, [vifRow]
+ movdqa [eax], xmm6
+ mov eax, [vifRegs]
+ movss dword ptr [eax+0100h], xmm6
+ psrldq xmm6, 4
+ movss dword ptr [eax+0110h], xmm6
+ psrldq xmm6, 4
+ movss dword ptr [eax+0120h], xmm6
+ psrldq xmm6, 4
+ movss dword ptr [eax+0130h], xmm6
+ endm
+
+SAVE_NO_REG macro
+ endm
+
+INIT_ARGS macro
+ mov edi, dword ptr [esp+4+12]
+ mov esi, dword ptr [esp+8+12]
+ mov edx, dword ptr [esp+12+12]
+ endm
+
+INC_STACK macro reg
+ add esp, 4
+ endm
+
+
+
+
+
+defUNPACK_SkippingWrite macro name, MaskType, ModeType, qsize, sign, SAVE_ROW_REG
+@CatStr(UNPACK_SkippingWrite_, name, _, sign, _, MaskType, _, ModeType) proc public
+ push edi
+ push esi
+ push ebx
+
+ INIT_ARGS
+ mov eax, [vifRegs]
+ movzx ecx, byte ptr [eax + 040h]
+ movzx ebx, byte ptr [eax + 041h]
+ sub ecx, ebx
+ shl ecx, 4
+
+ cmp ebx, 1
+ je @CatStr(name, _, sign, _, MaskType, _, ModeType, _WL1)
+ cmp ebx, 2
+ je @CatStr(name, _, sign, _, MaskType, _, ModeType, _WL2)
+ cmp ebx, 3
+ je @CatStr(name, _, sign, _, MaskType, _, ModeType, _WL3)
+ jmp @CatStr(name, _, sign, _, MaskType, _, ModeType, _WL4)
+
+@CatStr(name, _, sign, _, MaskType, _, ModeType, _WL1):
+ @CatStr(UNPACK_Start_Setup_, MaskType, _SSE_, ModeType) 0
+
+ cmp edx, qsize
+ jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_Done3)
+
+ add ecx, 16
+
+
+@CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_Align16):
+
+ test esi, 15
+ jz @CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_UnpackAligned)
+
+ @CatStr(UNPACK_, name, SSE_1) 0, 1, MaskType, ModeType
+
+ cmp edx, (2*qsize)
+ jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_DoneWithDec)
+ sub edx, qsize
+ jmp @CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_Align16)
+
+@CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_UnpackAligned):
+
+ cmp edx, (2*qsize)
+ jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_Unpack1)
+ cmp edx, (3*qsize)
+ jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_Unpack2)
+ cmp edx, (4*qsize)
+ jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_Unpack3)
+ prefetchnta [esi + 64]
+
+@CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_Unpack4):
+ @CatStr(UNPACK_, name, SSE_4A) 0, 1, MaskType, ModeType
+
+ cmp edx, (8*qsize)
+ jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_DoneUnpack4)
+ sub edx, (4*qsize)
+ jmp @CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_Unpack4)
+
+@CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_DoneUnpack4):
+
+ sub edx, (4*qsize)
+ cmp edx, qsize
+ jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_Done3)
+ cmp edx, (2*qsize)
+ jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_Unpack1)
+ cmp edx, (3*qsize)
+ jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_Unpack2)
+
+
+@CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_Unpack3):
+ @CatStr(UNPACK_, name, SSE_3A) 0, 1, MaskType, ModeType
+
+ sub edx, (3*qsize)
+ jmp @CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_Done3)
+
+@CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_Unpack2):
+ @CatStr(UNPACK_, name, SSE_2A) 0, 1, MaskType, ModeType
+
+ sub edx, (2*qsize)
+ jmp @CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_Done3)
+
+@CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_Unpack1):
+ @CatStr(UNPACK_, name, SSE_1A) 0, 1, MaskType, ModeType
+@CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_DoneWithDec):
+ sub edx, qsize
+@CatStr(name, _, sign, _, MaskType, _, ModeType, _C1_Done3):
+ SAVE_ROW_REG
+ mov eax, edx
+ pop ebx
+ pop esi
+ pop edi
+
+ ret
+
+@CatStr(name, _, sign, _, MaskType, _, ModeType, _WL2):
+ cmp edx, (2*qsize)
+
+ jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C2_Done3)
+@CatStr(name, _, sign, _, MaskType, _, ModeType, _C2_Unpack):
+ @CatStr(UNPACK_, name, SSE_2) 0, 0, MaskType, ModeType
+
+
+ add edi, ecx
+ cmp edx, (4*qsize)
+ jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C2_Done2)
+ sub edx, (2*qsize)
+
+ jmp @CatStr(name, _, sign, _, MaskType, _, ModeType, _C2_Unpack)
+
+@CatStr(name, _, sign, _, MaskType, _, ModeType, _C2_Done2):
+ sub edx, (2*qsize)
+@CatStr(name, _, sign, _, MaskType, _, ModeType, _C2_Done3):
+ cmp edx, qsize
+
+ jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C2_Done4)
+
+
+ @CatStr(UNPACK_, name, SSE_1) 0, 0, MaskType, ModeType
+
+ sub edx, qsize
+@CatStr(name, _, sign, _, MaskType, _, ModeType, _C2_Done4):
+
+ SAVE_ROW_REG
+ mov eax, edx
+ pop ebx
+ pop esi
+ pop edi
+
+ ret
+
+@CatStr(name, _, sign, _, MaskType, _, ModeType, _WL3):
+ cmp edx, (3*qsize)
+
+ jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C3_Done5)
+@CatStr(name, _, sign, _, MaskType, _, ModeType, _C3_Unpack):
+ @CatStr(UNPACK_, name, SSE_3) 0, 0, MaskType, ModeType
+
+ add edi, ecx
+ cmp edx, (6*qsize)
+ jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C3_Done2)
+ sub edx, (3*qsize)
+ jmp @CatStr(name, _, sign, _, MaskType, _, ModeType, _C3_Unpack)
+@CatStr(name, _, sign, _, MaskType, _, ModeType, _C3_Done2):
+ sub edx, (3*qsize)
+@CatStr(name, _, sign, _, MaskType, _, ModeType, _C3_Done5):
+ cmp edx, qsize
+ jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C3_Done4)
+
+ cmp edx, (2*qsize)
+ jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C3_Done3)
+
+ @CatStr(UNPACK_, name, SSE_2) 0, 0, MaskType, ModeType
+
+ sub edx, (2*qsize)
+ jmp @CatStr(name, _, sign, _, MaskType, _, ModeType, _C3_Done4)
+@CatStr(name, _, sign, _, MaskType, _, ModeType, _C3_Done3):
+ sub edx, qsize
+ @CatStr(UNPACK_, name, SSE_1) 0, 0, MaskType, ModeType
+@CatStr(name, _, sign, _, MaskType, _, ModeType, _C3_Done4):
+ SAVE_ROW_REG
+ mov eax, edx
+ pop ebx
+ pop esi
+ pop edi
+
+ ret
+
+@CatStr(name, _, sign, _, MaskType, _, ModeType, _WL4):
+ sub ebx, 3
+ push ecx
+ cmp edx, qsize
+ jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C4_Done)
+
+@CatStr(name, _, sign, _, MaskType, _, ModeType, _C4_Unpack):
+ cmp edx, (3*qsize)
+ jge @CatStr(name, _, sign, _, MaskType, _, ModeType, _C4_Unpack3)
+ cmp edx, (2*qsize)
+ jge @CatStr(name, _, sign, _, MaskType, _, ModeType, _C4_Unpack2)
+
+ @CatStr(UNPACK_, name, SSE_1) 0, 0, MaskType, ModeType
+
+
+ sub edx, qsize
+ jmp @CatStr(name, _, sign, _, MaskType, _, ModeType, _C4_Done)
+@CatStr(name, _, sign, _, MaskType, _, ModeType, _C4_Unpack2):
+ @CatStr(UNPACK_, name, SSE_2) 0, 0, MaskType, ModeType
+
+
+ sub edx, (2*qsize)
+ jmp @CatStr(name, _, sign, _, MaskType, _, ModeType, _C4_Done)
+@CatStr(name, _, sign, _, MaskType, _, ModeType, _C4_Unpack3):
+ @CatStr(UNPACK_, name, SSE_3) 0, 0, MaskType, ModeType
+
+
+ sub edx, (3*qsize)
+ mov ecx, ebx
+
+@CatStr(name, _, sign, _, MaskType, _, ModeType, _C4_UnpackX):
+
+
+ cmp edx, qsize
+ jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C4_Done)
+
+ @CatStr(UNPACK_, name, SSE_1) 3, 0, MaskType, ModeType
+
+ sub edx, qsize
+ cmp ecx, 1
+ je @CatStr(name, _, sign, _, MaskType, _, ModeType, _C4_DoneLoop)
+ sub ecx, 1
+ jmp @CatStr(name, _, sign, _, MaskType, _, ModeType, _C4_UnpackX)
+@CatStr(name, _, sign, _, MaskType, _, ModeType, _C4_DoneLoop):
+ add edi, [esp]
+ cmp edx, qsize
+ jl @CatStr(name, _, sign, _, MaskType, _, ModeType, _C4_Done)
+ jmp @CatStr(name, _, sign, _, MaskType, _, ModeType, _C4_Unpack)
+@CatStr(name, _, sign, _, MaskType, _, ModeType, _C4_Done):
+
+ SAVE_ROW_REG
+ INC_STACK()
+ mov eax, edx
+ pop ebx
+ pop esi
+ pop edi
+
+ ret
+@CatStr(UNPACK_SkippingWrite_, name, _, sign, _, MaskType, _, ModeType endp)
+endm
+
+UNPACK_RIGHTSHIFT macro reg, shift
+ psrld reg, shift
+ endm
+
+defUNPACK_SkippingWrite2 macro name, qsize
+ defUNPACK_SkippingWrite name, Regular, 0, qsize, u, SAVE_NO_REG
+ defUNPACK_SkippingWrite name, Regular, 1, qsize, u, SAVE_NO_REG
+ defUNPACK_SkippingWrite name, Regular, 2, qsize, u, SAVE_ROW_REG_BASE
+ defUNPACK_SkippingWrite name, Mask, 0, qsize, u, SAVE_NO_REG
+ defUNPACK_SkippingWrite name, Mask, 1, qsize, u, SAVE_NO_REG
+ defUNPACK_SkippingWrite name, Mask, 2, qsize, u, SAVE_ROW_REG_BASE
+ defUNPACK_SkippingWrite name, WriteMask, 0, qsize, u, SAVE_NO_REG
+ defUNPACK_SkippingWrite name, WriteMask, 1, qsize, u, SAVE_NO_REG
+ defUNPACK_SkippingWrite name, WriteMask, 2, qsize, u, SAVE_ROW_REG_BASE
+ endm
+
+defUNPACK_SkippingWrite2 S_32, 4
+defUNPACK_SkippingWrite2 S_16, 2
+defUNPACK_SkippingWrite2 S_8, 1
+defUNPACK_SkippingWrite2 V2_32, 8
+defUNPACK_SkippingWrite2 V2_16, 4
+defUNPACK_SkippingWrite2 V2_8, 2
+defUNPACK_SkippingWrite2 V3_32, 12
+defUNPACK_SkippingWrite2 V3_16, 6
+defUNPACK_SkippingWrite2 V3_8, 3
+defUNPACK_SkippingWrite2 V4_32, 16
+defUNPACK_SkippingWrite2 V4_16, 8
+defUNPACK_SkippingWrite2 V4_8, 4
+defUNPACK_SkippingWrite2 V4_5, 2
+
+UNPACK_RIGHTSHIFT macro reg, shift
+ psrad reg, shift
+ endm
+
+
+defUNPACK_SkippingWrite2a macro name, qsize
+ defUNPACK_SkippingWrite name, Mask, 0, qsize, s, SAVE_NO_REG
+ defUNPACK_SkippingWrite name, Regular, 0, qsize, s, SAVE_NO_REG
+ defUNPACK_SkippingWrite name, Regular, 1, qsize, s, SAVE_NO_REG
+ defUNPACK_SkippingWrite name, Regular, 2, qsize, s, SAVE_ROW_REG_BASE
+ defUNPACK_SkippingWrite name, Mask, 1, qsize, s, SAVE_NO_REG
+ defUNPACK_SkippingWrite name, Mask, 2, qsize, s, SAVE_ROW_REG_BASE
+ defUNPACK_SkippingWrite name, WriteMask, 0, qsize, s, SAVE_NO_REG
+ defUNPACK_SkippingWrite name, WriteMask, 1, qsize, s, SAVE_NO_REG
+ defUNPACK_SkippingWrite name, WriteMask, 2, qsize, s, SAVE_ROW_REG_BASE
+ endm
+
+defUNPACK_SkippingWrite2a S_16, 2
+defUNPACK_SkippingWrite2a S_8, 1
+defUNPACK_SkippingWrite2a V2_16, 4
+defUNPACK_SkippingWrite2a V2_8, 2
+defUNPACK_SkippingWrite2a V3_16, 6
+defUNPACK_SkippingWrite2a V3_8, 3
+defUNPACK_SkippingWrite2a V4_16, 8
+defUNPACK_SkippingWrite2a V4_8, 4
+
+end
diff --git a/plugins/CDVDiso/ReadMe.txt b/plugins/CDVDiso/ReadMe.txt
index b1a915352f..6287d13bf1 100644
--- a/plugins/CDVDiso/ReadMe.txt
+++ b/plugins/CDVDiso/ReadMe.txt
@@ -1,78 +1,78 @@
-CDVDiso v0.5
-------------
-
- This is an extension to use with play station2 emulators
- as PCSX2 (only one right now).
- The plugin is free open source code.
-
-Linux requeriments:
-------------------
- You need the GTK library, compiled with GTK v1.2.5,
- the Zlib library (v1.1.3) and the bz2 library (v1.0.0).
-
-Usage:
------
- Place the file "libCDVDiso.so" (linux) or "CDVDiso.dll" (win32) at the Plugin
- directory of the Emulator to use it.
-
- Linux only: Also place the cfgCDVDiso file at your $HOME directory or at the
- Emulator directory.
-
-Configuration:
--------------
- You can either write the iso you want to use in the config dialog, or everytime
- you run the emu open it, if you're doing this don't write anything in the dialog.
-
-Creating an iso (linux only):
----------------
- To create an iso you can use the buttons 'Create Iso' or 'Create Compressed Iso',
- the file will be the one in the Iso Edit, and the Cdrom Device is the cdrom that
- will be used as source.
- The compression method is specified by the Compression Method Combo.
-
- Note: This will fail if the file in the Iso Edit already exists (if it's
- compressed the .Z or .bz suffix will be added).
-
-Compressed isos:
----------------
- You must create them by the Compress Iso button, this will create a .Z or .bz
- file (the compressed image) and a .Z.table or .bz.index file (this is a table,
- for speed reasons), both will be created in the same dir the selected iso
- image, the original image will not be deleted and/or changed, and also you can
- decompress the compressed iso with Decompress Iso button.
- The compression method is specified by the Compression Method Combo.
-
- Note: you only can decompress the images with the Decompress button, not with
- compress or bzip2.
-
-Compression Method:
-------------------
- .Z - compress faster: this will compress faster, but not as good as the .bz.
- .bz - compress better: will compress better, but slower.
-
-Changes:
--------
- v0.5:
- * Added block dumping code
- * Added BZ2/Z2 format ;)
- * Added optimaze asm code of zlib with vsnet2003 only. Compression / Uncompression should be faster now (shadow)
- * Added Vsnet2005 beta1 project files + amd64 asm optimaze code for zlib (shadow)
-
- v0.4:
- * Rewrote mostly ;)
- * .bz is still unsupported
-
- v0.3:
- * Better Iso detection, thx florin :)
- * Updated to PS2Edefs v0.4.5
-
- v0.2:
- * Added support for isos using 2048 blocksize
- * Nero images are supported
- * Better extension filtering
-
- v0.1:
- * First Release
- * Tested with Pcsx2
-
- Email:
+CDVDiso v0.5
+------------
+
+ This is an extension to use with play station2 emulators
+ as PCSX2 (only one right now).
+ The plugin is free open source code.
+
+Linux requeriments:
+------------------
+ You need the GTK library, compiled with GTK v1.2.5,
+ the Zlib library (v1.1.3) and the bz2 library (v1.0.0).
+
+Usage:
+-----
+ Place the file "libCDVDiso.so" (linux) or "CDVDiso.dll" (win32) at the Plugin
+ directory of the Emulator to use it.
+
+ Linux only: Also place the cfgCDVDiso file at your $HOME directory or at the
+ Emulator directory.
+
+Configuration:
+-------------
+ You can either write the iso you want to use in the config dialog, or everytime
+ you run the emu open it, if you're doing this don't write anything in the dialog.
+
+Creating an iso (linux only):
+---------------
+ To create an iso you can use the buttons 'Create Iso' or 'Create Compressed Iso',
+ the file will be the one in the Iso Edit, and the Cdrom Device is the cdrom that
+ will be used as source.
+ The compression method is specified by the Compression Method Combo.
+
+ Note: This will fail if the file in the Iso Edit already exists (if it's
+ compressed the .Z or .bz suffix will be added).
+
+Compressed isos:
+---------------
+ You must create them by the Compress Iso button, this will create a .Z or .bz
+ file (the compressed image) and a .Z.table or .bz.index file (this is a table,
+ for speed reasons), both will be created in the same dir the selected iso
+ image, the original image will not be deleted and/or changed, and also you can
+ decompress the compressed iso with Decompress Iso button.
+ The compression method is specified by the Compression Method Combo.
+
+ Note: you only can decompress the images with the Decompress button, not with
+ compress or bzip2.
+
+Compression Method:
+------------------
+ .Z - compress faster: this will compress faster, but not as good as the .bz.
+ .bz - compress better: will compress better, but slower.
+
+Changes:
+-------
+ v0.5:
+ * Added block dumping code
+ * Added BZ2/Z2 format ;)
+ * Added optimaze asm code of zlib with vsnet2003 only. Compression / Uncompression should be faster now (shadow)
+ * Added Vsnet2005 beta1 project files + amd64 asm optimaze code for zlib (shadow)
+
+ v0.4:
+ * Rewrote mostly ;)
+ * .bz is still unsupported
+
+ v0.3:
+ * Better Iso detection, thx florin :)
+ * Updated to PS2Edefs v0.4.5
+
+ v0.2:
+ * Added support for isos using 2048 blocksize
+ * Nero images are supported
+ * Better extension filtering
+
+ v0.1:
+ * First Release
+ * Tested with Pcsx2
+
+ Email:
diff --git a/plugins/CDVDisoEFP/ChangeLog.txt b/plugins/CDVDisoEFP/ChangeLog.txt
index 525e384214..f271ce9dcd 100644
--- a/plugins/CDVDisoEFP/ChangeLog.txt
+++ b/plugins/CDVDisoEFP/ChangeLog.txt
@@ -1,58 +1,58 @@
-CDVDisoEFP v0.6 Changes:
---------------------
-
- v0.6:
- * Completely re-wrote screens (efp)
- * Used device access sources from CDVDlinuz to get data from DVDs. (efp)
- * Added ability to read devices from Windows XP (efp)
- Note: only ISO and CDDA seem to be readable from CDs at this time.
- If your trying to get another format, use Linux.
- DVD5 is readable. Don't have a DVD9 game to test. (I think - efp)
- * Separated image file access by OS. (Linux, Windows) (efp)
- * Separated Multi-file/Compression/Image-Typing to their own source files. (efp)
- * Added a few entries to the Image Typing database, based on Linux CD-ROM sources (efp)
- * Added Table Rebuild (for those who lost .table files.) (efp)
- * Put in a separate source program to compare two ISOs for data accuracy. (efp)
- * Renamed executables and config files (so not to conflict with CDVDiso) (efp)
- * Internalized the .INI File code (to allow use in other OS-es besides Windows) (efp)
- * Added temporarily a .toc file saving track info (for PS1 and Music CDs) (efp)
- * Added a new compression format. (BZip2 Size) (efp)
- * Added .glade files at linuzappz's request (efp)
- * Upgraded to 0.6.0 beta PS2Edef.h definitions (efp)
-
- * Data buffer start position re-set for CDs. (shadow caught the problem while testing)
- * Supported images grouped in "Browse" button (shadow's suggestion)
- * Initial Image reminder added to Windows CDVDOpen() (shadow's suggestion)
- * used 64 bit fstat (fstat64) for correct sizes on >2GB files in Linux (efp)
- * Adjusted CD types to allow for PS2 CDs (shadow pointed out an example iso)
- * Added changing CDs/DVDs while emulation stopped (shadow's suggestion)
- Built in an "open tray" delay when switching media. (efp)
- * Added ".img" to Image Filter (although .cue/.sub files aren't tapped.) (efp)
- * Added ".nrg" to Image Filter (shadow's suggestion)
- * In Windows, when newly selected from the PCSX2 configure screen, CDVDinit()
- (as well as InitConf()) are not called. Fixed (EFP)
-
- v0.5:
- * Added block dumping code
- * Added BZ2/Z2 format ;)
- * Added optimaze asm code of zlib with vsnet2003 only. Compression / Uncompression should be faster now (shadow)
- * Added Vsnet2005 beta1 project files + amd64 asm optimaze code for zlib (shadow)
-
- v0.4:
- * Rewrote mostly ;)
- * .bz is still unsupported
-
- v0.3:
- * Better Iso detection, thx florin :)
- * Updated to PS2Edefs v0.4.5
-
- v0.2:
- * Added support for isos using 2048 blocksize
- * Nero images are supported
- * Better extension filtering
-
- v0.1:
- * First Release
- * Tested with Pcsx2
-
- Email:
+CDVDisoEFP v0.6 Changes:
+--------------------
+
+ v0.6:
+ * Completely re-wrote screens (efp)
+ * Used device access sources from CDVDlinuz to get data from DVDs. (efp)
+ * Added ability to read devices from Windows XP (efp)
+ Note: only ISO and CDDA seem to be readable from CDs at this time.
+ If your trying to get another format, use Linux.
+ DVD5 is readable. Don't have a DVD9 game to test. (I think - efp)
+ * Separated image file access by OS. (Linux, Windows) (efp)
+ * Separated Multi-file/Compression/Image-Typing to their own source files. (efp)
+ * Added a few entries to the Image Typing database, based on Linux CD-ROM sources (efp)
+ * Added Table Rebuild (for those who lost .table files.) (efp)
+ * Put in a separate source program to compare two ISOs for data accuracy. (efp)
+ * Renamed executables and config files (so not to conflict with CDVDiso) (efp)
+ * Internalized the .INI File code (to allow use in other OS-es besides Windows) (efp)
+ * Added temporarily a .toc file saving track info (for PS1 and Music CDs) (efp)
+ * Added a new compression format. (BZip2 Size) (efp)
+ * Added .glade files at linuzappz's request (efp)
+ * Upgraded to 0.6.0 beta PS2Edef.h definitions (efp)
+
+ * Data buffer start position re-set for CDs. (shadow caught the problem while testing)
+ * Supported images grouped in "Browse" button (shadow's suggestion)
+ * Initial Image reminder added to Windows CDVDOpen() (shadow's suggestion)
+ * used 64 bit fstat (fstat64) for correct sizes on >2GB files in Linux (efp)
+ * Adjusted CD types to allow for PS2 CDs (shadow pointed out an example iso)
+ * Added changing CDs/DVDs while emulation stopped (shadow's suggestion)
+ Built in an "open tray" delay when switching media. (efp)
+ * Added ".img" to Image Filter (although .cue/.sub files aren't tapped.) (efp)
+ * Added ".nrg" to Image Filter (shadow's suggestion)
+ * In Windows, when newly selected from the PCSX2 configure screen, CDVDinit()
+ (as well as InitConf()) are not called. Fixed (EFP)
+
+ v0.5:
+ * Added block dumping code
+ * Added BZ2/Z2 format ;)
+ * Added optimaze asm code of zlib with vsnet2003 only. Compression / Uncompression should be faster now (shadow)
+ * Added Vsnet2005 beta1 project files + amd64 asm optimaze code for zlib (shadow)
+
+ v0.4:
+ * Rewrote mostly ;)
+ * .bz is still unsupported
+
+ v0.3:
+ * Better Iso detection, thx florin :)
+ * Updated to PS2Edefs v0.4.5
+
+ v0.2:
+ * Added support for isos using 2048 blocksize
+ * Nero images are supported
+ * Better extension filtering
+
+ v0.1:
+ * First Release
+ * Tested with Pcsx2
+
+ Email:
diff --git a/plugins/CDVDisoEFP/license.txt b/plugins/CDVDisoEFP/license.txt
index bb0a0ce0eb..1bcc46f53a 100644
--- a/plugins/CDVDisoEFP/license.txt
+++ b/plugins/CDVDisoEFP/license.txt
@@ -1,342 +1,342 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-
- Copyright (C)
-
- 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- , 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
-
-
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ , 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
+
+
diff --git a/plugins/CDVDisoEFP/readme.txt b/plugins/CDVDisoEFP/readme.txt
index fca4b91e6d..46d39a5ae8 100644
--- a/plugins/CDVDisoEFP/readme.txt
+++ b/plugins/CDVDisoEFP/readme.txt
@@ -1,55 +1,55 @@
-CDVDiso v0.6
-------------
-
- This is an extension to use with play station2 emulators
- as PCSX2 (only one right now).
- The plugin is free open source code.
-
-Linux requirements:
-------------------
- You need the GTK library, compiled with GTK v2.6.1 (at least).
-
-Usage:
------
- For those using Windows, place the file "CDVDisoEFP.dll" in the Plugin
- directory of the Emulator to use it.
-
- For Linux users, place the file "libCDVDisoEFP.so" in the plugin
- directory of the Emulator. Also, place the file "cfgCDVDisoEFP" in the "cfg"
- directory of the Emulator to use it.
-
-Configuration:
--------------
- You must select the iso you want to use in the Configuration dialog. You
- will come back to this dialog should the Emulator want another disc.
-
-Creating an iso (linux, Windows XP only):
----------------
- To create an iso you can use the button 'Make Image'. The file
- will be the one in the Iso Edit, and the Source Device is the CDRom or
- DVD drive that will have the disc you want to make an image of.
- The compression method is specified by the Compression Method Combo.
-
- Note: This will fail if the file already exists (if it's compressed
- a .z or .bz2 suffix will be added).
-
-Compressed isos:
----------------
- You can create them using the Convert button. This will create a .Z or .bz
- file (the compressed image) and a .z.table or .bz2.table file (this is a
- table, for speed reasons.) Both will be created in the same dir as the
- selected image. The original image will not be deleted and/or changed. Also,
- you can decompress a compressed image by selecting "None" in the
- Compression Method Combo.
-
- Note: you only can decompress the images with this program; not with
- compress or bzip2.
-
-Compression Method:
-------------------
- .z speed - fast compression, small blocks, table in memory.
- .bz2 speed - average compression, 32k - 40k blocks, table in memory.
- .bz2 size - best compression, 60k - 62k blocks, table on file.
-
-
- Email:
+CDVDiso v0.6
+------------
+
+ This is an extension to use with play station2 emulators
+ as PCSX2 (only one right now).
+ The plugin is free open source code.
+
+Linux requirements:
+------------------
+ You need the GTK library, compiled with GTK v2.6.1 (at least).
+
+Usage:
+-----
+ For those using Windows, place the file "CDVDisoEFP.dll" in the Plugin
+ directory of the Emulator to use it.
+
+ For Linux users, place the file "libCDVDisoEFP.so" in the plugin
+ directory of the Emulator. Also, place the file "cfgCDVDisoEFP" in the "cfg"
+ directory of the Emulator to use it.
+
+Configuration:
+-------------
+ You must select the iso you want to use in the Configuration dialog. You
+ will come back to this dialog should the Emulator want another disc.
+
+Creating an iso (linux, Windows XP only):
+---------------
+ To create an iso you can use the button 'Make Image'. The file
+ will be the one in the Iso Edit, and the Source Device is the CDRom or
+ DVD drive that will have the disc you want to make an image of.
+ The compression method is specified by the Compression Method Combo.
+
+ Note: This will fail if the file already exists (if it's compressed
+ a .z or .bz2 suffix will be added).
+
+Compressed isos:
+---------------
+ You can create them using the Convert button. This will create a .Z or .bz
+ file (the compressed image) and a .z.table or .bz2.table file (this is a
+ table, for speed reasons.) Both will be created in the same dir as the
+ selected image. The original image will not be deleted and/or changed. Also,
+ you can decompress a compressed image by selecting "None" in the
+ Compression Method Combo.
+
+ Note: you only can decompress the images with this program; not with
+ compress or bzip2.
+
+Compression Method:
+------------------
+ .z speed - fast compression, small blocks, table in memory.
+ .bz2 speed - average compression, 32k - 40k blocks, table in memory.
+ .bz2 size - best compression, 60k - 62k blocks, table on file.
+
+
+ Email:
diff --git a/plugins/GSdx/GPULocalMemory.cpp b/plugins/GSdx/GPULocalMemory.cpp
index 3a5a3d3a79..820b0534dd 100644
--- a/plugins/GSdx/GPULocalMemory.cpp
+++ b/plugins/GSdx/GPULocalMemory.cpp
@@ -1,662 +1,662 @@
-/*
- * Copyright (C) 2007-2009 Gabest
- * http://www.gabest.org
- *
- * 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, 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 GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "stdafx.h"
-#include "GPULocalMemory.h"
-#include "GSdx.h"
-
-const GSVector4i GPULocalMemory::m_xxxa(0x00008000);
-const GSVector4i GPULocalMemory::m_xxbx(0x00007c00);
-const GSVector4i GPULocalMemory::m_xgxx(0x000003e0);
-const GSVector4i GPULocalMemory::m_rxxx(0x0000001f);
-
-#define VM_SIZE ((1 << (12 + 11)) * sizeof(uint16))
-#define VM_ALLOC_SIZE (VM_SIZE * 2)
-#define TEX_ALLOC_SIZE (256 * 256 * (1 + 1 + 4) * 32)
-
-GPULocalMemory::GPULocalMemory()
-{
- m_scale.x = std::min(std::max(theApp.GetConfig("scale_x", 0), 0), 2);
- m_scale.y = std::min(std::max(theApp.GetConfig("scale_y", 0), 0), 2);
-
- //
-
- int size = VM_SIZE;
-
- m_vm = (uint16*)vmalloc(VM_ALLOC_SIZE, false);
-
- memset(m_vm, 0, size);
-
- //
-
- m_clut.buff = m_vm + size;
- m_clut.dirty = true;
-
- //
-
- size = TEX_ALLOC_SIZE;
-
- m_texture.buff[0] = (uint8*)vmalloc(size, false);
- m_texture.buff[1] = m_texture.buff[0] + 256 * 256 * 32;
- m_texture.buff[2] = m_texture.buff[1] + 256 * 256 * 32;
-
- memset(m_texture.buff[0], 0, size);
-
- memset(m_texture.valid, 0, sizeof(m_texture.valid));
-
- for(int y = 0, offset = 0; y < 2; y++)
- {
- for(int x = 0; x < 16; x++, offset += 256 * 256)
- {
- m_texture.page[0][y][x] = &((uint8*)m_texture.buff[0])[offset];
- m_texture.page[1][y][x] = &((uint8*)m_texture.buff[1])[offset];
- }
- }
-
- for(int y = 0, offset = 0; y < 2; y++)
- {
- for(int x = 0; x < 16; x++, offset += 256 * 256)
- {
- m_texture.page[2][y][x] = &((uint32*)m_texture.buff[2])[offset];
- }
- }
-}
-
-GPULocalMemory::~GPULocalMemory()
-{
- vmfree(m_vm, VM_ALLOC_SIZE);
-
- vmfree(m_texture.buff[0], TEX_ALLOC_SIZE);
-}
-
-const uint16* GPULocalMemory::GetCLUT(int tp, int cx, int cy)
-{
- if(m_clut.dirty || m_clut.tp != tp || m_clut.cx != cx || m_clut.cy != cy)
- {
- uint16* src = GetPixelAddressScaled(cx << 4, cy);
- uint16* dst = m_clut.buff;
-
- if(m_scale.x == 0)
- {
- memcpy(dst, src, (tp == 0 ? 16 : 256) * 2);
- }
- else if(m_scale.x == 1)
- {
- if(tp == 0)
- {
- for(int i = 0; i < 16; i++)
- {
- dst[i] = src[i * 2];
- }
- }
- else if(tp == 1)
- {
- for(int i = 0; i < 256; i++)
- {
- dst[i] = src[i * 2];
- }
- }
- }
- else if(m_scale.x == 2)
- {
- if(tp == 0)
- {
- for(int i = 0; i < 16; i++)
- {
- dst[i] = src[i * 4];
- }
- }
- else if(tp == 1)
- {
- for(int i = 0; i < 256; i++)
- {
- dst[i] = src[i * 4];
- }
- }
- }
- else
- {
- ASSERT(0);
- }
-
- m_clut.tp = tp;
- m_clut.cx = cx;
- m_clut.cy = cy;
- m_clut.dirty = false;
- }
-
- return m_clut.buff;
-}
-
-const void* GPULocalMemory::GetTexture(int tp, int tx, int ty)
-{
- if(tp == 3)
- {
- ASSERT(0);
-
- return NULL;
- }
-
- void* buff = m_texture.page[tp][ty][tx];
-
- uint32 flag = 1 << tx;
-
- if((m_texture.valid[tp][ty] & flag) == 0)
- {
- int bpp = 0;
-
- switch(tp)
- {
- case 0:
- ReadPage4(tx, ty, (uint8*)buff);
- bpp = 4;
- break;
- case 1:
- ReadPage8(tx, ty, (uint8*)buff);
- bpp = 8;
- break;
- case 2:
- case 3:
- ReadPage16(tx, ty, (uint16*)buff);
- bpp = 16;
- default:
- // FIXME: __assume(0); // vc9 generates bogus code in release mode
- break;
- }
-
- // TODO: m_state->m_perfmon.Put(GSPerfMon::Unswizzle, 256 * 256 * bpp >> 3);
-
- m_texture.valid[tp][ty] |= flag;
- }
-
- return buff;
-}
-
-void GPULocalMemory::Invalidate(const GSVector4i& r)
-{
- if(!m_clut.dirty)
- {
- if(r.top <= m_clut.cy && m_clut.cy < r.bottom)
- {
- int left = m_clut.cx << 4;
- int right = left + (m_clut.tp == 0 ? 16 : 256);
-
- if(r.left < right && r.right > left)
- {
- m_clut.dirty = true;
- }
- }
- }
-
- for(int y = 0, ye = min(r.bottom, 512), j = 0; y < ye; y += 256, j++)
- {
- if(r.top >= y + 256) continue;
-
- for(int x = 0, xe = min(r.right, 1024), i = 0; x < xe; x += 64, i++)
- {
- uint32 flag = 1 << i;
-
- if(r.left >= x + 256) continue;
-
- m_texture.valid[2][j] &= ~flag;
-
- if(r.left >= x + 128) continue;
-
- m_texture.valid[1][j] &= ~flag;
-
- if(r.left >= x + 64) continue;
-
- m_texture.valid[0][j] &= ~flag;
- }
- }
-}
-
-void GPULocalMemory::FillRect(const GSVector4i& r, uint16 c)
-{
- Invalidate(r);
-
- uint16* RESTRICT dst = GetPixelAddressScaled(r.left, r.top);
-
- int w = r.width() << m_scale.x;
- int h = r.height() << m_scale.y;
-
- int pitch = GetWidth();
-
- for(int j = 0; j < h; j++, dst += pitch)
- {
- for(int i = 0; i < w; i++)
- {
- dst[i] = c;
- }
- }
-}
-
-void GPULocalMemory::WriteRect(const GSVector4i& r, const uint16* RESTRICT src)
-{
- Invalidate(r);
-
- uint16* RESTRICT dst = GetPixelAddressScaled(r.left, r.top);
-
- int w = r.width();
- int h = r.height();
-
- int pitch = GetWidth();
-
- if(m_scale.x == 0)
- {
- for(int j = 0; j < h; j++, src += w)
- {
- for(int k = 1 << m_scale.y; k >= 1; k--, dst += pitch)
- {
- memcpy(dst, src, w * 2);
- }
- }
- }
- else if(m_scale.x == 1)
- {
- for(int j = 0; j < h; j++, src += w)
- {
- for(int k = 1 << m_scale.y; k >= 1; k--, dst += pitch)
- {
- for(int i = 0; i < w; i++)
- {
- dst[i * 2 + 0] = src[i];
- dst[i * 2 + 1] = src[i];
- }
- }
- }
- }
- else if(m_scale.x == 2)
- {
- for(int j = 0; j < h; j++, src += w)
- {
- for(int k = 1 << m_scale.y; k >= 1; k--, dst += pitch)
- {
- for(int i = 0; i < w; i++)
- {
- dst[i * 4 + 0] = src[i];
- dst[i * 4 + 1] = src[i];
- dst[i * 4 + 2] = src[i];
- dst[i * 4 + 3] = src[i];
- }
- }
- }
- }
- else
- {
- ASSERT(0);
- }
-}
-
-void GPULocalMemory::ReadRect(const GSVector4i& r, uint16* RESTRICT dst)
-{
- uint16* RESTRICT src = GetPixelAddressScaled(r.left, r.top);
-
- int w = r.width();
- int h = r.height();
-
- int pitch = GetWidth() << m_scale.y;
-
- if(m_scale.x == 0)
- {
- for(int j = 0; j < h; j++, src += pitch, dst += w)
- {
- memcpy(dst, src, w * 2);
- }
- }
- else if(m_scale.x == 1)
- {
- for(int j = 0; j < h; j++, src += pitch, dst += w)
- {
- for(int i = 0; i < w; i++)
- {
- dst[i] = src[i * 2];
- }
- }
- }
- else if(m_scale.x == 2)
- {
- for(int j = 0; j < h; j++, src += pitch, dst += w)
- {
- for(int i = 0; i < w; i++)
- {
- dst[i] = src[i * 4];
- }
- }
- }
- else
- {
- ASSERT(0);
- }
-}
-
-void GPULocalMemory::MoveRect(int sx, int sy, int dx, int dy, int w, int h)
-{
- Invalidate(GSVector4i(dx, dy, dx + w, dy + h));
-
- uint16* s = GetPixelAddressScaled(sx, sy);
- uint16* d = GetPixelAddressScaled(dx, dy);
-
- w <<= m_scale.x;
- h <<= m_scale.y;
-
- int pitch = GetWidth();
-
- for(int i = 0; i < h; i++, s += pitch, d += pitch)
- {
- memcpy(d, s, w * sizeof(uint16));
- }
-}
-
-void GPULocalMemory::ReadPage4(int tx, int ty, uint8* RESTRICT dst)
-{
- uint16* src = GetPixelAddressScaled(tx << 6, ty << 8);
-
- int pitch = GetWidth() << m_scale.y;
-
- if(m_scale.x == 0)
- {
- for(int j = 0; j < 256; j++, src += pitch, dst += 256)
- {
- for(int i = 0; i < 64; i++)
- {
- dst[i * 4 + 0] = (src[i] >> 0) & 0xf;
- dst[i * 4 + 1] = (src[i] >> 4) & 0xf;
- dst[i * 4 + 2] = (src[i] >> 8) & 0xf;
- dst[i * 4 + 3] = (src[i] >> 12) & 0xf;
- }
- }
- }
- else if(m_scale.x == 1)
- {
- for(int j = 0; j < 256; j++, src += pitch, dst += 256)
- {
- for(int i = 0; i < 64; i++)
- {
- dst[i * 4 + 0] = (src[i * 2] >> 0) & 0xf;
- dst[i * 4 + 1] = (src[i * 2] >> 4) & 0xf;
- dst[i * 4 + 2] = (src[i * 2] >> 8) & 0xf;
- dst[i * 4 + 3] = (src[i * 2] >> 12) & 0xf;
- }
- }
- }
- else if(m_scale.x == 2)
- {
- for(int j = 0; j < 256; j++, src += pitch, dst += 256)
- {
- for(int i = 0; i < 64; i++)
- {
- dst[i * 4 + 0] = (src[i * 4] >> 0) & 0xf;
- dst[i * 4 + 1] = (src[i * 4] >> 4) & 0xf;
- dst[i * 4 + 2] = (src[i * 4] >> 8) & 0xf;
- dst[i * 4 + 3] = (src[i * 4] >> 12) & 0xf;
- }
- }
- }
- else
- {
- ASSERT(0);
- }
-}
-
-void GPULocalMemory::ReadPage8(int tx, int ty, uint8* RESTRICT dst)
-{
- uint16* src = GetPixelAddressScaled(tx << 6, ty << 8);
-
- int pitch = GetWidth() << m_scale.y;
-
- if(m_scale.x == 0)
- {
- for(int j = 0; j < 256; j++, src += pitch, dst += 256)
- {
- memcpy(dst, src, 256);
- }
- }
- else if(m_scale.x == 1)
- {
- for(int j = 0; j < 256; j++, src += pitch, dst += 256)
- {
- for(int i = 0; i < 128; i++)
- {
- ((uint16*)dst)[i] = src[i * 2];
- }
- }
- }
- else if(m_scale.x == 2)
- {
- for(int j = 0; j < 256; j++, src += pitch, dst += 256)
- {
- for(int i = 0; i < 128; i++)
- {
- ((uint16*)dst)[i] = src[i * 4];
- }
- }
- }
- else
- {
- ASSERT(0);
- }
-}
-
-void GPULocalMemory::ReadPage16(int tx, int ty, uint16* RESTRICT dst)
-{
- uint16* src = GetPixelAddressScaled(tx << 6, ty << 8);
-
- int pitch = GetWidth() << m_scale.y;
-
- if(m_scale.x == 0)
- {
- for(int j = 0; j < 256; j++, src += pitch, dst += 256)
- {
- memcpy(dst, src, 512);
- }
- }
- else if(m_scale.x == 1)
- {
- for(int j = 0; j < 256; j++, src += pitch, dst += 256)
- {
- for(int i = 0; i < 256; i++)
- {
- dst[i] = src[i * 2];
- }
- }
- }
- else if(m_scale.x == 2)
- {
- for(int j = 0; j < 256; j++, src += pitch, dst += 256)
- {
- for(int i = 0; i < 256; i++)
- {
- dst[i] = src[i * 4];
- }
- }
- }
- else
- {
- ASSERT(0);
- }
-}
-
-void GPULocalMemory::ReadFrame32(const GSVector4i& r, uint32* RESTRICT dst, bool rgb24)
-{
- uint16* src = GetPixelAddress(r.left, r.top);
-
- int pitch = GetWidth();
-
- if(rgb24)
- {
- for(int i = r.top; i < r.bottom; i++, src += pitch, dst += pitch)
- {
- Expand24(src, dst, r.width());
- }
- }
- else
- {
- for(int i = r.top; i < r.bottom; i++, src += pitch, dst += pitch)
- {
- Expand16(src, dst, r.width());
- }
- }
-}
-
-void GPULocalMemory::Expand16(const uint16* RESTRICT src, uint32* RESTRICT dst, int pixels)
-{
- GSVector4i rm = m_rxxx;
- GSVector4i gm = m_xgxx;
- GSVector4i bm = m_xxbx;
- GSVector4i am = m_xxxa;
-
- GSVector4i* s = (GSVector4i*)src;
- GSVector4i* d = (GSVector4i*)dst;
-
- for(int i = 0, j = pixels >> 3; i < j; i++)
- {
- GSVector4i c = s[i];
-
- GSVector4i l = c.upl16();
- GSVector4i h = c.uph16();
-
- d[i * 2 + 0] = ((l & rm) << 3) | ((l & gm) << 6) | ((l & bm) << 9) | ((l & am) << 16);
- d[i * 2 + 1] = ((h & rm) << 3) | ((h & gm) << 6) | ((h & bm) << 9) | ((h & am) << 16);
- }
-}
-
-void GPULocalMemory::Expand24(const uint16* RESTRICT src, uint32* RESTRICT dst, int pixels)
-{
- uint8* s = (uint8*)src;
-
- if(m_scale.x == 0)
- {
- for(int i = 0; i < pixels; i += 2, s += 6)
- {
- dst[i + 0] = (s[2] << 16) | (s[1] << 8) | s[0];
- dst[i + 1] = (s[5] << 16) | (s[4] << 8) | s[3];
- }
- }
- else if(m_scale.x == 1)
- {
- for(int i = 0; i < pixels; i += 4, s += 12)
- {
- dst[i + 0] = dst[i + 1] = (s[4] << 16) | (s[1] << 8) | s[0];
- dst[i + 2] = dst[i + 3] = (s[9] << 16) | (s[8] << 8) | s[5];
- }
- }
- else if(m_scale.x == 2)
- {
- for(int i = 0; i < pixels; i += 8, s += 24)
- {
- dst[i + 0] = dst[i + 1] = dst[i + 2] = dst[i + 3] = (s[8] << 16) | (s[1] << 8) | s[0];
- dst[i + 4] = dst[i + 5] = dst[i + 6] = dst[i + 7] = (s[17] << 16) | (s[16] << 8) | s[9];
- }
- }
- else
- {
- ASSERT(0);
- }
-}
-
-#include "GSTextureSW.h"
-
-void GPULocalMemory::SaveBMP(const string& fn, const GSVector4i& r2, int tp, int cx, int cy)
-{
- GSVector4i r;
-
- r.left = r2.left << m_scale.x;
- r.top = r2.top << m_scale.y;
- r.right = r2.right << m_scale.x;
- r.bottom = r2.bottom << m_scale.y;
-
- r.left &= ~1;
- r.right &= ~1;
-
- GSTextureSW t(GSTexture::Offscreen, r.width(), r.height());
-
- GSTexture::GSMap m;
-
- if(t.Map(m, NULL))
- {
- int pitch = GetWidth();
-
- const uint16* RESTRICT src = GetPixelAddress(r.left, r.top);
- const uint16* RESTRICT clut = GetCLUT(tp, cx, cy);
-
- uint8* RESTRICT dst = m.bits;
-
- uint16* RESTRICT buff = (uint16*)_aligned_malloc(pitch * sizeof(uint16), 32);
- uint32* RESTRICT buff32 = (uint32*)_aligned_malloc(pitch * sizeof(uint32), 32);
-
- for(int j = r.top; j < r.bottom; j++, src += pitch, dst += m.pitch)
- {
- switch(tp)
- {
- case 0: // 4 bpp
-
- for(int i = 0, k = r.width() / 2; i < k; i++)
- {
- buff[i * 2 + 0] = clut[((uint8*)src)[i] & 0xf];
- buff[i * 2 + 1] = clut[((uint8*)src)[i] >> 4];
- }
-
- break;
-
- case 1: // 8 bpp
-
- for(int i = 0, k = r.width(); i < k; i++)
- {
- buff[i] = clut[((uint8*)src)[i]];
- }
-
- break;
-
- case 2: // 16 bpp;
-
- for(int i = 0, k = r.width(); i < k; i++)
- {
- buff[i] = src[i];
- }
-
- break;
-
- case 3: // 24 bpp
-
- // TODO
-
- break;
- }
-
- Expand16(buff, buff32, r.width());
-
- for(int i = 0, k = r.width(); i < k; i++)
- {
- buff32[i] = (buff32[i] & 0xff00ff00) | ((buff32[i] & 0x00ff0000) >> 16) | ((buff32[i] & 0x000000ff) << 16);
- }
-
- memcpy(dst, buff32, r.width() << 2);
- }
-
- _aligned_free(buff);
- _aligned_free(buff32);
-
- t.Unmap();
-
- t.Save(fn);
- }
-}
+/*
+ * Copyright (C) 2007-2009 Gabest
+ * http://www.gabest.org
+ *
+ * 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, 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 GNU Make; see the file COPYING. If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#include "stdafx.h"
+#include "GPULocalMemory.h"
+#include "GSdx.h"
+
+const GSVector4i GPULocalMemory::m_xxxa(0x00008000);
+const GSVector4i GPULocalMemory::m_xxbx(0x00007c00);
+const GSVector4i GPULocalMemory::m_xgxx(0x000003e0);
+const GSVector4i GPULocalMemory::m_rxxx(0x0000001f);
+
+#define VM_SIZE ((1 << (12 + 11)) * sizeof(uint16))
+#define VM_ALLOC_SIZE (VM_SIZE * 2)
+#define TEX_ALLOC_SIZE (256 * 256 * (1 + 1 + 4) * 32)
+
+GPULocalMemory::GPULocalMemory()
+{
+ m_scale.x = std::min(std::max(theApp.GetConfig("scale_x", 0), 0), 2);
+ m_scale.y = std::min(std::max(theApp.GetConfig("scale_y", 0), 0), 2);
+
+ //
+
+ int size = VM_SIZE;
+
+ m_vm = (uint16*)vmalloc(VM_ALLOC_SIZE, false);
+
+ memset(m_vm, 0, size);
+
+ //
+
+ m_clut.buff = m_vm + size;
+ m_clut.dirty = true;
+
+ //
+
+ size = TEX_ALLOC_SIZE;
+
+ m_texture.buff[0] = (uint8*)vmalloc(size, false);
+ m_texture.buff[1] = m_texture.buff[0] + 256 * 256 * 32;
+ m_texture.buff[2] = m_texture.buff[1] + 256 * 256 * 32;
+
+ memset(m_texture.buff[0], 0, size);
+
+ memset(m_texture.valid, 0, sizeof(m_texture.valid));
+
+ for(int y = 0, offset = 0; y < 2; y++)
+ {
+ for(int x = 0; x < 16; x++, offset += 256 * 256)
+ {
+ m_texture.page[0][y][x] = &((uint8*)m_texture.buff[0])[offset];
+ m_texture.page[1][y][x] = &((uint8*)m_texture.buff[1])[offset];
+ }
+ }
+
+ for(int y = 0, offset = 0; y < 2; y++)
+ {
+ for(int x = 0; x < 16; x++, offset += 256 * 256)
+ {
+ m_texture.page[2][y][x] = &((uint32*)m_texture.buff[2])[offset];
+ }
+ }
+}
+
+GPULocalMemory::~GPULocalMemory()
+{
+ vmfree(m_vm, VM_ALLOC_SIZE);
+
+ vmfree(m_texture.buff[0], TEX_ALLOC_SIZE);
+}
+
+const uint16* GPULocalMemory::GetCLUT(int tp, int cx, int cy)
+{
+ if(m_clut.dirty || m_clut.tp != tp || m_clut.cx != cx || m_clut.cy != cy)
+ {
+ uint16* src = GetPixelAddressScaled(cx << 4, cy);
+ uint16* dst = m_clut.buff;
+
+ if(m_scale.x == 0)
+ {
+ memcpy(dst, src, (tp == 0 ? 16 : 256) * 2);
+ }
+ else if(m_scale.x == 1)
+ {
+ if(tp == 0)
+ {
+ for(int i = 0; i < 16; i++)
+ {
+ dst[i] = src[i * 2];
+ }
+ }
+ else if(tp == 1)
+ {
+ for(int i = 0; i < 256; i++)
+ {
+ dst[i] = src[i * 2];
+ }
+ }
+ }
+ else if(m_scale.x == 2)
+ {
+ if(tp == 0)
+ {
+ for(int i = 0; i < 16; i++)
+ {
+ dst[i] = src[i * 4];
+ }
+ }
+ else if(tp == 1)
+ {
+ for(int i = 0; i < 256; i++)
+ {
+ dst[i] = src[i * 4];
+ }
+ }
+ }
+ else
+ {
+ ASSERT(0);
+ }
+
+ m_clut.tp = tp;
+ m_clut.cx = cx;
+ m_clut.cy = cy;
+ m_clut.dirty = false;
+ }
+
+ return m_clut.buff;
+}
+
+const void* GPULocalMemory::GetTexture(int tp, int tx, int ty)
+{
+ if(tp == 3)
+ {
+ ASSERT(0);
+
+ return NULL;
+ }
+
+ void* buff = m_texture.page[tp][ty][tx];
+
+ uint32 flag = 1 << tx;
+
+ if((m_texture.valid[tp][ty] & flag) == 0)
+ {
+ int bpp = 0;
+
+ switch(tp)
+ {
+ case 0:
+ ReadPage4(tx, ty, (uint8*)buff);
+ bpp = 4;
+ break;
+ case 1:
+ ReadPage8(tx, ty, (uint8*)buff);
+ bpp = 8;
+ break;
+ case 2:
+ case 3:
+ ReadPage16(tx, ty, (uint16*)buff);
+ bpp = 16;
+ default:
+ // FIXME: __assume(0); // vc9 generates bogus code in release mode
+ break;
+ }
+
+ // TODO: m_state->m_perfmon.Put(GSPerfMon::Unswizzle, 256 * 256 * bpp >> 3);
+
+ m_texture.valid[tp][ty] |= flag;
+ }
+
+ return buff;
+}
+
+void GPULocalMemory::Invalidate(const GSVector4i& r)
+{
+ if(!m_clut.dirty)
+ {
+ if(r.top <= m_clut.cy && m_clut.cy < r.bottom)
+ {
+ int left = m_clut.cx << 4;
+ int right = left + (m_clut.tp == 0 ? 16 : 256);
+
+ if(r.left < right && r.right > left)
+ {
+ m_clut.dirty = true;
+ }
+ }
+ }
+
+ for(int y = 0, ye = min(r.bottom, 512), j = 0; y < ye; y += 256, j++)
+ {
+ if(r.top >= y + 256) continue;
+
+ for(int x = 0, xe = min(r.right, 1024), i = 0; x < xe; x += 64, i++)
+ {
+ uint32 flag = 1 << i;
+
+ if(r.left >= x + 256) continue;
+
+ m_texture.valid[2][j] &= ~flag;
+
+ if(r.left >= x + 128) continue;
+
+ m_texture.valid[1][j] &= ~flag;
+
+ if(r.left >= x + 64) continue;
+
+ m_texture.valid[0][j] &= ~flag;
+ }
+ }
+}
+
+void GPULocalMemory::FillRect(const GSVector4i& r, uint16 c)
+{
+ Invalidate(r);
+
+ uint16* RESTRICT dst = GetPixelAddressScaled(r.left, r.top);
+
+ int w = r.width() << m_scale.x;
+ int h = r.height() << m_scale.y;
+
+ int pitch = GetWidth();
+
+ for(int j = 0; j < h; j++, dst += pitch)
+ {
+ for(int i = 0; i < w; i++)
+ {
+ dst[i] = c;
+ }
+ }
+}
+
+void GPULocalMemory::WriteRect(const GSVector4i& r, const uint16* RESTRICT src)
+{
+ Invalidate(r);
+
+ uint16* RESTRICT dst = GetPixelAddressScaled(r.left, r.top);
+
+ int w = r.width();
+ int h = r.height();
+
+ int pitch = GetWidth();
+
+ if(m_scale.x == 0)
+ {
+ for(int j = 0; j < h; j++, src += w)
+ {
+ for(int k = 1 << m_scale.y; k >= 1; k--, dst += pitch)
+ {
+ memcpy(dst, src, w * 2);
+ }
+ }
+ }
+ else if(m_scale.x == 1)
+ {
+ for(int j = 0; j < h; j++, src += w)
+ {
+ for(int k = 1 << m_scale.y; k >= 1; k--, dst += pitch)
+ {
+ for(int i = 0; i < w; i++)
+ {
+ dst[i * 2 + 0] = src[i];
+ dst[i * 2 + 1] = src[i];
+ }
+ }
+ }
+ }
+ else if(m_scale.x == 2)
+ {
+ for(int j = 0; j < h; j++, src += w)
+ {
+ for(int k = 1 << m_scale.y; k >= 1; k--, dst += pitch)
+ {
+ for(int i = 0; i < w; i++)
+ {
+ dst[i * 4 + 0] = src[i];
+ dst[i * 4 + 1] = src[i];
+ dst[i * 4 + 2] = src[i];
+ dst[i * 4 + 3] = src[i];
+ }
+ }
+ }
+ }
+ else
+ {
+ ASSERT(0);
+ }
+}
+
+void GPULocalMemory::ReadRect(const GSVector4i& r, uint16* RESTRICT dst)
+{
+ uint16* RESTRICT src = GetPixelAddressScaled(r.left, r.top);
+
+ int w = r.width();
+ int h = r.height();
+
+ int pitch = GetWidth() << m_scale.y;
+
+ if(m_scale.x == 0)
+ {
+ for(int j = 0; j < h; j++, src += pitch, dst += w)
+ {
+ memcpy(dst, src, w * 2);
+ }
+ }
+ else if(m_scale.x == 1)
+ {
+ for(int j = 0; j < h; j++, src += pitch, dst += w)
+ {
+ for(int i = 0; i < w; i++)
+ {
+ dst[i] = src[i * 2];
+ }
+ }
+ }
+ else if(m_scale.x == 2)
+ {
+ for(int j = 0; j < h; j++, src += pitch, dst += w)
+ {
+ for(int i = 0; i < w; i++)
+ {
+ dst[i] = src[i * 4];
+ }
+ }
+ }
+ else
+ {
+ ASSERT(0);
+ }
+}
+
+void GPULocalMemory::MoveRect(int sx, int sy, int dx, int dy, int w, int h)
+{
+ Invalidate(GSVector4i(dx, dy, dx + w, dy + h));
+
+ uint16* s = GetPixelAddressScaled(sx, sy);
+ uint16* d = GetPixelAddressScaled(dx, dy);
+
+ w <<= m_scale.x;
+ h <<= m_scale.y;
+
+ int pitch = GetWidth();
+
+ for(int i = 0; i < h; i++, s += pitch, d += pitch)
+ {
+ memcpy(d, s, w * sizeof(uint16));
+ }
+}
+
+void GPULocalMemory::ReadPage4(int tx, int ty, uint8* RESTRICT dst)
+{
+ uint16* src = GetPixelAddressScaled(tx << 6, ty << 8);
+
+ int pitch = GetWidth() << m_scale.y;
+
+ if(m_scale.x == 0)
+ {
+ for(int j = 0; j < 256; j++, src += pitch, dst += 256)
+ {
+ for(int i = 0; i < 64; i++)
+ {
+ dst[i * 4 + 0] = (src[i] >> 0) & 0xf;
+ dst[i * 4 + 1] = (src[i] >> 4) & 0xf;
+ dst[i * 4 + 2] = (src[i] >> 8) & 0xf;
+ dst[i * 4 + 3] = (src[i] >> 12) & 0xf;
+ }
+ }
+ }
+ else if(m_scale.x == 1)
+ {
+ for(int j = 0; j < 256; j++, src += pitch, dst += 256)
+ {
+ for(int i = 0; i < 64; i++)
+ {
+ dst[i * 4 + 0] = (src[i * 2] >> 0) & 0xf;
+ dst[i * 4 + 1] = (src[i * 2] >> 4) & 0xf;
+ dst[i * 4 + 2] = (src[i * 2] >> 8) & 0xf;
+ dst[i * 4 + 3] = (src[i * 2] >> 12) & 0xf;
+ }
+ }
+ }
+ else if(m_scale.x == 2)
+ {
+ for(int j = 0; j < 256; j++, src += pitch, dst += 256)
+ {
+ for(int i = 0; i < 64; i++)
+ {
+ dst[i * 4 + 0] = (src[i * 4] >> 0) & 0xf;
+ dst[i * 4 + 1] = (src[i * 4] >> 4) & 0xf;
+ dst[i * 4 + 2] = (src[i * 4] >> 8) & 0xf;
+ dst[i * 4 + 3] = (src[i * 4] >> 12) & 0xf;
+ }
+ }
+ }
+ else
+ {
+ ASSERT(0);
+ }
+}
+
+void GPULocalMemory::ReadPage8(int tx, int ty, uint8* RESTRICT dst)
+{
+ uint16* src = GetPixelAddressScaled(tx << 6, ty << 8);
+
+ int pitch = GetWidth() << m_scale.y;
+
+ if(m_scale.x == 0)
+ {
+ for(int j = 0; j < 256; j++, src += pitch, dst += 256)
+ {
+ memcpy(dst, src, 256);
+ }
+ }
+ else if(m_scale.x == 1)
+ {
+ for(int j = 0; j < 256; j++, src += pitch, dst += 256)
+ {
+ for(int i = 0; i < 128; i++)
+ {
+ ((uint16*)dst)[i] = src[i * 2];
+ }
+ }
+ }
+ else if(m_scale.x == 2)
+ {
+ for(int j = 0; j < 256; j++, src += pitch, dst += 256)
+ {
+ for(int i = 0; i < 128; i++)
+ {
+ ((uint16*)dst)[i] = src[i * 4];
+ }
+ }
+ }
+ else
+ {
+ ASSERT(0);
+ }
+}
+
+void GPULocalMemory::ReadPage16(int tx, int ty, uint16* RESTRICT dst)
+{
+ uint16* src = GetPixelAddressScaled(tx << 6, ty << 8);
+
+ int pitch = GetWidth() << m_scale.y;
+
+ if(m_scale.x == 0)
+ {
+ for(int j = 0; j < 256; j++, src += pitch, dst += 256)
+ {
+ memcpy(dst, src, 512);
+ }
+ }
+ else if(m_scale.x == 1)
+ {
+ for(int j = 0; j < 256; j++, src += pitch, dst += 256)
+ {
+ for(int i = 0; i < 256; i++)
+ {
+ dst[i] = src[i * 2];
+ }
+ }
+ }
+ else if(m_scale.x == 2)
+ {
+ for(int j = 0; j < 256; j++, src += pitch, dst += 256)
+ {
+ for(int i = 0; i < 256; i++)
+ {
+ dst[i] = src[i * 4];
+ }
+ }
+ }
+ else
+ {
+ ASSERT(0);
+ }
+}
+
+void GPULocalMemory::ReadFrame32(const GSVector4i& r, uint32* RESTRICT dst, bool rgb24)
+{
+ uint16* src = GetPixelAddress(r.left, r.top);
+
+ int pitch = GetWidth();
+
+ if(rgb24)
+ {
+ for(int i = r.top; i < r.bottom; i++, src += pitch, dst += pitch)
+ {
+ Expand24(src, dst, r.width());
+ }
+ }
+ else
+ {
+ for(int i = r.top; i < r.bottom; i++, src += pitch, dst += pitch)
+ {
+ Expand16(src, dst, r.width());
+ }
+ }
+}
+
+void GPULocalMemory::Expand16(const uint16* RESTRICT src, uint32* RESTRICT dst, int pixels)
+{
+ GSVector4i rm = m_rxxx;
+ GSVector4i gm = m_xgxx;
+ GSVector4i bm = m_xxbx;
+ GSVector4i am = m_xxxa;
+
+ GSVector4i* s = (GSVector4i*)src;
+ GSVector4i* d = (GSVector4i*)dst;
+
+ for(int i = 0, j = pixels >> 3; i < j; i++)
+ {
+ GSVector4i c = s[i];
+
+ GSVector4i l = c.upl16();
+ GSVector4i h = c.uph16();
+
+ d[i * 2 + 0] = ((l & rm) << 3) | ((l & gm) << 6) | ((l & bm) << 9) | ((l & am) << 16);
+ d[i * 2 + 1] = ((h & rm) << 3) | ((h & gm) << 6) | ((h & bm) << 9) | ((h & am) << 16);
+ }
+}
+
+void GPULocalMemory::Expand24(const uint16* RESTRICT src, uint32* RESTRICT dst, int pixels)
+{
+ uint8* s = (uint8*)src;
+
+ if(m_scale.x == 0)
+ {
+ for(int i = 0; i < pixels; i += 2, s += 6)
+ {
+ dst[i + 0] = (s[2] << 16) | (s[1] << 8) | s[0];
+ dst[i + 1] = (s[5] << 16) | (s[4] << 8) | s[3];
+ }
+ }
+ else if(m_scale.x == 1)
+ {
+ for(int i = 0; i < pixels; i += 4, s += 12)
+ {
+ dst[i + 0] = dst[i + 1] = (s[4] << 16) | (s[1] << 8) | s[0];
+ dst[i + 2] = dst[i + 3] = (s[9] << 16) | (s[8] << 8) | s[5];
+ }
+ }
+ else if(m_scale.x == 2)
+ {
+ for(int i = 0; i < pixels; i += 8, s += 24)
+ {
+ dst[i + 0] = dst[i + 1] = dst[i + 2] = dst[i + 3] = (s[8] << 16) | (s[1] << 8) | s[0];
+ dst[i + 4] = dst[i + 5] = dst[i + 6] = dst[i + 7] = (s[17] << 16) | (s[16] << 8) | s[9];
+ }
+ }
+ else
+ {
+ ASSERT(0);
+ }
+}
+
+#include "GSTextureSW.h"
+
+void GPULocalMemory::SaveBMP(const string& fn, const GSVector4i& r2, int tp, int cx, int cy)
+{
+ GSVector4i r;
+
+ r.left = r2.left << m_scale.x;
+ r.top = r2.top << m_scale.y;
+ r.right = r2.right << m_scale.x;
+ r.bottom = r2.bottom << m_scale.y;
+
+ r.left &= ~1;
+ r.right &= ~1;
+
+ GSTextureSW t(GSTexture::Offscreen, r.width(), r.height());
+
+ GSTexture::GSMap m;
+
+ if(t.Map(m, NULL))
+ {
+ int pitch = GetWidth();
+
+ const uint16* RESTRICT src = GetPixelAddress(r.left, r.top);
+ const uint16* RESTRICT clut = GetCLUT(tp, cx, cy);
+
+ uint8* RESTRICT dst = m.bits;
+
+ uint16* RESTRICT buff = (uint16*)_aligned_malloc(pitch * sizeof(uint16), 32);
+ uint32* RESTRICT buff32 = (uint32*)_aligned_malloc(pitch * sizeof(uint32), 32);
+
+ for(int j = r.top; j < r.bottom; j++, src += pitch, dst += m.pitch)
+ {
+ switch(tp)
+ {
+ case 0: // 4 bpp
+
+ for(int i = 0, k = r.width() / 2; i < k; i++)
+ {
+ buff[i * 2 + 0] = clut[((uint8*)src)[i] & 0xf];
+ buff[i * 2 + 1] = clut[((uint8*)src)[i] >> 4];
+ }
+
+ break;
+
+ case 1: // 8 bpp
+
+ for(int i = 0, k = r.width(); i < k; i++)
+ {
+ buff[i] = clut[((uint8*)src)[i]];
+ }
+
+ break;
+
+ case 2: // 16 bpp;
+
+ for(int i = 0, k = r.width(); i < k; i++)
+ {
+ buff[i] = src[i];
+ }
+
+ break;
+
+ case 3: // 24 bpp
+
+ // TODO
+
+ break;
+ }
+
+ Expand16(buff, buff32, r.width());
+
+ for(int i = 0, k = r.width(); i < k; i++)
+ {
+ buff32[i] = (buff32[i] & 0xff00ff00) | ((buff32[i] & 0x00ff0000) >> 16) | ((buff32[i] & 0x000000ff) << 16);
+ }
+
+ memcpy(dst, buff32, r.width() << 2);
+ }
+
+ _aligned_free(buff);
+ _aligned_free(buff32);
+
+ t.Unmap();
+
+ t.Save(fn);
+ }
+}
diff --git a/plugins/PadNull/ReadMe.txt b/plugins/PadNull/ReadMe.txt
index 75019a2573..1eed826cd7 100644
--- a/plugins/PadNull/ReadMe.txt
+++ b/plugins/PadNull/ReadMe.txt
@@ -1,23 +1,23 @@
-PadNull v0.1
--------------
-
- This is an extension to use with play station2 emulators
- as PCSX2 (only one right now).
- The plugin is free open source code.
-
-Usage:
------
- Place the file "libPadNull.so.0.1.0" (linux) or "PadNull.dll" (win32)
- at the Plugin directory of the Emulator to use it.
-
-Changes:
--------
- v0.1:
- * First Release
- * Tested with Pcsx2
-
-Authors:
--------
-arcum42@gmail.com
-
-
+PadNull v0.1
+-------------
+
+ This is an extension to use with play station2 emulators
+ as PCSX2 (only one right now).
+ The plugin is free open source code.
+
+Usage:
+-----
+ Place the file "libPadNull.so.0.1.0" (linux) or "PadNull.dll" (win32)
+ at the Plugin directory of the Emulator to use it.
+
+Changes:
+-------
+ v0.1:
+ * First Release
+ * Tested with Pcsx2
+
+Authors:
+-------
+arcum42@gmail.com
+
+
diff --git a/plugins/cdvdGigaherz/src/Windows/cdvdGigaherz.rc b/plugins/cdvdGigaherz/src/Windows/cdvdGigaherz.rc
index 97b8dec37f..4c1dd43508 100644
--- a/plugins/cdvdGigaherz/src/Windows/cdvdGigaherz.rc
+++ b/plugins/cdvdGigaherz/src/Windows/cdvdGigaherz.rc
@@ -1,99 +1,99 @@
-// Microsoft Visual C++ generated resource script.
-//
-#include "resource.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "afxres.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// Spanish resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ESN)
-#ifdef _WIN32
-LANGUAGE LANG_SPANISH, SUBLANG_SPANISH_MODERN
-#pragma code_page(1252)
-#endif //_WIN32
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#include ""afxres.h""\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE
-BEGIN
- "\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Dialog
-//
-
-IDD_CONFIG DIALOGEX 0, 0, 184, 77
-STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
-CAPTION "cdvdGigaherz"
-FONT 8, "MS Sans Serif", 0, 0, 0x0
-BEGIN
- DEFPUSHBUTTON "OK",IDOK,75,59,50,14
- PUSHBUTTON "Cancel",IDCANCEL,129,59,50,14
- COMBOBOX IDC_DRIVE,15,20,160,64,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
- GROUPBOX "Source drive...",IDC_STATIC,7,7,172,48
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// DESIGNINFO
-//
-
-#ifdef APSTUDIO_INVOKED
-GUIDELINES DESIGNINFO
-BEGIN
- IDD_CONFIG, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 179
- TOPMARGIN, 7
- BOTTOMMARGIN, 73
- END
-END
-#endif // APSTUDIO_INVOKED
-
-#endif // Spanish resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
+// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// Spanish resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ESN)
+#ifdef _WIN32
+LANGUAGE LANG_SPANISH, SUBLANG_SPANISH_MODERN
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#include ""afxres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_CONFIG DIALOGEX 0, 0, 184, 77
+STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "cdvdGigaherz"
+FONT 8, "MS Sans Serif", 0, 0, 0x0
+BEGIN
+ DEFPUSHBUTTON "OK",IDOK,75,59,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,129,59,50,14
+ COMBOBOX IDC_DRIVE,15,20,160,64,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ GROUPBOX "Source drive...",IDC_STATIC,7,7,172,48
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_CONFIG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 179
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 73
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+#endif // Spanish resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/plugins/cdvdGigaherz/src/Windows/plugin.def b/plugins/cdvdGigaherz/src/Windows/plugin.def
index e030a8ec58..dcd1f5bf87 100644
--- a/plugins/cdvdGigaherz/src/Windows/plugin.def
+++ b/plugins/cdvdGigaherz/src/Windows/plugin.def
@@ -1,26 +1,26 @@
-EXPORTS
- PS2EgetLibType @2
- PS2EgetLibName @3
- PS2EgetLibVersion2 @4
- CDVDinit @5
- CDVDshutdown @6
- CDVDopen @7
- CDVDclose @8
- CDVDreadTrack @9
- CDVDgetBuffer @10
- CDVDreadSubQ @11
- CDVDgetTN @12
- CDVDgetTD @13
- CDVDgetTOC @14
- CDVDgetDiskType @15
- CDVDgetTrayStatus @16
- CDVDctrlTrayOpen @17
- CDVDctrlTrayClose @18
- CDVDconfigure @19
- CDVDtest @20
- CDVDabout @21
- CDVDnewDiskCB @22
- CDVDgetBuffer2 @23
- CDVDreadSector @24
- CDVDgetDualInfo @25
- CDVDsetSettingsDir @26
+EXPORTS
+ PS2EgetLibType @2
+ PS2EgetLibName @3
+ PS2EgetLibVersion2 @4
+ CDVDinit @5
+ CDVDshutdown @6
+ CDVDopen @7
+ CDVDclose @8
+ CDVDreadTrack @9
+ CDVDgetBuffer @10
+ CDVDreadSubQ @11
+ CDVDgetTN @12
+ CDVDgetTD @13
+ CDVDgetTOC @14
+ CDVDgetDiskType @15
+ CDVDgetTrayStatus @16
+ CDVDctrlTrayOpen @17
+ CDVDctrlTrayClose @18
+ CDVDconfigure @19
+ CDVDtest @20
+ CDVDabout @21
+ CDVDnewDiskCB @22
+ CDVDgetBuffer2 @23
+ CDVDreadSector @24
+ CDVDgetDualInfo @25
+ CDVDsetSettingsDir @26
diff --git a/plugins/spu2-x/src/WavFile.cpp b/plugins/spu2-x/src/WavFile.cpp
index 30c0988e8a..dc0953ace3 100644
--- a/plugins/spu2-x/src/WavFile.cpp
+++ b/plugins/spu2-x/src/WavFile.cpp
@@ -1,149 +1,149 @@
-/* SPU2-X, A plugin for Emulating the Sound Processing Unit of the Playstation 2
- * Developed and maintained by the Pcsx2 Development Team.
- *
- * The file is based on WavFile.h from SoundTouch library.
- * Original portions are (c) 2009 by Olli Parviainen (oparviai 'at' iki.fi)
- *
- * SPU2-X 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.
- *
- * SPU2-X 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with SPU2-X. If not, see .
- */
-
-// Note the file is mostly a copy paste of the WavFile.h from SoundTouch library. It was
-// shrunken to support only output 16 bits wav files
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "WavFile.h"
-
-using namespace std;
-
-static const char riffStr[] = "RIFF";
-static const char waveStr[] = "WAVE";
-static const char fmtStr[] = "fmt ";
-static const char dataStr[] = "data";
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// Class WavOutFile
-//
-
-WavOutFile::WavOutFile(const char *fileName, int sampleRate, int bits, int channels)
-{
- bytesWritten = 0;
- fptr = fopen(fileName, "wb");
- if (fptr == NULL)
- {
- string msg = "Error : Unable to open file \"";
- msg += fileName;
- msg += "\" for writing.";
- //pmsg = msg.c_str;
- throw runtime_error(msg);
- }
-
- fillInHeader(sampleRate, bits, channels);
- writeHeader();
-}
-
-
-WavOutFile::~WavOutFile()
-{
- finishHeader();
- if (fptr) fclose(fptr);
- fptr = NULL;
-}
-
-
-
-void WavOutFile::fillInHeader(uint sampleRate, uint bits, uint channels)
-{
- // fill in the 'riff' part..
-
- // copy string 'RIFF' to riff_char
- memcpy(&(header.riff.riff_char), riffStr, 4);
- // package_len unknown so far
- header.riff.package_len = 0;
- // copy string 'WAVE' to wave
- memcpy(&(header.riff.wave), waveStr, 4);
-
-
- // fill in the 'format' part..
-
- // copy string 'fmt ' to fmt
- memcpy(&(header.format.fmt), fmtStr, 4);
-
- header.format.format_len = 0x10;
- header.format.fixed = 1;
- header.format.channel_number = (short)channels;
- header.format.sample_rate = (int)sampleRate;
- header.format.bits_per_sample = (short)bits;
- header.format.byte_per_sample = (short)(bits * channels / 8);
- header.format.byte_rate = header.format.byte_per_sample * (int)sampleRate;
- header.format.sample_rate = (int)sampleRate;
-
- // fill in the 'data' part..
-
- // copy string 'data' to data_field
- memcpy(&(header.data.data_field), dataStr, 4);
- // data_len unknown so far
- header.data.data_len = 0;
-}
-
-
-void WavOutFile::finishHeader()
-{
- // supplement the file length into the header structure
- header.riff.package_len = bytesWritten + 36;
- header.data.data_len = bytesWritten;
-
- writeHeader();
-}
-
-
-
-void WavOutFile::writeHeader()
-{
- int res;
-
- // write the supplemented header in the beginning of the file
- fseek(fptr, 0, SEEK_SET);
- res = fwrite(&header, sizeof(header), 1, fptr);
- if (res != 1)
- {
- throw runtime_error("Error while writing to a wav file.");
- }
-
- // jump back to the end of the file
- fseek(fptr, 0, SEEK_END);
-}
-
-
-void WavOutFile::write(const short *buffer, int numElems)
-{
- int res;
-
- // 16bit format & 16 bit samples
-
- assert(header.format.bits_per_sample == 16);
- if (numElems < 1) return; // nothing to do
-
- res = fwrite(buffer, 2, numElems, fptr);
-
- if (res != numElems)
- {
- throw runtime_error("Error while writing to a wav file.");
- }
- bytesWritten += 2 * numElems;
-}
+/* SPU2-X, A plugin for Emulating the Sound Processing Unit of the Playstation 2
+ * Developed and maintained by the Pcsx2 Development Team.
+ *
+ * The file is based on WavFile.h from SoundTouch library.
+ * Original portions are (c) 2009 by Olli Parviainen (oparviai 'at' iki.fi)
+ *
+ * SPU2-X 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.
+ *
+ * SPU2-X 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with SPU2-X. If not, see .
+ */
+
+// Note the file is mostly a copy paste of the WavFile.h from SoundTouch library. It was
+// shrunken to support only output 16 bits wav files
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "WavFile.h"
+
+using namespace std;
+
+static const char riffStr[] = "RIFF";
+static const char waveStr[] = "WAVE";
+static const char fmtStr[] = "fmt ";
+static const char dataStr[] = "data";
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// Class WavOutFile
+//
+
+WavOutFile::WavOutFile(const char *fileName, int sampleRate, int bits, int channels)
+{
+ bytesWritten = 0;
+ fptr = fopen(fileName, "wb");
+ if (fptr == NULL)
+ {
+ string msg = "Error : Unable to open file \"";
+ msg += fileName;
+ msg += "\" for writing.";
+ //pmsg = msg.c_str;
+ throw runtime_error(msg);
+ }
+
+ fillInHeader(sampleRate, bits, channels);
+ writeHeader();
+}
+
+
+WavOutFile::~WavOutFile()
+{
+ finishHeader();
+ if (fptr) fclose(fptr);
+ fptr = NULL;
+}
+
+
+
+void WavOutFile::fillInHeader(uint sampleRate, uint bits, uint channels)
+{
+ // fill in the 'riff' part..
+
+ // copy string 'RIFF' to riff_char
+ memcpy(&(header.riff.riff_char), riffStr, 4);
+ // package_len unknown so far
+ header.riff.package_len = 0;
+ // copy string 'WAVE' to wave
+ memcpy(&(header.riff.wave), waveStr, 4);
+
+
+ // fill in the 'format' part..
+
+ // copy string 'fmt ' to fmt
+ memcpy(&(header.format.fmt), fmtStr, 4);
+
+ header.format.format_len = 0x10;
+ header.format.fixed = 1;
+ header.format.channel_number = (short)channels;
+ header.format.sample_rate = (int)sampleRate;
+ header.format.bits_per_sample = (short)bits;
+ header.format.byte_per_sample = (short)(bits * channels / 8);
+ header.format.byte_rate = header.format.byte_per_sample * (int)sampleRate;
+ header.format.sample_rate = (int)sampleRate;
+
+ // fill in the 'data' part..
+
+ // copy string 'data' to data_field
+ memcpy(&(header.data.data_field), dataStr, 4);
+ // data_len unknown so far
+ header.data.data_len = 0;
+}
+
+
+void WavOutFile::finishHeader()
+{
+ // supplement the file length into the header structure
+ header.riff.package_len = bytesWritten + 36;
+ header.data.data_len = bytesWritten;
+
+ writeHeader();
+}
+
+
+
+void WavOutFile::writeHeader()
+{
+ int res;
+
+ // write the supplemented header in the beginning of the file
+ fseek(fptr, 0, SEEK_SET);
+ res = fwrite(&header, sizeof(header), 1, fptr);
+ if (res != 1)
+ {
+ throw runtime_error("Error while writing to a wav file.");
+ }
+
+ // jump back to the end of the file
+ fseek(fptr, 0, SEEK_END);
+}
+
+
+void WavOutFile::write(const short *buffer, int numElems)
+{
+ int res;
+
+ // 16bit format & 16 bit samples
+
+ assert(header.format.bits_per_sample == 16);
+ if (numElems < 1) return; // nothing to do
+
+ res = fwrite(buffer, 2, numElems, fptr);
+
+ if (res != numElems)
+ {
+ throw runtime_error("Error while writing to a wav file.");
+ }
+ bytesWritten += 2 * numElems;
+}
diff --git a/plugins/spu2-x/src/WavFile.h b/plugins/spu2-x/src/WavFile.h
index 7d75c4bac4..2e07f97edb 100644
--- a/plugins/spu2-x/src/WavFile.h
+++ b/plugins/spu2-x/src/WavFile.h
@@ -1,113 +1,113 @@
-/* SPU2-X, A plugin for Emulating the Sound Processing Unit of the Playstation 2
- * Developed and maintained by the Pcsx2 Development Team.
- *
- * The file is based on WavFile.h from SoundTouch library.
- * Original portions are (c) 2009 by Olli Parviainen (oparviai 'at' iki.fi)
- *
- * SPU2-X 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.
- *
- * SPU2-X 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with SPU2-X. If not, see .
- */
-
-// Note the file is mostly a copy paste of the WavFile.h from SoundTouch library. It was
-// shrunken to support only output 16 bits wav files
-
-#ifndef WAVFILE_H
-#define WAVFILE_H
-
-#include
-
-#ifndef uint
-typedef unsigned int uint;
-#endif
-
-
-/// WAV audio file 'riff' section header
-typedef struct
-{
- char riff_char[4];
- int package_len;
- char wave[4];
-} WavRiff;
-
-/// WAV audio file 'format' section header
-typedef struct
-{
- char fmt[4];
- int format_len;
- short fixed;
- short channel_number;
- int sample_rate;
- int byte_rate;
- short byte_per_sample;
- short bits_per_sample;
-} WavFormat;
-
-/// WAV audio file 'data' section header
-typedef struct
-{
- char data_field[4];
- uint data_len;
-} WavData;
-
-
-/// WAV audio file header
-typedef struct
-{
- WavRiff riff;
- WavFormat format;
- WavData data;
-} WavHeader;
-
-
-/// Class for writing WAV audio files.
-class WavOutFile
-{
-private:
- /// Pointer to the WAV file
- FILE *fptr;
-
- /// WAV file header data.
- WavHeader header;
-
- /// Counter of how many bytes have been written to the file so far.
- int bytesWritten;
-
- /// Fills in WAV file header information.
- void fillInHeader(const uint sampleRate, const uint bits, const uint channels);
-
- /// Finishes the WAV file header by supplementing information of amount of
- /// data written to file etc
- void finishHeader();
-
- /// Writes the WAV file header.
- void writeHeader();
-
-public:
- /// Constructor: Creates a new WAV file. Throws a 'runtime_error' exception
- /// if file creation fails.
- WavOutFile(const char *fileName, ///< Filename
- int sampleRate, ///< Sample rate (e.g. 44100 etc)
- int bits, ///< Bits per sample (8 or 16 bits)
- int channels ///< Number of channels (1=mono, 2=stereo)
- );
-
- /// Destructor: Finalizes & closes the WAV file.
- ~WavOutFile();
-
- /// Write data to WAV file. Throws a 'runtime_error' exception if writing to
- /// file fails.
- void write(const short *buffer, ///< Pointer to sample data buffer.
- int numElems ///< How many array items are to be written to file.
- );
-
-};
-
-#endif
+/* SPU2-X, A plugin for Emulating the Sound Processing Unit of the Playstation 2
+ * Developed and maintained by the Pcsx2 Development Team.
+ *
+ * The file is based on WavFile.h from SoundTouch library.
+ * Original portions are (c) 2009 by Olli Parviainen (oparviai 'at' iki.fi)
+ *
+ * SPU2-X 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.
+ *
+ * SPU2-X 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with SPU2-X. If not, see .
+ */
+
+// Note the file is mostly a copy paste of the WavFile.h from SoundTouch library. It was
+// shrunken to support only output 16 bits wav files
+
+#ifndef WAVFILE_H
+#define WAVFILE_H
+
+#include
+
+#ifndef uint
+typedef unsigned int uint;
+#endif
+
+
+/// WAV audio file 'riff' section header
+typedef struct
+{
+ char riff_char[4];
+ int package_len;
+ char wave[4];
+} WavRiff;
+
+/// WAV audio file 'format' section header
+typedef struct
+{
+ char fmt[4];
+ int format_len;
+ short fixed;
+ short channel_number;
+ int sample_rate;
+ int byte_rate;
+ short byte_per_sample;
+ short bits_per_sample;
+} WavFormat;
+
+/// WAV audio file 'data' section header
+typedef struct
+{
+ char data_field[4];
+ uint data_len;
+} WavData;
+
+
+/// WAV audio file header
+typedef struct
+{
+ WavRiff riff;
+ WavFormat format;
+ WavData data;
+} WavHeader;
+
+
+/// Class for writing WAV audio files.
+class WavOutFile
+{
+private:
+ /// Pointer to the WAV file
+ FILE *fptr;
+
+ /// WAV file header data.
+ WavHeader header;
+
+ /// Counter of how many bytes have been written to the file so far.
+ int bytesWritten;
+
+ /// Fills in WAV file header information.
+ void fillInHeader(const uint sampleRate, const uint bits, const uint channels);
+
+ /// Finishes the WAV file header by supplementing information of amount of
+ /// data written to file etc
+ void finishHeader();
+
+ /// Writes the WAV file header.
+ void writeHeader();
+
+public:
+ /// Constructor: Creates a new WAV file. Throws a 'runtime_error' exception
+ /// if file creation fails.
+ WavOutFile(const char *fileName, ///< Filename
+ int sampleRate, ///< Sample rate (e.g. 44100 etc)
+ int bits, ///< Bits per sample (8 or 16 bits)
+ int channels ///< Number of channels (1=mono, 2=stereo)
+ );
+
+ /// Destructor: Finalizes & closes the WAV file.
+ ~WavOutFile();
+
+ /// Write data to WAV file. Throws a 'runtime_error' exception if writing to
+ /// file fails.
+ void write(const short *buffer, ///< Pointer to sample data buffer.
+ int numElems ///< How many array items are to be written to file.
+ );
+
+};
+
+#endif
diff --git a/plugins/zerogs/dx/README.txt b/plugins/zerogs/dx/README.txt
index e54d8a1b31..3e9d8ca450 100644
--- a/plugins/zerogs/dx/README.txt
+++ b/plugins/zerogs/dx/README.txt
@@ -1,13 +1,13 @@
-ZeroGS DirectX
---------------
-author: zerofrog (@gmail.com)
-
-ZeroGS heavily uses GPU shaders. All the shaders are written in Microsoft's HLSL language and can be found in ps2hw.fx, ps2hw_ctx0.fx and ps2hw_ctx1.fx.
-
-'Dev' versions of ZeroGS directly read ps2hw.fx
-'Release' versions of ZeroGS read a precompiled version of ps2hw.fx from ps2hw.dat. In order to build ps2hw.dat, compile ZeroGSShaders and execute:
-
-./ZeroGSShaders ps2hw.fx ps2hw.dat
-
-For Windows users, once ZeroGSShaders is built, run buildshaders.bat directly. It will update all necessary resource files.
-Note that ZeroGSShaders has only been tested in Windows so far, but the Windows ps2hw.dat can be used in linux builds.
+ZeroGS DirectX
+--------------
+author: zerofrog (@gmail.com)
+
+ZeroGS heavily uses GPU shaders. All the shaders are written in Microsoft's HLSL language and can be found in ps2hw.fx, ps2hw_ctx0.fx and ps2hw_ctx1.fx.
+
+'Dev' versions of ZeroGS directly read ps2hw.fx
+'Release' versions of ZeroGS read a precompiled version of ps2hw.fx from ps2hw.dat. In order to build ps2hw.dat, compile ZeroGSShaders and execute:
+
+./ZeroGSShaders ps2hw.fx ps2hw.dat
+
+For Windows users, once ZeroGSShaders is built, run buildshaders.bat directly. It will update all necessary resource files.
+Note that ZeroGSShaders has only been tested in Windows so far, but the Windows ps2hw.dat can be used in linux builds.
diff --git a/plugins/zerogs/dx/ps2hw.fx b/plugins/zerogs/dx/ps2hw.fx
index 1bccf1b7a9..c678e07be3 100644
--- a/plugins/zerogs/dx/ps2hw.fx
+++ b/plugins/zerogs/dx/ps2hw.fx
@@ -1,993 +1,993 @@
-// Cg Shaders for PS2 GS emulation
-
-// divides by z for every pixel, instead of in vertex shader
-// fixes kh textures
-#define PERSPECTIVE_CORRECT_TEX
-
-//#define TEST_AEM // tests AEM for black pixels
-//#define REGION_REPEAT // set if texture wrapping mode is region repeat
-//#define WRITE_DEPTH // set if depth is also written in a MRT
-//#define ACCURATE_DECOMPRESSION // set for less capable hardware ATI Radeon 9000 series
-//#define EXACT_COLOR // make sure the output color is clamped to 1/255 boundaries (for alpha testing)
-
-#ifdef PERSPECTIVE_CORRECT_TEX
-#define TEX_XY tex.xy/tex.z
-#define TEX_DECL float3
-#else
-#define TEX_XY tex.xy
-#define TEX_DECL float2
-#endif
-
-#ifdef WRITE_DEPTH
-#define DOZWRITE(x) x
-#else
-#define DOZWRITE(x)
-#endif
-
-#include "ps2hw_ctx0.fx"
-
-// used to get the tiled offset into a page given the linear offset
-texture g_txBlocks;
-texture g_txBilinearBlocks;
-texture g_txSrc;
-
-texture g_txConv16to32;
-texture g_txConv32to16;
-
-// for region_repeat mode
-texture g_txBitwiseANDX;
-texture g_txBitwiseANDY;
-texture g_txCLUT;
-
-sampler g_sSrcFinal : register(s2) = sampler_state {
- Texture = ;
- MipFilter = LINEAR;
- MinFilter = LINEAR;
- MagFilter = LINEAR;
- AddressU = Clamp;
- AddressV = Clamp;
-};
-
-sampler g_sBlocks : register(s3) = sampler_state {
- Texture = ;
- MipFilter = POINT;
- MinFilter = POINT;
- MagFilter = POINT;
- AddressU = Wrap;
- AddressV = Wrap;
-};
-
-sampler g_sBilinearBlocks : register(s4) = sampler_state {
- Texture = ;
- MipFilter = POINT;
- MinFilter = POINT;
- MagFilter = POINT;
- AddressU = Wrap;
- AddressV = Wrap;
-};
-
-sampler g_sConv16to32 : register(s4) = sampler_state {
- Texture = ;
- MipFilter = POINT;
- MinFilter = POINT;
- MagFilter = POINT;
- AddressU = Wrap;
- AddressV = Wrap;
-};
-
-sampler3D g_sConv32to16 : register(s4) = sampler_state {
- Texture = ;
- MipFilter = POINT;
- MinFilter = POINT;
- MagFilter = POINT;
- AddressU = Wrap;
- AddressV = Wrap;
-};
-
-sampler g_sBitwiseANDX : register(s5) = sampler_state {
- Texture = ;
- MipFilter = POINT;
- MinFilter = POINT;
- MagFilter = POINT;
- AddressU = Wrap;
- AddressV = Wrap;
-};
-
-sampler g_sBitwiseANDY : register(s6) = sampler_state {
- Texture = ;
- MipFilter = POINT;
- MinFilter = POINT;
- MagFilter = POINT;
- AddressU = Wrap;
- AddressV = Wrap;
-};
-
-// used only on rare cases where the render target is PSMT8H
-sampler g_sCLUT : register(s2) = sampler_state {
- Texture = ;
- MipFilter = POINT;
- MinFilter = POINT;
- MagFilter = POINT;
- AddressU = Wrap;
- AddressV = Wrap;
-};
-
-// global pixel shader constants
-float4 g_fInvTexDims : register(c22); // similar to g_fClutOff
-float3 g_fFogColor : register(c23);
-
-// used for rectblitting
-float4 g_fBitBltZ : register(c24);
-
-half4 g_fOneColor : register(c25); // col*.xxxy+.zzzw
-
-// vertex shader constants
-float4 g_fBitBltPos : register(c4);
-float4 g_fZ : register(c5); // transforms d3dcolor z into float z
-float2 g_fZNorm : register(c6);
-float4 g_fBitBltTex : register(c7);
-
-// pixel shader consts
-// .z is used for the addressing fn
-half4 g_fExactColor : register(c27) = half4(0.5,0.5/256.0f,0,1/255.0f);
-float3 g_fBilinear : register(c28) = float3(-0.7f, -0.65f, 0.9);
-float4 g_fZBias : register(c29) = half4(1.0f/256.0f, 1.0004f, 1, 0.5);
-float4 g_fc0 : register(c30) = float4(0,1, 0.001, 0.5f); // also for vs
-float4 g_fMult : register(c31) = float4(1/1024.0f, 0.2f/1024.0f, 1/128.0f, 1/512.0f);
-
-// vertex shader consts
-float4 g_fBitBltTrans : register(c31) = float4(0.5f, -0.5f, 0.5, 0.5 + 0.4/416.0f);
-
-// given a local tex coord, returns the coord in the memory
-float2 ps2memcoord(float2 realtex)
-{
- float4 off;
-
- // block off
- realtex.xy = realtex.xy * g_fTexDims.xy + g_fTexDims.zw;
- realtex.xy = (realtex.xy - frac(realtex.xy)) * g_fMult.zw;
- float2 fblock = frac(realtex.xy);
- off.xy = realtex.xy-fblock.xy;
-
-#ifdef ACCURATE_DECOMPRESSION
- off.zw = tex2D(g_sBlocks, g_fTexBlock.xy*fblock + g_fTexBlock.zw).xw;
- off.x = dot(off.xyw, g_fTexOffset.xyw);
- float f = frac(off.x);
- float fadd = g_fTexOffset.z * off.z;
- off.w = off.x + fadd;
- off.x = frac(f + fadd);
- off.w -= off.x;
-#else
- off.z = tex2D(g_sBlocks, g_fTexBlock.xy*fblock + g_fTexBlock.zw).r;
-
- // combine the two
- off.x = dot(off.xyz, g_fTexOffset.xyz)+g_fTexOffset.w;
- off.x = modf(off.x, off.w);
-#endif
-
- off.y = off.w * g_fPageOffset.y + g_fPageOffset.x;
- return off.xy;
-}
-
-// find all texcoords for bilinear filtering
-// assume that orgtex are already on boundaries
-void ps2memcoord4(float4 orgtex, out float4 off0, out float4 off1)
-{
- //float4 off0, off1, off2, off3;
- float4 realtex;
-
- // block off
- realtex = (orgtex * g_fTexDims.xyxy + g_fTexDims.zwzw);// * g_fMult.zwzw;
- float4 fblock = frac(realtex.xyzw);
- float4 ftransblock = g_fTexBlock.xyxy*fblock + g_fTexBlock.zwzw;
- realtex -= fblock;
-
- float4 transvals = g_fTexOffset.x * realtex.xzxz + g_fTexOffset.y * realtex.yyww + g_fTexOffset.w;
-
- float4 colors;// = tex2D(g_sBilinearBlocks, ftransblock.xy);
-
- // this is faster on ffx ingame
- colors.x = tex2D(g_sBlocks, ftransblock.xy).r;
- colors.y = tex2D(g_sBlocks, ftransblock.zy).r;
- colors.z = tex2D(g_sBlocks, ftransblock.xw).r;
- colors.w = tex2D(g_sBlocks, ftransblock.zw).r;
-
- float4 fr, rem;
-
-#ifdef ACCURATE_DECOMPRESSION
- fr = frac(transvals);
- float4 fadd = colors * g_fTexOffset.z;
- rem = transvals + fadd;
- fr = frac(fr + fadd);
- rem -= fr;
-#else
- transvals += colors * g_fTexOffset.z;
-
- fr = modf(transvals, rem);
-#endif
-
- rem = rem * g_fPageOffset.y + g_fPageOffset.x;
-
- // combine
- off0 = g_fc0.yxyx * fr.xxyy + g_fc0.xyxy * rem.xxyy;
- off1 = g_fc0.yxyx * fr.zzww + g_fc0.xyxy * rem.zzww;
-}
-
-void ps2memcoord4_fast(float4 orgtex, out float4 off0, out float4 off1)
-{
- float4 realtex;
-
- realtex = (orgtex * g_fTexDims.xyxy + g_fTexDims.zwzw);// * g_fMult.zwzw;
- float4 fblock = frac(realtex.xyzw);
- float2 ftransblock = g_fTexBlock.xy*fblock.xy + g_fTexBlock.zw;
- realtex -= fblock;
-
- float4 transvals = g_fTexOffset.x * realtex.xzxz + g_fTexOffset.y * realtex.yyww + g_fTexOffset.w;
-
- float4 colors = tex2D(g_sBilinearBlocks, ftransblock.xy);
- float4 fr, rem;
-
-#ifdef ACCURATE_DECOMPRESSION
- fr = frac(transvals);
- float4 fadd = colors * g_fTexOffset.z;
- rem = transvals + fadd;
- fr = frac(fr + fadd);
- rem -= fr;
-#else
- transvals += colors * g_fTexOffset.z;
-
- fr = modf(transvals, rem);
-#endif
-
- rem = rem * g_fPageOffset.y + g_fPageOffset.x;
-
- off0 = g_fc0.yxyx * fr.xxyy + g_fc0.xyxy * rem.xxyy;
- off1 = g_fc0.yxyx * fr.zzww + g_fc0.xyxy * rem.zzww;
-}
-
-// Wrapping modes
-#if defined(REPEAT)
-
-float2 ps2addr(float2 coord)
-{
- return frac(coord.xy);
-}
-
-#elif defined(CLAMP)
-
-float2 ps2addr(float2 coord)
-{
- return clamp(coord.xy, g_fClampExts.xy, g_fClampExts.zw);
-}
-
-#elif defined(REGION_REPEAT)
-
-// computes the local tex coord along with addressing modes
-float2 ps2addr(float2 coord)
-{
- float2 final = frac(clamp(coord.xy, g_fClampExts.xy, g_fClampExts.zw));
-
- if( TexWrapMode.x > g_fBilinear.z ) // region repeat mode for x (umsk&x)|ufix
- final.x = tex2D(g_sBitwiseANDX, abs(coord.x)*TexWrapMode.z).x * g_fClampExts.x + g_fClampExts.z;
- if( TexWrapMode.y > g_fBilinear.z ) // region repeat mode for x (vmsk&x)|vfix
- final.y = tex2D(g_sBitwiseANDY, abs(coord.y)*TexWrapMode.w).x * g_fClampExts.y + g_fClampExts.w;
-
- return final;
-}
-
-#else
-
-float2 ps2addr(float2 coord)
-{
- return frac(clamp(coord.xy, g_fClampExts.xy, g_fClampExts.zw));
-}
-
-#endif
-
-half4 tex2DPS_32(float2 tex0)
-{
- return tex2D(g_sMemory, ps2memcoord(tex0).xy);
-}
-
-// use when texture is not tiled
-half4 tex2DPS_tex32(float2 tex0)
-{
- return tex2D(g_sMemory, g_fTexDims.xy*tex0+g_fTexDims.zw)*g_fZBias.zzzw+g_fPageOffset.w;
-}
-
-// use when texture is not tiled
-half4 tex2DPS_clut32(float2 tex0)
-{
- float index = tex2D(g_sMemory, g_fTexDims.xy*tex0+g_fTexDims.zw).a+g_fPageOffset.w;
- return tex1D(g_sCLUT, index*g_fExactColor.x+g_fExactColor.y);
-}
-
-// use when texture is not tiled and converting from 32bit to 16bit
-// don't convert on the block level, only on the column level
-// so every other 8 pixels, use the upper bits instead of lower
-half4 tex2DPS_tex32to16(float2 tex0)
-{
- bool upper = false;
- tex0.y += g_fPageOffset.z;
- float2 ffrac = fmod(tex0, g_fTexOffset.xy);
- //tex0.xy = g_fc0.ww * (tex0.xy + ffrac);
- tex0.y += ffrac.y;
-
- if( ffrac.x > g_fTexOffset.z ) {
- tex0.x -= g_fTexOffset.z;
- upper = true;
- }
- if( ffrac.y >= g_fTexOffset.w ) {
- tex0.y -= g_fTexOffset.y;
- tex0.x += g_fTexOffset.z;
- }
-
- half4 color = tex2D(g_sMemory, g_fTexDims.xy*tex0+g_fTexDims.zw)*g_fZBias.zzzw+g_fPageOffset.w;
- float2 uv = upper ? color.xw : color.zy;
- return tex2D(g_sConv16to32, uv+g_fPageOffset.xy).zyxw;
-}
-
-// used when a 16 bit texture is used an 8h
-half4 tex2DPS_tex16to8h(float2 tex0)
-{
- float4 final;
- float2 ffrac = fmod(tex0+g_fPageOffset.zw, g_fTexOffset.xy);
- //tex0.xy = g_fPageOffset.xy * tex0.xy - ffrac * g_fc0.yw;
- tex0.y += g_fPageOffset.y * ffrac.y;
-
- if( ffrac.x > g_fTexOffset.z ) {
- tex0.x -= g_fTexOffset.z;
- tex0.y += g_fTexOffset.w;
- }
-
- float4 upper = tex2D(g_sMemory, g_fTexDims.xy*tex0+g_fTexDims.zw);
-
- // only need alpha
- float index = tex3D(g_sConv32to16, upper.zyx-g_fc0.z).y + upper.w*g_fc0.w*g_fc0.w;
- return tex1D(g_sCLUT, index+g_fExactColor.y);
-}
-
-// used when a 16 bit texture is used a 32bit one
-half4 tex2DPS_tex16to32(float2 tex0)
-{
- float4 final;
- float2 ffrac = fmod(tex0+g_fPageOffset.zw, g_fTexOffset.xy);
- //tex0.xy = g_fPageOffset.xy * tex0.xy - ffrac * g_fc0.yw;
- tex0.y += g_fPageOffset.y * ffrac.y;
-
- if( ffrac.x > g_fTexOffset.z ) {
- tex0.x -= g_fTexOffset.z;
- tex0.y += g_fTexOffset.w;
- }
-
- float fconst = g_fc0.w*g_fc0.w;
- float4 lower = tex2D(g_sSrcFinal, g_fTexDims.xy*tex0);
- float4 upper = tex2D(g_sMemory, g_fTexDims.xy*tex0+g_fTexDims.zw);
-
- final.zy = tex3D(g_sConv32to16, lower.zyx).xy + lower.ww*fconst;
- final.xw = tex3D(g_sConv32to16, upper.zyx).xy + upper.ww*fconst;
- return final;
-}
-
-//half4 f;
-//f.w = old.y > (127.2f/255.0f) ? 1 : 0;
-//old.y -= 0.5f * f.w;
-//f.xyz = frac(old.yyx*half3(2.002*255.0f/256.0f, 64.025f*255.0f/256.0f, 8.002*255.0f/256.0f));
-//f.y += old.x * (0.25f*255.0f/256.0f);
-
-////////////////////////////////
-// calculates the texture color
-////////////////////////////////
-
-#define decl_ps2shade(num) \
-decl_ps2shade_##num(_32); \
-decl_ps2shade_##num(_tex32); \
-decl_ps2shade_##num(_clut32); \
-decl_ps2shade_##num(_tex32to16); \
-decl_ps2shade_##num(_tex16to8h); \
-
-// nearest
-#define decl_ps2shade_0(bit) \
-half4 ps2shade0##bit( TEX_DECL tex) \
-{ \
- return tex2DPS##bit( ps2addr(TEX_XY)); \
-} \
-
-// do fast memcoord4 calcs when textures behave well
-#ifdef REPEAT
-#define PS2MEMCOORD4 ps2memcoord4
-#else
-#define PS2MEMCOORD4 ps2memcoord4
-#endif
-
-#define decl_BilinearFilter(bit, addrfn) \
-half4 BilinearFilter##bit(float2 tex0) \
-{ \
- float4 off0, off1; \
- float4 ftex; \
- float2 ffrac; \
- ftex.xy = tex0 + g_fBilinear.xy * g_fRealTexDims.zw; \
- ffrac = frac(ftex.xy*g_fRealTexDims.xy); \
- ftex.xy -= ffrac.xy * g_fRealTexDims.zw; \
- \
- ftex.zw = ps2addr(ftex.xy + g_fRealTexDims.zw); \
- ftex.xy = ps2addr(ftex.xy); \
- \
- PS2MEMCOORD4(ftex, off0, off1); \
- half4 c0 = tex2D(g_sMemory, off0.xy); \
- half4 c1 = tex2D(g_sMemory, off0.zw); \
- half4 c2 = tex2D(g_sMemory, off1.xy); \
- half4 c3 = tex2D(g_sMemory, off1.zw); \
- return lerp( lerp(c0, c1, ffrac.x), lerp(c2, c3, ffrac.x), ffrac.y ); \
-} \
-
-decl_BilinearFilter(_32, ps2addr);
-decl_BilinearFilter(_tex32, ps2addr);
-decl_BilinearFilter(_clut32, ps2addr);
-decl_BilinearFilter(_tex32to16, ps2addr);
-decl_BilinearFilter(_tex16to8h, ps2addr);
-
-//TODO! For mip maps, only apply when LOD >= 0
-// lcm == 0, LOD = log(1/Q)*L + K, lcm == 1, LOD = K
-
-// bilinear
-#define decl_ps2shade_1(bit) \
-half4 ps2shade1##bit(TEX_DECL tex) \
-{ \
- return BilinearFilter##bit(TEX_XY); \
-} \
-
-// nearest, mip nearest
-#define decl_ps2shade_2(bit) \
-half4 ps2shade2##bit(TEX_DECL tex) \
-{ \
- return tex2DPS##bit( ps2addr(TEX_XY)); \
-} \
-
-// nearest, mip linear
-#define decl_ps2shade_3(bit) \
-half4 ps2shade3##bit(TEX_DECL tex) \
-{ \
- return tex2DPS##bit(ps2addr(TEX_XY)); \
-} \
-
-// linear, mip nearest
-#define decl_ps2shade_4(bit) \
-half4 ps2shade4##bit(TEX_DECL tex) \
-{ \
- return BilinearFilter##bit(TEX_XY); \
-} \
-
-// linear, mip linear
-#define decl_ps2shade_5(bit) \
-half4 ps2shade5##bit(TEX_DECL tex) \
-{ \
- return BilinearFilter##bit(TEX_XY); \
-} \
-
-decl_ps2shade(0);
-decl_ps2shade(1);
-decl_ps2shade(2);
-decl_ps2shade(3);
-decl_ps2shade(4);
-decl_ps2shade(5);
-
-half4 ps2CalcShade(half4 texcol, half4 color)
-{
-#ifdef TEST_AEM
- if( dot(texcol.xyzw, g_fTestBlack.xyzw) <= g_fc0.z )
- texcol.w = g_fc0.x;
- else
-#endif
- texcol.w = texcol.w * fTexAlpha.y + fTexAlpha.x;
-
- texcol = texcol * (fTexAlpha2.zzzw * color + fTexAlpha2.xxxy) + fTexAlpha.zzzw * color.wwww;
-
- return texcol;
-}
-
-// final ops on the color
-#ifdef EXACT_COLOR
-
-half4 ps2FinalColor(half4 col)
-{
- // g_fOneColor has to scale by 255
- half4 temp = col * g_fOneColor.xxxy + g_fOneColor.zzzw;
- temp.w = floor(temp.w)*g_fExactColor.w;
- return temp;
-}
-
-#else
-half4 ps2FinalColor(half4 col)
-{
- return col * g_fOneColor.xxxy + g_fOneColor.zzzw;
-}
-#endif
-
-////////////////
-// Techniques //
-////////////////
-
-// technique to copy a rectangle from source to target
-struct VSOUT_
-{
- float4 pos : POSITION;
- half4 color : COLOR0;
- DOZWRITE(float4 z : TEXCOORD0;)
-};
-
-struct VSOUT_T
-{
- float4 pos : POSITION;
- half4 color : COLOR0;
- TEX_DECL tex : TEXCOORD0;
- DOZWRITE(float4 z : TEXCOORD1;)
-};
-
-struct VSOUT_F
-{
- float4 pos : POSITION;
- half4 color : COLOR0;
- float fog : TEXCOORD0;
- DOZWRITE(float4 z : TEXCOORD1;)
-};
-
-struct VSOUT_TF
-{
- float4 pos : POSITION;
- half4 color : COLOR0;
- TEX_DECL tex : TEXCOORD0;
- half fog : TEXCOORD1;
- DOZWRITE(float4 z : TEXCOORD2;)
-};
-
-// just smooth shadering
-VSOUT_ RegularVS(float4 pos : POSITION,
- half4 color : COLOR0,
- float4 z : TEXCOORD0
- )
-{
- VSOUT_ o;
-
- o.pos.xy = pos.xy*g_fPosXY.xy+g_fPosXY.zw;
- o.pos.z = log(g_fc0.y+dot(g_fZ, z.zyxw))*g_fZNorm.x+g_fZNorm.y;
- o.pos.w = g_fc0.y; // 1
- o.color = color;
-
- DOZWRITE(o.z = z*g_fZBias.x+g_fZBias.y; o.z.w = g_fc0.y;)
- return o;
-}
-
-void RegularPS(VSOUT_ i, out half4 c0 : COLOR0
-#ifdef WRITE_DEPTH
- , out float4 c1 : COLOR1
-#endif
- )
-{
- // whenever outputting depth, make sure to mult by 255/256 and 1
- c0 = ps2FinalColor(i.color);
- DOZWRITE(c1 = i.z;)
-}
-
-technique Regular {
- pass p0 {
- VertexShader = compile vs_3_0 RegularVS();
- PixelShader = compile ps_3_0 RegularPS();
- }
-};
-
-// diffuse texture mapping
-VSOUT_T TextureVS(float4 pos : POSITION,
- half4 color : COLOR0,
- float3 tex0 : TEXCOORD1,
- float4 z : TEXCOORD0)
-{
- VSOUT_T o;
- o.pos.xy = pos.xy*g_fPosXY.xy+g_fPosXY.zw;
- o.pos.z = log(g_fc0.y+dot(g_fZ, z.zyxw))*g_fZNorm.x + g_fZNorm.y;
- o.pos.w = g_fc0.y;
- o.color = color;
- DOZWRITE(o.z = z*g_fZBias.x+g_fZBias.y; o.z.w = g_fc0.y;)
-#ifdef PERSPECTIVE_CORRECT_TEX
- o.tex = tex0;
-#else
- o.tex = tex0.xy/tex0.z;
-#endif
- return o;
-}
-
-#ifdef WRITE_DEPTH
-
-#define DECL_TEXPS(num, bit) \
-void Texture##num##bit##PS(VSOUT_T i, out half4 c0 : COLOR0, out float4 c1 : COLOR1) \
-{ \
- c0 = ps2FinalColor(ps2CalcShade(ps2shade##num##bit(i.tex), i.color)); \
- c1 = i.z; \
-} \
-
-#else
-
-#define DECL_TEXPS(num, bit) \
-void Texture##num##bit##PS(VSOUT_T i, out half4 c0 : COLOR0) \
-{ \
- c0 = ps2FinalColor(ps2CalcShade(ps2shade##num##bit(i.tex), i.color)); \
-} \
-
-#endif
-
-#define DECL_TEXPS_(num) \
-DECL_TEXPS(num, _32); \
-DECL_TEXPS(num, _tex32); \
-DECL_TEXPS(num, _clut32); \
-DECL_TEXPS(num, _tex32to16); \
-DECL_TEXPS(num, _tex16to8h); \
-
-DECL_TEXPS_(0);
-DECL_TEXPS_(1);
-DECL_TEXPS_(2);
-DECL_TEXPS_(3);
-DECL_TEXPS_(4);
-DECL_TEXPS_(5);
-
-// special functions for limitations on ps20
-technique Texture {
- pass p0 {
- VertexShader = compile vs_2_0 TextureVS();
- PixelShader = compile ps_2_a Texture0_32PS();
- }
-}
-
-VSOUT_F RegularFogVS(float4 pos : POSITION,
- half4 color : COLOR0,
- float4 z : TEXCOORD0)
-{
- VSOUT_F o;
-
- o.pos.xy = pos.xy*g_fPosXY.xy+g_fPosXY.zw;
- o.pos.z = log(g_fc0.y+dot(g_fZ, z.zyxw))*g_fZNorm.x+g_fZNorm.y;
- o.pos.w = g_fc0.y;
- DOZWRITE(o.z = z*g_fZBias.x+g_fZBias.y; o.z.w = g_fc0.y;)
- o.color = color;
- o.fog = pos.z;
- return o;
-}
-
-void RegularFogPS(VSOUT_F i, out half4 c0 : COLOR0
-#ifdef WRITE_DEPTH
- , out float4 c1 : COLOR1
-#endif
- )
-{
- half4 c;
- c.xyz = lerp(g_fFogColor.xyz, i.color.xyz, i.fog); \
- c.w = i.color.w;
- c0 = ps2FinalColor(c);
- DOZWRITE(c1 = i.z;)
-}
-
-technique RegularFog {
- pass p0 {
- VertexShader = compile vs_2_0 RegularFogVS();
- PixelShader = compile ps_2_a RegularFogPS();
- }
-};
-
-VSOUT_TF TextureFogVS(float4 pos : POSITION,
- half4 color : COLOR0,
- float3 tex0 : TEXCOORD1,
- float4 z : TEXCOORD0)
-{
- VSOUT_TF o;
-
- o.pos.xy = pos.xy*g_fPosXY.xy+g_fPosXY.zw;
- o.pos.z = log(g_fc0.y+dot(g_fZ, z.zyxw))*g_fZNorm.x+g_fZNorm.y;
- o.pos.w = g_fc0.y;
- o.color = color;
- o.fog = pos.z;
- DOZWRITE(o.z = z*g_fZBias.x+g_fZBias.y; o.z.w = g_fc0.y;)
-#ifdef PERSPECTIVE_CORRECT_TEX
- o.tex = tex0;
-#else
- o.tex = tex0.xy/tex0.z;
-#endif
- return o;
-}
-
-#ifdef WRITE_DEPTH
-
-#define DECL_TEXFOGPS(num, bit) \
-void TextureFog##num##bit##PS(VSOUT_TF i, out half4 c0 : COLOR0, out float4 c1 : COLOR1 ) \
-{ \
- half4 c = ps2CalcShade(ps2shade##num##bit(i.tex), i.color); \
- c.xyz = lerp(g_fFogColor.xyz, c.xyz, i.fog); \
- c0 = ps2FinalColor(c); \
- c1 = i.z; \
-} \
-
-#else
-
-#define DECL_TEXFOGPS(num, bit) \
-void TextureFog##num##bit##PS(VSOUT_TF i, out half4 c0 : COLOR0) \
-{ \
- half4 c = ps2CalcShade(ps2shade##num##bit(i.tex), i.color); \
- c.xyz = lerp(g_fFogColor.xyz, c.xyz, i.fog); \
- c0 = ps2FinalColor(c); \
-} \
-
-#endif
-
-#define DECL_TEXFOGPS_(num) \
-DECL_TEXFOGPS(num, _32); \
-DECL_TEXFOGPS(num, _tex32); \
-DECL_TEXFOGPS(num, _clut32); \
-DECL_TEXFOGPS(num, _tex32to16); \
-DECL_TEXFOGPS(num, _tex16to8h); \
-
-DECL_TEXFOGPS_(0);
-DECL_TEXFOGPS_(1);
-DECL_TEXFOGPS_(2);
-DECL_TEXFOGPS_(3);
-DECL_TEXFOGPS_(4);
-DECL_TEXFOGPS_(5);
-
-technique TextureFog {
- pass p0 {
- VertexShader = compile vs_2_0 TextureFogVS();
- PixelShader = compile ps_2_a TextureFog0_32PS();
- }
-};
-
-//-------------------------------------------------------
-// Techniques not related to the main primitive commands
-half4 BilinearBitBlt(float2 tex0)
-{
- float4 ftex;
- float2 ffrac;
-
- ffrac.xy = frac(tex0*g_fRealTexDims.xy);
- ftex.xy = tex0 - ffrac.xy * g_fRealTexDims.zw;
- ftex.zw = ftex.xy + g_fRealTexDims.zw;
-
- float4 off0, off1;
- ps2memcoord4_fast(ftex, off0, off1);
- half4 c0 = tex2D(g_sMemory, off0.xy);
- half4 c1 = tex2D(g_sMemory, off0.zw);
- half4 c2 = tex2D(g_sMemory, off1.xy);
- half4 c3 = tex2D(g_sMemory, off1.zw);
-
- return lerp( lerp(c0, c1, ffrac.x), lerp(c2, c3, ffrac.x), ffrac.y );
-}
-
-void BitBltVS(in float4 pos : POSITION,
- in half4 tex0 : TEXCOORD0,
- in float3 tex : TEXCOORD1,
- out float4 opos : POSITION,
- out float2 otex0 : TEXCOORD0,
- out float2 ointerpos : TEXCOORD1)
-{
- opos.xy = pos.xy * g_fBitBltPos.xy + g_fBitBltPos.zw;
- ointerpos = opos.xy * g_fBitBltTrans.xy + g_fBitBltTrans.zw;
- opos.zw = g_fc0.xy;
- otex0 = tex * g_fBitBltTex.xy + g_fBitBltTex.zw;
-}
-
-half4 BitBltPS(in float2 tex0 : TEXCOORD0) : COLOR
-{
- return tex2D(g_sMemory, ps2memcoord(tex0).xy)*g_fOneColor.xxxy;
-}
-
-// used when AA
-half4 BitBltAAPS(in float2 tex0 : TEXCOORD0) : COLOR
-{
- return BilinearBitBlt(tex0)*g_fOneColor.xxxy;
-}
-
-void BitBltDepthPS(in float2 tex0 : TEXCOORD0,
- out float4 c : COLOR0,
- out float depth : DEPTH)
-{
- c = tex2D(g_sMemory, ps2memcoord(tex0));
-
- depth = log(g_fc0.y+dot(c, g_fBitBltZ))*g_fOneColor.w;
- c += g_fZBias.y;
-}
-
-void BitBltDepthMRTPS(in float2 tex0 : TEXCOORD0,
- out half4 c0 : COLOR0,
- out float4 c1 : COLOR1,
- out float depth : DEPTH)
-{
- c1 = tex2D(g_sMemory, ps2memcoord(tex0));
-
- depth = log(g_fc0.y+dot(c1, g_fBitBltZ))*g_fOneColor.w;
- c1 += g_fZBias.y;
- c0 = g_fc0.x;
-}
-
-// no swizzling
-void BitBltDepthTexPS(in float2 tex0 : TEXCOORD0,
- out float4 c : COLOR0,
- out float depth : DEPTH)
-{
- c = tex2D(g_sSrcFinal, tex0);
-
- depth = log(g_fc0.y+dot(c-g_fZBias.y, g_fBitBltZ))*g_fOneColor.w;
- //c += g_fZBias.y;
-}
-
-// no swizzling
-void BitBltDepthTexMRTPS(in float2 tex0 : TEXCOORD0,
- out half4 c0 : COLOR0,
- out float4 c1 : COLOR1,
- out float depth : DEPTH)
-{
- c1 = tex2D(g_sSrcFinal, tex0);
-
- depth = log(g_fc0.y+dot(c1-g_fZBias.y, g_fBitBltZ))*g_fOneColor.w;
- //c1 += g_fZBias.y;
- c0 = g_fc0.x;
-}
-
-technique BitBlt {
- pass p0 {
- VertexShader = compile vs_1_1 BitBltVS();
- PixelShader = compile ps_2_0 BitBltDepthMRTPS();
- }
-}
-
-/*static const float BlurKernel[9] = {
- 0.027601,
- 0.066213,
- 0.123701,
- 0.179952,
- 0.205065,
- 0.179952,
- 0.123701,
- 0.066213,
- 0.027601
-};*/
-
-half4 BilinearFloat16(float2 tex0)
-{
- /*float4 ffrac, ftex;
- ffrac.xy = frac(tex0);
- ftex.xy = (tex0 - ffrac.xy) * g_fInvTexDims.xy + g_fInvTexDims.zw;
- ftex.zw = ftex.xy + g_fInvTexDims.xy;
-
- half4 c0 = tex2D(g_sSrcFinal, ftex.xy);
- half4 c1 = tex2D(g_sSrcFinal, ftex.zy);
- half4 c2 = tex2D(g_sSrcFinal, ftex.xw);
- half4 c3 = tex2D(g_sSrcFinal, ftex.zw);
-
- return lerp( lerp(c0, c1, ffrac.x), lerp(c2, c3, ffrac.x), ffrac.y );*/
- return tex2D(g_sSrcFinal, tex0.xy);
-// return 0.55f * tex2D(g_sSrcFinal, tex0.xy) +
-// 0.15f * tex2D(g_sSrcFinal, tex0.xy+g_fInvTexDims.xz) +
-// 0.15f * tex2D(g_sSrcFinal, tex0.xy+g_fInvTexDims.zy) +
-// 0.15f * tex2D(g_sSrcFinal, tex0.xy+g_fInvTexDims.xy);
-}
-
-half4 CRTCTargInterPS(in float2 tex0 : TEXCOORD0, in float2 ointerpos : TEXCOORD1) : COLOR
-{
- float finter = tex1D(g_sBitwiseANDX, ointerpos.y).x;
- clip(finter * g_fOneColor.z + g_fOneColor.w);
-
- half4 c = BilinearFloat16(tex0);
- c.w = g_fc0.w*c.w * g_fOneColor.x + g_fOneColor.y;
- return c.zyxw;
-}
-
-half4 CRTCTargPS(in float2 tex0 : TEXCOORD0) : COLOR
-{
- float4 c = BilinearFloat16(tex0);
- c.w = g_fc0.w*c.w * g_fOneColor.x + g_fOneColor.y;
- return c.zyxw;
-}
-
-half4 CRTCInterPS(in float2 tex0 : TEXCOORD0, in float2 ointerpos : TEXCOORD1) : COLOR
-{
- float2 filtcoord = (tex0-frac(tex0))*g_fInvTexDims.xy+g_fInvTexDims.zw;
- float finter = tex1D(g_sBitwiseANDX, ointerpos.y).x;
- clip(finter * g_fOneColor.z + g_fOneColor.w);
-
- half4 c = BilinearBitBlt(filtcoord);
- c.w = c.w * g_fOneColor.x + g_fOneColor.y;
-
- return c.zyxw;
-}
-
-half4 CRTCPS(in float2 tex0 : TEXCOORD0) : COLOR
-{
- float2 filtcoord = (tex0/*-frac(tex0)*/)*g_fInvTexDims.xy+g_fInvTexDims.zw;
- half4 c = BilinearBitBlt(filtcoord);
- c.w = c.w * g_fOneColor.x + g_fOneColor.y;
-
- return c.zyxw;
-}
-
-half4 CRTC24InterPS(in float2 tex0 : TEXCOORD0, in float2 ointerpos : TEXCOORD1) : COLOR
-{
- float2 filtcoord = (tex0-frac(tex0))*g_fInvTexDims.xy+g_fInvTexDims.zw;
- float finter = tex1D(g_sBitwiseANDX, ointerpos.y).x;
- clip(finter * g_fOneColor.z + g_fOneColor.w);
-
- half4 c = tex2D(g_sMemory, ps2memcoord(filtcoord).xy).x;
- c.w = c.w * g_fOneColor.x + g_fOneColor.y;
-
- return c.zyxw;
-}
-
-half4 CRTC24PS(in float2 tex0 : TEXCOORD0) : COLOR
-{
- float2 filtcoord = (tex0-frac(tex0))*g_fInvTexDims.xy+g_fInvTexDims.zw;
- half4 c = tex2D(g_sMemory, ps2memcoord(filtcoord).xy).x;
- c.w = c.w * g_fOneColor.x + g_fOneColor.y;
-
- return c.zyxw;
-}
-
-technique CRTC {
- pass p0 {
- VertexShader = compile vs_1_1 BitBltVS();
- PixelShader = compile ps_2_0 CRTCTargInterPS();
- }
-}
-
-half4 ZeroPS() : COLOR
-{
- return g_fOneColor.x;
-}
-
-half4 BaseTexturePS(in float2 tex0 : TEXCOORD0) : COLOR
-{
- return tex2D(g_sSrcFinal, tex0) * g_fOneColor;
-}
-
-// inverse of 32->16bit conversion
-half4 Convert16to32PS(float2 tex0 : TEXCOORD0) : COLOR
-{
- float4 final;
- float2 ffrac = fmod(tex0+g_fTexDims.zw, g_fTexOffset.xy);
- tex0.y += g_fTexDims.y * ffrac.y;
-
- if( ffrac.x > g_fTexOffset.z ) {
- tex0.x -= g_fTexOffset.z;
- tex0.y += g_fTexOffset.w;
- }
-
- float4 lower = tex2D(g_sSrcFinal, tex0);
- float4 upper = tex2D(g_sSrcFinal, tex0+g_fPageOffset.xy);
-
- //return half4(frac(32*tex0.x),frac(7*tex0.y),0,1);
- final.zy = tex3D(g_sConv32to16, lower.zyx).xy + lower.ww*g_fPageOffset.zw;
- final.xw = tex3D(g_sConv32to16, upper.zyx).xy + upper.ww*g_fPageOffset.zw;
- return final;
-}
-
-// use when texture is not tiled and converting from 32bit to 16bit
-// one condition is that the converted texture has to keep the same block configuration
-// every 16 32bit horz pixels gets converted to 16x2 16bit horz pixels.
-// the first row is the first 8 pixels, the second row is the last 8 pixels
-// the last 8 columns are the upper bits
-half4 Convert32to16PS(float2 tex0 : TEXCOORD0) : COLOR
-{
- bool upper = false;
- float2 ffrac = fmod(tex0+g_fTexDims.zw, g_fTexOffset.xy);
- //tex0 += g_fTexDims.xy * ffrac;
- //tex0.y += g_fTexDims.y * ffrac.y;
- tex0.y += ffrac.y;
- //tex0.x -= g_fc0.w*ffrac.x;
- if( ffrac.x > g_fTexOffset.z ) {
- tex0.x -= g_fTexOffset.z;
- upper = true;
- }
- if( ffrac.y >= g_fTexOffset.w ) {
- tex0.y -= g_fTexOffset.y;
- tex0.x += g_fTexOffset.z;
- }
-
- //return half4(frac(32*tex0.x),frac(7*tex0.y),0,1);
- half4 color = tex2D(g_sSrcFinal, tex0)*g_fc0.yyyw;
- float2 uv = upper ? color.xw : color.zy;
- return tex2D(g_sConv16to32, uv*g_fPageOffset.xy+g_fPageOffset.zw).zyxw*g_fOneColor;
-}
+// Cg Shaders for PS2 GS emulation
+
+// divides by z for every pixel, instead of in vertex shader
+// fixes kh textures
+#define PERSPECTIVE_CORRECT_TEX
+
+//#define TEST_AEM // tests AEM for black pixels
+//#define REGION_REPEAT // set if texture wrapping mode is region repeat
+//#define WRITE_DEPTH // set if depth is also written in a MRT
+//#define ACCURATE_DECOMPRESSION // set for less capable hardware ATI Radeon 9000 series
+//#define EXACT_COLOR // make sure the output color is clamped to 1/255 boundaries (for alpha testing)
+
+#ifdef PERSPECTIVE_CORRECT_TEX
+#define TEX_XY tex.xy/tex.z
+#define TEX_DECL float3
+#else
+#define TEX_XY tex.xy
+#define TEX_DECL float2
+#endif
+
+#ifdef WRITE_DEPTH
+#define DOZWRITE(x) x
+#else
+#define DOZWRITE(x)
+#endif
+
+#include "ps2hw_ctx0.fx"
+
+// used to get the tiled offset into a page given the linear offset
+texture g_txBlocks;
+texture g_txBilinearBlocks;
+texture g_txSrc;
+
+texture g_txConv16to32;
+texture g_txConv32to16;
+
+// for region_repeat mode
+texture g_txBitwiseANDX;
+texture g_txBitwiseANDY;
+texture g_txCLUT;
+
+sampler g_sSrcFinal : register(s2) = sampler_state {
+ Texture = ;
+ MipFilter = LINEAR;
+ MinFilter = LINEAR;
+ MagFilter = LINEAR;
+ AddressU = Clamp;
+ AddressV = Clamp;
+};
+
+sampler g_sBlocks : register(s3) = sampler_state {
+ Texture = ;
+ MipFilter = POINT;
+ MinFilter = POINT;
+ MagFilter = POINT;
+ AddressU = Wrap;
+ AddressV = Wrap;
+};
+
+sampler g_sBilinearBlocks : register(s4) = sampler_state {
+ Texture = ;
+ MipFilter = POINT;
+ MinFilter = POINT;
+ MagFilter = POINT;
+ AddressU = Wrap;
+ AddressV = Wrap;
+};
+
+sampler g_sConv16to32 : register(s4) = sampler_state {
+ Texture = ;
+ MipFilter = POINT;
+ MinFilter = POINT;
+ MagFilter = POINT;
+ AddressU = Wrap;
+ AddressV = Wrap;
+};
+
+sampler3D g_sConv32to16 : register(s4) = sampler_state {
+ Texture = ;
+ MipFilter = POINT;
+ MinFilter = POINT;
+ MagFilter = POINT;
+ AddressU = Wrap;
+ AddressV = Wrap;
+};
+
+sampler g_sBitwiseANDX : register(s5) = sampler_state {
+ Texture = ;
+ MipFilter = POINT;
+ MinFilter = POINT;
+ MagFilter = POINT;
+ AddressU = Wrap;
+ AddressV = Wrap;
+};
+
+sampler g_sBitwiseANDY : register(s6) = sampler_state {
+ Texture = ;
+ MipFilter = POINT;
+ MinFilter = POINT;
+ MagFilter = POINT;
+ AddressU = Wrap;
+ AddressV = Wrap;
+};
+
+// used only on rare cases where the render target is PSMT8H
+sampler g_sCLUT : register(s2) = sampler_state {
+ Texture = ;
+ MipFilter = POINT;
+ MinFilter = POINT;
+ MagFilter = POINT;
+ AddressU = Wrap;
+ AddressV = Wrap;
+};
+
+// global pixel shader constants
+float4 g_fInvTexDims : register(c22); // similar to g_fClutOff
+float3 g_fFogColor : register(c23);
+
+// used for rectblitting
+float4 g_fBitBltZ : register(c24);
+
+half4 g_fOneColor : register(c25); // col*.xxxy+.zzzw
+
+// vertex shader constants
+float4 g_fBitBltPos : register(c4);
+float4 g_fZ : register(c5); // transforms d3dcolor z into float z
+float2 g_fZNorm : register(c6);
+float4 g_fBitBltTex : register(c7);
+
+// pixel shader consts
+// .z is used for the addressing fn
+half4 g_fExactColor : register(c27) = half4(0.5,0.5/256.0f,0,1/255.0f);
+float3 g_fBilinear : register(c28) = float3(-0.7f, -0.65f, 0.9);
+float4 g_fZBias : register(c29) = half4(1.0f/256.0f, 1.0004f, 1, 0.5);
+float4 g_fc0 : register(c30) = float4(0,1, 0.001, 0.5f); // also for vs
+float4 g_fMult : register(c31) = float4(1/1024.0f, 0.2f/1024.0f, 1/128.0f, 1/512.0f);
+
+// vertex shader consts
+float4 g_fBitBltTrans : register(c31) = float4(0.5f, -0.5f, 0.5, 0.5 + 0.4/416.0f);
+
+// given a local tex coord, returns the coord in the memory
+float2 ps2memcoord(float2 realtex)
+{
+ float4 off;
+
+ // block off
+ realtex.xy = realtex.xy * g_fTexDims.xy + g_fTexDims.zw;
+ realtex.xy = (realtex.xy - frac(realtex.xy)) * g_fMult.zw;
+ float2 fblock = frac(realtex.xy);
+ off.xy = realtex.xy-fblock.xy;
+
+#ifdef ACCURATE_DECOMPRESSION
+ off.zw = tex2D(g_sBlocks, g_fTexBlock.xy*fblock + g_fTexBlock.zw).xw;
+ off.x = dot(off.xyw, g_fTexOffset.xyw);
+ float f = frac(off.x);
+ float fadd = g_fTexOffset.z * off.z;
+ off.w = off.x + fadd;
+ off.x = frac(f + fadd);
+ off.w -= off.x;
+#else
+ off.z = tex2D(g_sBlocks, g_fTexBlock.xy*fblock + g_fTexBlock.zw).r;
+
+ // combine the two
+ off.x = dot(off.xyz, g_fTexOffset.xyz)+g_fTexOffset.w;
+ off.x = modf(off.x, off.w);
+#endif
+
+ off.y = off.w * g_fPageOffset.y + g_fPageOffset.x;
+ return off.xy;
+}
+
+// find all texcoords for bilinear filtering
+// assume that orgtex are already on boundaries
+void ps2memcoord4(float4 orgtex, out float4 off0, out float4 off1)
+{
+ //float4 off0, off1, off2, off3;
+ float4 realtex;
+
+ // block off
+ realtex = (orgtex * g_fTexDims.xyxy + g_fTexDims.zwzw);// * g_fMult.zwzw;
+ float4 fblock = frac(realtex.xyzw);
+ float4 ftransblock = g_fTexBlock.xyxy*fblock + g_fTexBlock.zwzw;
+ realtex -= fblock;
+
+ float4 transvals = g_fTexOffset.x * realtex.xzxz + g_fTexOffset.y * realtex.yyww + g_fTexOffset.w;
+
+ float4 colors;// = tex2D(g_sBilinearBlocks, ftransblock.xy);
+
+ // this is faster on ffx ingame
+ colors.x = tex2D(g_sBlocks, ftransblock.xy).r;
+ colors.y = tex2D(g_sBlocks, ftransblock.zy).r;
+ colors.z = tex2D(g_sBlocks, ftransblock.xw).r;
+ colors.w = tex2D(g_sBlocks, ftransblock.zw).r;
+
+ float4 fr, rem;
+
+#ifdef ACCURATE_DECOMPRESSION
+ fr = frac(transvals);
+ float4 fadd = colors * g_fTexOffset.z;
+ rem = transvals + fadd;
+ fr = frac(fr + fadd);
+ rem -= fr;
+#else
+ transvals += colors * g_fTexOffset.z;
+
+ fr = modf(transvals, rem);
+#endif
+
+ rem = rem * g_fPageOffset.y + g_fPageOffset.x;
+
+ // combine
+ off0 = g_fc0.yxyx * fr.xxyy + g_fc0.xyxy * rem.xxyy;
+ off1 = g_fc0.yxyx * fr.zzww + g_fc0.xyxy * rem.zzww;
+}
+
+void ps2memcoord4_fast(float4 orgtex, out float4 off0, out float4 off1)
+{
+ float4 realtex;
+
+ realtex = (orgtex * g_fTexDims.xyxy + g_fTexDims.zwzw);// * g_fMult.zwzw;
+ float4 fblock = frac(realtex.xyzw);
+ float2 ftransblock = g_fTexBlock.xy*fblock.xy + g_fTexBlock.zw;
+ realtex -= fblock;
+
+ float4 transvals = g_fTexOffset.x * realtex.xzxz + g_fTexOffset.y * realtex.yyww + g_fTexOffset.w;
+
+ float4 colors = tex2D(g_sBilinearBlocks, ftransblock.xy);
+ float4 fr, rem;
+
+#ifdef ACCURATE_DECOMPRESSION
+ fr = frac(transvals);
+ float4 fadd = colors * g_fTexOffset.z;
+ rem = transvals + fadd;
+ fr = frac(fr + fadd);
+ rem -= fr;
+#else
+ transvals += colors * g_fTexOffset.z;
+
+ fr = modf(transvals, rem);
+#endif
+
+ rem = rem * g_fPageOffset.y + g_fPageOffset.x;
+
+ off0 = g_fc0.yxyx * fr.xxyy + g_fc0.xyxy * rem.xxyy;
+ off1 = g_fc0.yxyx * fr.zzww + g_fc0.xyxy * rem.zzww;
+}
+
+// Wrapping modes
+#if defined(REPEAT)
+
+float2 ps2addr(float2 coord)
+{
+ return frac(coord.xy);
+}
+
+#elif defined(CLAMP)
+
+float2 ps2addr(float2 coord)
+{
+ return clamp(coord.xy, g_fClampExts.xy, g_fClampExts.zw);
+}
+
+#elif defined(REGION_REPEAT)
+
+// computes the local tex coord along with addressing modes
+float2 ps2addr(float2 coord)
+{
+ float2 final = frac(clamp(coord.xy, g_fClampExts.xy, g_fClampExts.zw));
+
+ if( TexWrapMode.x > g_fBilinear.z ) // region repeat mode for x (umsk&x)|ufix
+ final.x = tex2D(g_sBitwiseANDX, abs(coord.x)*TexWrapMode.z).x * g_fClampExts.x + g_fClampExts.z;
+ if( TexWrapMode.y > g_fBilinear.z ) // region repeat mode for x (vmsk&x)|vfix
+ final.y = tex2D(g_sBitwiseANDY, abs(coord.y)*TexWrapMode.w).x * g_fClampExts.y + g_fClampExts.w;
+
+ return final;
+}
+
+#else
+
+float2 ps2addr(float2 coord)
+{
+ return frac(clamp(coord.xy, g_fClampExts.xy, g_fClampExts.zw));
+}
+
+#endif
+
+half4 tex2DPS_32(float2 tex0)
+{
+ return tex2D(g_sMemory, ps2memcoord(tex0).xy);
+}
+
+// use when texture is not tiled
+half4 tex2DPS_tex32(float2 tex0)
+{
+ return tex2D(g_sMemory, g_fTexDims.xy*tex0+g_fTexDims.zw)*g_fZBias.zzzw+g_fPageOffset.w;
+}
+
+// use when texture is not tiled
+half4 tex2DPS_clut32(float2 tex0)
+{
+ float index = tex2D(g_sMemory, g_fTexDims.xy*tex0+g_fTexDims.zw).a+g_fPageOffset.w;
+ return tex1D(g_sCLUT, index*g_fExactColor.x+g_fExactColor.y);
+}
+
+// use when texture is not tiled and converting from 32bit to 16bit
+// don't convert on the block level, only on the column level
+// so every other 8 pixels, use the upper bits instead of lower
+half4 tex2DPS_tex32to16(float2 tex0)
+{
+ bool upper = false;
+ tex0.y += g_fPageOffset.z;
+ float2 ffrac = fmod(tex0, g_fTexOffset.xy);
+ //tex0.xy = g_fc0.ww * (tex0.xy + ffrac);
+ tex0.y += ffrac.y;
+
+ if( ffrac.x > g_fTexOffset.z ) {
+ tex0.x -= g_fTexOffset.z;
+ upper = true;
+ }
+ if( ffrac.y >= g_fTexOffset.w ) {
+ tex0.y -= g_fTexOffset.y;
+ tex0.x += g_fTexOffset.z;
+ }
+
+ half4 color = tex2D(g_sMemory, g_fTexDims.xy*tex0+g_fTexDims.zw)*g_fZBias.zzzw+g_fPageOffset.w;
+ float2 uv = upper ? color.xw : color.zy;
+ return tex2D(g_sConv16to32, uv+g_fPageOffset.xy).zyxw;
+}
+
+// used when a 16 bit texture is used an 8h
+half4 tex2DPS_tex16to8h(float2 tex0)
+{
+ float4 final;
+ float2 ffrac = fmod(tex0+g_fPageOffset.zw, g_fTexOffset.xy);
+ //tex0.xy = g_fPageOffset.xy * tex0.xy - ffrac * g_fc0.yw;
+ tex0.y += g_fPageOffset.y * ffrac.y;
+
+ if( ffrac.x > g_fTexOffset.z ) {
+ tex0.x -= g_fTexOffset.z;
+ tex0.y += g_fTexOffset.w;
+ }
+
+ float4 upper = tex2D(g_sMemory, g_fTexDims.xy*tex0+g_fTexDims.zw);
+
+ // only need alpha
+ float index = tex3D(g_sConv32to16, upper.zyx-g_fc0.z).y + upper.w*g_fc0.w*g_fc0.w;
+ return tex1D(g_sCLUT, index+g_fExactColor.y);
+}
+
+// used when a 16 bit texture is used a 32bit one
+half4 tex2DPS_tex16to32(float2 tex0)
+{
+ float4 final;
+ float2 ffrac = fmod(tex0+g_fPageOffset.zw, g_fTexOffset.xy);
+ //tex0.xy = g_fPageOffset.xy * tex0.xy - ffrac * g_fc0.yw;
+ tex0.y += g_fPageOffset.y * ffrac.y;
+
+ if( ffrac.x > g_fTexOffset.z ) {
+ tex0.x -= g_fTexOffset.z;
+ tex0.y += g_fTexOffset.w;
+ }
+
+ float fconst = g_fc0.w*g_fc0.w;
+ float4 lower = tex2D(g_sSrcFinal, g_fTexDims.xy*tex0);
+ float4 upper = tex2D(g_sMemory, g_fTexDims.xy*tex0+g_fTexDims.zw);
+
+ final.zy = tex3D(g_sConv32to16, lower.zyx).xy + lower.ww*fconst;
+ final.xw = tex3D(g_sConv32to16, upper.zyx).xy + upper.ww*fconst;
+ return final;
+}
+
+//half4 f;
+//f.w = old.y > (127.2f/255.0f) ? 1 : 0;
+//old.y -= 0.5f * f.w;
+//f.xyz = frac(old.yyx*half3(2.002*255.0f/256.0f, 64.025f*255.0f/256.0f, 8.002*255.0f/256.0f));
+//f.y += old.x * (0.25f*255.0f/256.0f);
+
+////////////////////////////////
+// calculates the texture color
+////////////////////////////////
+
+#define decl_ps2shade(num) \
+decl_ps2shade_##num(_32); \
+decl_ps2shade_##num(_tex32); \
+decl_ps2shade_##num(_clut32); \
+decl_ps2shade_##num(_tex32to16); \
+decl_ps2shade_##num(_tex16to8h); \
+
+// nearest
+#define decl_ps2shade_0(bit) \
+half4 ps2shade0##bit( TEX_DECL tex) \
+{ \
+ return tex2DPS##bit( ps2addr(TEX_XY)); \
+} \
+
+// do fast memcoord4 calcs when textures behave well
+#ifdef REPEAT
+#define PS2MEMCOORD4 ps2memcoord4
+#else
+#define PS2MEMCOORD4 ps2memcoord4
+#endif
+
+#define decl_BilinearFilter(bit, addrfn) \
+half4 BilinearFilter##bit(float2 tex0) \
+{ \
+ float4 off0, off1; \
+ float4 ftex; \
+ float2 ffrac; \
+ ftex.xy = tex0 + g_fBilinear.xy * g_fRealTexDims.zw; \
+ ffrac = frac(ftex.xy*g_fRealTexDims.xy); \
+ ftex.xy -= ffrac.xy * g_fRealTexDims.zw; \
+ \
+ ftex.zw = ps2addr(ftex.xy + g_fRealTexDims.zw); \
+ ftex.xy = ps2addr(ftex.xy); \
+ \
+ PS2MEMCOORD4(ftex, off0, off1); \
+ half4 c0 = tex2D(g_sMemory, off0.xy); \
+ half4 c1 = tex2D(g_sMemory, off0.zw); \
+ half4 c2 = tex2D(g_sMemory, off1.xy); \
+ half4 c3 = tex2D(g_sMemory, off1.zw); \
+ return lerp( lerp(c0, c1, ffrac.x), lerp(c2, c3, ffrac.x), ffrac.y ); \
+} \
+
+decl_BilinearFilter(_32, ps2addr);
+decl_BilinearFilter(_tex32, ps2addr);
+decl_BilinearFilter(_clut32, ps2addr);
+decl_BilinearFilter(_tex32to16, ps2addr);
+decl_BilinearFilter(_tex16to8h, ps2addr);
+
+//TODO! For mip maps, only apply when LOD >= 0
+// lcm == 0, LOD = log(1/Q)*L + K, lcm == 1, LOD = K
+
+// bilinear
+#define decl_ps2shade_1(bit) \
+half4 ps2shade1##bit(TEX_DECL tex) \
+{ \
+ return BilinearFilter##bit(TEX_XY); \
+} \
+
+// nearest, mip nearest
+#define decl_ps2shade_2(bit) \
+half4 ps2shade2##bit(TEX_DECL tex) \
+{ \
+ return tex2DPS##bit( ps2addr(TEX_XY)); \
+} \
+
+// nearest, mip linear
+#define decl_ps2shade_3(bit) \
+half4 ps2shade3##bit(TEX_DECL tex) \
+{ \
+ return tex2DPS##bit(ps2addr(TEX_XY)); \
+} \
+
+// linear, mip nearest
+#define decl_ps2shade_4(bit) \
+half4 ps2shade4##bit(TEX_DECL tex) \
+{ \
+ return BilinearFilter##bit(TEX_XY); \
+} \
+
+// linear, mip linear
+#define decl_ps2shade_5(bit) \
+half4 ps2shade5##bit(TEX_DECL tex) \
+{ \
+ return BilinearFilter##bit(TEX_XY); \
+} \
+
+decl_ps2shade(0);
+decl_ps2shade(1);
+decl_ps2shade(2);
+decl_ps2shade(3);
+decl_ps2shade(4);
+decl_ps2shade(5);
+
+half4 ps2CalcShade(half4 texcol, half4 color)
+{
+#ifdef TEST_AEM
+ if( dot(texcol.xyzw, g_fTestBlack.xyzw) <= g_fc0.z )
+ texcol.w = g_fc0.x;
+ else
+#endif
+ texcol.w = texcol.w * fTexAlpha.y + fTexAlpha.x;
+
+ texcol = texcol * (fTexAlpha2.zzzw * color + fTexAlpha2.xxxy) + fTexAlpha.zzzw * color.wwww;
+
+ return texcol;
+}
+
+// final ops on the color
+#ifdef EXACT_COLOR
+
+half4 ps2FinalColor(half4 col)
+{
+ // g_fOneColor has to scale by 255
+ half4 temp = col * g_fOneColor.xxxy + g_fOneColor.zzzw;
+ temp.w = floor(temp.w)*g_fExactColor.w;
+ return temp;
+}
+
+#else
+half4 ps2FinalColor(half4 col)
+{
+ return col * g_fOneColor.xxxy + g_fOneColor.zzzw;
+}
+#endif
+
+////////////////
+// Techniques //
+////////////////
+
+// technique to copy a rectangle from source to target
+struct VSOUT_
+{
+ float4 pos : POSITION;
+ half4 color : COLOR0;
+ DOZWRITE(float4 z : TEXCOORD0;)
+};
+
+struct VSOUT_T
+{
+ float4 pos : POSITION;
+ half4 color : COLOR0;
+ TEX_DECL tex : TEXCOORD0;
+ DOZWRITE(float4 z : TEXCOORD1;)
+};
+
+struct VSOUT_F
+{
+ float4 pos : POSITION;
+ half4 color : COLOR0;
+ float fog : TEXCOORD0;
+ DOZWRITE(float4 z : TEXCOORD1;)
+};
+
+struct VSOUT_TF
+{
+ float4 pos : POSITION;
+ half4 color : COLOR0;
+ TEX_DECL tex : TEXCOORD0;
+ half fog : TEXCOORD1;
+ DOZWRITE(float4 z : TEXCOORD2;)
+};
+
+// just smooth shadering
+VSOUT_ RegularVS(float4 pos : POSITION,
+ half4 color : COLOR0,
+ float4 z : TEXCOORD0
+ )
+{
+ VSOUT_ o;
+
+ o.pos.xy = pos.xy*g_fPosXY.xy+g_fPosXY.zw;
+ o.pos.z = log(g_fc0.y+dot(g_fZ, z.zyxw))*g_fZNorm.x+g_fZNorm.y;
+ o.pos.w = g_fc0.y; // 1
+ o.color = color;
+
+ DOZWRITE(o.z = z*g_fZBias.x+g_fZBias.y; o.z.w = g_fc0.y;)
+ return o;
+}
+
+void RegularPS(VSOUT_ i, out half4 c0 : COLOR0
+#ifdef WRITE_DEPTH
+ , out float4 c1 : COLOR1
+#endif
+ )
+{
+ // whenever outputting depth, make sure to mult by 255/256 and 1
+ c0 = ps2FinalColor(i.color);
+ DOZWRITE(c1 = i.z;)
+}
+
+technique Regular {
+ pass p0 {
+ VertexShader = compile vs_3_0 RegularVS();
+ PixelShader = compile ps_3_0 RegularPS();
+ }
+};
+
+// diffuse texture mapping
+VSOUT_T TextureVS(float4 pos : POSITION,
+ half4 color : COLOR0,
+ float3 tex0 : TEXCOORD1,
+ float4 z : TEXCOORD0)
+{
+ VSOUT_T o;
+ o.pos.xy = pos.xy*g_fPosXY.xy+g_fPosXY.zw;
+ o.pos.z = log(g_fc0.y+dot(g_fZ, z.zyxw))*g_fZNorm.x + g_fZNorm.y;
+ o.pos.w = g_fc0.y;
+ o.color = color;
+ DOZWRITE(o.z = z*g_fZBias.x+g_fZBias.y; o.z.w = g_fc0.y;)
+#ifdef PERSPECTIVE_CORRECT_TEX
+ o.tex = tex0;
+#else
+ o.tex = tex0.xy/tex0.z;
+#endif
+ return o;
+}
+
+#ifdef WRITE_DEPTH
+
+#define DECL_TEXPS(num, bit) \
+void Texture##num##bit##PS(VSOUT_T i, out half4 c0 : COLOR0, out float4 c1 : COLOR1) \
+{ \
+ c0 = ps2FinalColor(ps2CalcShade(ps2shade##num##bit(i.tex), i.color)); \
+ c1 = i.z; \
+} \
+
+#else
+
+#define DECL_TEXPS(num, bit) \
+void Texture##num##bit##PS(VSOUT_T i, out half4 c0 : COLOR0) \
+{ \
+ c0 = ps2FinalColor(ps2CalcShade(ps2shade##num##bit(i.tex), i.color)); \
+} \
+
+#endif
+
+#define DECL_TEXPS_(num) \
+DECL_TEXPS(num, _32); \
+DECL_TEXPS(num, _tex32); \
+DECL_TEXPS(num, _clut32); \
+DECL_TEXPS(num, _tex32to16); \
+DECL_TEXPS(num, _tex16to8h); \
+
+DECL_TEXPS_(0);
+DECL_TEXPS_(1);
+DECL_TEXPS_(2);
+DECL_TEXPS_(3);
+DECL_TEXPS_(4);
+DECL_TEXPS_(5);
+
+// special functions for limitations on ps20
+technique Texture {
+ pass p0 {
+ VertexShader = compile vs_2_0 TextureVS();
+ PixelShader = compile ps_2_a Texture0_32PS();
+ }
+}
+
+VSOUT_F RegularFogVS(float4 pos : POSITION,
+ half4 color : COLOR0,
+ float4 z : TEXCOORD0)
+{
+ VSOUT_F o;
+
+ o.pos.xy = pos.xy*g_fPosXY.xy+g_fPosXY.zw;
+ o.pos.z = log(g_fc0.y+dot(g_fZ, z.zyxw))*g_fZNorm.x+g_fZNorm.y;
+ o.pos.w = g_fc0.y;
+ DOZWRITE(o.z = z*g_fZBias.x+g_fZBias.y; o.z.w = g_fc0.y;)
+ o.color = color;
+ o.fog = pos.z;
+ return o;
+}
+
+void RegularFogPS(VSOUT_F i, out half4 c0 : COLOR0
+#ifdef WRITE_DEPTH
+ , out float4 c1 : COLOR1
+#endif
+ )
+{
+ half4 c;
+ c.xyz = lerp(g_fFogColor.xyz, i.color.xyz, i.fog); \
+ c.w = i.color.w;
+ c0 = ps2FinalColor(c);
+ DOZWRITE(c1 = i.z;)
+}
+
+technique RegularFog {
+ pass p0 {
+ VertexShader = compile vs_2_0 RegularFogVS();
+ PixelShader = compile ps_2_a RegularFogPS();
+ }
+};
+
+VSOUT_TF TextureFogVS(float4 pos : POSITION,
+ half4 color : COLOR0,
+ float3 tex0 : TEXCOORD1,
+ float4 z : TEXCOORD0)
+{
+ VSOUT_TF o;
+
+ o.pos.xy = pos.xy*g_fPosXY.xy+g_fPosXY.zw;
+ o.pos.z = log(g_fc0.y+dot(g_fZ, z.zyxw))*g_fZNorm.x+g_fZNorm.y;
+ o.pos.w = g_fc0.y;
+ o.color = color;
+ o.fog = pos.z;
+ DOZWRITE(o.z = z*g_fZBias.x+g_fZBias.y; o.z.w = g_fc0.y;)
+#ifdef PERSPECTIVE_CORRECT_TEX
+ o.tex = tex0;
+#else
+ o.tex = tex0.xy/tex0.z;
+#endif
+ return o;
+}
+
+#ifdef WRITE_DEPTH
+
+#define DECL_TEXFOGPS(num, bit) \
+void TextureFog##num##bit##PS(VSOUT_TF i, out half4 c0 : COLOR0, out float4 c1 : COLOR1 ) \
+{ \
+ half4 c = ps2CalcShade(ps2shade##num##bit(i.tex), i.color); \
+ c.xyz = lerp(g_fFogColor.xyz, c.xyz, i.fog); \
+ c0 = ps2FinalColor(c); \
+ c1 = i.z; \
+} \
+
+#else
+
+#define DECL_TEXFOGPS(num, bit) \
+void TextureFog##num##bit##PS(VSOUT_TF i, out half4 c0 : COLOR0) \
+{ \
+ half4 c = ps2CalcShade(ps2shade##num##bit(i.tex), i.color); \
+ c.xyz = lerp(g_fFogColor.xyz, c.xyz, i.fog); \
+ c0 = ps2FinalColor(c); \
+} \
+
+#endif
+
+#define DECL_TEXFOGPS_(num) \
+DECL_TEXFOGPS(num, _32); \
+DECL_TEXFOGPS(num, _tex32); \
+DECL_TEXFOGPS(num, _clut32); \
+DECL_TEXFOGPS(num, _tex32to16); \
+DECL_TEXFOGPS(num, _tex16to8h); \
+
+DECL_TEXFOGPS_(0);
+DECL_TEXFOGPS_(1);
+DECL_TEXFOGPS_(2);
+DECL_TEXFOGPS_(3);
+DECL_TEXFOGPS_(4);
+DECL_TEXFOGPS_(5);
+
+technique TextureFog {
+ pass p0 {
+ VertexShader = compile vs_2_0 TextureFogVS();
+ PixelShader = compile ps_2_a TextureFog0_32PS();
+ }
+};
+
+//-------------------------------------------------------
+// Techniques not related to the main primitive commands
+half4 BilinearBitBlt(float2 tex0)
+{
+ float4 ftex;
+ float2 ffrac;
+
+ ffrac.xy = frac(tex0*g_fRealTexDims.xy);
+ ftex.xy = tex0 - ffrac.xy * g_fRealTexDims.zw;
+ ftex.zw = ftex.xy + g_fRealTexDims.zw;
+
+ float4 off0, off1;
+ ps2memcoord4_fast(ftex, off0, off1);
+ half4 c0 = tex2D(g_sMemory, off0.xy);
+ half4 c1 = tex2D(g_sMemory, off0.zw);
+ half4 c2 = tex2D(g_sMemory, off1.xy);
+ half4 c3 = tex2D(g_sMemory, off1.zw);
+
+ return lerp( lerp(c0, c1, ffrac.x), lerp(c2, c3, ffrac.x), ffrac.y );
+}
+
+void BitBltVS(in float4 pos : POSITION,
+ in half4 tex0 : TEXCOORD0,
+ in float3 tex : TEXCOORD1,
+ out float4 opos : POSITION,
+ out float2 otex0 : TEXCOORD0,
+ out float2 ointerpos : TEXCOORD1)
+{
+ opos.xy = pos.xy * g_fBitBltPos.xy + g_fBitBltPos.zw;
+ ointerpos = opos.xy * g_fBitBltTrans.xy + g_fBitBltTrans.zw;
+ opos.zw = g_fc0.xy;
+ otex0 = tex * g_fBitBltTex.xy + g_fBitBltTex.zw;
+}
+
+half4 BitBltPS(in float2 tex0 : TEXCOORD0) : COLOR
+{
+ return tex2D(g_sMemory, ps2memcoord(tex0).xy)*g_fOneColor.xxxy;
+}
+
+// used when AA
+half4 BitBltAAPS(in float2 tex0 : TEXCOORD0) : COLOR
+{
+ return BilinearBitBlt(tex0)*g_fOneColor.xxxy;
+}
+
+void BitBltDepthPS(in float2 tex0 : TEXCOORD0,
+ out float4 c : COLOR0,
+ out float depth : DEPTH)
+{
+ c = tex2D(g_sMemory, ps2memcoord(tex0));
+
+ depth = log(g_fc0.y+dot(c, g_fBitBltZ))*g_fOneColor.w;
+ c += g_fZBias.y;
+}
+
+void BitBltDepthMRTPS(in float2 tex0 : TEXCOORD0,
+ out half4 c0 : COLOR0,
+ out float4 c1 : COLOR1,
+ out float depth : DEPTH)
+{
+ c1 = tex2D(g_sMemory, ps2memcoord(tex0));
+
+ depth = log(g_fc0.y+dot(c1, g_fBitBltZ))*g_fOneColor.w;
+ c1 += g_fZBias.y;
+ c0 = g_fc0.x;
+}
+
+// no swizzling
+void BitBltDepthTexPS(in float2 tex0 : TEXCOORD0,
+ out float4 c : COLOR0,
+ out float depth : DEPTH)
+{
+ c = tex2D(g_sSrcFinal, tex0);
+
+ depth = log(g_fc0.y+dot(c-g_fZBias.y, g_fBitBltZ))*g_fOneColor.w;
+ //c += g_fZBias.y;
+}
+
+// no swizzling
+void BitBltDepthTexMRTPS(in float2 tex0 : TEXCOORD0,
+ out half4 c0 : COLOR0,
+ out float4 c1 : COLOR1,
+ out float depth : DEPTH)
+{
+ c1 = tex2D(g_sSrcFinal, tex0);
+
+ depth = log(g_fc0.y+dot(c1-g_fZBias.y, g_fBitBltZ))*g_fOneColor.w;
+ //c1 += g_fZBias.y;
+ c0 = g_fc0.x;
+}
+
+technique BitBlt {
+ pass p0 {
+ VertexShader = compile vs_1_1 BitBltVS();
+ PixelShader = compile ps_2_0 BitBltDepthMRTPS();
+ }
+}
+
+/*static const float BlurKernel[9] = {
+ 0.027601,
+ 0.066213,
+ 0.123701,
+ 0.179952,
+ 0.205065,
+ 0.179952,
+ 0.123701,
+ 0.066213,
+ 0.027601
+};*/
+
+half4 BilinearFloat16(float2 tex0)
+{
+ /*float4 ffrac, ftex;
+ ffrac.xy = frac(tex0);
+ ftex.xy = (tex0 - ffrac.xy) * g_fInvTexDims.xy + g_fInvTexDims.zw;
+ ftex.zw = ftex.xy + g_fInvTexDims.xy;
+
+ half4 c0 = tex2D(g_sSrcFinal, ftex.xy);
+ half4 c1 = tex2D(g_sSrcFinal, ftex.zy);
+ half4 c2 = tex2D(g_sSrcFinal, ftex.xw);
+ half4 c3 = tex2D(g_sSrcFinal, ftex.zw);
+
+ return lerp( lerp(c0, c1, ffrac.x), lerp(c2, c3, ffrac.x), ffrac.y );*/
+ return tex2D(g_sSrcFinal, tex0.xy);
+// return 0.55f * tex2D(g_sSrcFinal, tex0.xy) +
+// 0.15f * tex2D(g_sSrcFinal, tex0.xy+g_fInvTexDims.xz) +
+// 0.15f * tex2D(g_sSrcFinal, tex0.xy+g_fInvTexDims.zy) +
+// 0.15f * tex2D(g_sSrcFinal, tex0.xy+g_fInvTexDims.xy);
+}
+
+half4 CRTCTargInterPS(in float2 tex0 : TEXCOORD0, in float2 ointerpos : TEXCOORD1) : COLOR
+{
+ float finter = tex1D(g_sBitwiseANDX, ointerpos.y).x;
+ clip(finter * g_fOneColor.z + g_fOneColor.w);
+
+ half4 c = BilinearFloat16(tex0);
+ c.w = g_fc0.w*c.w * g_fOneColor.x + g_fOneColor.y;
+ return c.zyxw;
+}
+
+half4 CRTCTargPS(in float2 tex0 : TEXCOORD0) : COLOR
+{
+ float4 c = BilinearFloat16(tex0);
+ c.w = g_fc0.w*c.w * g_fOneColor.x + g_fOneColor.y;
+ return c.zyxw;
+}
+
+half4 CRTCInterPS(in float2 tex0 : TEXCOORD0, in float2 ointerpos : TEXCOORD1) : COLOR
+{
+ float2 filtcoord = (tex0-frac(tex0))*g_fInvTexDims.xy+g_fInvTexDims.zw;
+ float finter = tex1D(g_sBitwiseANDX, ointerpos.y).x;
+ clip(finter * g_fOneColor.z + g_fOneColor.w);
+
+ half4 c = BilinearBitBlt(filtcoord);
+ c.w = c.w * g_fOneColor.x + g_fOneColor.y;
+
+ return c.zyxw;
+}
+
+half4 CRTCPS(in float2 tex0 : TEXCOORD0) : COLOR
+{
+ float2 filtcoord = (tex0/*-frac(tex0)*/)*g_fInvTexDims.xy+g_fInvTexDims.zw;
+ half4 c = BilinearBitBlt(filtcoord);
+ c.w = c.w * g_fOneColor.x + g_fOneColor.y;
+
+ return c.zyxw;
+}
+
+half4 CRTC24InterPS(in float2 tex0 : TEXCOORD0, in float2 ointerpos : TEXCOORD1) : COLOR
+{
+ float2 filtcoord = (tex0-frac(tex0))*g_fInvTexDims.xy+g_fInvTexDims.zw;
+ float finter = tex1D(g_sBitwiseANDX, ointerpos.y).x;
+ clip(finter * g_fOneColor.z + g_fOneColor.w);
+
+ half4 c = tex2D(g_sMemory, ps2memcoord(filtcoord).xy).x;
+ c.w = c.w * g_fOneColor.x + g_fOneColor.y;
+
+ return c.zyxw;
+}
+
+half4 CRTC24PS(in float2 tex0 : TEXCOORD0) : COLOR
+{
+ float2 filtcoord = (tex0-frac(tex0))*g_fInvTexDims.xy+g_fInvTexDims.zw;
+ half4 c = tex2D(g_sMemory, ps2memcoord(filtcoord).xy).x;
+ c.w = c.w * g_fOneColor.x + g_fOneColor.y;
+
+ return c.zyxw;
+}
+
+technique CRTC {
+ pass p0 {
+ VertexShader = compile vs_1_1 BitBltVS();
+ PixelShader = compile ps_2_0 CRTCTargInterPS();
+ }
+}
+
+half4 ZeroPS() : COLOR
+{
+ return g_fOneColor.x;
+}
+
+half4 BaseTexturePS(in float2 tex0 : TEXCOORD0) : COLOR
+{
+ return tex2D(g_sSrcFinal, tex0) * g_fOneColor;
+}
+
+// inverse of 32->16bit conversion
+half4 Convert16to32PS(float2 tex0 : TEXCOORD0) : COLOR
+{
+ float4 final;
+ float2 ffrac = fmod(tex0+g_fTexDims.zw, g_fTexOffset.xy);
+ tex0.y += g_fTexDims.y * ffrac.y;
+
+ if( ffrac.x > g_fTexOffset.z ) {
+ tex0.x -= g_fTexOffset.z;
+ tex0.y += g_fTexOffset.w;
+ }
+
+ float4 lower = tex2D(g_sSrcFinal, tex0);
+ float4 upper = tex2D(g_sSrcFinal, tex0+g_fPageOffset.xy);
+
+ //return half4(frac(32*tex0.x),frac(7*tex0.y),0,1);
+ final.zy = tex3D(g_sConv32to16, lower.zyx).xy + lower.ww*g_fPageOffset.zw;
+ final.xw = tex3D(g_sConv32to16, upper.zyx).xy + upper.ww*g_fPageOffset.zw;
+ return final;
+}
+
+// use when texture is not tiled and converting from 32bit to 16bit
+// one condition is that the converted texture has to keep the same block configuration
+// every 16 32bit horz pixels gets converted to 16x2 16bit horz pixels.
+// the first row is the first 8 pixels, the second row is the last 8 pixels
+// the last 8 columns are the upper bits
+half4 Convert32to16PS(float2 tex0 : TEXCOORD0) : COLOR
+{
+ bool upper = false;
+ float2 ffrac = fmod(tex0+g_fTexDims.zw, g_fTexOffset.xy);
+ //tex0 += g_fTexDims.xy * ffrac;
+ //tex0.y += g_fTexDims.y * ffrac.y;
+ tex0.y += ffrac.y;
+ //tex0.x -= g_fc0.w*ffrac.x;
+ if( ffrac.x > g_fTexOffset.z ) {
+ tex0.x -= g_fTexOffset.z;
+ upper = true;
+ }
+ if( ffrac.y >= g_fTexOffset.w ) {
+ tex0.y -= g_fTexOffset.y;
+ tex0.x += g_fTexOffset.z;
+ }
+
+ //return half4(frac(32*tex0.x),frac(7*tex0.y),0,1);
+ half4 color = tex2D(g_sSrcFinal, tex0)*g_fc0.yyyw;
+ float2 uv = upper ? color.xw : color.zy;
+ return tex2D(g_sConv16to32, uv*g_fPageOffset.xy+g_fPageOffset.zw).zyxw*g_fOneColor;
+}
diff --git a/plugins/zerogs/dx/ps2hw_ctx0.fx b/plugins/zerogs/dx/ps2hw_ctx0.fx
index 0e2b100f20..37c269a026 100644
--- a/plugins/zerogs/dx/ps2hw_ctx0.fx
+++ b/plugins/zerogs/dx/ps2hw_ctx0.fx
@@ -1,33 +1,33 @@
-// main ps2 memory, each pixel is stored in 32bit color
-texture g_txMem0;
-
-sampler g_sMemory : register(s0) = sampler_state {
- Texture = ;
- MipFilter = POINT;
- MinFilter = POINT;
- MagFilter = POINT;
- AddressU = Clamp;
- AddressV = Clamp;
-};
-
-// per context pixel shader constants
-half4 fTexAlpha2 : register(c2);
-
-float4 g_fTexOffset : register(c4); // converts the page and block offsets into the mem addr/1024
-float4 g_fTexDims : register(c6); // mult by tex dims when accessing the block texture
-float4 g_fTexBlock : register(c8);
-
-float4 g_fClampExts : register(c10); // if clamping the texture, use (minu, minv, maxu, maxv)
-float4 TexWrapMode : register(c12); // 0 - repeat/clamp, 1 - region rep (use fRegRepMask)
-
-float4 g_fRealTexDims : register(c14); // tex dims used for linear filtering (w,h,1/w,1/h)
-
-// (alpha0, alpha1, 1 if highlight2 and tcc is rgba, 1-y)
-half4 g_fTestBlack : register(c16); // used for aem bit
-
-float4 g_fPageOffset : register(c18);
-
-half4 fTexAlpha : register(c20);
-
-// vertex shader constants
+// main ps2 memory, each pixel is stored in 32bit color
+texture g_txMem0;
+
+sampler g_sMemory : register(s0) = sampler_state {
+ Texture = ;
+ MipFilter = POINT;
+ MinFilter = POINT;
+ MagFilter = POINT;
+ AddressU = Clamp;
+ AddressV = Clamp;
+};
+
+// per context pixel shader constants
+half4 fTexAlpha2 : register(c2);
+
+float4 g_fTexOffset : register(c4); // converts the page and block offsets into the mem addr/1024
+float4 g_fTexDims : register(c6); // mult by tex dims when accessing the block texture
+float4 g_fTexBlock : register(c8);
+
+float4 g_fClampExts : register(c10); // if clamping the texture, use (minu, minv, maxu, maxv)
+float4 TexWrapMode : register(c12); // 0 - repeat/clamp, 1 - region rep (use fRegRepMask)
+
+float4 g_fRealTexDims : register(c14); // tex dims used for linear filtering (w,h,1/w,1/h)
+
+// (alpha0, alpha1, 1 if highlight2 and tcc is rgba, 1-y)
+half4 g_fTestBlack : register(c16); // used for aem bit
+
+float4 g_fPageOffset : register(c18);
+
+half4 fTexAlpha : register(c20);
+
+// vertex shader constants
float4 g_fPosXY : register(c2);
\ No newline at end of file
diff --git a/plugins/zerogs/dx/ps2hw_ctx1.fx b/plugins/zerogs/dx/ps2hw_ctx1.fx
index f9423a9019..608ee4022c 100644
--- a/plugins/zerogs/dx/ps2hw_ctx1.fx
+++ b/plugins/zerogs/dx/ps2hw_ctx1.fx
@@ -1,32 +1,32 @@
-texture g_txMem1;
-
-sampler g_sMemory : register(s1) = sampler_state {
- Texture = ;
- MipFilter = POINT;
- MinFilter = POINT;
- MagFilter = POINT;
- AddressU = Clamp;
- AddressV = Clamp;
-};
-
-// per context pixel shader constants
-half4 fTexAlpha2 : register(c3);
-
-float4 g_fTexOffset : register(c5); // converts the page and block offsets into the mem addr/1024
-float4 g_fTexDims : register(c7); // mult by tex dims when accessing the block texture
-float4 g_fTexBlock : register(c9);
-
-float4 g_fClampExts : register(c11); // if clamping the texture, use (minu, minv, maxu, maxv)
-float4 TexWrapMode : register(c13); // 0 - repeat/clamp, 1 - region rep (use fRegRepMask)
-
-float4 g_fRealTexDims : register(c15); // tex dims used for linear filtering (w,h,1/w,1/h)
-
-// (alpha0, alpha1, 1 if highlight2 and tcc is rgba, 1-y)
-half4 g_fTestBlack : register(c17); // used for aem bit
-
-float4 g_fPageOffset : register(c19);
-
-half4 fTexAlpha : register(c21);
-
-// vertex shader constants
+texture g_txMem1;
+
+sampler g_sMemory : register(s1) = sampler_state {
+ Texture = ;
+ MipFilter = POINT;
+ MinFilter = POINT;
+ MagFilter = POINT;
+ AddressU = Clamp;
+ AddressV = Clamp;
+};
+
+// per context pixel shader constants
+half4 fTexAlpha2 : register(c3);
+
+float4 g_fTexOffset : register(c5); // converts the page and block offsets into the mem addr/1024
+float4 g_fTexDims : register(c7); // mult by tex dims when accessing the block texture
+float4 g_fTexBlock : register(c9);
+
+float4 g_fClampExts : register(c11); // if clamping the texture, use (minu, minv, maxu, maxv)
+float4 TexWrapMode : register(c13); // 0 - repeat/clamp, 1 - region rep (use fRegRepMask)
+
+float4 g_fRealTexDims : register(c15); // tex dims used for linear filtering (w,h,1/w,1/h)
+
+// (alpha0, alpha1, 1 if highlight2 and tcc is rgba, 1-y)
+half4 g_fTestBlack : register(c17); // used for aem bit
+
+float4 g_fPageOffset : register(c19);
+
+half4 fTexAlpha : register(c21);
+
+// vertex shader constants
float4 g_fPosXY : register(c3);
\ No newline at end of file
diff --git a/plugins/zerogs/dx/x86-32.asm b/plugins/zerogs/dx/x86-32.asm
index 1c55682057..2ce84c66ba 100644
--- a/plugins/zerogs/dx/x86-32.asm
+++ b/plugins/zerogs/dx/x86-32.asm
@@ -1,1353 +1,1353 @@
-; Copyright (C) 2003-2005 Gabest
-; http://www.gabest.org
-;
-; 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, 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 GNU Make; see the file COPYING. If not, write to
-; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-; http://www.gnu.org/copyleft/gpl.html
-;
-;
- .686
- .model flat
- .mmx
- .xmm
-
- .const
-
- __uvmin DD 0d01502f9r ; -1e+010
- __uvmax DD 0501502f9r ; +1e+010
-
- .code
-
-;
-; memsetd
-;
-
-@memsetd@12 proc public
-
- push edi
-
- mov edi, ecx
- mov eax, edx
- mov ecx, [esp+4+4]
- cld
- rep stosd
-
- pop edi
-
- ret 4
-
-@memsetd@12 endp
-
-;
-; SaturateColor
-;
-
-@SaturateColor_sse2@4 proc public
-
- pxor xmm0, xmm0
- movdqa xmm1, [ecx]
- packssdw xmm1, xmm0
- packuswb xmm1, xmm0
- punpcklbw xmm1, xmm0
- punpcklwd xmm1, xmm0
- movdqa [ecx], xmm1
-
- ret
-
-@SaturateColor_sse2@4 endp
-
-@SaturateColor_asm@4 proc public
-
- push esi
-
- mov esi, ecx
-
- xor eax, eax
- mov edx, 000000ffh
-
- mov ecx, [esi]
- cmp ecx, eax
- cmovl ecx, eax
- cmp ecx, edx
- cmovg ecx, edx
- mov [esi], ecx
-
- mov ecx, [esi+4]
- cmp ecx, eax
- cmovl ecx, eax
- cmp ecx, edx
- cmovg ecx, edx
- mov [esi+4], ecx
-
- mov ecx, [esi+8]
- cmp ecx, eax
- cmovl ecx, eax
- cmp ecx, edx
- cmovg ecx, edx
- mov [esi+8], ecx
-
- mov ecx, [esi+12]
- cmp ecx, eax
- cmovl ecx, eax
- cmp ecx, edx
- cmovg ecx, edx
- mov [esi+12], ecx
-
- pop esi
-
- ret
-
-@SaturateColor_asm@4 endp
-
-;
-; swizzling
-;
-
-punpck macro op, sd0, sd2, s1, s3, d1, d3
-
- movdqa @CatStr(xmm, %d1), @CatStr(xmm, %sd0)
- pshufd @CatStr(xmm, %d3), @CatStr(xmm, %sd2), 0e4h
-
- @CatStr(punpckl, op) @CatStr(xmm, %sd0), @CatStr(xmm, %s1)
- @CatStr(punpckh, op) @CatStr(xmm, %d1), @CatStr(xmm, %s1)
- @CatStr(punpckl, op) @CatStr(xmm, %sd2), @CatStr(xmm, %s3)
- @CatStr(punpckh, op) @CatStr(xmm, %d3), @CatStr(xmm, %s3)
-
- endm
-
-punpcknb macro
-
- movdqa xmm4, xmm0
- pshufd xmm5, xmm1, 0e4h
-
- psllq xmm1, 4
- psrlq xmm4, 4
-
- movdqa xmm6, xmm7
- pand xmm0, xmm7
- pandn xmm6, xmm1
- por xmm0, xmm6
-
- movdqa xmm6, xmm7
- pand xmm4, xmm7
- pandn xmm6, xmm5
- por xmm4, xmm6
-
- movdqa xmm1, xmm4
-
- movdqa xmm4, xmm2
- pshufd xmm5, xmm3, 0e4h
-
- psllq xmm3, 4
- psrlq xmm4, 4
-
- movdqa xmm6, xmm7
- pand xmm2, xmm7
- pandn xmm6, xmm3
- por xmm2, xmm6
-
- movdqa xmm6, xmm7
- pand xmm4, xmm7
- pandn xmm6, xmm5
- por xmm4, xmm6
-
- movdqa xmm3, xmm4
-
- punpck bw, 0, 2, 1, 3, 4, 6
-
- endm
-
-;
-; unSwizzleBlock32
-;
-
-@unSwizzleBlock32_sse2@12 proc public
-
- push ebx
-
- mov ebx, [esp+4+4]
- lea eax, [ebx*2]
- add eax, ebx
-
- movdqa xmm0, [ecx+16*0]
- movdqa xmm1, [ecx+16*1]
- movdqa xmm2, [ecx+16*2]
- movdqa xmm3, [ecx+16*3]
-
- punpck qdq, 0, 2, 1, 3, 4, 6
-
- movdqa [edx], xmm0
- movdqa [edx+16], xmm2
- movdqa [edx+ebx], xmm4
- movdqa [edx+ebx+16], xmm6
-
- movdqa xmm0, [ecx+16*4]
- movdqa xmm1, [ecx+16*5]
- movdqa xmm2, [ecx+16*6]
- movdqa xmm3, [ecx+16*7]
-
- punpck qdq, 0, 2, 1, 3, 4, 6
-
- movdqa [edx+ebx*2], xmm0
- movdqa [edx+ebx*2+16], xmm2
- movdqa [edx+eax], xmm4
- movdqa [edx+eax+16], xmm6
-
- lea edx, [edx+ebx*4]
-
- movdqa xmm0, [ecx+16*8]
- movdqa xmm1, [ecx+16*9]
- movdqa xmm2, [ecx+16*10]
- movdqa xmm3, [ecx+16*11]
-
- punpck qdq, 0, 2, 1, 3, 4, 6
-
- movdqa [edx], xmm0
- movdqa [edx+16], xmm2
- movdqa [edx+ebx], xmm4
- movdqa [edx+ebx+16], xmm6
-
- movdqa xmm0, [ecx+16*12]
- movdqa xmm1, [ecx+16*13]
- movdqa xmm2, [ecx+16*14]
- movdqa xmm3, [ecx+16*15]
-
- punpck qdq, 0, 2, 1, 3, 4, 6
-
- movdqa [edx+ebx*2], xmm0
- movdqa [edx+ebx*2+16], xmm2
- movdqa [edx+eax], xmm4
- movdqa [edx+eax+16], xmm6
-
- pop ebx
-
- ret 4
-
-@unSwizzleBlock32_sse2@12 endp
-
-;
-; unSwizzleBlock16
-;
-
-@unSwizzleBlock16_sse2@12 proc public
-
- push ebx
-
- mov ebx, [esp+4+4]
- mov eax, 4
-
- align 16
-@@:
- movdqa xmm0, [ecx+16*0]
- movdqa xmm1, [ecx+16*1]
- movdqa xmm2, [ecx+16*2]
- movdqa xmm3, [ecx+16*3]
-
- punpck wd, 0, 2, 1, 3, 4, 6
- punpck dq, 0, 4, 2, 6, 1, 3
- punpck wd, 0, 4, 1, 3, 2, 6
-
- movdqa [edx], xmm0
- movdqa [edx+16], xmm2
- movdqa [edx+ebx], xmm4
- movdqa [edx+ebx+16], xmm6
-
- add ecx, 64
- lea edx, [edx+ebx*2]
-
- dec eax
- jnz @B
-
- pop ebx
-
- ret 4
-
-@unSwizzleBlock16_sse2@12 endp
-
-;
-; unSwizzleBlock8
-;
-
-@unSwizzleBlock8_sse2@12 proc public
-
- push ebx
-
- mov ebx, [esp+4+4]
- mov eax, 2
-
- align 16
-@@:
- ; col 0, 2
-
- movdqa xmm0, [ecx+16*0]
- movdqa xmm1, [ecx+16*1]
- movdqa xmm4, [ecx+16*2]
- movdqa xmm5, [ecx+16*3]
-
- punpck bw, 0, 4, 1, 5, 2, 6
- punpck wd, 0, 2, 4, 6, 1, 3
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck qdq, 0, 2, 4, 6, 1, 3
-
- pshufd xmm1, xmm1, 0b1h
- pshufd xmm3, xmm3, 0b1h
-
- movdqa [edx], xmm0
- movdqa [edx+ebx], xmm2
- lea edx, [edx+ebx*2]
-
- movdqa [edx], xmm1
- movdqa [edx+ebx], xmm3
- lea edx, [edx+ebx*2]
-
- ; col 1, 3
-
- movdqa xmm0, [ecx+16*4]
- movdqa xmm1, [ecx+16*5]
- movdqa xmm4, [ecx+16*6]
- movdqa xmm5, [ecx+16*7]
-
- punpck bw, 0, 4, 1, 5, 2, 6
- punpck wd, 0, 2, 4, 6, 1, 3
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck qdq, 0, 2, 4, 6, 1, 3
-
- pshufd xmm0, xmm0, 0b1h
- pshufd xmm2, xmm2, 0b1h
-
- movdqa [edx], xmm0
- movdqa [edx+ebx], xmm2
- lea edx, [edx+ebx*2]
-
- movdqa [edx], xmm1
- movdqa [edx+ebx], xmm3
- lea edx, [edx+ebx*2]
-
- add ecx, 128
-
- dec eax
- jnz @B
-
- pop ebx
-
- ret 4
-
-@unSwizzleBlock8_sse2@12 endp
-
-;
-; unSwizzleBlock4
-;
-
-@unSwizzleBlock4_sse2@12 proc public
-
- push ebx
-
- mov eax, 0f0f0f0fh
- movd xmm7, eax
- pshufd xmm7, xmm7, 0
-
- mov ebx, [esp+4+4]
- mov eax, 2
-
- align 16
-@@:
- ; col 0, 2
-
- movdqa xmm0, [ecx+16*0]
- movdqa xmm1, [ecx+16*1]
- movdqa xmm4, [ecx+16*2]
- movdqa xmm3, [ecx+16*3]
-
- punpck dq, 0, 4, 1, 3, 2, 6
- punpck dq, 0, 2, 4, 6, 1, 3
- punpcknb
- punpck bw, 0, 2, 4, 6, 1, 3
- punpck wd, 0, 2, 1, 3, 4, 6
-
- pshufd xmm0, xmm0, 0d8h
- pshufd xmm2, xmm2, 0d8h
- pshufd xmm4, xmm4, 0d8h
- pshufd xmm6, xmm6, 0d8h
-
- punpck qdq, 0, 2, 4, 6, 1, 3
-
- pshuflw xmm1, xmm1, 0b1h
- pshuflw xmm3, xmm3, 0b1h
- pshufhw xmm1, xmm1, 0b1h
- pshufhw xmm3, xmm3, 0b1h
-
- movdqa [edx], xmm0
- movdqa [edx+ebx], xmm2
- lea edx, [edx+ebx*2]
-
- movdqa [edx], xmm1
- movdqa [edx+ebx], xmm3
- lea edx, [edx+ebx*2]
-
- ; col 1, 3
-
- movdqa xmm0, [ecx+16*4]
- movdqa xmm1, [ecx+16*5]
- movdqa xmm4, [ecx+16*6]
- movdqa xmm3, [ecx+16*7]
-
- punpck dq, 0, 4, 1, 3, 2, 6
- punpck dq, 0, 2, 4, 6, 1, 3
- punpcknb
- punpck bw, 0, 2, 4, 6, 1, 3
- punpck wd, 0, 2, 1, 3, 4, 6
-
- pshufd xmm0, xmm0, 0d8h
- pshufd xmm2, xmm2, 0d8h
- pshufd xmm4, xmm4, 0d8h
- pshufd xmm6, xmm6, 0d8h
-
- punpck qdq, 0, 2, 4, 6, 1, 3
-
- pshuflw xmm0, xmm0, 0b1h
- pshuflw xmm2, xmm2, 0b1h
- pshufhw xmm0, xmm0, 0b1h
- pshufhw xmm2, xmm2, 0b1h
-
- movdqa [edx], xmm0
- movdqa [edx+ebx], xmm2
- lea edx, [edx+ebx*2]
-
- movdqa [edx], xmm1
- movdqa [edx+ebx], xmm3
- lea edx, [edx+ebx*2]
-
- add ecx, 128
-
- dec eax
- jnz @B
-
- pop ebx
-
- ret 4
-
-@unSwizzleBlock4_sse2@12 endp
-
-;
-; unSwizzleBlock8HP
-;
-
-@unSwizzleBlock8HP_sse2@12 proc public
-
- push ebx
-
- mov ebx, [esp+4+4]
- mov eax, 4
-
- align 16
-@@:
- movdqa xmm0, [ecx+16*0]
- movdqa xmm1, [ecx+16*1]
- movdqa xmm2, [ecx+16*2]
- movdqa xmm3, [ecx+16*3]
-
- punpck qdq, 0, 2, 1, 3, 4, 6
-
- psrld xmm0, 24
- psrld xmm2, 24
- psrld xmm4, 24
- psrld xmm6, 24
-
- packssdw xmm0, xmm2
- packssdw xmm4, xmm6
- packuswb xmm0, xmm4
-
- movlps qword ptr [edx], xmm0
- movhps qword ptr [edx+ebx], xmm0
-
- add ecx, 64
- lea edx, [edx+ebx*2]
-
- dec eax
- jnz @B
-
- pop ebx
-
- ret 4
-
-@unSwizzleBlock8HP_sse2@12 endp
-
-;
-; unSwizzleBlock4HLP
-;
-
-@unSwizzleBlock4HLP_sse2@12 proc public
-
- push ebx
-
- mov eax, 0f0f0f0fh
- movd xmm7, eax
- pshufd xmm7, xmm7, 0
-
- mov ebx, [esp+4+4]
- mov eax, 4
-
- align 16
-@@:
- movdqa xmm0, [ecx+16*0]
- movdqa xmm1, [ecx+16*1]
- movdqa xmm2, [ecx+16*2]
- movdqa xmm3, [ecx+16*3]
-
- punpck qdq, 0, 2, 1, 3, 4, 6
-
- psrld xmm0, 24
- psrld xmm2, 24
- psrld xmm4, 24
- psrld xmm6, 24
-
- packssdw xmm0, xmm2
- packssdw xmm4, xmm6
- packuswb xmm0, xmm4
-
- pand xmm0, xmm7
-
- movlps qword ptr [edx], xmm0
- movhps qword ptr [edx+ebx], xmm0
-
- add ecx, 64
- lea edx, [edx+ebx*2]
-
- dec eax
- jnz @B
-
- pop ebx
-
- ret 4
-
-@unSwizzleBlock4HLP_sse2@12 endp
-
-;
-; unSwizzleBlock4HHP
-;
-
-@unSwizzleBlock4HHP_sse2@12 proc public
-
- push ebx
-
- mov ebx, [esp+4+4]
- mov eax, 4
-
- align 16
-@@:
- movdqa xmm0, [ecx+16*0]
- movdqa xmm1, [ecx+16*1]
- movdqa xmm2, [ecx+16*2]
- movdqa xmm3, [ecx+16*3]
-
- punpck qdq, 0, 2, 1, 3, 4, 6
-
- psrld xmm0, 28
- psrld xmm2, 28
- psrld xmm4, 28
- psrld xmm6, 28
-
- packssdw xmm0, xmm2
- packssdw xmm4, xmm6
- packuswb xmm0, xmm4
-
- movlps qword ptr [edx], xmm0
- movhps qword ptr [edx+ebx], xmm0
-
- add ecx, 64
- lea edx, [edx+ebx*2]
-
- dec eax
- jnz @B
-
- pop ebx
-
- ret 4
-
-@unSwizzleBlock4HHP_sse2@12 endp
-
-;
-; unSwizzleBlock4P
-;
-
-@unSwizzleBlock4P_sse2@12 proc public
-
- push esi
- push edi
-
- mov eax, 0f0f0f0fh
- movd xmm7, eax
- pshufd xmm7, xmm7, 0
-
- mov esi, [esp+4+8]
- lea edi, [esi*2]
- add edi, esi
-
- ; col 0
-
- movdqa xmm0, [ecx+16*0]
- movdqa xmm1, [ecx+16*1]
- movdqa xmm2, [ecx+16*2]
- movdqa xmm3, [ecx+16*3]
-
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck wd, 0, 4, 2, 6, 1, 3
- punpck bw, 0, 4, 1, 3, 2, 6
-
- movdqa xmm1, xmm7
- pandn xmm1, xmm0
- pand xmm0, xmm7
- pshufd xmm1, xmm1, 0b1h
- psrlq xmm1, 4
-
- movdqa xmm3, xmm7
- pandn xmm3, xmm2
- pand xmm2, xmm7
- pshufd xmm3, xmm3, 0b1h
- psrlq xmm3, 4
-
- movdqa [edx], xmm0
- movdqa [edx+16], xmm2
- movdqa [edx+esi*2], xmm1
- movdqa [edx+esi*2+16], xmm3
-
- movdqa xmm1, xmm7
- pandn xmm1, xmm4
- pand xmm4, xmm7
- pshufd xmm1, xmm1, 0b1h
- psrlq xmm1, 4
-
- movdqa xmm3, xmm7
- pandn xmm3, xmm6
- pand xmm6, xmm7
- pshufd xmm3, xmm3, 0b1h
- psrlq xmm3, 4
-
- movdqa [edx+esi], xmm4
- movdqa [edx+esi+16], xmm6
- movdqa [edx+edi], xmm1
- movdqa [edx+edi+16], xmm3
-
- lea edx, [edx+esi*4]
-
- ; col 1
-
- movdqa xmm0, [ecx+16*4]
- movdqa xmm1, [ecx+16*5]
- movdqa xmm2, [ecx+16*6]
- movdqa xmm3, [ecx+16*7]
-
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck wd, 0, 4, 2, 6, 1, 3
- punpck bw, 0, 4, 1, 3, 2, 6
-
- movdqa xmm1, xmm7
- pandn xmm1, xmm0
- pand xmm0, xmm7
- pshufd xmm0, xmm0, 0b1h
- psrlq xmm1, 4
-
- movdqa xmm3, xmm7
- pandn xmm3, xmm2
- pand xmm2, xmm7
- pshufd xmm2, xmm2, 0b1h
- psrlq xmm3, 4
-
- movdqa [edx], xmm0
- movdqa [edx+16], xmm2
- movdqa [edx+esi*2], xmm1
- movdqa [edx+esi*2+16], xmm3
-
- movdqa xmm1, xmm7
- pandn xmm1, xmm4
- pand xmm4, xmm7
- pshufd xmm4, xmm4, 0b1h
- psrlq xmm1, 4
-
- movdqa xmm3, xmm7
- pandn xmm3, xmm6
- pand xmm6, xmm7
- pshufd xmm6, xmm6, 0b1h
- psrlq xmm3, 4
-
- movdqa [edx+esi], xmm4
- movdqa [edx+esi+16], xmm6
- movdqa [edx+edi], xmm1
- movdqa [edx+edi+16], xmm3
-
- lea edx, [edx+esi*4]
-
- ; col 2
-
- movdqa xmm0, [ecx+16*8]
- movdqa xmm1, [ecx+16*9]
- movdqa xmm2, [ecx+16*10]
- movdqa xmm3, [ecx+16*11]
-
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck wd, 0, 4, 2, 6, 1, 3
- punpck bw, 0, 4, 1, 3, 2, 6
-
- movdqa xmm1, xmm7
- pandn xmm1, xmm0
- pand xmm0, xmm7
- pshufd xmm1, xmm1, 0b1h
- psrlq xmm1, 4
-
- movdqa xmm3, xmm7
- pandn xmm3, xmm2
- pand xmm2, xmm7
- pshufd xmm3, xmm3, 0b1h
- psrlq xmm3, 4
-
- movdqa [edx], xmm0
- movdqa [edx+16], xmm2
- movdqa [edx+esi*2], xmm1
- movdqa [edx+esi*2+16], xmm3
-
- movdqa xmm1, xmm7
- pandn xmm1, xmm4
- pand xmm4, xmm7
- pshufd xmm1, xmm1, 0b1h
- psrlq xmm1, 4
-
- movdqa xmm3, xmm7
- pandn xmm3, xmm6
- pand xmm6, xmm7
- pshufd xmm3, xmm3, 0b1h
- psrlq xmm3, 4
-
- movdqa [edx+esi], xmm4
- movdqa [edx+esi+16], xmm6
- movdqa [edx+edi], xmm1
- movdqa [edx+edi+16], xmm3
-
- lea edx, [edx+esi*4]
-
- ; col 3
-
- movdqa xmm0, [ecx+16*12]
- movdqa xmm1, [ecx+16*13]
- movdqa xmm2, [ecx+16*14]
- movdqa xmm3, [ecx+16*15]
-
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck wd, 0, 4, 2, 6, 1, 3
- punpck bw, 0, 4, 1, 3, 2, 6
-
- movdqa xmm1, xmm7
- pandn xmm1, xmm0
- pand xmm0, xmm7
- pshufd xmm0, xmm0, 0b1h
- psrlq xmm1, 4
-
- movdqa xmm3, xmm7
- pandn xmm3, xmm2
- pand xmm2, xmm7
- pshufd xmm2, xmm2, 0b1h
- psrlq xmm3, 4
-
- movdqa [edx], xmm0
- movdqa [edx+16], xmm2
- movdqa [edx+esi*2], xmm1
- movdqa [edx+esi*2+16], xmm3
-
- movdqa xmm1, xmm7
- pandn xmm1, xmm4
- pand xmm4, xmm7
- pshufd xmm4, xmm4, 0b1h
- psrlq xmm1, 4
-
- movdqa xmm3, xmm7
- pandn xmm3, xmm6
- pand xmm6, xmm7
- pshufd xmm6, xmm6, 0b1h
- psrlq xmm3, 4
-
- movdqa [edx+esi], xmm4
- movdqa [edx+esi+16], xmm6
- movdqa [edx+edi], xmm1
- movdqa [edx+edi+16], xmm3
-
- ; lea edx, [edx+esi*4]
-
- pop edi
- pop esi
-
- ret 4
-
-@unSwizzleBlock4P_sse2@12 endp
-
-;
-; swizzling
-;
-
-;
-; SwizzleBlock32
-;
-
-@SwizzleBlock32_sse2@16 proc public
-
-
- push esi
- push edi
-
- mov edi, ecx
- mov esi, edx
- mov edx, [esp+4+8]
- mov ecx, 4
-
- mov eax, [esp+8+8]
- cmp eax, 0ffffffffh
- jnz SwizzleBlock32_sse2@WM
-
- align 16
-@@:
- movdqa xmm0, [esi]
- movdqa xmm4, [esi+16]
- movdqa xmm1, [esi+edx]
- movdqa xmm5, [esi+edx+16]
-
- punpck qdq, 0, 4, 1, 5, 2, 6
-
- movntps [edi+16*0], xmm0
- movntps [edi+16*1], xmm2
- movntps [edi+16*2], xmm4
- movntps [edi+16*3], xmm6
-
- lea esi, [esi+edx*2]
- add edi, 64
-
- dec ecx
- jnz @B
-
- pop edi
- pop esi
-
- ret 8
-
-SwizzleBlock32_sse2@WM:
-
- movd xmm7, eax
- pshufd xmm7, xmm7, 0
-
- align 16
-@@:
- movdqa xmm0, [esi]
- movdqa xmm4, [esi+16]
- movdqa xmm1, [esi+edx]
- movdqa xmm5, [esi+edx+16]
-
- punpck qdq, 0, 4, 1, 5, 2, 6
-
- movdqa xmm3, xmm7
- pshufd xmm5, xmm7, 0e4h
-
- pandn xmm3, [edi+16*0]
- pand xmm0, xmm7
- por xmm0, xmm3
- movntps [edi+16*0], xmm0
-
- pandn xmm5, [edi+16*1]
- pand xmm2, xmm7
- por xmm2, xmm5
- movntps [edi+16*1], xmm2
-
- movdqa xmm3, xmm7
- pshufd xmm5, xmm7, 0e4h
-
- pandn xmm3, [edi+16*2]
- pand xmm4, xmm7
- por xmm4, xmm3
- movntps [edi+16*2], xmm4
-
- pandn xmm5, [edi+16*3]
- pand xmm6, xmm7
- por xmm6, xmm5
- movntps [edi+16*3], xmm6
-
- lea esi, [esi+edx*2]
- add edi, 64
-
- dec ecx
- jnz @B
-
- pop edi
- pop esi
-
- ret 8
-
-@SwizzleBlock32_sse2@16 endp
-
-;
-; SwizzleBlock16
-;
-
-@SwizzleBlock16_sse2@12 proc public
-
- push ebx
-
- mov ebx, [esp+4+4]
- mov eax, 4
-
- align 16
-@@:
- movdqa xmm0, [edx]
- movdqa xmm1, [edx+16]
- movdqa xmm2, [edx+ebx]
- movdqa xmm3, [edx+ebx+16]
-
- punpck wd, 0, 2, 1, 3, 4, 6
- punpck qdq, 0, 4, 2, 6, 1, 5
-
- movntps [ecx+16*0], xmm0
- movntps [ecx+16*1], xmm1
- movntps [ecx+16*2], xmm4
- movntps [ecx+16*3], xmm5
-
- lea edx, [edx+ebx*2]
- add ecx, 64
-
- dec eax
- jnz @B
-
- pop ebx
-
- ret 4
-
-@SwizzleBlock16_sse2@12 endp
-
-;
-; SwizzleBlock8
-;
-
-@SwizzleBlock8_sse2@12 proc public
-
- push ebx
-
- mov ebx, [esp+4+4]
- mov eax, 2
-
- align 16
-@@:
- ; col 0, 2
-
- movdqa xmm0, [edx]
- movdqa xmm2, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- pshufd xmm1, [edx], 0b1h
- pshufd xmm3, [edx+ebx], 0b1h
- lea edx, [edx+ebx*2]
-
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck wd, 0, 2, 4, 6, 1, 3
- punpck qdq, 0, 1, 2, 3, 4, 5
-
- movntps [ecx+16*0], xmm0
- movntps [ecx+16*1], xmm4
- movntps [ecx+16*2], xmm1
- movntps [ecx+16*3], xmm5
-
- ; col 1, 3
-
- pshufd xmm0, [edx], 0b1h
- pshufd xmm2, [edx+ebx], 0b1h
- lea edx, [edx+ebx*2]
-
- movdqa xmm1, [edx]
- movdqa xmm3, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck wd, 0, 2, 4, 6, 1, 3
- punpck qdq, 0, 1, 2, 3, 4, 5
-
- movntps [ecx+16*4], xmm0
- movntps [ecx+16*5], xmm4
- movntps [ecx+16*6], xmm1
- movntps [ecx+16*7], xmm5
-
- add ecx, 128
-
- dec eax
- jnz @B
-
- pop ebx
-
- ret 4
-
-@SwizzleBlock8_sse2@12 endp
-
-;
-; SwizzleBlock4
-;
-
-@SwizzleBlock4_sse2@12 proc public
-
- push ebx
-
- mov eax, 0f0f0f0fh
- movd xmm7, eax
- pshufd xmm7, xmm7, 0
-
- mov ebx, [esp+4+4]
- mov eax, 2
-
- align 16
-@@:
- ; col 0, 2
-
- movdqa xmm0, [edx]
- movdqa xmm2, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- movdqa xmm1, [edx]
- movdqa xmm3, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- pshuflw xmm1, xmm1, 0b1h
- pshuflw xmm3, xmm3, 0b1h
- pshufhw xmm1, xmm1, 0b1h
- pshufhw xmm3, xmm3, 0b1h
-
- punpcknb
- punpck bw, 0, 2, 4, 6, 1, 3
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck qdq, 0, 4, 2, 6, 1, 3
-
- movntps [ecx+16*0], xmm0
- movntps [ecx+16*1], xmm1
- movntps [ecx+16*2], xmm4
- movntps [ecx+16*3], xmm3
-
- ; col 1, 3
-
- movdqa xmm0, [edx]
- movdqa xmm2, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- movdqa xmm1, [edx]
- movdqa xmm3, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- pshuflw xmm0, xmm0, 0b1h
- pshuflw xmm2, xmm2, 0b1h
- pshufhw xmm0, xmm0, 0b1h
- pshufhw xmm2, xmm2, 0b1h
-
- punpcknb
- punpck bw, 0, 2, 4, 6, 1, 3
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck qdq, 0, 4, 2, 6, 1, 3
-
- movntps [ecx+16*4], xmm0
- movntps [ecx+16*5], xmm1
- movntps [ecx+16*6], xmm4
- movntps [ecx+16*7], xmm3
-
- add ecx, 128
-
- dec eax
- jnz @B
-
- pop ebx
-
- ret 4
-
-@SwizzleBlock4_sse2@12 endp
-
-;
-; swizzling with unaligned reads
-;
-
-;
-; SwizzleBlock32u
-;
-
-@SwizzleBlock32u_sse2@16 proc public
-
- push esi
- push edi
-
- mov edi, ecx
- mov esi, edx
- mov edx, [esp+4+8]
- mov ecx, 4
-
- mov eax, [esp+8+8]
- cmp eax, 0ffffffffh
- jnz SwizzleBlock32u_sse2@WM
-
- align 16
-@@:
- movdqu xmm0, [esi]
- movdqu xmm4, [esi+16]
- movdqu xmm1, [esi+edx]
- movdqu xmm5, [esi+edx+16]
-
- punpck qdq, 0, 4, 1, 5, 2, 6
-
- movntps [edi+16*0], xmm0
- movntps [edi+16*1], xmm2
- movntps [edi+16*2], xmm4
- movntps [edi+16*3], xmm6
-
- lea esi, [esi+edx*2]
- add edi, 64
-
- dec ecx
- jnz @B
-
- pop edi
- pop esi
-
- ret 8
-
-SwizzleBlock32u_sse2@WM:
-
- movd xmm7, eax
- pshufd xmm7, xmm7, 0
-
- align 16
-@@:
- movdqu xmm0, [esi]
- movdqu xmm4, [esi+16]
- movdqu xmm1, [esi+edx]
- movdqu xmm5, [esi+edx+16]
-
- punpck qdq, 0, 4, 1, 5, 2, 6
-
- movdqa xmm3, xmm7
- pshufd xmm5, xmm7, 0e4h
-
- pandn xmm3, [edi+16*0]
- pand xmm0, xmm7
- por xmm0, xmm3
- movdqa [edi+16*0], xmm0
-
- pandn xmm5, [edi+16*1]
- pand xmm2, xmm7
- por xmm2, xmm5
- movdqa [edi+16*1], xmm2
-
- movdqa xmm3, xmm7
- pshufd xmm5, xmm7, 0e4h
-
- pandn xmm3, [edi+16*2]
- pand xmm4, xmm7
- por xmm4, xmm3
- movdqa [edi+16*2], xmm4
-
- pandn xmm5, [edi+16*3]
- pand xmm6, xmm7
- por xmm6, xmm5
- movdqa [edi+16*3], xmm6
-
- lea esi, [esi+edx*2]
- add edi, 64
-
- dec ecx
- jnz @B
-
- pop edi
- pop esi
-
- ret 8
-
-@SwizzleBlock32u_sse2@16 endp
-
-;
-; SwizzleBlock16u
-;
-
-@SwizzleBlock16u_sse2@12 proc public
-
- push ebx
-
- mov ebx, [esp+4+4]
- mov eax, 4
-
- align 16
-@@:
- movdqu xmm0, [edx]
- movdqu xmm1, [edx+16]
- movdqu xmm2, [edx+ebx]
- movdqu xmm3, [edx+ebx+16]
-
- punpck wd, 0, 2, 1, 3, 4, 6
- punpck qdq, 0, 4, 2, 6, 1, 5
-
- movntps [ecx+16*0], xmm0
- movntps [ecx+16*1], xmm1
- movntps [ecx+16*2], xmm4
- movntps [ecx+16*3], xmm5
-
- lea edx, [edx+ebx*2]
- add ecx, 64
-
- dec eax
- jnz @B
-
- pop ebx
-
- ret 4
-
-@SwizzleBlock16u_sse2@12 endp
-
-;
-; SwizzleBlock8u
-;
-
-@SwizzleBlock8u_sse2@12 proc public
-
- push ebx
-
- mov ebx, [esp+4+4]
- mov eax, 2
-
- align 16
-@@:
- ; col 0, 2
-
- movdqu xmm0, [edx]
- movdqu xmm2, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- movdqu xmm1, [edx]
- movdqu xmm3, [edx+ebx]
- pshufd xmm1, xmm1, 0b1h
- pshufd xmm3, xmm3, 0b1h
- lea edx, [edx+ebx*2]
-
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck wd, 0, 2, 4, 6, 1, 3
- punpck qdq, 0, 1, 2, 3, 4, 5
-
- movntps [ecx+16*0], xmm0
- movntps [ecx+16*1], xmm4
- movntps [ecx+16*2], xmm1
- movntps [ecx+16*3], xmm5
-
- ; col 1, 3
-
- movdqu xmm0, [edx]
- movdqu xmm2, [edx+ebx]
- pshufd xmm0, xmm0, 0b1h
- pshufd xmm2, xmm2, 0b1h
- lea edx, [edx+ebx*2]
-
- movdqu xmm1, [edx]
- movdqu xmm3, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck wd, 0, 2, 4, 6, 1, 3
- punpck qdq, 0, 1, 2, 3, 4, 5
-
- movntps [ecx+16*4], xmm0
- movntps [ecx+16*5], xmm4
- movntps [ecx+16*6], xmm1
- movntps [ecx+16*7], xmm5
-
- add ecx, 128
-
- dec eax
- jnz @B
-
- pop ebx
-
- ret 4
-
-@SwizzleBlock8u_sse2@12 endp
-
-;
-; SwizzleBlock4u
-;
-
-@SwizzleBlock4u_sse2@12 proc public
-
- push ebx
-
- mov eax, 0f0f0f0fh
- movd xmm7, eax
- pshufd xmm7, xmm7, 0
-
- mov ebx, [esp+4+4]
- mov eax, 2
-
- align 16
-@@:
- ; col 0, 2
-
- movdqu xmm0, [edx]
- movdqu xmm2, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- movdqu xmm1, [edx]
- movdqu xmm3, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- pshuflw xmm1, xmm1, 0b1h
- pshuflw xmm3, xmm3, 0b1h
- pshufhw xmm1, xmm1, 0b1h
- pshufhw xmm3, xmm3, 0b1h
-
- punpcknb
- punpck bw, 0, 2, 4, 6, 1, 3
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck qdq, 0, 4, 2, 6, 1, 3
-
- movntps [ecx+16*0], xmm0
- movntps [ecx+16*1], xmm1
- movntps [ecx+16*2], xmm4
- movntps [ecx+16*3], xmm3
-
- ; col 1, 3
-
- movdqu xmm0, [edx]
- movdqu xmm2, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- movdqu xmm1, [edx]
- movdqu xmm3, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- pshuflw xmm0, xmm0, 0b1h
- pshuflw xmm2, xmm2, 0b1h
- pshufhw xmm0, xmm0, 0b1h
- pshufhw xmm2, xmm2, 0b1h
-
- punpcknb
- punpck bw, 0, 2, 4, 6, 1, 3
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck qdq, 0, 4, 2, 6, 1, 3
-
- movntps [ecx+16*4], xmm0
- movntps [ecx+16*5], xmm1
- movntps [ecx+16*6], xmm4
- movntps [ecx+16*7], xmm3
-
- add ecx, 128
-
- dec eax
- jnz @B
-
- pop ebx
-
- ret 4
-
-@SwizzleBlock4u_sse2@12 endp
-
+; Copyright (C) 2003-2005 Gabest
+; http://www.gabest.org
+;
+; 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, 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 GNU Make; see the file COPYING. If not, write to
+; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+; http://www.gnu.org/copyleft/gpl.html
+;
+;
+ .686
+ .model flat
+ .mmx
+ .xmm
+
+ .const
+
+ __uvmin DD 0d01502f9r ; -1e+010
+ __uvmax DD 0501502f9r ; +1e+010
+
+ .code
+
+;
+; memsetd
+;
+
+@memsetd@12 proc public
+
+ push edi
+
+ mov edi, ecx
+ mov eax, edx
+ mov ecx, [esp+4+4]
+ cld
+ rep stosd
+
+ pop edi
+
+ ret 4
+
+@memsetd@12 endp
+
+;
+; SaturateColor
+;
+
+@SaturateColor_sse2@4 proc public
+
+ pxor xmm0, xmm0
+ movdqa xmm1, [ecx]
+ packssdw xmm1, xmm0
+ packuswb xmm1, xmm0
+ punpcklbw xmm1, xmm0
+ punpcklwd xmm1, xmm0
+ movdqa [ecx], xmm1
+
+ ret
+
+@SaturateColor_sse2@4 endp
+
+@SaturateColor_asm@4 proc public
+
+ push esi
+
+ mov esi, ecx
+
+ xor eax, eax
+ mov edx, 000000ffh
+
+ mov ecx, [esi]
+ cmp ecx, eax
+ cmovl ecx, eax
+ cmp ecx, edx
+ cmovg ecx, edx
+ mov [esi], ecx
+
+ mov ecx, [esi+4]
+ cmp ecx, eax
+ cmovl ecx, eax
+ cmp ecx, edx
+ cmovg ecx, edx
+ mov [esi+4], ecx
+
+ mov ecx, [esi+8]
+ cmp ecx, eax
+ cmovl ecx, eax
+ cmp ecx, edx
+ cmovg ecx, edx
+ mov [esi+8], ecx
+
+ mov ecx, [esi+12]
+ cmp ecx, eax
+ cmovl ecx, eax
+ cmp ecx, edx
+ cmovg ecx, edx
+ mov [esi+12], ecx
+
+ pop esi
+
+ ret
+
+@SaturateColor_asm@4 endp
+
+;
+; swizzling
+;
+
+punpck macro op, sd0, sd2, s1, s3, d1, d3
+
+ movdqa @CatStr(xmm, %d1), @CatStr(xmm, %sd0)
+ pshufd @CatStr(xmm, %d3), @CatStr(xmm, %sd2), 0e4h
+
+ @CatStr(punpckl, op) @CatStr(xmm, %sd0), @CatStr(xmm, %s1)
+ @CatStr(punpckh, op) @CatStr(xmm, %d1), @CatStr(xmm, %s1)
+ @CatStr(punpckl, op) @CatStr(xmm, %sd2), @CatStr(xmm, %s3)
+ @CatStr(punpckh, op) @CatStr(xmm, %d3), @CatStr(xmm, %s3)
+
+ endm
+
+punpcknb macro
+
+ movdqa xmm4, xmm0
+ pshufd xmm5, xmm1, 0e4h
+
+ psllq xmm1, 4
+ psrlq xmm4, 4
+
+ movdqa xmm6, xmm7
+ pand xmm0, xmm7
+ pandn xmm6, xmm1
+ por xmm0, xmm6
+
+ movdqa xmm6, xmm7
+ pand xmm4, xmm7
+ pandn xmm6, xmm5
+ por xmm4, xmm6
+
+ movdqa xmm1, xmm4
+
+ movdqa xmm4, xmm2
+ pshufd xmm5, xmm3, 0e4h
+
+ psllq xmm3, 4
+ psrlq xmm4, 4
+
+ movdqa xmm6, xmm7
+ pand xmm2, xmm7
+ pandn xmm6, xmm3
+ por xmm2, xmm6
+
+ movdqa xmm6, xmm7
+ pand xmm4, xmm7
+ pandn xmm6, xmm5
+ por xmm4, xmm6
+
+ movdqa xmm3, xmm4
+
+ punpck bw, 0, 2, 1, 3, 4, 6
+
+ endm
+
+;
+; unSwizzleBlock32
+;
+
+@unSwizzleBlock32_sse2@12 proc public
+
+ push ebx
+
+ mov ebx, [esp+4+4]
+ lea eax, [ebx*2]
+ add eax, ebx
+
+ movdqa xmm0, [ecx+16*0]
+ movdqa xmm1, [ecx+16*1]
+ movdqa xmm2, [ecx+16*2]
+ movdqa xmm3, [ecx+16*3]
+
+ punpck qdq, 0, 2, 1, 3, 4, 6
+
+ movdqa [edx], xmm0
+ movdqa [edx+16], xmm2
+ movdqa [edx+ebx], xmm4
+ movdqa [edx+ebx+16], xmm6
+
+ movdqa xmm0, [ecx+16*4]
+ movdqa xmm1, [ecx+16*5]
+ movdqa xmm2, [ecx+16*6]
+ movdqa xmm3, [ecx+16*7]
+
+ punpck qdq, 0, 2, 1, 3, 4, 6
+
+ movdqa [edx+ebx*2], xmm0
+ movdqa [edx+ebx*2+16], xmm2
+ movdqa [edx+eax], xmm4
+ movdqa [edx+eax+16], xmm6
+
+ lea edx, [edx+ebx*4]
+
+ movdqa xmm0, [ecx+16*8]
+ movdqa xmm1, [ecx+16*9]
+ movdqa xmm2, [ecx+16*10]
+ movdqa xmm3, [ecx+16*11]
+
+ punpck qdq, 0, 2, 1, 3, 4, 6
+
+ movdqa [edx], xmm0
+ movdqa [edx+16], xmm2
+ movdqa [edx+ebx], xmm4
+ movdqa [edx+ebx+16], xmm6
+
+ movdqa xmm0, [ecx+16*12]
+ movdqa xmm1, [ecx+16*13]
+ movdqa xmm2, [ecx+16*14]
+ movdqa xmm3, [ecx+16*15]
+
+ punpck qdq, 0, 2, 1, 3, 4, 6
+
+ movdqa [edx+ebx*2], xmm0
+ movdqa [edx+ebx*2+16], xmm2
+ movdqa [edx+eax], xmm4
+ movdqa [edx+eax+16], xmm6
+
+ pop ebx
+
+ ret 4
+
+@unSwizzleBlock32_sse2@12 endp
+
+;
+; unSwizzleBlock16
+;
+
+@unSwizzleBlock16_sse2@12 proc public
+
+ push ebx
+
+ mov ebx, [esp+4+4]
+ mov eax, 4
+
+ align 16
+@@:
+ movdqa xmm0, [ecx+16*0]
+ movdqa xmm1, [ecx+16*1]
+ movdqa xmm2, [ecx+16*2]
+ movdqa xmm3, [ecx+16*3]
+
+ punpck wd, 0, 2, 1, 3, 4, 6
+ punpck dq, 0, 4, 2, 6, 1, 3
+ punpck wd, 0, 4, 1, 3, 2, 6
+
+ movdqa [edx], xmm0
+ movdqa [edx+16], xmm2
+ movdqa [edx+ebx], xmm4
+ movdqa [edx+ebx+16], xmm6
+
+ add ecx, 64
+ lea edx, [edx+ebx*2]
+
+ dec eax
+ jnz @B
+
+ pop ebx
+
+ ret 4
+
+@unSwizzleBlock16_sse2@12 endp
+
+;
+; unSwizzleBlock8
+;
+
+@unSwizzleBlock8_sse2@12 proc public
+
+ push ebx
+
+ mov ebx, [esp+4+4]
+ mov eax, 2
+
+ align 16
+@@:
+ ; col 0, 2
+
+ movdqa xmm0, [ecx+16*0]
+ movdqa xmm1, [ecx+16*1]
+ movdqa xmm4, [ecx+16*2]
+ movdqa xmm5, [ecx+16*3]
+
+ punpck bw, 0, 4, 1, 5, 2, 6
+ punpck wd, 0, 2, 4, 6, 1, 3
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck qdq, 0, 2, 4, 6, 1, 3
+
+ pshufd xmm1, xmm1, 0b1h
+ pshufd xmm3, xmm3, 0b1h
+
+ movdqa [edx], xmm0
+ movdqa [edx+ebx], xmm2
+ lea edx, [edx+ebx*2]
+
+ movdqa [edx], xmm1
+ movdqa [edx+ebx], xmm3
+ lea edx, [edx+ebx*2]
+
+ ; col 1, 3
+
+ movdqa xmm0, [ecx+16*4]
+ movdqa xmm1, [ecx+16*5]
+ movdqa xmm4, [ecx+16*6]
+ movdqa xmm5, [ecx+16*7]
+
+ punpck bw, 0, 4, 1, 5, 2, 6
+ punpck wd, 0, 2, 4, 6, 1, 3
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck qdq, 0, 2, 4, 6, 1, 3
+
+ pshufd xmm0, xmm0, 0b1h
+ pshufd xmm2, xmm2, 0b1h
+
+ movdqa [edx], xmm0
+ movdqa [edx+ebx], xmm2
+ lea edx, [edx+ebx*2]
+
+ movdqa [edx], xmm1
+ movdqa [edx+ebx], xmm3
+ lea edx, [edx+ebx*2]
+
+ add ecx, 128
+
+ dec eax
+ jnz @B
+
+ pop ebx
+
+ ret 4
+
+@unSwizzleBlock8_sse2@12 endp
+
+;
+; unSwizzleBlock4
+;
+
+@unSwizzleBlock4_sse2@12 proc public
+
+ push ebx
+
+ mov eax, 0f0f0f0fh
+ movd xmm7, eax
+ pshufd xmm7, xmm7, 0
+
+ mov ebx, [esp+4+4]
+ mov eax, 2
+
+ align 16
+@@:
+ ; col 0, 2
+
+ movdqa xmm0, [ecx+16*0]
+ movdqa xmm1, [ecx+16*1]
+ movdqa xmm4, [ecx+16*2]
+ movdqa xmm3, [ecx+16*3]
+
+ punpck dq, 0, 4, 1, 3, 2, 6
+ punpck dq, 0, 2, 4, 6, 1, 3
+ punpcknb
+ punpck bw, 0, 2, 4, 6, 1, 3
+ punpck wd, 0, 2, 1, 3, 4, 6
+
+ pshufd xmm0, xmm0, 0d8h
+ pshufd xmm2, xmm2, 0d8h
+ pshufd xmm4, xmm4, 0d8h
+ pshufd xmm6, xmm6, 0d8h
+
+ punpck qdq, 0, 2, 4, 6, 1, 3
+
+ pshuflw xmm1, xmm1, 0b1h
+ pshuflw xmm3, xmm3, 0b1h
+ pshufhw xmm1, xmm1, 0b1h
+ pshufhw xmm3, xmm3, 0b1h
+
+ movdqa [edx], xmm0
+ movdqa [edx+ebx], xmm2
+ lea edx, [edx+ebx*2]
+
+ movdqa [edx], xmm1
+ movdqa [edx+ebx], xmm3
+ lea edx, [edx+ebx*2]
+
+ ; col 1, 3
+
+ movdqa xmm0, [ecx+16*4]
+ movdqa xmm1, [ecx+16*5]
+ movdqa xmm4, [ecx+16*6]
+ movdqa xmm3, [ecx+16*7]
+
+ punpck dq, 0, 4, 1, 3, 2, 6
+ punpck dq, 0, 2, 4, 6, 1, 3
+ punpcknb
+ punpck bw, 0, 2, 4, 6, 1, 3
+ punpck wd, 0, 2, 1, 3, 4, 6
+
+ pshufd xmm0, xmm0, 0d8h
+ pshufd xmm2, xmm2, 0d8h
+ pshufd xmm4, xmm4, 0d8h
+ pshufd xmm6, xmm6, 0d8h
+
+ punpck qdq, 0, 2, 4, 6, 1, 3
+
+ pshuflw xmm0, xmm0, 0b1h
+ pshuflw xmm2, xmm2, 0b1h
+ pshufhw xmm0, xmm0, 0b1h
+ pshufhw xmm2, xmm2, 0b1h
+
+ movdqa [edx], xmm0
+ movdqa [edx+ebx], xmm2
+ lea edx, [edx+ebx*2]
+
+ movdqa [edx], xmm1
+ movdqa [edx+ebx], xmm3
+ lea edx, [edx+ebx*2]
+
+ add ecx, 128
+
+ dec eax
+ jnz @B
+
+ pop ebx
+
+ ret 4
+
+@unSwizzleBlock4_sse2@12 endp
+
+;
+; unSwizzleBlock8HP
+;
+
+@unSwizzleBlock8HP_sse2@12 proc public
+
+ push ebx
+
+ mov ebx, [esp+4+4]
+ mov eax, 4
+
+ align 16
+@@:
+ movdqa xmm0, [ecx+16*0]
+ movdqa xmm1, [ecx+16*1]
+ movdqa xmm2, [ecx+16*2]
+ movdqa xmm3, [ecx+16*3]
+
+ punpck qdq, 0, 2, 1, 3, 4, 6
+
+ psrld xmm0, 24
+ psrld xmm2, 24
+ psrld xmm4, 24
+ psrld xmm6, 24
+
+ packssdw xmm0, xmm2
+ packssdw xmm4, xmm6
+ packuswb xmm0, xmm4
+
+ movlps qword ptr [edx], xmm0
+ movhps qword ptr [edx+ebx], xmm0
+
+ add ecx, 64
+ lea edx, [edx+ebx*2]
+
+ dec eax
+ jnz @B
+
+ pop ebx
+
+ ret 4
+
+@unSwizzleBlock8HP_sse2@12 endp
+
+;
+; unSwizzleBlock4HLP
+;
+
+@unSwizzleBlock4HLP_sse2@12 proc public
+
+ push ebx
+
+ mov eax, 0f0f0f0fh
+ movd xmm7, eax
+ pshufd xmm7, xmm7, 0
+
+ mov ebx, [esp+4+4]
+ mov eax, 4
+
+ align 16
+@@:
+ movdqa xmm0, [ecx+16*0]
+ movdqa xmm1, [ecx+16*1]
+ movdqa xmm2, [ecx+16*2]
+ movdqa xmm3, [ecx+16*3]
+
+ punpck qdq, 0, 2, 1, 3, 4, 6
+
+ psrld xmm0, 24
+ psrld xmm2, 24
+ psrld xmm4, 24
+ psrld xmm6, 24
+
+ packssdw xmm0, xmm2
+ packssdw xmm4, xmm6
+ packuswb xmm0, xmm4
+
+ pand xmm0, xmm7
+
+ movlps qword ptr [edx], xmm0
+ movhps qword ptr [edx+ebx], xmm0
+
+ add ecx, 64
+ lea edx, [edx+ebx*2]
+
+ dec eax
+ jnz @B
+
+ pop ebx
+
+ ret 4
+
+@unSwizzleBlock4HLP_sse2@12 endp
+
+;
+; unSwizzleBlock4HHP
+;
+
+@unSwizzleBlock4HHP_sse2@12 proc public
+
+ push ebx
+
+ mov ebx, [esp+4+4]
+ mov eax, 4
+
+ align 16
+@@:
+ movdqa xmm0, [ecx+16*0]
+ movdqa xmm1, [ecx+16*1]
+ movdqa xmm2, [ecx+16*2]
+ movdqa xmm3, [ecx+16*3]
+
+ punpck qdq, 0, 2, 1, 3, 4, 6
+
+ psrld xmm0, 28
+ psrld xmm2, 28
+ psrld xmm4, 28
+ psrld xmm6, 28
+
+ packssdw xmm0, xmm2
+ packssdw xmm4, xmm6
+ packuswb xmm0, xmm4
+
+ movlps qword ptr [edx], xmm0
+ movhps qword ptr [edx+ebx], xmm0
+
+ add ecx, 64
+ lea edx, [edx+ebx*2]
+
+ dec eax
+ jnz @B
+
+ pop ebx
+
+ ret 4
+
+@unSwizzleBlock4HHP_sse2@12 endp
+
+;
+; unSwizzleBlock4P
+;
+
+@unSwizzleBlock4P_sse2@12 proc public
+
+ push esi
+ push edi
+
+ mov eax, 0f0f0f0fh
+ movd xmm7, eax
+ pshufd xmm7, xmm7, 0
+
+ mov esi, [esp+4+8]
+ lea edi, [esi*2]
+ add edi, esi
+
+ ; col 0
+
+ movdqa xmm0, [ecx+16*0]
+ movdqa xmm1, [ecx+16*1]
+ movdqa xmm2, [ecx+16*2]
+ movdqa xmm3, [ecx+16*3]
+
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck wd, 0, 4, 2, 6, 1, 3
+ punpck bw, 0, 4, 1, 3, 2, 6
+
+ movdqa xmm1, xmm7
+ pandn xmm1, xmm0
+ pand xmm0, xmm7
+ pshufd xmm1, xmm1, 0b1h
+ psrlq xmm1, 4
+
+ movdqa xmm3, xmm7
+ pandn xmm3, xmm2
+ pand xmm2, xmm7
+ pshufd xmm3, xmm3, 0b1h
+ psrlq xmm3, 4
+
+ movdqa [edx], xmm0
+ movdqa [edx+16], xmm2
+ movdqa [edx+esi*2], xmm1
+ movdqa [edx+esi*2+16], xmm3
+
+ movdqa xmm1, xmm7
+ pandn xmm1, xmm4
+ pand xmm4, xmm7
+ pshufd xmm1, xmm1, 0b1h
+ psrlq xmm1, 4
+
+ movdqa xmm3, xmm7
+ pandn xmm3, xmm6
+ pand xmm6, xmm7
+ pshufd xmm3, xmm3, 0b1h
+ psrlq xmm3, 4
+
+ movdqa [edx+esi], xmm4
+ movdqa [edx+esi+16], xmm6
+ movdqa [edx+edi], xmm1
+ movdqa [edx+edi+16], xmm3
+
+ lea edx, [edx+esi*4]
+
+ ; col 1
+
+ movdqa xmm0, [ecx+16*4]
+ movdqa xmm1, [ecx+16*5]
+ movdqa xmm2, [ecx+16*6]
+ movdqa xmm3, [ecx+16*7]
+
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck wd, 0, 4, 2, 6, 1, 3
+ punpck bw, 0, 4, 1, 3, 2, 6
+
+ movdqa xmm1, xmm7
+ pandn xmm1, xmm0
+ pand xmm0, xmm7
+ pshufd xmm0, xmm0, 0b1h
+ psrlq xmm1, 4
+
+ movdqa xmm3, xmm7
+ pandn xmm3, xmm2
+ pand xmm2, xmm7
+ pshufd xmm2, xmm2, 0b1h
+ psrlq xmm3, 4
+
+ movdqa [edx], xmm0
+ movdqa [edx+16], xmm2
+ movdqa [edx+esi*2], xmm1
+ movdqa [edx+esi*2+16], xmm3
+
+ movdqa xmm1, xmm7
+ pandn xmm1, xmm4
+ pand xmm4, xmm7
+ pshufd xmm4, xmm4, 0b1h
+ psrlq xmm1, 4
+
+ movdqa xmm3, xmm7
+ pandn xmm3, xmm6
+ pand xmm6, xmm7
+ pshufd xmm6, xmm6, 0b1h
+ psrlq xmm3, 4
+
+ movdqa [edx+esi], xmm4
+ movdqa [edx+esi+16], xmm6
+ movdqa [edx+edi], xmm1
+ movdqa [edx+edi+16], xmm3
+
+ lea edx, [edx+esi*4]
+
+ ; col 2
+
+ movdqa xmm0, [ecx+16*8]
+ movdqa xmm1, [ecx+16*9]
+ movdqa xmm2, [ecx+16*10]
+ movdqa xmm3, [ecx+16*11]
+
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck wd, 0, 4, 2, 6, 1, 3
+ punpck bw, 0, 4, 1, 3, 2, 6
+
+ movdqa xmm1, xmm7
+ pandn xmm1, xmm0
+ pand xmm0, xmm7
+ pshufd xmm1, xmm1, 0b1h
+ psrlq xmm1, 4
+
+ movdqa xmm3, xmm7
+ pandn xmm3, xmm2
+ pand xmm2, xmm7
+ pshufd xmm3, xmm3, 0b1h
+ psrlq xmm3, 4
+
+ movdqa [edx], xmm0
+ movdqa [edx+16], xmm2
+ movdqa [edx+esi*2], xmm1
+ movdqa [edx+esi*2+16], xmm3
+
+ movdqa xmm1, xmm7
+ pandn xmm1, xmm4
+ pand xmm4, xmm7
+ pshufd xmm1, xmm1, 0b1h
+ psrlq xmm1, 4
+
+ movdqa xmm3, xmm7
+ pandn xmm3, xmm6
+ pand xmm6, xmm7
+ pshufd xmm3, xmm3, 0b1h
+ psrlq xmm3, 4
+
+ movdqa [edx+esi], xmm4
+ movdqa [edx+esi+16], xmm6
+ movdqa [edx+edi], xmm1
+ movdqa [edx+edi+16], xmm3
+
+ lea edx, [edx+esi*4]
+
+ ; col 3
+
+ movdqa xmm0, [ecx+16*12]
+ movdqa xmm1, [ecx+16*13]
+ movdqa xmm2, [ecx+16*14]
+ movdqa xmm3, [ecx+16*15]
+
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck wd, 0, 4, 2, 6, 1, 3
+ punpck bw, 0, 4, 1, 3, 2, 6
+
+ movdqa xmm1, xmm7
+ pandn xmm1, xmm0
+ pand xmm0, xmm7
+ pshufd xmm0, xmm0, 0b1h
+ psrlq xmm1, 4
+
+ movdqa xmm3, xmm7
+ pandn xmm3, xmm2
+ pand xmm2, xmm7
+ pshufd xmm2, xmm2, 0b1h
+ psrlq xmm3, 4
+
+ movdqa [edx], xmm0
+ movdqa [edx+16], xmm2
+ movdqa [edx+esi*2], xmm1
+ movdqa [edx+esi*2+16], xmm3
+
+ movdqa xmm1, xmm7
+ pandn xmm1, xmm4
+ pand xmm4, xmm7
+ pshufd xmm4, xmm4, 0b1h
+ psrlq xmm1, 4
+
+ movdqa xmm3, xmm7
+ pandn xmm3, xmm6
+ pand xmm6, xmm7
+ pshufd xmm6, xmm6, 0b1h
+ psrlq xmm3, 4
+
+ movdqa [edx+esi], xmm4
+ movdqa [edx+esi+16], xmm6
+ movdqa [edx+edi], xmm1
+ movdqa [edx+edi+16], xmm3
+
+ ; lea edx, [edx+esi*4]
+
+ pop edi
+ pop esi
+
+ ret 4
+
+@unSwizzleBlock4P_sse2@12 endp
+
+;
+; swizzling
+;
+
+;
+; SwizzleBlock32
+;
+
+@SwizzleBlock32_sse2@16 proc public
+
+
+ push esi
+ push edi
+
+ mov edi, ecx
+ mov esi, edx
+ mov edx, [esp+4+8]
+ mov ecx, 4
+
+ mov eax, [esp+8+8]
+ cmp eax, 0ffffffffh
+ jnz SwizzleBlock32_sse2@WM
+
+ align 16
+@@:
+ movdqa xmm0, [esi]
+ movdqa xmm4, [esi+16]
+ movdqa xmm1, [esi+edx]
+ movdqa xmm5, [esi+edx+16]
+
+ punpck qdq, 0, 4, 1, 5, 2, 6
+
+ movntps [edi+16*0], xmm0
+ movntps [edi+16*1], xmm2
+ movntps [edi+16*2], xmm4
+ movntps [edi+16*3], xmm6
+
+ lea esi, [esi+edx*2]
+ add edi, 64
+
+ dec ecx
+ jnz @B
+
+ pop edi
+ pop esi
+
+ ret 8
+
+SwizzleBlock32_sse2@WM:
+
+ movd xmm7, eax
+ pshufd xmm7, xmm7, 0
+
+ align 16
+@@:
+ movdqa xmm0, [esi]
+ movdqa xmm4, [esi+16]
+ movdqa xmm1, [esi+edx]
+ movdqa xmm5, [esi+edx+16]
+
+ punpck qdq, 0, 4, 1, 5, 2, 6
+
+ movdqa xmm3, xmm7
+ pshufd xmm5, xmm7, 0e4h
+
+ pandn xmm3, [edi+16*0]
+ pand xmm0, xmm7
+ por xmm0, xmm3
+ movntps [edi+16*0], xmm0
+
+ pandn xmm5, [edi+16*1]
+ pand xmm2, xmm7
+ por xmm2, xmm5
+ movntps [edi+16*1], xmm2
+
+ movdqa xmm3, xmm7
+ pshufd xmm5, xmm7, 0e4h
+
+ pandn xmm3, [edi+16*2]
+ pand xmm4, xmm7
+ por xmm4, xmm3
+ movntps [edi+16*2], xmm4
+
+ pandn xmm5, [edi+16*3]
+ pand xmm6, xmm7
+ por xmm6, xmm5
+ movntps [edi+16*3], xmm6
+
+ lea esi, [esi+edx*2]
+ add edi, 64
+
+ dec ecx
+ jnz @B
+
+ pop edi
+ pop esi
+
+ ret 8
+
+@SwizzleBlock32_sse2@16 endp
+
+;
+; SwizzleBlock16
+;
+
+@SwizzleBlock16_sse2@12 proc public
+
+ push ebx
+
+ mov ebx, [esp+4+4]
+ mov eax, 4
+
+ align 16
+@@:
+ movdqa xmm0, [edx]
+ movdqa xmm1, [edx+16]
+ movdqa xmm2, [edx+ebx]
+ movdqa xmm3, [edx+ebx+16]
+
+ punpck wd, 0, 2, 1, 3, 4, 6
+ punpck qdq, 0, 4, 2, 6, 1, 5
+
+ movntps [ecx+16*0], xmm0
+ movntps [ecx+16*1], xmm1
+ movntps [ecx+16*2], xmm4
+ movntps [ecx+16*3], xmm5
+
+ lea edx, [edx+ebx*2]
+ add ecx, 64
+
+ dec eax
+ jnz @B
+
+ pop ebx
+
+ ret 4
+
+@SwizzleBlock16_sse2@12 endp
+
+;
+; SwizzleBlock8
+;
+
+@SwizzleBlock8_sse2@12 proc public
+
+ push ebx
+
+ mov ebx, [esp+4+4]
+ mov eax, 2
+
+ align 16
+@@:
+ ; col 0, 2
+
+ movdqa xmm0, [edx]
+ movdqa xmm2, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ pshufd xmm1, [edx], 0b1h
+ pshufd xmm3, [edx+ebx], 0b1h
+ lea edx, [edx+ebx*2]
+
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck wd, 0, 2, 4, 6, 1, 3
+ punpck qdq, 0, 1, 2, 3, 4, 5
+
+ movntps [ecx+16*0], xmm0
+ movntps [ecx+16*1], xmm4
+ movntps [ecx+16*2], xmm1
+ movntps [ecx+16*3], xmm5
+
+ ; col 1, 3
+
+ pshufd xmm0, [edx], 0b1h
+ pshufd xmm2, [edx+ebx], 0b1h
+ lea edx, [edx+ebx*2]
+
+ movdqa xmm1, [edx]
+ movdqa xmm3, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck wd, 0, 2, 4, 6, 1, 3
+ punpck qdq, 0, 1, 2, 3, 4, 5
+
+ movntps [ecx+16*4], xmm0
+ movntps [ecx+16*5], xmm4
+ movntps [ecx+16*6], xmm1
+ movntps [ecx+16*7], xmm5
+
+ add ecx, 128
+
+ dec eax
+ jnz @B
+
+ pop ebx
+
+ ret 4
+
+@SwizzleBlock8_sse2@12 endp
+
+;
+; SwizzleBlock4
+;
+
+@SwizzleBlock4_sse2@12 proc public
+
+ push ebx
+
+ mov eax, 0f0f0f0fh
+ movd xmm7, eax
+ pshufd xmm7, xmm7, 0
+
+ mov ebx, [esp+4+4]
+ mov eax, 2
+
+ align 16
+@@:
+ ; col 0, 2
+
+ movdqa xmm0, [edx]
+ movdqa xmm2, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ movdqa xmm1, [edx]
+ movdqa xmm3, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ pshuflw xmm1, xmm1, 0b1h
+ pshuflw xmm3, xmm3, 0b1h
+ pshufhw xmm1, xmm1, 0b1h
+ pshufhw xmm3, xmm3, 0b1h
+
+ punpcknb
+ punpck bw, 0, 2, 4, 6, 1, 3
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck qdq, 0, 4, 2, 6, 1, 3
+
+ movntps [ecx+16*0], xmm0
+ movntps [ecx+16*1], xmm1
+ movntps [ecx+16*2], xmm4
+ movntps [ecx+16*3], xmm3
+
+ ; col 1, 3
+
+ movdqa xmm0, [edx]
+ movdqa xmm2, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ movdqa xmm1, [edx]
+ movdqa xmm3, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ pshuflw xmm0, xmm0, 0b1h
+ pshuflw xmm2, xmm2, 0b1h
+ pshufhw xmm0, xmm0, 0b1h
+ pshufhw xmm2, xmm2, 0b1h
+
+ punpcknb
+ punpck bw, 0, 2, 4, 6, 1, 3
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck qdq, 0, 4, 2, 6, 1, 3
+
+ movntps [ecx+16*4], xmm0
+ movntps [ecx+16*5], xmm1
+ movntps [ecx+16*6], xmm4
+ movntps [ecx+16*7], xmm3
+
+ add ecx, 128
+
+ dec eax
+ jnz @B
+
+ pop ebx
+
+ ret 4
+
+@SwizzleBlock4_sse2@12 endp
+
+;
+; swizzling with unaligned reads
+;
+
+;
+; SwizzleBlock32u
+;
+
+@SwizzleBlock32u_sse2@16 proc public
+
+ push esi
+ push edi
+
+ mov edi, ecx
+ mov esi, edx
+ mov edx, [esp+4+8]
+ mov ecx, 4
+
+ mov eax, [esp+8+8]
+ cmp eax, 0ffffffffh
+ jnz SwizzleBlock32u_sse2@WM
+
+ align 16
+@@:
+ movdqu xmm0, [esi]
+ movdqu xmm4, [esi+16]
+ movdqu xmm1, [esi+edx]
+ movdqu xmm5, [esi+edx+16]
+
+ punpck qdq, 0, 4, 1, 5, 2, 6
+
+ movntps [edi+16*0], xmm0
+ movntps [edi+16*1], xmm2
+ movntps [edi+16*2], xmm4
+ movntps [edi+16*3], xmm6
+
+ lea esi, [esi+edx*2]
+ add edi, 64
+
+ dec ecx
+ jnz @B
+
+ pop edi
+ pop esi
+
+ ret 8
+
+SwizzleBlock32u_sse2@WM:
+
+ movd xmm7, eax
+ pshufd xmm7, xmm7, 0
+
+ align 16
+@@:
+ movdqu xmm0, [esi]
+ movdqu xmm4, [esi+16]
+ movdqu xmm1, [esi+edx]
+ movdqu xmm5, [esi+edx+16]
+
+ punpck qdq, 0, 4, 1, 5, 2, 6
+
+ movdqa xmm3, xmm7
+ pshufd xmm5, xmm7, 0e4h
+
+ pandn xmm3, [edi+16*0]
+ pand xmm0, xmm7
+ por xmm0, xmm3
+ movdqa [edi+16*0], xmm0
+
+ pandn xmm5, [edi+16*1]
+ pand xmm2, xmm7
+ por xmm2, xmm5
+ movdqa [edi+16*1], xmm2
+
+ movdqa xmm3, xmm7
+ pshufd xmm5, xmm7, 0e4h
+
+ pandn xmm3, [edi+16*2]
+ pand xmm4, xmm7
+ por xmm4, xmm3
+ movdqa [edi+16*2], xmm4
+
+ pandn xmm5, [edi+16*3]
+ pand xmm6, xmm7
+ por xmm6, xmm5
+ movdqa [edi+16*3], xmm6
+
+ lea esi, [esi+edx*2]
+ add edi, 64
+
+ dec ecx
+ jnz @B
+
+ pop edi
+ pop esi
+
+ ret 8
+
+@SwizzleBlock32u_sse2@16 endp
+
+;
+; SwizzleBlock16u
+;
+
+@SwizzleBlock16u_sse2@12 proc public
+
+ push ebx
+
+ mov ebx, [esp+4+4]
+ mov eax, 4
+
+ align 16
+@@:
+ movdqu xmm0, [edx]
+ movdqu xmm1, [edx+16]
+ movdqu xmm2, [edx+ebx]
+ movdqu xmm3, [edx+ebx+16]
+
+ punpck wd, 0, 2, 1, 3, 4, 6
+ punpck qdq, 0, 4, 2, 6, 1, 5
+
+ movntps [ecx+16*0], xmm0
+ movntps [ecx+16*1], xmm1
+ movntps [ecx+16*2], xmm4
+ movntps [ecx+16*3], xmm5
+
+ lea edx, [edx+ebx*2]
+ add ecx, 64
+
+ dec eax
+ jnz @B
+
+ pop ebx
+
+ ret 4
+
+@SwizzleBlock16u_sse2@12 endp
+
+;
+; SwizzleBlock8u
+;
+
+@SwizzleBlock8u_sse2@12 proc public
+
+ push ebx
+
+ mov ebx, [esp+4+4]
+ mov eax, 2
+
+ align 16
+@@:
+ ; col 0, 2
+
+ movdqu xmm0, [edx]
+ movdqu xmm2, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ movdqu xmm1, [edx]
+ movdqu xmm3, [edx+ebx]
+ pshufd xmm1, xmm1, 0b1h
+ pshufd xmm3, xmm3, 0b1h
+ lea edx, [edx+ebx*2]
+
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck wd, 0, 2, 4, 6, 1, 3
+ punpck qdq, 0, 1, 2, 3, 4, 5
+
+ movntps [ecx+16*0], xmm0
+ movntps [ecx+16*1], xmm4
+ movntps [ecx+16*2], xmm1
+ movntps [ecx+16*3], xmm5
+
+ ; col 1, 3
+
+ movdqu xmm0, [edx]
+ movdqu xmm2, [edx+ebx]
+ pshufd xmm0, xmm0, 0b1h
+ pshufd xmm2, xmm2, 0b1h
+ lea edx, [edx+ebx*2]
+
+ movdqu xmm1, [edx]
+ movdqu xmm3, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck wd, 0, 2, 4, 6, 1, 3
+ punpck qdq, 0, 1, 2, 3, 4, 5
+
+ movntps [ecx+16*4], xmm0
+ movntps [ecx+16*5], xmm4
+ movntps [ecx+16*6], xmm1
+ movntps [ecx+16*7], xmm5
+
+ add ecx, 128
+
+ dec eax
+ jnz @B
+
+ pop ebx
+
+ ret 4
+
+@SwizzleBlock8u_sse2@12 endp
+
+;
+; SwizzleBlock4u
+;
+
+@SwizzleBlock4u_sse2@12 proc public
+
+ push ebx
+
+ mov eax, 0f0f0f0fh
+ movd xmm7, eax
+ pshufd xmm7, xmm7, 0
+
+ mov ebx, [esp+4+4]
+ mov eax, 2
+
+ align 16
+@@:
+ ; col 0, 2
+
+ movdqu xmm0, [edx]
+ movdqu xmm2, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ movdqu xmm1, [edx]
+ movdqu xmm3, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ pshuflw xmm1, xmm1, 0b1h
+ pshuflw xmm3, xmm3, 0b1h
+ pshufhw xmm1, xmm1, 0b1h
+ pshufhw xmm3, xmm3, 0b1h
+
+ punpcknb
+ punpck bw, 0, 2, 4, 6, 1, 3
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck qdq, 0, 4, 2, 6, 1, 3
+
+ movntps [ecx+16*0], xmm0
+ movntps [ecx+16*1], xmm1
+ movntps [ecx+16*2], xmm4
+ movntps [ecx+16*3], xmm3
+
+ ; col 1, 3
+
+ movdqu xmm0, [edx]
+ movdqu xmm2, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ movdqu xmm1, [edx]
+ movdqu xmm3, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ pshuflw xmm0, xmm0, 0b1h
+ pshuflw xmm2, xmm2, 0b1h
+ pshufhw xmm0, xmm0, 0b1h
+ pshufhw xmm2, xmm2, 0b1h
+
+ punpcknb
+ punpck bw, 0, 2, 4, 6, 1, 3
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck qdq, 0, 4, 2, 6, 1, 3
+
+ movntps [ecx+16*4], xmm0
+ movntps [ecx+16*5], xmm1
+ movntps [ecx+16*6], xmm4
+ movntps [ecx+16*7], xmm3
+
+ add ecx, 128
+
+ dec eax
+ jnz @B
+
+ pop ebx
+
+ ret 4
+
+@SwizzleBlock4u_sse2@12 endp
+
end
\ No newline at end of file
diff --git a/plugins/zerogs/dx/x86-64.asm b/plugins/zerogs/dx/x86-64.asm
index 430960809f..5ab84d473a 100644
--- a/plugins/zerogs/dx/x86-64.asm
+++ b/plugins/zerogs/dx/x86-64.asm
@@ -1,1090 +1,1090 @@
-; Copyright (C) 2003-2005 Gabest/zerofrog
-; http:;;www.gabest.org
-;
-; 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, 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 GNU Make; see the file COPYING. If not, write to
-; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-; http:;;www.gnu.org/copyleft/gpl.html
-;
-;
-extern s_clut16mask:ptr
-
- .code
-
-; mmx memcpy implementation, size has to be a multiple of 8
-; returns 0 is equal, nonzero value if not equal
-; ~10 times faster than standard memcmp
-; (zerofrog)
-; u8 memcmp_mmx(const void* src1, const void* src2, int cmpsize)
-; rcx - src1
-; rdx - src2
-; r8d - cmpsize
-memcmp_mmx proc public
- cmp r8d, 32
- jl Done4
-
- ; custom test first 8 to make sure things are ok
- movq mm0, [rdx]
- movq mm1, [rdx+8]
- pcmpeqd mm0, [rcx]
- pcmpeqd mm1, [rcx+8]
- pand mm0, mm1
- movq mm2, [rdx+16]
- pmovmskb eax, mm0
- movq mm3, [rdx+24]
-
- ; check if eq
- cmp eax, 0ffh
- je NextComp
- mov eax, 1
- jmp Finish
-
-NextComp:
- pcmpeqd mm2, [rcx+16]
- pcmpeqd mm3, [rcx+24]
- pand mm2, mm3
- pmovmskb eax, mm2
-
- sub r8d, 32
- add rdx, 32
- add rcx, 32
-
- ; check if eq
- cmp eax, 0ffh
- je ContinueTest
- mov eax, 1
- jmp Finish
-
- cmp r8d, 64
- jl Done8
-
-Cmp8:
- movq mm0, [rdx]
- movq mm1, [rdx+8]
- movq mm2, [rdx+16]
- movq mm3, [rdx+24]
- movq mm4, [rdx+32]
- movq mm5, [rdx+40]
- movq mm6, [rdx+48]
- movq mm7, [rdx+56]
- pcmpeqd mm0, [rcx]
- pcmpeqd mm1, [rcx+8]
- pcmpeqd mm2, [rcx+16]
- pcmpeqd mm3, [rcx+24]
- pand mm0, mm1
- pcmpeqd mm4, [rcx+32]
- pand mm0, mm2
- pcmpeqd mm5, [rcx+40]
- pand mm0, mm3
- pcmpeqd mm6, [rcx+48]
- pand mm0, mm4
- pcmpeqd mm7, [rcx+56]
- pand mm0, mm5
- pand mm0, mm6
- pand mm0, mm7
- pmovmskb eax, mm0
-
- ; check if eq
- cmp eax, 0ffh
- je Continue
- mov eax, 1
- jmp Finish
-
-Continue:
- sub r8d, 64
- add rdx, 64
- add rcx, 64
-ContinueTest:
- cmp r8d, 64
- jge Cmp8
-
-Done8:
- test r8d, 020h
- jz Done4
- movq mm0, [rdx]
- movq mm1, [rdx+8]
- movq mm2, [rdx+16]
- movq mm3, [rdx+24]
- pcmpeqd mm0, [rcx]
- pcmpeqd mm1, [rcx+8]
- pcmpeqd mm2, [rcx+16]
- pcmpeqd mm3, [rcx+24]
- pand mm0, mm1
- pand mm0, mm2
- pand mm0, mm3
- pmovmskb eax, mm0
- sub r8d, 32
- add rdx, 32
- add rcx, 32
-
- ; check if eq
- cmp eax, 0ffh
- je Done4
- mov eax, 1
- jmp Finish
-
-Done4:
- cmp r8d, 24
- jne Done2
- movq mm0, [rdx]
- movq mm1, [rdx+8]
- movq mm2, [rdx+16]
- pcmpeqd mm0, [rcx]
- pcmpeqd mm1, [rcx+8]
- pcmpeqd mm2, [rcx+16]
- pand mm0, mm1
- pand mm0, mm2
- pmovmskb eax, mm0
-
- ; check if eq
- cmp eax, 0ffh
- je Done
- mov eax, 1
- jmp Finish
-
-Done2:
- cmp r8d, 16
- jne Done1
-
- movq mm0, [rdx]
- movq mm1, [rdx+8]
- pcmpeqd mm0, [rcx]
- pcmpeqd mm1, [rcx+8]
- pand mm0, mm1
- pmovmskb eax, mm0
-
- ; check if eq
- cmp eax, 0ffh
- je Done
- mov eax, 1
- jmp Finish
-
-Done1:
- cmp r8d, 8
- jne Done
-
- mov eax, [rdx]
- mov rdx, [rdx+4]
- cmp eax, [rcx]
- je Next
- mov eax, 1
- jmp Finish
-
-Next:
- cmp rdx, [rcx+4]
- je Done
- mov eax, 1
- jmp Finish
-
-Done:
- xor eax, eax
-
-Finish:
- emms
- ret
-
-memcmp_mmx endp
-
-; TestClutChangeMMX
-; mov rdx, dst
-; mov rcx, src
-; mov r8d, entries
-TestClutChangeMMX proc public
-
-Start:
- movq mm0, [rdx]
- movq mm1, [rdx+8]
- pcmpeqd mm0, [rcx]
- pcmpeqd mm1, [rcx+16]
-
- movq mm2, [rdx+16]
- movq mm3, [rdx+24]
- pcmpeqd mm2, [rcx+32]
- pcmpeqd mm3, [rcx+48]
-
- pand mm0, mm1
- pand mm2, mm3
- movq mm4, [rdx+32]
- movq mm5, [rdx+40]
- pcmpeqd mm4, [rcx+8]
- pcmpeqd mm5, [rcx+24]
-
- pand mm0, mm2
- pand mm4, mm5
- movq mm6, [rdx+48]
- movq mm7, [rdx+56]
- pcmpeqd mm6, [rcx+40]
- pcmpeqd mm7, [rcx+56]
-
- pand mm0, mm4
- pand mm6, mm7
- pand mm0, mm6
-
- pmovmskb eax, mm0
- cmp eax, 0ffh
- je Continue
- mov byte ptr [r9], 1
- jmp Return
-
-Continue:
- cmp r8d, 16
- jle Return
-
- test r8d, 010h
- jz AddRcx
- sub rcx, 448 ; go back and down one column,
-AddRcx:
- add rcx, 256 ; go to the right block
-
-
- jne Continue1
- add rcx, 256 ; skip whole block
-Continue1:
- add rdx, 64
- sub r8d, 16
- jmp Start
-
-Return:
- emms
- ret
-
-TestClutChangeMMX endp
-
-UnswizzleZ16Target proc public
- pxor xmm7, xmm7
-
-Z16Loop:
- ;; unpack 64 bytes at a time
- movdqa xmm0, [rdx]
- movdqa xmm2, [rdx+16]
- movdqa xmm4, [rdx+32]
- movdqa xmm6, [rdx+48]
-
- movdqa xmm1, xmm0
- movdqa xmm3, xmm2
- movdqa xmm5, xmm4
-
- punpcklwd xmm0, xmm7
- punpckhwd xmm1, xmm7
- punpcklwd xmm2, xmm7
- punpckhwd xmm3, xmm7
-
- ;; start saving
- movdqa [rcx], xmm0
- movdqa [rcx+16], xmm1
-
- punpcklwd xmm4, xmm7
- punpckhwd xmm5, xmm7
-
- movdqa [rcx+32], xmm2
- movdqa [rcx+48], xmm3
-
- movdqa xmm0, xmm6
- punpcklwd xmm6, xmm7
-
- movdqa [rcx+64], xmm4
- movdqa [rcx+80], xmm5
-
- punpckhwd xmm0, xmm7
-
- movdqa [rcx+96], xmm6
- movdqa [rcx+112], xmm0
-
- add rdx, 64
- add rcx, 128
- sub r9d, 1
- jne Z16Loop
-
- ret
-UnswizzleZ16Target endp
-
-;
-; swizzling
-;
-
-punpck macro op, sd0, sd2, s1, s3, d1, d3
-
- movdqa @CatStr(xmm, %d1), @CatStr(xmm, %sd0)
- pshufd @CatStr(xmm, %d3), @CatStr(xmm, %sd2), 0e4h
-
- @CatStr(punpckl, op) @CatStr(xmm, %sd0), @CatStr(xmm, %s1)
- @CatStr(punpckh, op) @CatStr(xmm, %d1), @CatStr(xmm, %s1)
- @CatStr(punpckl, op) @CatStr(xmm, %sd2), @CatStr(xmm, %s3)
- @CatStr(punpckh, op) @CatStr(xmm, %d3), @CatStr(xmm, %s3)
-
- endm
-
-punpcknbl macro
-
- movdqa xmm4, xmm0
- pshufd xmm5, xmm1, 0e4h
-
- psllq xmm1, 4
- psrlq xmm4, 4
-
- movdqa xmm6, xmm7
- pand xmm0, xmm7
- pandn xmm6, xmm1
- por xmm0, xmm6
-
- movdqa xmm6, xmm7
- pand xmm4, xmm7
- pandn xmm6, xmm5
- por xmm4, xmm6
-
- movdqa xmm1, xmm4
-
- movdqa xmm4, xmm2
- pshufd xmm5, xmm3, 0e4h
-
- psllq xmm3, 4
- psrlq xmm4, 4
-
- movdqa xmm6, xmm7
- pand xmm2, xmm7
- pandn xmm6, xmm3
- por xmm2, xmm6
-
- movdqa xmm6, xmm7
- pand xmm4, xmm7
- pandn xmm6, xmm5
- por xmm4, xmm6
-
- movdqa xmm3, xmm4
-
- punpck bw, 0, 2, 1, 3, 4, 6
-
- endm
-
-punpcknbh macro
-
- movdqa xmm12, xmm8
- pshufd xmm13, xmm9, 0e4h
-
- psllq xmm9, 4
- psrlq xmm12, 4
-
- movdqa xmm14, xmm15
- pand xmm8, xmm15
- pandn xmm14, xmm9
- por xmm8, xmm14
-
- movdqa xmm14, xmm15
- pand xmm12, xmm15
- pandn xmm14, xmm13
- por xmm12, xmm14
-
- movdqa xmm9, xmm12
-
- movdqa xmm12, xmm10
- pshufd xmm13, xmm11, 0e4h
-
- psllq xmm11, 4
- psrlq xmm12, 4
-
- movdqa xmm14, xmm15
- pand xmm10, xmm15
- pandn xmm14, xmm11
- por xmm10, xmm14
-
- movdqa xmm14, xmm15
- pand xmm12, xmm15
- pandn xmm14, xmm13
- por xmm12, xmm14
-
- movdqa xmm11, xmm12
-
- punpck bw, 8, 10, 9, 11, 12, 14
-
- endm
-
-;
-; SwizzleBlock32_sse2
-;
-
-SwizzleBlock32_sse2 proc public
-
- push rsi
- push rdi
-
- mov rdi, rcx
- mov rsi, rdx
- mov rcx, 4
-
- cmp r9d, 0ffffffffh
- jne SwizzleBlock32_sse2@WM
-
- align 16
-@@:
- movdqa xmm0, [rsi]
- movdqa xmm4, [rsi+16]
- movdqa xmm1, [rsi+r8]
- movdqa xmm5, [rsi+r8+16]
-
- punpck qdq, 0, 4, 1, 5, 2, 6
-
- movdqa [rdi+16*0], xmm0
- movdqa [rdi+16*1], xmm2
- movdqa [rdi+16*2], xmm4
- movdqa [rdi+16*3], xmm6
-
- lea rsi, [rsi+r8*2]
- add rdi, 64
-
- dec rcx
- jnz @B
-
- pop rdi
- pop rsi
-
- ret
-
-SwizzleBlock32_sse2@WM:
-
- movd xmm7, r9d
- pshufd xmm7, xmm7, 0
-
- align 16
-@@:
- movdqa xmm0, [rsi]
- movdqa xmm4, [rsi+16]
- movdqa xmm1, [rsi+r8]
- movdqa xmm5, [rsi+r8+16]
-
- punpck qdq, 0, 4, 1, 5, 2, 6
-
- movdqa xmm3, xmm7
- pshufd xmm5, xmm7, 0e4h
- movdqa xmm9, xmm7
- pshufd xmm11, xmm7, 0e4h
-
- pandn xmm3, [rdi+16*0]
- pand xmm0, xmm7
- por xmm0, xmm3
- movdqa [rdi+16*0], xmm0
-
- pandn xmm5, [rdi+16*1]
- pand xmm2, xmm7
- por xmm2, xmm5
- movdqa [rdi+16*1], xmm2
-
- pandn xmm9, [rdi+16*2]
- pand xmm4, xmm7
- por xmm4, xmm9
- movdqa [rdi+16*2], xmm4
-
- pandn xmm11, [rdi+16*3]
- pand xmm6, xmm7
- por xmm6, xmm11
- movdqa [edi+16*3], xmm6
-
- lea rsi, [rsi+r8*2]
- add rdi, 64
-
- dec rcx
- jnz @B
-
- pop rdi
- pop rsi
-
- ret
-
-SwizzleBlock32_sse2 endp
-
-;
-; SwizzleBlock16_sse2
-;
-
-SwizzleBlock16_sse2 proc public
-
- push rsi
- push rdi
-
- mov rdi, rcx
- mov rsi, rdx
- mov rcx, 4
-
- align 16
-@@:
- movdqa xmm0, [rsi]
- movdqa xmm1, [rsi+16]
- movdqa xmm2, [rsi+r8]
- movdqa xmm3, [rsi+r8+16]
-
- punpck wd, 0, 2, 1, 3, 4, 6
- punpck qdq, 0, 4, 2, 6, 1, 5
-
- movdqa [rdi+16*0], xmm0
- movdqa [rdi+16*1], xmm1
- movdqa [rdi+16*2], xmm4
- movdqa [rdi+16*3], xmm5
-
- lea rsi, [rsi+r8*2]
- add rdi, 64
-
- dec rcx
- jnz @B
-
- pop rdi
- pop rsi
-
- ret
-
-SwizzleBlock16_sse2 endp
-
-;
-; SwizzleBlock8
-;
-
-SwizzleBlock8_sse2 proc public
-
- push rsi
- push rdi
-
- mov rdi, rcx
- mov rsi, rdx
- mov ecx, 2
-
- align 16
-@@:
- ; col 0, 2
-
- movdqa xmm0, [rsi]
- movdqa xmm2, [rsi+r8]
- lea rsi, [rsi+r8*2]
-
- pshufd xmm1, [rsi], 0b1h
- pshufd xmm3, [rsi+r8], 0b1h
- lea rsi, [rsi+r8*2]
-
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck wd, 0, 2, 4, 6, 1, 3
- punpck qdq, 0, 1, 2, 3, 4, 5
-
- movdqa [rdi+16*0], xmm0
- movdqa [rdi+16*1], xmm4
- movdqa [rdi+16*2], xmm1
- movdqa [rdi+16*3], xmm5
-
- ; col 1, 3
-
- pshufd xmm0, [rsi], 0b1h
- pshufd xmm2, [rsi+r8], 0b1h
- lea rsi, [rsi+r8*2]
-
- movdqa xmm1, [rsi]
- movdqa xmm3, [rsi+r8]
- lea rsi, [rsi+r8*2]
-
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck wd, 0, 2, 4, 6, 1, 3
- punpck qdq, 0, 1, 2, 3, 4, 5
-
- movdqa [rdi+16*4], xmm0
- movdqa [rdi+16*5], xmm4
- movdqa [rdi+16*6], xmm1
- movdqa [rdi+16*7], xmm5
-
- add edi, 128
-
- dec rcx
- jnz @B
-
- pop rdi
- pop rsi
-
- ret
-
-SwizzleBlock8_sse2 endp
-
-;
-; SwizzleBlock4
-;
-
-SwizzleBlock4_sse2 proc public
-
- push rsi
- push rdi
-
- mov rdi, rcx
- mov rsi, rdx
- mov rcx, 2
-
- mov eax, 0f0f0f0fh
- movd xmm7, eax
- pshufd xmm7, xmm7, 0
-
- align 16
-@@:
- ; col 0, 2
-
- movdqa xmm0, [rsi]
- movdqa xmm2, [rsi+r8]
- lea rsi, [rsi+r8*2]
-
- movdqa xmm1, [rsi]
- movdqa xmm3, [rsi+r8]
- lea rsi, [rsi+r8*2]
-
- pshuflw xmm1, xmm1, 0b1h
- pshuflw xmm3, xmm3, 0b1h
- pshufhw xmm1, xmm1, 0b1h
- pshufhw xmm3, xmm3, 0b1h
-
- punpcknbl
- punpck bw, 0, 2, 4, 6, 1, 3
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck qdq, 0, 4, 2, 6, 1, 3
-
- movdqa [rdi+16*0], xmm0
- movdqa [rdi+16*1], xmm1
- movdqa [rdi+16*2], xmm4
- movdqa [rdi+16*3], xmm3
-
- ; col 1, 3
-
- movdqa xmm0, [rsi]
- movdqa xmm2, [rsi+r8]
- lea esi, [rsi+r8*2]
-
- movdqa xmm1, [rsi]
- movdqa xmm3, [rsi+r8]
- lea rsi, [rsi+r8*2]
-
- pshuflw xmm0, xmm0, 0b1h
- pshuflw xmm2, xmm2, 0b1h
- pshufhw xmm0, xmm0, 0b1h
- pshufhw xmm2, xmm2, 0b1h
-
- punpcknbl
- punpck bw, 0, 2, 4, 6, 1, 3
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck qdq, 0, 4, 2, 6, 1, 3
-
- movdqa [rdi+16*4], xmm0
- movdqa [rdi+16*5], xmm1
- movdqa [rdi+16*6], xmm4
- movdqa [rdi+16*7], xmm3
-
- add rdi, 128
-
- dec rcx
- jnz @B
-
- pop rdi
- pop rsi
-
- ret
-
-SwizzleBlock4_sse2 endp
-
-;
-; swizzling with unaligned reads
-;
-
-;
-; SwizzleBlock32u_sse2
-;
-
-SwizzleBlock32u_sse2 proc public
-
- push rsi
- push rdi
-
- mov rdi, rcx
- mov rsi, rdx
- mov rcx, 4
-
- cmp r9d, 0ffffffffh
- jne SwizzleBlock32u_sse2@WM
-
- align 16
-@@:
- movdqu xmm0, [rsi]
- movdqu xmm4, [rsi+16]
- movdqu xmm1, [rsi+r8]
- movdqu xmm5, [rsi+r8+16]
-
- punpck qdq, 0, 4, 1, 5, 2, 6
-
- movdqa [rdi+16*0], xmm0
- movdqa [rdi+16*1], xmm2
- movdqa [rdi+16*2], xmm4
- movdqa [rdi+16*3], xmm6
-
- lea rsi, [rsi+r8*2]
- add rdi, 64
-
- dec rcx
- jnz @B
-
- pop rdi
- pop rsi
-
- ret
-
-SwizzleBlock32u_sse2@WM:
-
- movd xmm7, r9d
- pshufd xmm7, xmm7, 0
-
- align 16
-@@:
- movdqu xmm0, [rsi]
- movdqu xmm4, [rsi+16]
- movdqu xmm1, [rsi+r8]
- movdqu xmm5, [rsi+r8+16]
-
- punpck qdq, 0, 4, 1, 5, 2, 6
-
- movdqa xmm3, xmm7
- pshufd xmm5, xmm7, 0e4h
- movdqa xmm9, xmm7
- pshufd xmm11, xmm7, 0e4h
-
- pandn xmm3, [rdi+16*0]
- pand xmm0, xmm7
- por xmm0, xmm3
- movdqa [rdi+16*0], xmm0
-
- pandn xmm5, [rdi+16*1]
- pand xmm2, xmm7
- por xmm2, xmm5
- movdqa [rdi+16*1], xmm2
-
- pandn xmm9, [rdi+16*2]
- pand xmm4, xmm7
- por xmm4, xmm9
- movdqa [rdi+16*2], xmm4
-
- pandn xmm11, [rdi+16*3]
- pand xmm6, xmm7
- por xmm6, xmm11
- movdqa [edi+16*3], xmm6
-
- lea rsi, [rsi+r8*2]
- add rdi, 64
-
- dec rcx
- jnz @B
-
- pop rdi
- pop rsi
-
- ret
-
-SwizzleBlock32u_sse2 endp
-
-;
-; SwizzleBlock16u_sse2
-;
-
-SwizzleBlock16u_sse2 proc public
-
- push rsi
- push rdi
-
- mov rdi, rcx
- mov rsi, rdx
- mov rcx, 4
-
- align 16
-@@:
- movdqu xmm0, [rsi]
- movdqu xmm1, [rsi+16]
- movdqu xmm2, [rsi+r8]
- movdqu xmm3, [rsi+r8+16]
-
- punpck wd, 0, 2, 1, 3, 4, 6
- punpck qdq, 0, 4, 2, 6, 1, 5
-
- movdqa [rdi+16*0], xmm0
- movdqa [rdi+16*1], xmm1
- movdqa [rdi+16*2], xmm4
- movdqa [rdi+16*3], xmm5
-
- lea rsi, [rsi+r8*2]
- add rdi, 64
-
- dec rcx
- jnz @B
-
- pop rdi
- pop rsi
-
- ret
-
-SwizzleBlock16u_sse2 endp
-
-;
-; SwizzleBlock8u
-;
-
-SwizzleBlock8u_sse2 proc public
-
- push rsi
- push rdi
-
- mov rdi, rcx
- mov rsi, rdx
- mov ecx, 2
-
- align 16
-@@:
- ; col 0, 2
-
- movdqu xmm0, [rsi]
- movdqu xmm2, [rsi+r8]
- lea rsi, [rsi+r8*2]
-
- pshufd xmm1, xmm0, 0b1h
- pshufd xmm3, xmm2, 0b1h
- lea rsi, [rsi+r8*2]
-
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck wd, 0, 2, 4, 6, 1, 3
- punpck qdq, 0, 1, 2, 3, 4, 5
-
- movdqa [rdi+16*0], xmm0
- movdqa [rdi+16*1], xmm4
- movdqa [rdi+16*2], xmm1
- movdqa [rdi+16*3], xmm5
-
- ; col 1, 3
-
- movdqu xmm0, [rsi]
- movdqu xmm2, [rsi+r8]
- pshufd xmm0, xmm0, 0b1h
- pshufd xmm2, xmm2, 0b1h
- lea rsi, [rsi+r8*2]
-
- movdqu xmm1, [rsi]
- movdqu xmm3, [rsi+r8]
- lea rsi, [rsi+r8*2]
-
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck wd, 0, 2, 4, 6, 1, 3
- punpck qdq, 0, 1, 2, 3, 4, 5
-
- movdqa [rdi+16*4], xmm0
- movdqa [rdi+16*5], xmm4
- movdqa [rdi+16*6], xmm1
- movdqa [rdi+16*7], xmm5
-
- add edi, 128
-
- dec rcx
- jnz @B
-
- pop rdi
- pop rsi
-
- ret
-
-SwizzleBlock8u_sse2 endp
-
-;
-; SwizzleBlock4u
-;
-
-SwizzleBlock4u_sse2 proc public
-
- push rsi
- push rdi
-
- mov rdi, rcx
- mov rsi, rdx
- mov rcx, 2
-
- mov eax, 0f0f0f0fh
- movd xmm7, eax
- pshufd xmm7, xmm7, 0
-
- align 16
-@@:
- ; col 0, 2
-
- movdqu xmm0, [rsi]
- movdqu xmm2, [rsi+r8]
- lea rsi, [rsi+r8*2]
-
- movdqu xmm1, [rsi]
- movdqu xmm3, [rsi+r8]
- lea rsi, [rsi+r8*2]
-
- pshuflw xmm1, xmm1, 0b1h
- pshuflw xmm3, xmm3, 0b1h
- pshufhw xmm1, xmm1, 0b1h
- pshufhw xmm3, xmm3, 0b1h
-
- punpcknbl
- punpck bw, 0, 2, 4, 6, 1, 3
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck qdq, 0, 4, 2, 6, 1, 3
-
- movdqa [rdi+16*0], xmm0
- movdqa [rdi+16*1], xmm1
- movdqa [rdi+16*2], xmm4
- movdqa [rdi+16*3], xmm3
-
- ; col 1, 3
-
- movdqu xmm0, [rsi]
- movdqu xmm2, [rsi+r8]
- lea esi, [rsi+r8*2]
-
- movdqu xmm1, [rsi]
- movdqu xmm3, [rsi+r8]
- lea rsi, [rsi+r8*2]
-
- pshuflw xmm0, xmm0, 0b1h
- pshuflw xmm2, xmm2, 0b1h
- pshufhw xmm0, xmm0, 0b1h
- pshufhw xmm2, xmm2, 0b1h
-
- punpcknbl
- punpck bw, 0, 2, 4, 6, 1, 3
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck qdq, 0, 4, 2, 6, 1, 3
-
- movdqa [rdi+16*4], xmm0
- movdqa [rdi+16*5], xmm1
- movdqa [rdi+16*6], xmm4
- movdqa [rdi+16*7], xmm3
-
- add rdi, 128
-
- dec rcx
- jnz @B
-
- pop rdi
- pop rsi
-
- ret
-
-SwizzleBlock4u_sse2 endp
-
-WriteCLUT_T16_I4_CSM1_sse2 proc public
- movdqa xmm0, XMMWORD PTR [rcx]
- movdqa xmm1, XMMWORD PTR [rcx+16]
- movdqa xmm2, XMMWORD PTR [rcx+32]
- movdqa xmm3, XMMWORD PTR [rcx+48]
-
- ;; rearrange
- pshuflw xmm0, xmm0, 088h
- pshufhw xmm0, xmm0, 088h
- pshuflw xmm1, xmm1, 088h
- pshufhw xmm1, xmm1, 088h
- pshuflw xmm2, xmm2, 088h
- pshufhw xmm2, xmm2, 088h
- pshuflw xmm3, xmm3, 088h
- pshufhw xmm3, xmm3, 088h
-
- shufps xmm0, xmm1, 088h
- shufps xmm2, xmm3, 088h
-
- pshufd xmm0, xmm0, 0d8h
- pshufd xmm2, xmm2, 0d8h
-
- pxor xmm6, xmm6
- mov rax, offset s_clut16mask
-
- test rdx, 15
- jnz WriteUnaligned
-
- movdqa xmm7, XMMWORD PTR [rax] ;; saves upper 16 bits
-
- ;; have to save interlaced with the old data
- movdqa xmm4, [rdx]
- movdqa xmm5, [rdx+32]
- movhlps xmm1, xmm0
- movlhps xmm0, xmm2 ;; lower 8 colors
-
- pand xmm4, xmm7
- pand xmm5, xmm7
-
- shufps xmm1, xmm2, 0e4h ;; upper 8 colors
- movdqa xmm2, xmm0
- movdqa xmm3, xmm1
-
- punpcklwd xmm0, xmm6
- punpcklwd xmm1, xmm6
- por xmm0, xmm4
- por xmm1, xmm5
-
- punpckhwd xmm2, xmm6
- punpckhwd xmm3, xmm6
-
- movdqa [rdx], xmm0
- movdqa [rdx+32], xmm1
-
- movdqa xmm5, xmm7
- pand xmm7, [rdx+16]
- pand xmm5, [rdx+48]
-
- por xmm2, xmm7
- por xmm3, xmm5
-
- movdqa [rdx+16], xmm2
- movdqa [rdx+48], xmm3
- jmp WriteCLUT_T16_I4_CSM1_End
-
-WriteUnaligned:
- ;; rdx is offset by 2
- sub rdx, 2
-
- movdqa xmm7, XMMWORD PTR [rax+16] ;; saves lower 16 bits
-
- ;; have to save interlaced with the old data
- movdqa xmm4, [rdx]
- movdqa xmm5, [rdx+32]
- movhlps xmm1, xmm0
- movlhps xmm0, xmm2 ;; lower 8 colors
-
- pand xmm4, xmm7
- pand xmm5, xmm7
-
- shufps xmm1, xmm2, 0e4h ;; upper 8 colors
- movdqa xmm2, xmm0
- movdqa xmm3, xmm1
-
- punpcklwd xmm0, xmm6
- punpcklwd xmm1, xmm6
- pslld xmm0, 16
- pslld xmm1, 16
- por xmm0, xmm4
- por xmm1, xmm5
-
- punpckhwd xmm2, xmm6
- punpckhwd xmm3, xmm6
- pslld xmm2, 16
- pslld xmm3, 16
-
- movdqa [rdx], xmm0
- movdqa [rdx+32], xmm1
-
- movdqa xmm5, xmm7
- pand xmm7, [rdx+16]
- pand xmm5, [rdx+48]
-
- por xmm2, xmm7
- por xmm3, xmm5
-
- movdqa [rdx+16], xmm2
- movdqa [rdx+48], xmm3
-WriteCLUT_T16_I4_CSM1_End:
- ret
-
-WriteCLUT_T16_I4_CSM1_sse2 endp
-
+; Copyright (C) 2003-2005 Gabest/zerofrog
+; http:;;www.gabest.org
+;
+; 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, 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 GNU Make; see the file COPYING. If not, write to
+; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+; http:;;www.gnu.org/copyleft/gpl.html
+;
+;
+extern s_clut16mask:ptr
+
+ .code
+
+; mmx memcpy implementation, size has to be a multiple of 8
+; returns 0 is equal, nonzero value if not equal
+; ~10 times faster than standard memcmp
+; (zerofrog)
+; u8 memcmp_mmx(const void* src1, const void* src2, int cmpsize)
+; rcx - src1
+; rdx - src2
+; r8d - cmpsize
+memcmp_mmx proc public
+ cmp r8d, 32
+ jl Done4
+
+ ; custom test first 8 to make sure things are ok
+ movq mm0, [rdx]
+ movq mm1, [rdx+8]
+ pcmpeqd mm0, [rcx]
+ pcmpeqd mm1, [rcx+8]
+ pand mm0, mm1
+ movq mm2, [rdx+16]
+ pmovmskb eax, mm0
+ movq mm3, [rdx+24]
+
+ ; check if eq
+ cmp eax, 0ffh
+ je NextComp
+ mov eax, 1
+ jmp Finish
+
+NextComp:
+ pcmpeqd mm2, [rcx+16]
+ pcmpeqd mm3, [rcx+24]
+ pand mm2, mm3
+ pmovmskb eax, mm2
+
+ sub r8d, 32
+ add rdx, 32
+ add rcx, 32
+
+ ; check if eq
+ cmp eax, 0ffh
+ je ContinueTest
+ mov eax, 1
+ jmp Finish
+
+ cmp r8d, 64
+ jl Done8
+
+Cmp8:
+ movq mm0, [rdx]
+ movq mm1, [rdx+8]
+ movq mm2, [rdx+16]
+ movq mm3, [rdx+24]
+ movq mm4, [rdx+32]
+ movq mm5, [rdx+40]
+ movq mm6, [rdx+48]
+ movq mm7, [rdx+56]
+ pcmpeqd mm0, [rcx]
+ pcmpeqd mm1, [rcx+8]
+ pcmpeqd mm2, [rcx+16]
+ pcmpeqd mm3, [rcx+24]
+ pand mm0, mm1
+ pcmpeqd mm4, [rcx+32]
+ pand mm0, mm2
+ pcmpeqd mm5, [rcx+40]
+ pand mm0, mm3
+ pcmpeqd mm6, [rcx+48]
+ pand mm0, mm4
+ pcmpeqd mm7, [rcx+56]
+ pand mm0, mm5
+ pand mm0, mm6
+ pand mm0, mm7
+ pmovmskb eax, mm0
+
+ ; check if eq
+ cmp eax, 0ffh
+ je Continue
+ mov eax, 1
+ jmp Finish
+
+Continue:
+ sub r8d, 64
+ add rdx, 64
+ add rcx, 64
+ContinueTest:
+ cmp r8d, 64
+ jge Cmp8
+
+Done8:
+ test r8d, 020h
+ jz Done4
+ movq mm0, [rdx]
+ movq mm1, [rdx+8]
+ movq mm2, [rdx+16]
+ movq mm3, [rdx+24]
+ pcmpeqd mm0, [rcx]
+ pcmpeqd mm1, [rcx+8]
+ pcmpeqd mm2, [rcx+16]
+ pcmpeqd mm3, [rcx+24]
+ pand mm0, mm1
+ pand mm0, mm2
+ pand mm0, mm3
+ pmovmskb eax, mm0
+ sub r8d, 32
+ add rdx, 32
+ add rcx, 32
+
+ ; check if eq
+ cmp eax, 0ffh
+ je Done4
+ mov eax, 1
+ jmp Finish
+
+Done4:
+ cmp r8d, 24
+ jne Done2
+ movq mm0, [rdx]
+ movq mm1, [rdx+8]
+ movq mm2, [rdx+16]
+ pcmpeqd mm0, [rcx]
+ pcmpeqd mm1, [rcx+8]
+ pcmpeqd mm2, [rcx+16]
+ pand mm0, mm1
+ pand mm0, mm2
+ pmovmskb eax, mm0
+
+ ; check if eq
+ cmp eax, 0ffh
+ je Done
+ mov eax, 1
+ jmp Finish
+
+Done2:
+ cmp r8d, 16
+ jne Done1
+
+ movq mm0, [rdx]
+ movq mm1, [rdx+8]
+ pcmpeqd mm0, [rcx]
+ pcmpeqd mm1, [rcx+8]
+ pand mm0, mm1
+ pmovmskb eax, mm0
+
+ ; check if eq
+ cmp eax, 0ffh
+ je Done
+ mov eax, 1
+ jmp Finish
+
+Done1:
+ cmp r8d, 8
+ jne Done
+
+ mov eax, [rdx]
+ mov rdx, [rdx+4]
+ cmp eax, [rcx]
+ je Next
+ mov eax, 1
+ jmp Finish
+
+Next:
+ cmp rdx, [rcx+4]
+ je Done
+ mov eax, 1
+ jmp Finish
+
+Done:
+ xor eax, eax
+
+Finish:
+ emms
+ ret
+
+memcmp_mmx endp
+
+; TestClutChangeMMX
+; mov rdx, dst
+; mov rcx, src
+; mov r8d, entries
+TestClutChangeMMX proc public
+
+Start:
+ movq mm0, [rdx]
+ movq mm1, [rdx+8]
+ pcmpeqd mm0, [rcx]
+ pcmpeqd mm1, [rcx+16]
+
+ movq mm2, [rdx+16]
+ movq mm3, [rdx+24]
+ pcmpeqd mm2, [rcx+32]
+ pcmpeqd mm3, [rcx+48]
+
+ pand mm0, mm1
+ pand mm2, mm3
+ movq mm4, [rdx+32]
+ movq mm5, [rdx+40]
+ pcmpeqd mm4, [rcx+8]
+ pcmpeqd mm5, [rcx+24]
+
+ pand mm0, mm2
+ pand mm4, mm5
+ movq mm6, [rdx+48]
+ movq mm7, [rdx+56]
+ pcmpeqd mm6, [rcx+40]
+ pcmpeqd mm7, [rcx+56]
+
+ pand mm0, mm4
+ pand mm6, mm7
+ pand mm0, mm6
+
+ pmovmskb eax, mm0
+ cmp eax, 0ffh
+ je Continue
+ mov byte ptr [r9], 1
+ jmp Return
+
+Continue:
+ cmp r8d, 16
+ jle Return
+
+ test r8d, 010h
+ jz AddRcx
+ sub rcx, 448 ; go back and down one column,
+AddRcx:
+ add rcx, 256 ; go to the right block
+
+
+ jne Continue1
+ add rcx, 256 ; skip whole block
+Continue1:
+ add rdx, 64
+ sub r8d, 16
+ jmp Start
+
+Return:
+ emms
+ ret
+
+TestClutChangeMMX endp
+
+UnswizzleZ16Target proc public
+ pxor xmm7, xmm7
+
+Z16Loop:
+ ;; unpack 64 bytes at a time
+ movdqa xmm0, [rdx]
+ movdqa xmm2, [rdx+16]
+ movdqa xmm4, [rdx+32]
+ movdqa xmm6, [rdx+48]
+
+ movdqa xmm1, xmm0
+ movdqa xmm3, xmm2
+ movdqa xmm5, xmm4
+
+ punpcklwd xmm0, xmm7
+ punpckhwd xmm1, xmm7
+ punpcklwd xmm2, xmm7
+ punpckhwd xmm3, xmm7
+
+ ;; start saving
+ movdqa [rcx], xmm0
+ movdqa [rcx+16], xmm1
+
+ punpcklwd xmm4, xmm7
+ punpckhwd xmm5, xmm7
+
+ movdqa [rcx+32], xmm2
+ movdqa [rcx+48], xmm3
+
+ movdqa xmm0, xmm6
+ punpcklwd xmm6, xmm7
+
+ movdqa [rcx+64], xmm4
+ movdqa [rcx+80], xmm5
+
+ punpckhwd xmm0, xmm7
+
+ movdqa [rcx+96], xmm6
+ movdqa [rcx+112], xmm0
+
+ add rdx, 64
+ add rcx, 128
+ sub r9d, 1
+ jne Z16Loop
+
+ ret
+UnswizzleZ16Target endp
+
+;
+; swizzling
+;
+
+punpck macro op, sd0, sd2, s1, s3, d1, d3
+
+ movdqa @CatStr(xmm, %d1), @CatStr(xmm, %sd0)
+ pshufd @CatStr(xmm, %d3), @CatStr(xmm, %sd2), 0e4h
+
+ @CatStr(punpckl, op) @CatStr(xmm, %sd0), @CatStr(xmm, %s1)
+ @CatStr(punpckh, op) @CatStr(xmm, %d1), @CatStr(xmm, %s1)
+ @CatStr(punpckl, op) @CatStr(xmm, %sd2), @CatStr(xmm, %s3)
+ @CatStr(punpckh, op) @CatStr(xmm, %d3), @CatStr(xmm, %s3)
+
+ endm
+
+punpcknbl macro
+
+ movdqa xmm4, xmm0
+ pshufd xmm5, xmm1, 0e4h
+
+ psllq xmm1, 4
+ psrlq xmm4, 4
+
+ movdqa xmm6, xmm7
+ pand xmm0, xmm7
+ pandn xmm6, xmm1
+ por xmm0, xmm6
+
+ movdqa xmm6, xmm7
+ pand xmm4, xmm7
+ pandn xmm6, xmm5
+ por xmm4, xmm6
+
+ movdqa xmm1, xmm4
+
+ movdqa xmm4, xmm2
+ pshufd xmm5, xmm3, 0e4h
+
+ psllq xmm3, 4
+ psrlq xmm4, 4
+
+ movdqa xmm6, xmm7
+ pand xmm2, xmm7
+ pandn xmm6, xmm3
+ por xmm2, xmm6
+
+ movdqa xmm6, xmm7
+ pand xmm4, xmm7
+ pandn xmm6, xmm5
+ por xmm4, xmm6
+
+ movdqa xmm3, xmm4
+
+ punpck bw, 0, 2, 1, 3, 4, 6
+
+ endm
+
+punpcknbh macro
+
+ movdqa xmm12, xmm8
+ pshufd xmm13, xmm9, 0e4h
+
+ psllq xmm9, 4
+ psrlq xmm12, 4
+
+ movdqa xmm14, xmm15
+ pand xmm8, xmm15
+ pandn xmm14, xmm9
+ por xmm8, xmm14
+
+ movdqa xmm14, xmm15
+ pand xmm12, xmm15
+ pandn xmm14, xmm13
+ por xmm12, xmm14
+
+ movdqa xmm9, xmm12
+
+ movdqa xmm12, xmm10
+ pshufd xmm13, xmm11, 0e4h
+
+ psllq xmm11, 4
+ psrlq xmm12, 4
+
+ movdqa xmm14, xmm15
+ pand xmm10, xmm15
+ pandn xmm14, xmm11
+ por xmm10, xmm14
+
+ movdqa xmm14, xmm15
+ pand xmm12, xmm15
+ pandn xmm14, xmm13
+ por xmm12, xmm14
+
+ movdqa xmm11, xmm12
+
+ punpck bw, 8, 10, 9, 11, 12, 14
+
+ endm
+
+;
+; SwizzleBlock32_sse2
+;
+
+SwizzleBlock32_sse2 proc public
+
+ push rsi
+ push rdi
+
+ mov rdi, rcx
+ mov rsi, rdx
+ mov rcx, 4
+
+ cmp r9d, 0ffffffffh
+ jne SwizzleBlock32_sse2@WM
+
+ align 16
+@@:
+ movdqa xmm0, [rsi]
+ movdqa xmm4, [rsi+16]
+ movdqa xmm1, [rsi+r8]
+ movdqa xmm5, [rsi+r8+16]
+
+ punpck qdq, 0, 4, 1, 5, 2, 6
+
+ movdqa [rdi+16*0], xmm0
+ movdqa [rdi+16*1], xmm2
+ movdqa [rdi+16*2], xmm4
+ movdqa [rdi+16*3], xmm6
+
+ lea rsi, [rsi+r8*2]
+ add rdi, 64
+
+ dec rcx
+ jnz @B
+
+ pop rdi
+ pop rsi
+
+ ret
+
+SwizzleBlock32_sse2@WM:
+
+ movd xmm7, r9d
+ pshufd xmm7, xmm7, 0
+
+ align 16
+@@:
+ movdqa xmm0, [rsi]
+ movdqa xmm4, [rsi+16]
+ movdqa xmm1, [rsi+r8]
+ movdqa xmm5, [rsi+r8+16]
+
+ punpck qdq, 0, 4, 1, 5, 2, 6
+
+ movdqa xmm3, xmm7
+ pshufd xmm5, xmm7, 0e4h
+ movdqa xmm9, xmm7
+ pshufd xmm11, xmm7, 0e4h
+
+ pandn xmm3, [rdi+16*0]
+ pand xmm0, xmm7
+ por xmm0, xmm3
+ movdqa [rdi+16*0], xmm0
+
+ pandn xmm5, [rdi+16*1]
+ pand xmm2, xmm7
+ por xmm2, xmm5
+ movdqa [rdi+16*1], xmm2
+
+ pandn xmm9, [rdi+16*2]
+ pand xmm4, xmm7
+ por xmm4, xmm9
+ movdqa [rdi+16*2], xmm4
+
+ pandn xmm11, [rdi+16*3]
+ pand xmm6, xmm7
+ por xmm6, xmm11
+ movdqa [edi+16*3], xmm6
+
+ lea rsi, [rsi+r8*2]
+ add rdi, 64
+
+ dec rcx
+ jnz @B
+
+ pop rdi
+ pop rsi
+
+ ret
+
+SwizzleBlock32_sse2 endp
+
+;
+; SwizzleBlock16_sse2
+;
+
+SwizzleBlock16_sse2 proc public
+
+ push rsi
+ push rdi
+
+ mov rdi, rcx
+ mov rsi, rdx
+ mov rcx, 4
+
+ align 16
+@@:
+ movdqa xmm0, [rsi]
+ movdqa xmm1, [rsi+16]
+ movdqa xmm2, [rsi+r8]
+ movdqa xmm3, [rsi+r8+16]
+
+ punpck wd, 0, 2, 1, 3, 4, 6
+ punpck qdq, 0, 4, 2, 6, 1, 5
+
+ movdqa [rdi+16*0], xmm0
+ movdqa [rdi+16*1], xmm1
+ movdqa [rdi+16*2], xmm4
+ movdqa [rdi+16*3], xmm5
+
+ lea rsi, [rsi+r8*2]
+ add rdi, 64
+
+ dec rcx
+ jnz @B
+
+ pop rdi
+ pop rsi
+
+ ret
+
+SwizzleBlock16_sse2 endp
+
+;
+; SwizzleBlock8
+;
+
+SwizzleBlock8_sse2 proc public
+
+ push rsi
+ push rdi
+
+ mov rdi, rcx
+ mov rsi, rdx
+ mov ecx, 2
+
+ align 16
+@@:
+ ; col 0, 2
+
+ movdqa xmm0, [rsi]
+ movdqa xmm2, [rsi+r8]
+ lea rsi, [rsi+r8*2]
+
+ pshufd xmm1, [rsi], 0b1h
+ pshufd xmm3, [rsi+r8], 0b1h
+ lea rsi, [rsi+r8*2]
+
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck wd, 0, 2, 4, 6, 1, 3
+ punpck qdq, 0, 1, 2, 3, 4, 5
+
+ movdqa [rdi+16*0], xmm0
+ movdqa [rdi+16*1], xmm4
+ movdqa [rdi+16*2], xmm1
+ movdqa [rdi+16*3], xmm5
+
+ ; col 1, 3
+
+ pshufd xmm0, [rsi], 0b1h
+ pshufd xmm2, [rsi+r8], 0b1h
+ lea rsi, [rsi+r8*2]
+
+ movdqa xmm1, [rsi]
+ movdqa xmm3, [rsi+r8]
+ lea rsi, [rsi+r8*2]
+
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck wd, 0, 2, 4, 6, 1, 3
+ punpck qdq, 0, 1, 2, 3, 4, 5
+
+ movdqa [rdi+16*4], xmm0
+ movdqa [rdi+16*5], xmm4
+ movdqa [rdi+16*6], xmm1
+ movdqa [rdi+16*7], xmm5
+
+ add edi, 128
+
+ dec rcx
+ jnz @B
+
+ pop rdi
+ pop rsi
+
+ ret
+
+SwizzleBlock8_sse2 endp
+
+;
+; SwizzleBlock4
+;
+
+SwizzleBlock4_sse2 proc public
+
+ push rsi
+ push rdi
+
+ mov rdi, rcx
+ mov rsi, rdx
+ mov rcx, 2
+
+ mov eax, 0f0f0f0fh
+ movd xmm7, eax
+ pshufd xmm7, xmm7, 0
+
+ align 16
+@@:
+ ; col 0, 2
+
+ movdqa xmm0, [rsi]
+ movdqa xmm2, [rsi+r8]
+ lea rsi, [rsi+r8*2]
+
+ movdqa xmm1, [rsi]
+ movdqa xmm3, [rsi+r8]
+ lea rsi, [rsi+r8*2]
+
+ pshuflw xmm1, xmm1, 0b1h
+ pshuflw xmm3, xmm3, 0b1h
+ pshufhw xmm1, xmm1, 0b1h
+ pshufhw xmm3, xmm3, 0b1h
+
+ punpcknbl
+ punpck bw, 0, 2, 4, 6, 1, 3
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck qdq, 0, 4, 2, 6, 1, 3
+
+ movdqa [rdi+16*0], xmm0
+ movdqa [rdi+16*1], xmm1
+ movdqa [rdi+16*2], xmm4
+ movdqa [rdi+16*3], xmm3
+
+ ; col 1, 3
+
+ movdqa xmm0, [rsi]
+ movdqa xmm2, [rsi+r8]
+ lea esi, [rsi+r8*2]
+
+ movdqa xmm1, [rsi]
+ movdqa xmm3, [rsi+r8]
+ lea rsi, [rsi+r8*2]
+
+ pshuflw xmm0, xmm0, 0b1h
+ pshuflw xmm2, xmm2, 0b1h
+ pshufhw xmm0, xmm0, 0b1h
+ pshufhw xmm2, xmm2, 0b1h
+
+ punpcknbl
+ punpck bw, 0, 2, 4, 6, 1, 3
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck qdq, 0, 4, 2, 6, 1, 3
+
+ movdqa [rdi+16*4], xmm0
+ movdqa [rdi+16*5], xmm1
+ movdqa [rdi+16*6], xmm4
+ movdqa [rdi+16*7], xmm3
+
+ add rdi, 128
+
+ dec rcx
+ jnz @B
+
+ pop rdi
+ pop rsi
+
+ ret
+
+SwizzleBlock4_sse2 endp
+
+;
+; swizzling with unaligned reads
+;
+
+;
+; SwizzleBlock32u_sse2
+;
+
+SwizzleBlock32u_sse2 proc public
+
+ push rsi
+ push rdi
+
+ mov rdi, rcx
+ mov rsi, rdx
+ mov rcx, 4
+
+ cmp r9d, 0ffffffffh
+ jne SwizzleBlock32u_sse2@WM
+
+ align 16
+@@:
+ movdqu xmm0, [rsi]
+ movdqu xmm4, [rsi+16]
+ movdqu xmm1, [rsi+r8]
+ movdqu xmm5, [rsi+r8+16]
+
+ punpck qdq, 0, 4, 1, 5, 2, 6
+
+ movdqa [rdi+16*0], xmm0
+ movdqa [rdi+16*1], xmm2
+ movdqa [rdi+16*2], xmm4
+ movdqa [rdi+16*3], xmm6
+
+ lea rsi, [rsi+r8*2]
+ add rdi, 64
+
+ dec rcx
+ jnz @B
+
+ pop rdi
+ pop rsi
+
+ ret
+
+SwizzleBlock32u_sse2@WM:
+
+ movd xmm7, r9d
+ pshufd xmm7, xmm7, 0
+
+ align 16
+@@:
+ movdqu xmm0, [rsi]
+ movdqu xmm4, [rsi+16]
+ movdqu xmm1, [rsi+r8]
+ movdqu xmm5, [rsi+r8+16]
+
+ punpck qdq, 0, 4, 1, 5, 2, 6
+
+ movdqa xmm3, xmm7
+ pshufd xmm5, xmm7, 0e4h
+ movdqa xmm9, xmm7
+ pshufd xmm11, xmm7, 0e4h
+
+ pandn xmm3, [rdi+16*0]
+ pand xmm0, xmm7
+ por xmm0, xmm3
+ movdqa [rdi+16*0], xmm0
+
+ pandn xmm5, [rdi+16*1]
+ pand xmm2, xmm7
+ por xmm2, xmm5
+ movdqa [rdi+16*1], xmm2
+
+ pandn xmm9, [rdi+16*2]
+ pand xmm4, xmm7
+ por xmm4, xmm9
+ movdqa [rdi+16*2], xmm4
+
+ pandn xmm11, [rdi+16*3]
+ pand xmm6, xmm7
+ por xmm6, xmm11
+ movdqa [edi+16*3], xmm6
+
+ lea rsi, [rsi+r8*2]
+ add rdi, 64
+
+ dec rcx
+ jnz @B
+
+ pop rdi
+ pop rsi
+
+ ret
+
+SwizzleBlock32u_sse2 endp
+
+;
+; SwizzleBlock16u_sse2
+;
+
+SwizzleBlock16u_sse2 proc public
+
+ push rsi
+ push rdi
+
+ mov rdi, rcx
+ mov rsi, rdx
+ mov rcx, 4
+
+ align 16
+@@:
+ movdqu xmm0, [rsi]
+ movdqu xmm1, [rsi+16]
+ movdqu xmm2, [rsi+r8]
+ movdqu xmm3, [rsi+r8+16]
+
+ punpck wd, 0, 2, 1, 3, 4, 6
+ punpck qdq, 0, 4, 2, 6, 1, 5
+
+ movdqa [rdi+16*0], xmm0
+ movdqa [rdi+16*1], xmm1
+ movdqa [rdi+16*2], xmm4
+ movdqa [rdi+16*3], xmm5
+
+ lea rsi, [rsi+r8*2]
+ add rdi, 64
+
+ dec rcx
+ jnz @B
+
+ pop rdi
+ pop rsi
+
+ ret
+
+SwizzleBlock16u_sse2 endp
+
+;
+; SwizzleBlock8u
+;
+
+SwizzleBlock8u_sse2 proc public
+
+ push rsi
+ push rdi
+
+ mov rdi, rcx
+ mov rsi, rdx
+ mov ecx, 2
+
+ align 16
+@@:
+ ; col 0, 2
+
+ movdqu xmm0, [rsi]
+ movdqu xmm2, [rsi+r8]
+ lea rsi, [rsi+r8*2]
+
+ pshufd xmm1, xmm0, 0b1h
+ pshufd xmm3, xmm2, 0b1h
+ lea rsi, [rsi+r8*2]
+
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck wd, 0, 2, 4, 6, 1, 3
+ punpck qdq, 0, 1, 2, 3, 4, 5
+
+ movdqa [rdi+16*0], xmm0
+ movdqa [rdi+16*1], xmm4
+ movdqa [rdi+16*2], xmm1
+ movdqa [rdi+16*3], xmm5
+
+ ; col 1, 3
+
+ movdqu xmm0, [rsi]
+ movdqu xmm2, [rsi+r8]
+ pshufd xmm0, xmm0, 0b1h
+ pshufd xmm2, xmm2, 0b1h
+ lea rsi, [rsi+r8*2]
+
+ movdqu xmm1, [rsi]
+ movdqu xmm3, [rsi+r8]
+ lea rsi, [rsi+r8*2]
+
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck wd, 0, 2, 4, 6, 1, 3
+ punpck qdq, 0, 1, 2, 3, 4, 5
+
+ movdqa [rdi+16*4], xmm0
+ movdqa [rdi+16*5], xmm4
+ movdqa [rdi+16*6], xmm1
+ movdqa [rdi+16*7], xmm5
+
+ add edi, 128
+
+ dec rcx
+ jnz @B
+
+ pop rdi
+ pop rsi
+
+ ret
+
+SwizzleBlock8u_sse2 endp
+
+;
+; SwizzleBlock4u
+;
+
+SwizzleBlock4u_sse2 proc public
+
+ push rsi
+ push rdi
+
+ mov rdi, rcx
+ mov rsi, rdx
+ mov rcx, 2
+
+ mov eax, 0f0f0f0fh
+ movd xmm7, eax
+ pshufd xmm7, xmm7, 0
+
+ align 16
+@@:
+ ; col 0, 2
+
+ movdqu xmm0, [rsi]
+ movdqu xmm2, [rsi+r8]
+ lea rsi, [rsi+r8*2]
+
+ movdqu xmm1, [rsi]
+ movdqu xmm3, [rsi+r8]
+ lea rsi, [rsi+r8*2]
+
+ pshuflw xmm1, xmm1, 0b1h
+ pshuflw xmm3, xmm3, 0b1h
+ pshufhw xmm1, xmm1, 0b1h
+ pshufhw xmm3, xmm3, 0b1h
+
+ punpcknbl
+ punpck bw, 0, 2, 4, 6, 1, 3
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck qdq, 0, 4, 2, 6, 1, 3
+
+ movdqa [rdi+16*0], xmm0
+ movdqa [rdi+16*1], xmm1
+ movdqa [rdi+16*2], xmm4
+ movdqa [rdi+16*3], xmm3
+
+ ; col 1, 3
+
+ movdqu xmm0, [rsi]
+ movdqu xmm2, [rsi+r8]
+ lea esi, [rsi+r8*2]
+
+ movdqu xmm1, [rsi]
+ movdqu xmm3, [rsi+r8]
+ lea rsi, [rsi+r8*2]
+
+ pshuflw xmm0, xmm0, 0b1h
+ pshuflw xmm2, xmm2, 0b1h
+ pshufhw xmm0, xmm0, 0b1h
+ pshufhw xmm2, xmm2, 0b1h
+
+ punpcknbl
+ punpck bw, 0, 2, 4, 6, 1, 3
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck qdq, 0, 4, 2, 6, 1, 3
+
+ movdqa [rdi+16*4], xmm0
+ movdqa [rdi+16*5], xmm1
+ movdqa [rdi+16*6], xmm4
+ movdqa [rdi+16*7], xmm3
+
+ add rdi, 128
+
+ dec rcx
+ jnz @B
+
+ pop rdi
+ pop rsi
+
+ ret
+
+SwizzleBlock4u_sse2 endp
+
+WriteCLUT_T16_I4_CSM1_sse2 proc public
+ movdqa xmm0, XMMWORD PTR [rcx]
+ movdqa xmm1, XMMWORD PTR [rcx+16]
+ movdqa xmm2, XMMWORD PTR [rcx+32]
+ movdqa xmm3, XMMWORD PTR [rcx+48]
+
+ ;; rearrange
+ pshuflw xmm0, xmm0, 088h
+ pshufhw xmm0, xmm0, 088h
+ pshuflw xmm1, xmm1, 088h
+ pshufhw xmm1, xmm1, 088h
+ pshuflw xmm2, xmm2, 088h
+ pshufhw xmm2, xmm2, 088h
+ pshuflw xmm3, xmm3, 088h
+ pshufhw xmm3, xmm3, 088h
+
+ shufps xmm0, xmm1, 088h
+ shufps xmm2, xmm3, 088h
+
+ pshufd xmm0, xmm0, 0d8h
+ pshufd xmm2, xmm2, 0d8h
+
+ pxor xmm6, xmm6
+ mov rax, offset s_clut16mask
+
+ test rdx, 15
+ jnz WriteUnaligned
+
+ movdqa xmm7, XMMWORD PTR [rax] ;; saves upper 16 bits
+
+ ;; have to save interlaced with the old data
+ movdqa xmm4, [rdx]
+ movdqa xmm5, [rdx+32]
+ movhlps xmm1, xmm0
+ movlhps xmm0, xmm2 ;; lower 8 colors
+
+ pand xmm4, xmm7
+ pand xmm5, xmm7
+
+ shufps xmm1, xmm2, 0e4h ;; upper 8 colors
+ movdqa xmm2, xmm0
+ movdqa xmm3, xmm1
+
+ punpcklwd xmm0, xmm6
+ punpcklwd xmm1, xmm6
+ por xmm0, xmm4
+ por xmm1, xmm5
+
+ punpckhwd xmm2, xmm6
+ punpckhwd xmm3, xmm6
+
+ movdqa [rdx], xmm0
+ movdqa [rdx+32], xmm1
+
+ movdqa xmm5, xmm7
+ pand xmm7, [rdx+16]
+ pand xmm5, [rdx+48]
+
+ por xmm2, xmm7
+ por xmm3, xmm5
+
+ movdqa [rdx+16], xmm2
+ movdqa [rdx+48], xmm3
+ jmp WriteCLUT_T16_I4_CSM1_End
+
+WriteUnaligned:
+ ;; rdx is offset by 2
+ sub rdx, 2
+
+ movdqa xmm7, XMMWORD PTR [rax+16] ;; saves lower 16 bits
+
+ ;; have to save interlaced with the old data
+ movdqa xmm4, [rdx]
+ movdqa xmm5, [rdx+32]
+ movhlps xmm1, xmm0
+ movlhps xmm0, xmm2 ;; lower 8 colors
+
+ pand xmm4, xmm7
+ pand xmm5, xmm7
+
+ shufps xmm1, xmm2, 0e4h ;; upper 8 colors
+ movdqa xmm2, xmm0
+ movdqa xmm3, xmm1
+
+ punpcklwd xmm0, xmm6
+ punpcklwd xmm1, xmm6
+ pslld xmm0, 16
+ pslld xmm1, 16
+ por xmm0, xmm4
+ por xmm1, xmm5
+
+ punpckhwd xmm2, xmm6
+ punpckhwd xmm3, xmm6
+ pslld xmm2, 16
+ pslld xmm3, 16
+
+ movdqa [rdx], xmm0
+ movdqa [rdx+32], xmm1
+
+ movdqa xmm5, xmm7
+ pand xmm7, [rdx+16]
+ pand xmm5, [rdx+48]
+
+ por xmm2, xmm7
+ por xmm3, xmm5
+
+ movdqa [rdx+16], xmm2
+ movdqa [rdx+48], xmm3
+WriteCLUT_T16_I4_CSM1_End:
+ ret
+
+WriteCLUT_T16_I4_CSM1_sse2 endp
+
end
\ No newline at end of file
diff --git a/plugins/zerogs/opengl/ctx0/ps2hw_ctx.fx b/plugins/zerogs/opengl/ctx0/ps2hw_ctx.fx
index 7988a22bb7..5a27899665 100644
--- a/plugins/zerogs/opengl/ctx0/ps2hw_ctx.fx
+++ b/plugins/zerogs/opengl/ctx0/ps2hw_ctx.fx
@@ -1,24 +1,24 @@
-// main ps2 memory, each pixel is stored in 32bit color
-uniform samplerRECT g_sMemory : register(s0);
-
-// per context pixel shader constants
-uniform half4 fTexAlpha2 : register(c2);
-
-uniform float4 g_fTexOffset : register(c4); // converts the page and block offsets into the mem addr/1024
-uniform float4 g_fTexDims : register(c6); // mult by tex dims when accessing the block texture
-uniform float4 g_fTexBlock : register(c8);
-
-uniform float4 g_fClampExts : register(c10); // if clamping the texture, use (minu, minv, maxu, maxv)
-uniform float4 TexWrapMode : register(c12); // 0 - repeat/clamp, 1 - region rep (use fRegRepMask)
-
-uniform float4 g_fRealTexDims : register(c14); // tex dims used for linear filtering (w,h,1/w,1/h)
-
-// (alpha0, alpha1, 1 if highlight2 and tcc is rgba, 1-y)
-uniform half4 g_fTestBlack : register(c16); // used for aem bit
-
-uniform float4 g_fPageOffset : register(c18);
-
-uniform half4 fTexAlpha : register(c20);
-
-// vertex shader constants
-uniform float4 g_fPosXY : register(c2);
\ No newline at end of file
+// main ps2 memory, each pixel is stored in 32bit color
+uniform samplerRECT g_sMemory : register(s0);
+
+// per context pixel shader constants
+uniform half4 fTexAlpha2 : register(c2);
+
+uniform float4 g_fTexOffset : register(c4); // converts the page and block offsets into the mem addr/1024
+uniform float4 g_fTexDims : register(c6); // mult by tex dims when accessing the block texture
+uniform float4 g_fTexBlock : register(c8);
+
+uniform float4 g_fClampExts : register(c10); // if clamping the texture, use (minu, minv, maxu, maxv)
+uniform float4 TexWrapMode : register(c12); // 0 - repeat/clamp, 1 - region rep (use fRegRepMask)
+
+uniform float4 g_fRealTexDims : register(c14); // tex dims used for linear filtering (w,h,1/w,1/h)
+
+// (alpha0, alpha1, 1 if highlight2 and tcc is rgba, 1-y)
+uniform half4 g_fTestBlack : register(c16); // used for aem bit
+
+uniform float4 g_fPageOffset : register(c18);
+
+uniform half4 fTexAlpha : register(c20);
+
+// vertex shader constants
+uniform float4 g_fPosXY : register(c2);
diff --git a/plugins/zerogs/opengl/ctx1/ps2hw_ctx.fx b/plugins/zerogs/opengl/ctx1/ps2hw_ctx.fx
index c6332c1a59..58c755ea92 100644
--- a/plugins/zerogs/opengl/ctx1/ps2hw_ctx.fx
+++ b/plugins/zerogs/opengl/ctx1/ps2hw_ctx.fx
@@ -1,23 +1,23 @@
-uniform samplerRECT g_sMemory : register(s1);
-
-// per context pixel shader constants
-uniform half4 fTexAlpha2 : register(c3);
-
-uniform float4 g_fTexOffset : register(c5); // converts the page and block offsets into the mem addr/1024
-uniform float4 g_fTexDims : register(c7); // mult by tex dims when accessing the block texture
-uniform float4 g_fTexBlock : register(c9);
-
-uniform float4 g_fClampExts : register(c11); // if clamping the texture, use (minu, minv, maxu, maxv)
-uniform float4 TexWrapMode : register(c13); // 0 - repeat/clamp, 1 - region rep (use fRegRepMask)
-
-uniform float4 g_fRealTexDims : register(c15); // tex dims used for linear filtering (w,h,1/w,1/h)
-
-// (alpha0, alpha1, 1 if highlight2 and tcc is rgba, 1-y)
-uniform half4 g_fTestBlack : register(c17); // used for aem bit
-
-uniform float4 g_fPageOffset : register(c19);
-
-uniform half4 fTexAlpha : register(c21);
-
-// vertex shader constants
+uniform samplerRECT g_sMemory : register(s1);
+
+// per context pixel shader constants
+uniform half4 fTexAlpha2 : register(c3);
+
+uniform float4 g_fTexOffset : register(c5); // converts the page and block offsets into the mem addr/1024
+uniform float4 g_fTexDims : register(c7); // mult by tex dims when accessing the block texture
+uniform float4 g_fTexBlock : register(c9);
+
+uniform float4 g_fClampExts : register(c11); // if clamping the texture, use (minu, minv, maxu, maxv)
+uniform float4 TexWrapMode : register(c13); // 0 - repeat/clamp, 1 - region rep (use fRegRepMask)
+
+uniform float4 g_fRealTexDims : register(c15); // tex dims used for linear filtering (w,h,1/w,1/h)
+
+// (alpha0, alpha1, 1 if highlight2 and tcc is rgba, 1-y)
+uniform half4 g_fTestBlack : register(c17); // used for aem bit
+
+uniform float4 g_fPageOffset : register(c19);
+
+uniform half4 fTexAlpha : register(c21);
+
+// vertex shader constants
uniform float4 g_fPosXY : register(c3);
\ No newline at end of file
diff --git a/plugins/zerogs/opengl/x86-32.asm b/plugins/zerogs/opengl/x86-32.asm
index 1507d2192d..0531e9542f 100644
--- a/plugins/zerogs/opengl/x86-32.asm
+++ b/plugins/zerogs/opengl/x86-32.asm
@@ -1,652 +1,652 @@
-; Copyright (C) 2003-2005 Gabest
-; http://www.gabest.org
-;
-; 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, 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 GNU Make; see the file COPYING. If not, write to
-; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-; http://www.gnu.org/copyleft/gpl.html
-;
-;
- .686
- .model flat
- .mmx
- .xmm
-
- .const
-
- __uvmin DD 0d01502f9r ; -1e+010
- __uvmax DD 0501502f9r ; +1e+010
-
- .code
-
-;
-; swizzling
-;
-
-punpck macro op, sd0, sd2, s1, s3, d1, d3
-
- movdqa @CatStr(xmm, %d1), @CatStr(xmm, %sd0)
- pshufd @CatStr(xmm, %d3), @CatStr(xmm, %sd2), 0e4h
-
- @CatStr(punpckl, op) @CatStr(xmm, %sd0), @CatStr(xmm, %s1)
- @CatStr(punpckh, op) @CatStr(xmm, %d1), @CatStr(xmm, %s1)
- @CatStr(punpckl, op) @CatStr(xmm, %sd2), @CatStr(xmm, %s3)
- @CatStr(punpckh, op) @CatStr(xmm, %d3), @CatStr(xmm, %s3)
-
- endm
-
-punpcknb macro
-
- movdqa xmm4, xmm0
- pshufd xmm5, xmm1, 0e4h
-
- psllq xmm1, 4
- psrlq xmm4, 4
-
- movdqa xmm6, xmm7
- pand xmm0, xmm7
- pandn xmm6, xmm1
- por xmm0, xmm6
-
- movdqa xmm6, xmm7
- pand xmm4, xmm7
- pandn xmm6, xmm5
- por xmm4, xmm6
-
- movdqa xmm1, xmm4
-
- movdqa xmm4, xmm2
- pshufd xmm5, xmm3, 0e4h
-
- psllq xmm3, 4
- psrlq xmm4, 4
-
- movdqa xmm6, xmm7
- pand xmm2, xmm7
- pandn xmm6, xmm3
- por xmm2, xmm6
-
- movdqa xmm6, xmm7
- pand xmm4, xmm7
- pandn xmm6, xmm5
- por xmm4, xmm6
-
- movdqa xmm3, xmm4
-
- punpck bw, 0, 2, 1, 3, 4, 6
-
- endm
-
-
-;
-; swizzling
-;
-
-;
-; SwizzleBlock32
-;
-
-@SwizzleBlock32_sse2@16 proc public
-
-
- push esi
- push edi
-
- mov edi, ecx
- mov esi, edx
- mov edx, [esp+4+8]
- mov ecx, 4
-
- mov eax, [esp+8+8]
- cmp eax, 0ffffffffh
- jne SwizzleBlock32_sse2@WM
-
- align 16
-@@:
- movdqa xmm0, [esi]
- movdqa xmm4, [esi+16]
- movdqa xmm1, [esi+edx]
- movdqa xmm5, [esi+edx+16]
-
- punpck qdq, 0, 4, 1, 5, 2, 6
-
- movntps [edi+16*0], xmm0
- movntps [edi+16*1], xmm2
- movntps [edi+16*2], xmm4
- movntps [edi+16*3], xmm6
-
- lea esi, [esi+edx*2]
- add edi, 64
-
- dec ecx
- jnz @B
-
- pop edi
- pop esi
-
- ret 8
-
-SwizzleBlock32_sse2@WM:
-
- movd xmm7, eax
- pshufd xmm7, xmm7, 0
-
- align 16
-@@:
- movdqa xmm0, [esi]
- movdqa xmm4, [esi+16]
- movdqa xmm1, [esi+edx]
- movdqa xmm5, [esi+edx+16]
-
- punpck qdq, 0, 4, 1, 5, 2, 6
-
- movdqa xmm3, xmm7
- pshufd xmm5, xmm7, 0e4h
-
- pandn xmm3, [edi+16*0]
- pand xmm0, xmm7
- por xmm0, xmm3
- movntps [edi+16*0], xmm0
-
- pandn xmm5, [edi+16*1]
- pand xmm2, xmm7
- por xmm2, xmm5
- movntps [edi+16*1], xmm2
-
- movdqa xmm3, xmm7
- pshufd xmm5, xmm7, 0e4h
-
- pandn xmm3, [edi+16*2]
- pand xmm4, xmm7
- por xmm4, xmm3
- movntps [edi+16*2], xmm4
-
- pandn xmm5, [edi+16*3]
- pand xmm6, xmm7
- por xmm6, xmm5
- movntps [edi+16*3], xmm6
-
- lea esi, [esi+edx*2]
- add edi, 64
-
- dec ecx
- jnz @B
-
- pop edi
- pop esi
-
- ret 8
-
-@SwizzleBlock32_sse2@16 endp
-
-;
-; SwizzleBlock16
-;
-
-@SwizzleBlock16_sse2@12 proc public
-
- push ebx
-
- mov ebx, [esp+4+4]
- mov eax, 4
-
- align 16
-@@:
- movdqa xmm0, [edx]
- movdqa xmm1, [edx+16]
- movdqa xmm2, [edx+ebx]
- movdqa xmm3, [edx+ebx+16]
-
- punpck wd, 0, 2, 1, 3, 4, 6
- punpck qdq, 0, 4, 2, 6, 1, 5
-
- movntps [ecx+16*0], xmm0
- movntps [ecx+16*1], xmm1
- movntps [ecx+16*2], xmm4
- movntps [ecx+16*3], xmm5
-
- lea edx, [edx+ebx*2]
- add ecx, 64
-
- dec eax
- jnz @B
-
- pop ebx
-
- ret 4
-
-@SwizzleBlock16_sse2@12 endp
-
-;
-; SwizzleBlock8
-;
-
-@SwizzleBlock8_sse2@12 proc public
-
- push ebx
-
- mov ebx, [esp+4+4]
- mov eax, 2
-
- align 16
-@@:
- ; col 0, 2
-
- movdqa xmm0, [edx]
- movdqa xmm2, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- pshufd xmm1, [edx], 0b1h
- pshufd xmm3, [edx+ebx], 0b1h
- lea edx, [edx+ebx*2]
-
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck wd, 0, 2, 4, 6, 1, 3
- punpck qdq, 0, 1, 2, 3, 4, 5
-
- movntps [ecx+16*0], xmm0
- movntps [ecx+16*1], xmm4
- movntps [ecx+16*2], xmm1
- movntps [ecx+16*3], xmm5
-
- ; col 1, 3
-
- pshufd xmm0, [edx], 0b1h
- pshufd xmm2, [edx+ebx], 0b1h
- lea edx, [edx+ebx*2]
-
- movdqa xmm1, [edx]
- movdqa xmm3, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck wd, 0, 2, 4, 6, 1, 3
- punpck qdq, 0, 1, 2, 3, 4, 5
-
- movntps [ecx+16*4], xmm0
- movntps [ecx+16*5], xmm4
- movntps [ecx+16*6], xmm1
- movntps [ecx+16*7], xmm5
-
- add ecx, 128
-
- dec eax
- jnz @B
-
- pop ebx
-
- ret 4
-
-@SwizzleBlock8_sse2@12 endp
-
-;
-; SwizzleBlock4
-;
-
-@SwizzleBlock4_sse2@12 proc public
-
- push ebx
-
- mov eax, 0f0f0f0fh
- movd xmm7, eax
- pshufd xmm7, xmm7, 0
-
- mov ebx, [esp+4+4]
- mov eax, 2
-
- align 16
-@@:
- ; col 0, 2
-
- movdqa xmm0, [edx]
- movdqa xmm2, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- movdqa xmm1, [edx]
- movdqa xmm3, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- pshuflw xmm1, xmm1, 0b1h
- pshuflw xmm3, xmm3, 0b1h
- pshufhw xmm1, xmm1, 0b1h
- pshufhw xmm3, xmm3, 0b1h
-
- punpcknb
- punpck bw, 0, 2, 4, 6, 1, 3
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck qdq, 0, 4, 2, 6, 1, 3
-
- movntps [ecx+16*0], xmm0
- movntps [ecx+16*1], xmm1
- movntps [ecx+16*2], xmm4
- movntps [ecx+16*3], xmm3
-
- ; col 1, 3
-
- movdqa xmm0, [edx]
- movdqa xmm2, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- movdqa xmm1, [edx]
- movdqa xmm3, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- pshuflw xmm0, xmm0, 0b1h
- pshuflw xmm2, xmm2, 0b1h
- pshufhw xmm0, xmm0, 0b1h
- pshufhw xmm2, xmm2, 0b1h
-
- punpcknb
- punpck bw, 0, 2, 4, 6, 1, 3
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck qdq, 0, 4, 2, 6, 1, 3
-
- movntps [ecx+16*4], xmm0
- movntps [ecx+16*5], xmm1
- movntps [ecx+16*6], xmm4
- movntps [ecx+16*7], xmm3
-
- add ecx, 128
-
- dec eax
- jnz @B
-
- pop ebx
-
- ret 4
-
-@SwizzleBlock4_sse2@12 endp
-
-;
-; swizzling with unaligned reads
-;
-
-;
-; SwizzleBlock32u
-;
-
-@SwizzleBlock32u_sse2@16 proc public
-
- push esi
- push edi
-
- mov edi, ecx
- mov esi, edx
- mov edx, [esp+4+8]
- mov ecx, 4
-
- mov eax, [esp+8+8]
- cmp eax, 0ffffffffh
- jne SwizzleBlock32u_sse2@WM
-
- align 16
-@@:
- movdqu xmm0, [esi]
- movdqu xmm4, [esi+16]
- movdqu xmm1, [esi+edx]
- movdqu xmm5, [esi+edx+16]
-
- punpck qdq, 0, 4, 1, 5, 2, 6
-
- movntps [edi+16*0], xmm0
- movntps [edi+16*1], xmm2
- movntps [edi+16*2], xmm4
- movntps [edi+16*3], xmm6
-
- lea esi, [esi+edx*2]
- add edi, 64
-
- dec ecx
- jnz @B
-
- pop edi
- pop esi
-
- ret 8
-
-SwizzleBlock32u_sse2@WM:
-
- movd xmm7, eax
- pshufd xmm7, xmm7, 0
-
- align 16
-@@:
- movdqu xmm0, [esi]
- movdqu xmm4, [esi+16]
- movdqu xmm1, [esi+edx]
- movdqu xmm5, [esi+edx+16]
-
- punpck qdq, 0, 4, 1, 5, 2, 6
-
- movdqa xmm3, xmm7
- pshufd xmm5, xmm7, 0e4h
-
- pandn xmm3, [edi+16*0]
- pand xmm0, xmm7
- por xmm0, xmm3
- movdqa [edi+16*0], xmm0
-
- pandn xmm5, [edi+16*1]
- pand xmm2, xmm7
- por xmm2, xmm5
- movdqa [edi+16*1], xmm2
-
- movdqa xmm3, xmm7
- pshufd xmm5, xmm7, 0e4h
-
- pandn xmm3, [edi+16*2]
- pand xmm4, xmm7
- por xmm4, xmm3
- movdqa [edi+16*2], xmm4
-
- pandn xmm5, [edi+16*3]
- pand xmm6, xmm7
- por xmm6, xmm5
- movdqa [edi+16*3], xmm6
-
- lea esi, [esi+edx*2]
- add edi, 64
-
- dec ecx
- jnz @B
-
- pop edi
- pop esi
-
- ret 8
-
-@SwizzleBlock32u_sse2@16 endp
-
-;
-; SwizzleBlock16u
-;
-
-@SwizzleBlock16u_sse2@12 proc public
-
- push ebx
-
- mov ebx, [esp+4+4]
- mov eax, 4
-
- align 16
-@@:
- movdqu xmm0, [edx]
- movdqu xmm1, [edx+16]
- movdqu xmm2, [edx+ebx]
- movdqu xmm3, [edx+ebx+16]
-
- punpck wd, 0, 2, 1, 3, 4, 6
- punpck qdq, 0, 4, 2, 6, 1, 5
-
- movntps [ecx+16*0], xmm0
- movntps [ecx+16*1], xmm1
- movntps [ecx+16*2], xmm4
- movntps [ecx+16*3], xmm5
-
- lea edx, [edx+ebx*2]
- add ecx, 64
-
- dec eax
- jnz @B
-
- pop ebx
-
- ret 4
-
-@SwizzleBlock16u_sse2@12 endp
-
-;
-; SwizzleBlock8u
-;
-
-@SwizzleBlock8u_sse2@12 proc public
-
- push ebx
-
- mov ebx, [esp+4+4]
- mov eax, 2
-
- align 16
-@@:
- ; col 0, 2
-
- movdqu xmm0, [edx]
- movdqu xmm2, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- movdqu xmm1, [edx]
- movdqu xmm3, [edx+ebx]
- pshufd xmm1, xmm1, 0b1h
- pshufd xmm3, xmm3, 0b1h
- lea edx, [edx+ebx*2]
-
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck wd, 0, 2, 4, 6, 1, 3
- punpck qdq, 0, 1, 2, 3, 4, 5
-
- movntps [ecx+16*0], xmm0
- movntps [ecx+16*1], xmm4
- movntps [ecx+16*2], xmm1
- movntps [ecx+16*3], xmm5
-
- ; col 1, 3
-
- movdqu xmm0, [edx]
- movdqu xmm2, [edx+ebx]
- pshufd xmm0, xmm0, 0b1h
- pshufd xmm2, xmm2, 0b1h
- lea edx, [edx+ebx*2]
-
- movdqu xmm1, [edx]
- movdqu xmm3, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck wd, 0, 2, 4, 6, 1, 3
- punpck qdq, 0, 1, 2, 3, 4, 5
-
- movntps [ecx+16*4], xmm0
- movntps [ecx+16*5], xmm4
- movntps [ecx+16*6], xmm1
- movntps [ecx+16*7], xmm5
-
- add ecx, 128
-
- dec eax
- jnz @B
-
- pop ebx
-
- ret 4
-
-@SwizzleBlock8u_sse2@12 endp
-
-;
-; SwizzleBlock4u
-;
-
-@SwizzleBlock4u_sse2@12 proc public
-
- push ebx
-
- mov eax, 0f0f0f0fh
- movd xmm7, eax
- pshufd xmm7, xmm7, 0
-
- mov ebx, [esp+4+4]
- mov eax, 2
-
- align 16
-@@:
- ; col 0, 2
-
- movdqu xmm0, [edx]
- movdqu xmm2, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- movdqu xmm1, [edx]
- movdqu xmm3, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- pshuflw xmm1, xmm1, 0b1h
- pshuflw xmm3, xmm3, 0b1h
- pshufhw xmm1, xmm1, 0b1h
- pshufhw xmm3, xmm3, 0b1h
-
- punpcknb
- punpck bw, 0, 2, 4, 6, 1, 3
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck qdq, 0, 4, 2, 6, 1, 3
-
- movntps [ecx+16*0], xmm0
- movntps [ecx+16*1], xmm1
- movntps [ecx+16*2], xmm4
- movntps [ecx+16*3], xmm3
-
- ; col 1, 3
-
- movdqu xmm0, [edx]
- movdqu xmm2, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- movdqu xmm1, [edx]
- movdqu xmm3, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- pshuflw xmm0, xmm0, 0b1h
- pshuflw xmm2, xmm2, 0b1h
- pshufhw xmm0, xmm0, 0b1h
- pshufhw xmm2, xmm2, 0b1h
-
- punpcknb
- punpck bw, 0, 2, 4, 6, 1, 3
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck qdq, 0, 4, 2, 6, 1, 3
-
- movntps [ecx+16*4], xmm0
- movntps [ecx+16*5], xmm1
- movntps [ecx+16*6], xmm4
- movntps [ecx+16*7], xmm3
-
- add ecx, 128
-
- dec eax
- jnz @B
-
- pop ebx
-
- ret 4
-
-@SwizzleBlock4u_sse2@12 endp
-
+; Copyright (C) 2003-2005 Gabest
+; http://www.gabest.org
+;
+; 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, 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 GNU Make; see the file COPYING. If not, write to
+; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+; http://www.gnu.org/copyleft/gpl.html
+;
+;
+ .686
+ .model flat
+ .mmx
+ .xmm
+
+ .const
+
+ __uvmin DD 0d01502f9r ; -1e+010
+ __uvmax DD 0501502f9r ; +1e+010
+
+ .code
+
+;
+; swizzling
+;
+
+punpck macro op, sd0, sd2, s1, s3, d1, d3
+
+ movdqa @CatStr(xmm, %d1), @CatStr(xmm, %sd0)
+ pshufd @CatStr(xmm, %d3), @CatStr(xmm, %sd2), 0e4h
+
+ @CatStr(punpckl, op) @CatStr(xmm, %sd0), @CatStr(xmm, %s1)
+ @CatStr(punpckh, op) @CatStr(xmm, %d1), @CatStr(xmm, %s1)
+ @CatStr(punpckl, op) @CatStr(xmm, %sd2), @CatStr(xmm, %s3)
+ @CatStr(punpckh, op) @CatStr(xmm, %d3), @CatStr(xmm, %s3)
+
+ endm
+
+punpcknb macro
+
+ movdqa xmm4, xmm0
+ pshufd xmm5, xmm1, 0e4h
+
+ psllq xmm1, 4
+ psrlq xmm4, 4
+
+ movdqa xmm6, xmm7
+ pand xmm0, xmm7
+ pandn xmm6, xmm1
+ por xmm0, xmm6
+
+ movdqa xmm6, xmm7
+ pand xmm4, xmm7
+ pandn xmm6, xmm5
+ por xmm4, xmm6
+
+ movdqa xmm1, xmm4
+
+ movdqa xmm4, xmm2
+ pshufd xmm5, xmm3, 0e4h
+
+ psllq xmm3, 4
+ psrlq xmm4, 4
+
+ movdqa xmm6, xmm7
+ pand xmm2, xmm7
+ pandn xmm6, xmm3
+ por xmm2, xmm6
+
+ movdqa xmm6, xmm7
+ pand xmm4, xmm7
+ pandn xmm6, xmm5
+ por xmm4, xmm6
+
+ movdqa xmm3, xmm4
+
+ punpck bw, 0, 2, 1, 3, 4, 6
+
+ endm
+
+
+;
+; swizzling
+;
+
+;
+; SwizzleBlock32
+;
+
+@SwizzleBlock32_sse2@16 proc public
+
+
+ push esi
+ push edi
+
+ mov edi, ecx
+ mov esi, edx
+ mov edx, [esp+4+8]
+ mov ecx, 4
+
+ mov eax, [esp+8+8]
+ cmp eax, 0ffffffffh
+ jne SwizzleBlock32_sse2@WM
+
+ align 16
+@@:
+ movdqa xmm0, [esi]
+ movdqa xmm4, [esi+16]
+ movdqa xmm1, [esi+edx]
+ movdqa xmm5, [esi+edx+16]
+
+ punpck qdq, 0, 4, 1, 5, 2, 6
+
+ movntps [edi+16*0], xmm0
+ movntps [edi+16*1], xmm2
+ movntps [edi+16*2], xmm4
+ movntps [edi+16*3], xmm6
+
+ lea esi, [esi+edx*2]
+ add edi, 64
+
+ dec ecx
+ jnz @B
+
+ pop edi
+ pop esi
+
+ ret 8
+
+SwizzleBlock32_sse2@WM:
+
+ movd xmm7, eax
+ pshufd xmm7, xmm7, 0
+
+ align 16
+@@:
+ movdqa xmm0, [esi]
+ movdqa xmm4, [esi+16]
+ movdqa xmm1, [esi+edx]
+ movdqa xmm5, [esi+edx+16]
+
+ punpck qdq, 0, 4, 1, 5, 2, 6
+
+ movdqa xmm3, xmm7
+ pshufd xmm5, xmm7, 0e4h
+
+ pandn xmm3, [edi+16*0]
+ pand xmm0, xmm7
+ por xmm0, xmm3
+ movntps [edi+16*0], xmm0
+
+ pandn xmm5, [edi+16*1]
+ pand xmm2, xmm7
+ por xmm2, xmm5
+ movntps [edi+16*1], xmm2
+
+ movdqa xmm3, xmm7
+ pshufd xmm5, xmm7, 0e4h
+
+ pandn xmm3, [edi+16*2]
+ pand xmm4, xmm7
+ por xmm4, xmm3
+ movntps [edi+16*2], xmm4
+
+ pandn xmm5, [edi+16*3]
+ pand xmm6, xmm7
+ por xmm6, xmm5
+ movntps [edi+16*3], xmm6
+
+ lea esi, [esi+edx*2]
+ add edi, 64
+
+ dec ecx
+ jnz @B
+
+ pop edi
+ pop esi
+
+ ret 8
+
+@SwizzleBlock32_sse2@16 endp
+
+;
+; SwizzleBlock16
+;
+
+@SwizzleBlock16_sse2@12 proc public
+
+ push ebx
+
+ mov ebx, [esp+4+4]
+ mov eax, 4
+
+ align 16
+@@:
+ movdqa xmm0, [edx]
+ movdqa xmm1, [edx+16]
+ movdqa xmm2, [edx+ebx]
+ movdqa xmm3, [edx+ebx+16]
+
+ punpck wd, 0, 2, 1, 3, 4, 6
+ punpck qdq, 0, 4, 2, 6, 1, 5
+
+ movntps [ecx+16*0], xmm0
+ movntps [ecx+16*1], xmm1
+ movntps [ecx+16*2], xmm4
+ movntps [ecx+16*3], xmm5
+
+ lea edx, [edx+ebx*2]
+ add ecx, 64
+
+ dec eax
+ jnz @B
+
+ pop ebx
+
+ ret 4
+
+@SwizzleBlock16_sse2@12 endp
+
+;
+; SwizzleBlock8
+;
+
+@SwizzleBlock8_sse2@12 proc public
+
+ push ebx
+
+ mov ebx, [esp+4+4]
+ mov eax, 2
+
+ align 16
+@@:
+ ; col 0, 2
+
+ movdqa xmm0, [edx]
+ movdqa xmm2, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ pshufd xmm1, [edx], 0b1h
+ pshufd xmm3, [edx+ebx], 0b1h
+ lea edx, [edx+ebx*2]
+
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck wd, 0, 2, 4, 6, 1, 3
+ punpck qdq, 0, 1, 2, 3, 4, 5
+
+ movntps [ecx+16*0], xmm0
+ movntps [ecx+16*1], xmm4
+ movntps [ecx+16*2], xmm1
+ movntps [ecx+16*3], xmm5
+
+ ; col 1, 3
+
+ pshufd xmm0, [edx], 0b1h
+ pshufd xmm2, [edx+ebx], 0b1h
+ lea edx, [edx+ebx*2]
+
+ movdqa xmm1, [edx]
+ movdqa xmm3, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck wd, 0, 2, 4, 6, 1, 3
+ punpck qdq, 0, 1, 2, 3, 4, 5
+
+ movntps [ecx+16*4], xmm0
+ movntps [ecx+16*5], xmm4
+ movntps [ecx+16*6], xmm1
+ movntps [ecx+16*7], xmm5
+
+ add ecx, 128
+
+ dec eax
+ jnz @B
+
+ pop ebx
+
+ ret 4
+
+@SwizzleBlock8_sse2@12 endp
+
+;
+; SwizzleBlock4
+;
+
+@SwizzleBlock4_sse2@12 proc public
+
+ push ebx
+
+ mov eax, 0f0f0f0fh
+ movd xmm7, eax
+ pshufd xmm7, xmm7, 0
+
+ mov ebx, [esp+4+4]
+ mov eax, 2
+
+ align 16
+@@:
+ ; col 0, 2
+
+ movdqa xmm0, [edx]
+ movdqa xmm2, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ movdqa xmm1, [edx]
+ movdqa xmm3, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ pshuflw xmm1, xmm1, 0b1h
+ pshuflw xmm3, xmm3, 0b1h
+ pshufhw xmm1, xmm1, 0b1h
+ pshufhw xmm3, xmm3, 0b1h
+
+ punpcknb
+ punpck bw, 0, 2, 4, 6, 1, 3
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck qdq, 0, 4, 2, 6, 1, 3
+
+ movntps [ecx+16*0], xmm0
+ movntps [ecx+16*1], xmm1
+ movntps [ecx+16*2], xmm4
+ movntps [ecx+16*3], xmm3
+
+ ; col 1, 3
+
+ movdqa xmm0, [edx]
+ movdqa xmm2, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ movdqa xmm1, [edx]
+ movdqa xmm3, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ pshuflw xmm0, xmm0, 0b1h
+ pshuflw xmm2, xmm2, 0b1h
+ pshufhw xmm0, xmm0, 0b1h
+ pshufhw xmm2, xmm2, 0b1h
+
+ punpcknb
+ punpck bw, 0, 2, 4, 6, 1, 3
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck qdq, 0, 4, 2, 6, 1, 3
+
+ movntps [ecx+16*4], xmm0
+ movntps [ecx+16*5], xmm1
+ movntps [ecx+16*6], xmm4
+ movntps [ecx+16*7], xmm3
+
+ add ecx, 128
+
+ dec eax
+ jnz @B
+
+ pop ebx
+
+ ret 4
+
+@SwizzleBlock4_sse2@12 endp
+
+;
+; swizzling with unaligned reads
+;
+
+;
+; SwizzleBlock32u
+;
+
+@SwizzleBlock32u_sse2@16 proc public
+
+ push esi
+ push edi
+
+ mov edi, ecx
+ mov esi, edx
+ mov edx, [esp+4+8]
+ mov ecx, 4
+
+ mov eax, [esp+8+8]
+ cmp eax, 0ffffffffh
+ jne SwizzleBlock32u_sse2@WM
+
+ align 16
+@@:
+ movdqu xmm0, [esi]
+ movdqu xmm4, [esi+16]
+ movdqu xmm1, [esi+edx]
+ movdqu xmm5, [esi+edx+16]
+
+ punpck qdq, 0, 4, 1, 5, 2, 6
+
+ movntps [edi+16*0], xmm0
+ movntps [edi+16*1], xmm2
+ movntps [edi+16*2], xmm4
+ movntps [edi+16*3], xmm6
+
+ lea esi, [esi+edx*2]
+ add edi, 64
+
+ dec ecx
+ jnz @B
+
+ pop edi
+ pop esi
+
+ ret 8
+
+SwizzleBlock32u_sse2@WM:
+
+ movd xmm7, eax
+ pshufd xmm7, xmm7, 0
+
+ align 16
+@@:
+ movdqu xmm0, [esi]
+ movdqu xmm4, [esi+16]
+ movdqu xmm1, [esi+edx]
+ movdqu xmm5, [esi+edx+16]
+
+ punpck qdq, 0, 4, 1, 5, 2, 6
+
+ movdqa xmm3, xmm7
+ pshufd xmm5, xmm7, 0e4h
+
+ pandn xmm3, [edi+16*0]
+ pand xmm0, xmm7
+ por xmm0, xmm3
+ movdqa [edi+16*0], xmm0
+
+ pandn xmm5, [edi+16*1]
+ pand xmm2, xmm7
+ por xmm2, xmm5
+ movdqa [edi+16*1], xmm2
+
+ movdqa xmm3, xmm7
+ pshufd xmm5, xmm7, 0e4h
+
+ pandn xmm3, [edi+16*2]
+ pand xmm4, xmm7
+ por xmm4, xmm3
+ movdqa [edi+16*2], xmm4
+
+ pandn xmm5, [edi+16*3]
+ pand xmm6, xmm7
+ por xmm6, xmm5
+ movdqa [edi+16*3], xmm6
+
+ lea esi, [esi+edx*2]
+ add edi, 64
+
+ dec ecx
+ jnz @B
+
+ pop edi
+ pop esi
+
+ ret 8
+
+@SwizzleBlock32u_sse2@16 endp
+
+;
+; SwizzleBlock16u
+;
+
+@SwizzleBlock16u_sse2@12 proc public
+
+ push ebx
+
+ mov ebx, [esp+4+4]
+ mov eax, 4
+
+ align 16
+@@:
+ movdqu xmm0, [edx]
+ movdqu xmm1, [edx+16]
+ movdqu xmm2, [edx+ebx]
+ movdqu xmm3, [edx+ebx+16]
+
+ punpck wd, 0, 2, 1, 3, 4, 6
+ punpck qdq, 0, 4, 2, 6, 1, 5
+
+ movntps [ecx+16*0], xmm0
+ movntps [ecx+16*1], xmm1
+ movntps [ecx+16*2], xmm4
+ movntps [ecx+16*3], xmm5
+
+ lea edx, [edx+ebx*2]
+ add ecx, 64
+
+ dec eax
+ jnz @B
+
+ pop ebx
+
+ ret 4
+
+@SwizzleBlock16u_sse2@12 endp
+
+;
+; SwizzleBlock8u
+;
+
+@SwizzleBlock8u_sse2@12 proc public
+
+ push ebx
+
+ mov ebx, [esp+4+4]
+ mov eax, 2
+
+ align 16
+@@:
+ ; col 0, 2
+
+ movdqu xmm0, [edx]
+ movdqu xmm2, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ movdqu xmm1, [edx]
+ movdqu xmm3, [edx+ebx]
+ pshufd xmm1, xmm1, 0b1h
+ pshufd xmm3, xmm3, 0b1h
+ lea edx, [edx+ebx*2]
+
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck wd, 0, 2, 4, 6, 1, 3
+ punpck qdq, 0, 1, 2, 3, 4, 5
+
+ movntps [ecx+16*0], xmm0
+ movntps [ecx+16*1], xmm4
+ movntps [ecx+16*2], xmm1
+ movntps [ecx+16*3], xmm5
+
+ ; col 1, 3
+
+ movdqu xmm0, [edx]
+ movdqu xmm2, [edx+ebx]
+ pshufd xmm0, xmm0, 0b1h
+ pshufd xmm2, xmm2, 0b1h
+ lea edx, [edx+ebx*2]
+
+ movdqu xmm1, [edx]
+ movdqu xmm3, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck wd, 0, 2, 4, 6, 1, 3
+ punpck qdq, 0, 1, 2, 3, 4, 5
+
+ movntps [ecx+16*4], xmm0
+ movntps [ecx+16*5], xmm4
+ movntps [ecx+16*6], xmm1
+ movntps [ecx+16*7], xmm5
+
+ add ecx, 128
+
+ dec eax
+ jnz @B
+
+ pop ebx
+
+ ret 4
+
+@SwizzleBlock8u_sse2@12 endp
+
+;
+; SwizzleBlock4u
+;
+
+@SwizzleBlock4u_sse2@12 proc public
+
+ push ebx
+
+ mov eax, 0f0f0f0fh
+ movd xmm7, eax
+ pshufd xmm7, xmm7, 0
+
+ mov ebx, [esp+4+4]
+ mov eax, 2
+
+ align 16
+@@:
+ ; col 0, 2
+
+ movdqu xmm0, [edx]
+ movdqu xmm2, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ movdqu xmm1, [edx]
+ movdqu xmm3, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ pshuflw xmm1, xmm1, 0b1h
+ pshuflw xmm3, xmm3, 0b1h
+ pshufhw xmm1, xmm1, 0b1h
+ pshufhw xmm3, xmm3, 0b1h
+
+ punpcknb
+ punpck bw, 0, 2, 4, 6, 1, 3
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck qdq, 0, 4, 2, 6, 1, 3
+
+ movntps [ecx+16*0], xmm0
+ movntps [ecx+16*1], xmm1
+ movntps [ecx+16*2], xmm4
+ movntps [ecx+16*3], xmm3
+
+ ; col 1, 3
+
+ movdqu xmm0, [edx]
+ movdqu xmm2, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ movdqu xmm1, [edx]
+ movdqu xmm3, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ pshuflw xmm0, xmm0, 0b1h
+ pshuflw xmm2, xmm2, 0b1h
+ pshufhw xmm0, xmm0, 0b1h
+ pshufhw xmm2, xmm2, 0b1h
+
+ punpcknb
+ punpck bw, 0, 2, 4, 6, 1, 3
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck qdq, 0, 4, 2, 6, 1, 3
+
+ movntps [ecx+16*4], xmm0
+ movntps [ecx+16*5], xmm1
+ movntps [ecx+16*6], xmm4
+ movntps [ecx+16*7], xmm3
+
+ add ecx, 128
+
+ dec eax
+ jnz @B
+
+ pop ebx
+
+ ret 4
+
+@SwizzleBlock4u_sse2@12 endp
+
end
\ No newline at end of file
diff --git a/plugins/zerospu2/WavFile.cpp b/plugins/zerospu2/WavFile.cpp
index 30c0988e8a..dc0953ace3 100644
--- a/plugins/zerospu2/WavFile.cpp
+++ b/plugins/zerospu2/WavFile.cpp
@@ -1,149 +1,149 @@
-/* SPU2-X, A plugin for Emulating the Sound Processing Unit of the Playstation 2
- * Developed and maintained by the Pcsx2 Development Team.
- *
- * The file is based on WavFile.h from SoundTouch library.
- * Original portions are (c) 2009 by Olli Parviainen (oparviai 'at' iki.fi)
- *
- * SPU2-X 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.
- *
- * SPU2-X 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with SPU2-X. If not, see .
- */
-
-// Note the file is mostly a copy paste of the WavFile.h from SoundTouch library. It was
-// shrunken to support only output 16 bits wav files
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "WavFile.h"
-
-using namespace std;
-
-static const char riffStr[] = "RIFF";
-static const char waveStr[] = "WAVE";
-static const char fmtStr[] = "fmt ";
-static const char dataStr[] = "data";
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// Class WavOutFile
-//
-
-WavOutFile::WavOutFile(const char *fileName, int sampleRate, int bits, int channels)
-{
- bytesWritten = 0;
- fptr = fopen(fileName, "wb");
- if (fptr == NULL)
- {
- string msg = "Error : Unable to open file \"";
- msg += fileName;
- msg += "\" for writing.";
- //pmsg = msg.c_str;
- throw runtime_error(msg);
- }
-
- fillInHeader(sampleRate, bits, channels);
- writeHeader();
-}
-
-
-WavOutFile::~WavOutFile()
-{
- finishHeader();
- if (fptr) fclose(fptr);
- fptr = NULL;
-}
-
-
-
-void WavOutFile::fillInHeader(uint sampleRate, uint bits, uint channels)
-{
- // fill in the 'riff' part..
-
- // copy string 'RIFF' to riff_char
- memcpy(&(header.riff.riff_char), riffStr, 4);
- // package_len unknown so far
- header.riff.package_len = 0;
- // copy string 'WAVE' to wave
- memcpy(&(header.riff.wave), waveStr, 4);
-
-
- // fill in the 'format' part..
-
- // copy string 'fmt ' to fmt
- memcpy(&(header.format.fmt), fmtStr, 4);
-
- header.format.format_len = 0x10;
- header.format.fixed = 1;
- header.format.channel_number = (short)channels;
- header.format.sample_rate = (int)sampleRate;
- header.format.bits_per_sample = (short)bits;
- header.format.byte_per_sample = (short)(bits * channels / 8);
- header.format.byte_rate = header.format.byte_per_sample * (int)sampleRate;
- header.format.sample_rate = (int)sampleRate;
-
- // fill in the 'data' part..
-
- // copy string 'data' to data_field
- memcpy(&(header.data.data_field), dataStr, 4);
- // data_len unknown so far
- header.data.data_len = 0;
-}
-
-
-void WavOutFile::finishHeader()
-{
- // supplement the file length into the header structure
- header.riff.package_len = bytesWritten + 36;
- header.data.data_len = bytesWritten;
-
- writeHeader();
-}
-
-
-
-void WavOutFile::writeHeader()
-{
- int res;
-
- // write the supplemented header in the beginning of the file
- fseek(fptr, 0, SEEK_SET);
- res = fwrite(&header, sizeof(header), 1, fptr);
- if (res != 1)
- {
- throw runtime_error("Error while writing to a wav file.");
- }
-
- // jump back to the end of the file
- fseek(fptr, 0, SEEK_END);
-}
-
-
-void WavOutFile::write(const short *buffer, int numElems)
-{
- int res;
-
- // 16bit format & 16 bit samples
-
- assert(header.format.bits_per_sample == 16);
- if (numElems < 1) return; // nothing to do
-
- res = fwrite(buffer, 2, numElems, fptr);
-
- if (res != numElems)
- {
- throw runtime_error("Error while writing to a wav file.");
- }
- bytesWritten += 2 * numElems;
-}
+/* SPU2-X, A plugin for Emulating the Sound Processing Unit of the Playstation 2
+ * Developed and maintained by the Pcsx2 Development Team.
+ *
+ * The file is based on WavFile.h from SoundTouch library.
+ * Original portions are (c) 2009 by Olli Parviainen (oparviai 'at' iki.fi)
+ *
+ * SPU2-X 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.
+ *
+ * SPU2-X 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with SPU2-X. If not, see .
+ */
+
+// Note the file is mostly a copy paste of the WavFile.h from SoundTouch library. It was
+// shrunken to support only output 16 bits wav files
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "WavFile.h"
+
+using namespace std;
+
+static const char riffStr[] = "RIFF";
+static const char waveStr[] = "WAVE";
+static const char fmtStr[] = "fmt ";
+static const char dataStr[] = "data";
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// Class WavOutFile
+//
+
+WavOutFile::WavOutFile(const char *fileName, int sampleRate, int bits, int channels)
+{
+ bytesWritten = 0;
+ fptr = fopen(fileName, "wb");
+ if (fptr == NULL)
+ {
+ string msg = "Error : Unable to open file \"";
+ msg += fileName;
+ msg += "\" for writing.";
+ //pmsg = msg.c_str;
+ throw runtime_error(msg);
+ }
+
+ fillInHeader(sampleRate, bits, channels);
+ writeHeader();
+}
+
+
+WavOutFile::~WavOutFile()
+{
+ finishHeader();
+ if (fptr) fclose(fptr);
+ fptr = NULL;
+}
+
+
+
+void WavOutFile::fillInHeader(uint sampleRate, uint bits, uint channels)
+{
+ // fill in the 'riff' part..
+
+ // copy string 'RIFF' to riff_char
+ memcpy(&(header.riff.riff_char), riffStr, 4);
+ // package_len unknown so far
+ header.riff.package_len = 0;
+ // copy string 'WAVE' to wave
+ memcpy(&(header.riff.wave), waveStr, 4);
+
+
+ // fill in the 'format' part..
+
+ // copy string 'fmt ' to fmt
+ memcpy(&(header.format.fmt), fmtStr, 4);
+
+ header.format.format_len = 0x10;
+ header.format.fixed = 1;
+ header.format.channel_number = (short)channels;
+ header.format.sample_rate = (int)sampleRate;
+ header.format.bits_per_sample = (short)bits;
+ header.format.byte_per_sample = (short)(bits * channels / 8);
+ header.format.byte_rate = header.format.byte_per_sample * (int)sampleRate;
+ header.format.sample_rate = (int)sampleRate;
+
+ // fill in the 'data' part..
+
+ // copy string 'data' to data_field
+ memcpy(&(header.data.data_field), dataStr, 4);
+ // data_len unknown so far
+ header.data.data_len = 0;
+}
+
+
+void WavOutFile::finishHeader()
+{
+ // supplement the file length into the header structure
+ header.riff.package_len = bytesWritten + 36;
+ header.data.data_len = bytesWritten;
+
+ writeHeader();
+}
+
+
+
+void WavOutFile::writeHeader()
+{
+ int res;
+
+ // write the supplemented header in the beginning of the file
+ fseek(fptr, 0, SEEK_SET);
+ res = fwrite(&header, sizeof(header), 1, fptr);
+ if (res != 1)
+ {
+ throw runtime_error("Error while writing to a wav file.");
+ }
+
+ // jump back to the end of the file
+ fseek(fptr, 0, SEEK_END);
+}
+
+
+void WavOutFile::write(const short *buffer, int numElems)
+{
+ int res;
+
+ // 16bit format & 16 bit samples
+
+ assert(header.format.bits_per_sample == 16);
+ if (numElems < 1) return; // nothing to do
+
+ res = fwrite(buffer, 2, numElems, fptr);
+
+ if (res != numElems)
+ {
+ throw runtime_error("Error while writing to a wav file.");
+ }
+ bytesWritten += 2 * numElems;
+}
diff --git a/plugins/zerospu2/WavFile.h b/plugins/zerospu2/WavFile.h
index 7d75c4bac4..2e07f97edb 100644
--- a/plugins/zerospu2/WavFile.h
+++ b/plugins/zerospu2/WavFile.h
@@ -1,113 +1,113 @@
-/* SPU2-X, A plugin for Emulating the Sound Processing Unit of the Playstation 2
- * Developed and maintained by the Pcsx2 Development Team.
- *
- * The file is based on WavFile.h from SoundTouch library.
- * Original portions are (c) 2009 by Olli Parviainen (oparviai 'at' iki.fi)
- *
- * SPU2-X 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.
- *
- * SPU2-X 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with SPU2-X. If not, see .
- */
-
-// Note the file is mostly a copy paste of the WavFile.h from SoundTouch library. It was
-// shrunken to support only output 16 bits wav files
-
-#ifndef WAVFILE_H
-#define WAVFILE_H
-
-#include
-
-#ifndef uint
-typedef unsigned int uint;
-#endif
-
-
-/// WAV audio file 'riff' section header
-typedef struct
-{
- char riff_char[4];
- int package_len;
- char wave[4];
-} WavRiff;
-
-/// WAV audio file 'format' section header
-typedef struct
-{
- char fmt[4];
- int format_len;
- short fixed;
- short channel_number;
- int sample_rate;
- int byte_rate;
- short byte_per_sample;
- short bits_per_sample;
-} WavFormat;
-
-/// WAV audio file 'data' section header
-typedef struct
-{
- char data_field[4];
- uint data_len;
-} WavData;
-
-
-/// WAV audio file header
-typedef struct
-{
- WavRiff riff;
- WavFormat format;
- WavData data;
-} WavHeader;
-
-
-/// Class for writing WAV audio files.
-class WavOutFile
-{
-private:
- /// Pointer to the WAV file
- FILE *fptr;
-
- /// WAV file header data.
- WavHeader header;
-
- /// Counter of how many bytes have been written to the file so far.
- int bytesWritten;
-
- /// Fills in WAV file header information.
- void fillInHeader(const uint sampleRate, const uint bits, const uint channels);
-
- /// Finishes the WAV file header by supplementing information of amount of
- /// data written to file etc
- void finishHeader();
-
- /// Writes the WAV file header.
- void writeHeader();
-
-public:
- /// Constructor: Creates a new WAV file. Throws a 'runtime_error' exception
- /// if file creation fails.
- WavOutFile(const char *fileName, ///< Filename
- int sampleRate, ///< Sample rate (e.g. 44100 etc)
- int bits, ///< Bits per sample (8 or 16 bits)
- int channels ///< Number of channels (1=mono, 2=stereo)
- );
-
- /// Destructor: Finalizes & closes the WAV file.
- ~WavOutFile();
-
- /// Write data to WAV file. Throws a 'runtime_error' exception if writing to
- /// file fails.
- void write(const short *buffer, ///< Pointer to sample data buffer.
- int numElems ///< How many array items are to be written to file.
- );
-
-};
-
-#endif
+/* SPU2-X, A plugin for Emulating the Sound Processing Unit of the Playstation 2
+ * Developed and maintained by the Pcsx2 Development Team.
+ *
+ * The file is based on WavFile.h from SoundTouch library.
+ * Original portions are (c) 2009 by Olli Parviainen (oparviai 'at' iki.fi)
+ *
+ * SPU2-X 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.
+ *
+ * SPU2-X 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with SPU2-X. If not, see .
+ */
+
+// Note the file is mostly a copy paste of the WavFile.h from SoundTouch library. It was
+// shrunken to support only output 16 bits wav files
+
+#ifndef WAVFILE_H
+#define WAVFILE_H
+
+#include
+
+#ifndef uint
+typedef unsigned int uint;
+#endif
+
+
+/// WAV audio file 'riff' section header
+typedef struct
+{
+ char riff_char[4];
+ int package_len;
+ char wave[4];
+} WavRiff;
+
+/// WAV audio file 'format' section header
+typedef struct
+{
+ char fmt[4];
+ int format_len;
+ short fixed;
+ short channel_number;
+ int sample_rate;
+ int byte_rate;
+ short byte_per_sample;
+ short bits_per_sample;
+} WavFormat;
+
+/// WAV audio file 'data' section header
+typedef struct
+{
+ char data_field[4];
+ uint data_len;
+} WavData;
+
+
+/// WAV audio file header
+typedef struct
+{
+ WavRiff riff;
+ WavFormat format;
+ WavData data;
+} WavHeader;
+
+
+/// Class for writing WAV audio files.
+class WavOutFile
+{
+private:
+ /// Pointer to the WAV file
+ FILE *fptr;
+
+ /// WAV file header data.
+ WavHeader header;
+
+ /// Counter of how many bytes have been written to the file so far.
+ int bytesWritten;
+
+ /// Fills in WAV file header information.
+ void fillInHeader(const uint sampleRate, const uint bits, const uint channels);
+
+ /// Finishes the WAV file header by supplementing information of amount of
+ /// data written to file etc
+ void finishHeader();
+
+ /// Writes the WAV file header.
+ void writeHeader();
+
+public:
+ /// Constructor: Creates a new WAV file. Throws a 'runtime_error' exception
+ /// if file creation fails.
+ WavOutFile(const char *fileName, ///< Filename
+ int sampleRate, ///< Sample rate (e.g. 44100 etc)
+ int bits, ///< Bits per sample (8 or 16 bits)
+ int channels ///< Number of channels (1=mono, 2=stereo)
+ );
+
+ /// Destructor: Finalizes & closes the WAV file.
+ ~WavOutFile();
+
+ /// Write data to WAV file. Throws a 'runtime_error' exception if writing to
+ /// file fails.
+ void write(const short *buffer, ///< Pointer to sample data buffer.
+ int numElems ///< How many array items are to be written to file.
+ );
+
+};
+
+#endif
diff --git a/plugins/zzogl-pg/opengl/Profile.h b/plugins/zzogl-pg/opengl/Profile.h
index 7c46f4ce9e..b6e17b7af3 100644
--- a/plugins/zzogl-pg/opengl/Profile.h
+++ b/plugins/zzogl-pg/opengl/Profile.h
@@ -1,172 +1,172 @@
-/* ZZ Open GL graphics plugin
- * Copyright (c)2009-2010 zeydlitz@gmail.com, arcum42@gmail.com
- * Based on Zerofrog's ZeroGS KOSMOS (c)2005-2008
- *
- * 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
- */
-
-#ifndef PROFILE_H_INCLUDED
-#define PROFILE_H_INCLUDED
-
-#include "Util.h"
-
-#if !defined(ZEROGS_DEVBUILD)
-#define g_bWriteProfile 0
-#else
-extern bool g_bWriteProfile;
-#endif
-
-extern u64 luPerfFreq;
-
-
-// Copied from Utilities; remove later.
-#ifdef __LINUX__
-
-#include
-#include // ftime(), struct timeb
-
-inline unsigned long timeGetTime()
-{
- timeb t;
- ftime(&t);
-
- return (unsigned long)(t.time*1000 + t.millitm);
-}
-
-inline unsigned long timeGetPreciseTime()
-{
- timespec t;
- clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &t);
-
- return t.tv_nsec;
-}
-
-static __forceinline void InitCPUTicks()
-{
-}
-
-static __forceinline u64 GetTickFrequency()
-{
- return 1000000; // unix measures in microseconds
-}
-
-static __forceinline u64 GetCPUTicks()
-{
-
- struct timeval t;
- gettimeofday(&t, NULL);
- return ((u64)t.tv_sec*GetTickFrequency()) + t.tv_usec;
-}
-
-#else
-static __aligned16 LARGE_INTEGER lfreq;
-
-inline unsigned long timeGetPreciseTime()
-{
- // Implement later.
- return 0;
-}
-
-static __forceinline void InitCPUTicks()
-{
- QueryPerformanceFrequency(&lfreq);
-}
-
-static __forceinline u64 GetTickFrequency()
-{
- return lfreq.QuadPart;
-}
-
-static __forceinline u64 GetCPUTicks()
-{
- LARGE_INTEGER count;
- QueryPerformanceCounter(&count);
- return count.QuadPart;
-}
-
-#endif
-
-// IMPORTANT: For every Register there must be an End
-void DVProfRegister(char* pname); // first checks if this profiler exists in g_listProfilers
-void DVProfEnd(u32 dwUserData);
-void DVProfWrite(char* pfilename, u32 frames = 0);
-void DVProfClear(); // clears all the profilers
-
-#define DVPROFILE
-#ifdef DVPROFILE
-
-class DVProfileFunc
-{
- public:
- u32 dwUserData;
- DVProfileFunc(char* pname) { DVProfRegister(pname); dwUserData = 0; }
- DVProfileFunc(char* pname, u32 dwUserData) : dwUserData(dwUserData) { DVProfRegister(pname); }
- ~DVProfileFunc() { DVProfEnd(dwUserData); }
-};
-
-#else
-
-class DVProfileFunc
-{
-
- public:
- u32 dwUserData;
- static __forceinline DVProfileFunc(char* pname) {}
- static __forceinline DVProfileFunc(char* pname, u32 dwUserData) { }
- ~DVProfileFunc() {}
-};
-
-#endif
-
-
-template
-class CInterfacePtr
-{
-
- public:
- inline CInterfacePtr() : ptr(NULL) {}
- inline explicit CInterfacePtr(T* newptr) : ptr(newptr) { if (ptr != NULL) ptr->AddRef(); }
- inline ~CInterfacePtr() { if (ptr != NULL) ptr->Release(); }
- inline T* operator*() { assert(ptr != NULL); return *ptr; }
- inline T* operator->() { return ptr; }
- inline T* get() { return ptr; }
-
- inline void release()
- {
- if (ptr != NULL) { ptr->Release(); ptr = NULL; }
- }
-
- inline operator T*() { return ptr; }
- inline bool operator==(T* rhs) { return ptr == rhs; }
- inline bool operator!=(T* rhs) { return ptr != rhs; }
-
- inline CInterfacePtr& operator= (T* newptr)
- {
- if (ptr != NULL) ptr->Release();
-
- ptr = newptr;
-
- if (ptr != NULL) ptr->AddRef();
-
- return *this;
- }
-
- private:
- T* ptr;
-};
-
-extern void InitProfile();
-
-#endif // PROFILE_H_INCLUDED
+/* ZZ Open GL graphics plugin
+ * Copyright (c)2009-2010 zeydlitz@gmail.com, arcum42@gmail.com
+ * Based on Zerofrog's ZeroGS KOSMOS (c)2005-2008
+ *
+ * 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
+ */
+
+#ifndef PROFILE_H_INCLUDED
+#define PROFILE_H_INCLUDED
+
+#include "Util.h"
+
+#if !defined(ZEROGS_DEVBUILD)
+#define g_bWriteProfile 0
+#else
+extern bool g_bWriteProfile;
+#endif
+
+extern u64 luPerfFreq;
+
+
+// Copied from Utilities; remove later.
+#ifdef __LINUX__
+
+#include
+#include // ftime(), struct timeb
+
+inline unsigned long timeGetTime()
+{
+ timeb t;
+ ftime(&t);
+
+ return (unsigned long)(t.time*1000 + t.millitm);
+}
+
+inline unsigned long timeGetPreciseTime()
+{
+ timespec t;
+ clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &t);
+
+ return t.tv_nsec;
+}
+
+static __forceinline void InitCPUTicks()
+{
+}
+
+static __forceinline u64 GetTickFrequency()
+{
+ return 1000000; // unix measures in microseconds
+}
+
+static __forceinline u64 GetCPUTicks()
+{
+
+ struct timeval t;
+ gettimeofday(&t, NULL);
+ return ((u64)t.tv_sec*GetTickFrequency()) + t.tv_usec;
+}
+
+#else
+static __aligned16 LARGE_INTEGER lfreq;
+
+inline unsigned long timeGetPreciseTime()
+{
+ // Implement later.
+ return 0;
+}
+
+static __forceinline void InitCPUTicks()
+{
+ QueryPerformanceFrequency(&lfreq);
+}
+
+static __forceinline u64 GetTickFrequency()
+{
+ return lfreq.QuadPart;
+}
+
+static __forceinline u64 GetCPUTicks()
+{
+ LARGE_INTEGER count;
+ QueryPerformanceCounter(&count);
+ return count.QuadPart;
+}
+
+#endif
+
+// IMPORTANT: For every Register there must be an End
+void DVProfRegister(char* pname); // first checks if this profiler exists in g_listProfilers
+void DVProfEnd(u32 dwUserData);
+void DVProfWrite(char* pfilename, u32 frames = 0);
+void DVProfClear(); // clears all the profilers
+
+#define DVPROFILE
+#ifdef DVPROFILE
+
+class DVProfileFunc
+{
+ public:
+ u32 dwUserData;
+ DVProfileFunc(char* pname) { DVProfRegister(pname); dwUserData = 0; }
+ DVProfileFunc(char* pname, u32 dwUserData) : dwUserData(dwUserData) { DVProfRegister(pname); }
+ ~DVProfileFunc() { DVProfEnd(dwUserData); }
+};
+
+#else
+
+class DVProfileFunc
+{
+
+ public:
+ u32 dwUserData;
+ static __forceinline DVProfileFunc(char* pname) {}
+ static __forceinline DVProfileFunc(char* pname, u32 dwUserData) { }
+ ~DVProfileFunc() {}
+};
+
+#endif
+
+
+template
+class CInterfacePtr
+{
+
+ public:
+ inline CInterfacePtr() : ptr(NULL) {}
+ inline explicit CInterfacePtr(T* newptr) : ptr(newptr) { if (ptr != NULL) ptr->AddRef(); }
+ inline ~CInterfacePtr() { if (ptr != NULL) ptr->Release(); }
+ inline T* operator*() { assert(ptr != NULL); return *ptr; }
+ inline T* operator->() { return ptr; }
+ inline T* get() { return ptr; }
+
+ inline void release()
+ {
+ if (ptr != NULL) { ptr->Release(); ptr = NULL; }
+ }
+
+ inline operator T*() { return ptr; }
+ inline bool operator==(T* rhs) { return ptr == rhs; }
+ inline bool operator!=(T* rhs) { return ptr != rhs; }
+
+ inline CInterfacePtr& operator= (T* newptr)
+ {
+ if (ptr != NULL) ptr->Release();
+
+ ptr = newptr;
+
+ if (ptr != NULL) ptr->AddRef();
+
+ return *this;
+ }
+
+ private:
+ T* ptr;
+};
+
+extern void InitProfile();
+
+#endif // PROFILE_H_INCLUDED
diff --git a/plugins/zzogl-pg/opengl/README.txt b/plugins/zzogl-pg/opengl/README.txt
index edeb776031..447dfdf204 100644
--- a/plugins/zzogl-pg/opengl/README.txt
+++ b/plugins/zzogl-pg/opengl/README.txt
@@ -1,13 +1,13 @@
-ZeroGS OpenGL
--------------
-author: zerofrog (@gmail.com)
-
-ZeroGS heavily uses GPU shaders. All the shaders are written in nVidia's Cg language and can be found in ps2hw.fx.
-
-'Dev' versions of ZeroGS directly read ps2hw.fx
-'Release' versions of ZeroGS read a precompiled version of ps2hw.fx from ps2hw.dat. In order to build ps2hw.dat, compile ZeroGSShaders and execute:
-
-./ZeroGSShaders ps2hw.fx ps2hw.dat
-
-For Windows users, once ZeroGSShaders is built, run buildshaders.bat directly. It will update all necessary resource files.
+ZeroGS OpenGL
+-------------
+author: zerofrog (@gmail.com)
+
+ZeroGS heavily uses GPU shaders. All the shaders are written in nVidia's Cg language and can be found in ps2hw.fx.
+
+'Dev' versions of ZeroGS directly read ps2hw.fx
+'Release' versions of ZeroGS read a precompiled version of ps2hw.fx from ps2hw.dat. In order to build ps2hw.dat, compile ZeroGSShaders and execute:
+
+./ZeroGSShaders ps2hw.fx ps2hw.dat
+
+For Windows users, once ZeroGSShaders is built, run buildshaders.bat directly. It will update all necessary resource files.
Note that ZeroGSShaders has only been tested in Windows so far, but the Windows ps2hw.dat can be used in linux builds.
\ No newline at end of file
diff --git a/plugins/zzogl-pg/opengl/ZZGl.h b/plugins/zzogl-pg/opengl/ZZGl.h
index 74ab676c43..c2979b7185 100644
--- a/plugins/zzogl-pg/opengl/ZZGl.h
+++ b/plugins/zzogl-pg/opengl/ZZGl.h
@@ -1,134 +1,134 @@
-/* ZZ Open GL graphics plugin
- * Copyright (c)2009-2010 zeydlitz@gmail.com, arcum42@gmail.com
- * Based on Zerofrog's ZeroGS KOSMOS (c)2005-2008
- *
- * 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
- */
-
-#ifndef ZZGL_H_INCLUDED
-#define ZZGL_H_INCLUDED
-
-#include "PS2Etypes.h"
-#include "PS2Edefs.h"
-
-// Need this before gl.h
-#ifdef _WIN32
-
-#include "Utilities/RedtapeWindows.h"
-
-#include
-#include
-#include "glprocs.h"
-
-#else
-
-// adding glew support instead of glXGetProcAddress (thanks to scaught)
-#include
-#include
-#include
-#include
-
-inline void* wglGetProcAddress(const char* x)
-{
- return (void*)glXGetProcAddress((const GLubyte*)x);
-}
-
-#endif
-
-extern u32 s_stencilfunc, s_stencilref, s_stencilmask;
-// Defines
-
-#ifndef GL_DEPTH24_STENCIL8_EXT // allows FBOs to support stencils
-# define GL_DEPTH_STENCIL_EXT 0x84F9
-# define GL_UNSIGNED_INT_24_8_EXT 0x84FA
-# define GL_DEPTH24_STENCIL8_EXT 0x88F0
-# define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1
-#endif
-
-#define GL_STENCILFUNC(func, ref, mask) { \
- s_stencilfunc = func; \
- s_stencilref = ref; \
- s_stencilmask = mask; \
- glStencilFunc(func, ref, mask); \
-}
-
-#define GL_STENCILFUNC_SET() glStencilFunc(s_stencilfunc, s_stencilref, s_stencilmask)
-
-
-// sets the data stream
-#define SET_STREAM() { \
- glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(VertexGPU), (void*)8); \
- glSecondaryColorPointerEXT(4, GL_UNSIGNED_BYTE, sizeof(VertexGPU), (void*)12); \
- glTexCoordPointer(3, GL_FLOAT, sizeof(VertexGPU), (void*)16); \
- glVertexPointer(4, GL_SHORT, sizeof(VertexGPU), (void*)0); \
-}
-
-
-// global alpha blending settings
-extern GLenum g_internalRGBAFloat16Fmt;
-
-#define SAFE_RELEASE_TEX(x) { if( (x) != 0 ) { glDeleteTextures(1, &(x)); x = 0; } }
-
-// inline for an extremely often used sequence
-// This is turning off all gl functions. Safe to do updates.
-inline void DisableAllgl()
-{
- glDisable(GL_SCISSOR_TEST);
- glDisable(GL_BLEND);
- glDisable(GL_ALPHA_TEST);
- glDisable(GL_DEPTH_TEST);
- glDepthMask(0);
- glDisable(GL_STENCIL_TEST);
- glColorMask(1, 1, 1, 1);
-}
-
-//--------------------- Dummies
-
-#ifdef _WIN32
-extern void (__stdcall *zgsBlendEquationSeparateEXT)(GLenum, GLenum);
-extern void (__stdcall *zgsBlendFuncSeparateEXT)(GLenum, GLenum, GLenum, GLenum);
-#else
-extern void (APIENTRY *zgsBlendEquationSeparateEXT)(GLenum, GLenum);
-extern void (APIENTRY *zgsBlendFuncSeparateEXT)(GLenum, GLenum, GLenum, GLenum);
-#endif
-
-
-// ------------------------ Types -------------------------
-
-/////////////////////
-// graphics resources
-extern GLenum s_srcrgb, s_dstrgb, s_srcalpha, s_dstalpha; // set by zgsBlendFuncSeparateEXT
-
-// GL prototypes
-extern PFNGLISRENDERBUFFEREXTPROC glIsRenderbufferEXT;
-extern PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT;
-extern PFNGLDELETERENDERBUFFERSEXTPROC glDeleteRenderbuffersEXT;
-extern PFNGLGENRENDERBUFFERSEXTPROC glGenRenderbuffersEXT;
-extern PFNGLRENDERBUFFERSTORAGEEXTPROC glRenderbufferStorageEXT;
-extern PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC glGetRenderbufferParameterivEXT;
-extern PFNGLISFRAMEBUFFEREXTPROC glIsFramebufferEXT;
-extern PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT;
-extern PFNGLDELETEFRAMEBUFFERSEXTPROC glDeleteFramebuffersEXT;
-extern PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT;
-extern PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glCheckFramebufferStatusEXT;
-extern PFNGLFRAMEBUFFERTEXTURE1DEXTPROC glFramebufferTexture1DEXT;
-extern PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glFramebufferTexture2DEXT;
-extern PFNGLFRAMEBUFFERTEXTURE3DEXTPROC glFramebufferTexture3DEXT;
-extern PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC glFramebufferRenderbufferEXT;
-extern PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC glGetFramebufferAttachmentParameterivEXT;
-extern PFNGLGENERATEMIPMAPEXTPROC glGenerateMipmapEXT;
-extern PFNGLDRAWBUFFERSPROC glDrawBuffers;
-
-#endif // ZZGL_H_INCLUDED
+/* ZZ Open GL graphics plugin
+ * Copyright (c)2009-2010 zeydlitz@gmail.com, arcum42@gmail.com
+ * Based on Zerofrog's ZeroGS KOSMOS (c)2005-2008
+ *
+ * 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
+ */
+
+#ifndef ZZGL_H_INCLUDED
+#define ZZGL_H_INCLUDED
+
+#include "PS2Etypes.h"
+#include "PS2Edefs.h"
+
+// Need this before gl.h
+#ifdef _WIN32
+
+#include "Utilities/RedtapeWindows.h"
+
+#include
+#include
+#include "glprocs.h"
+
+#else
+
+// adding glew support instead of glXGetProcAddress (thanks to scaught)
+#include
+#include
+#include
+#include
+
+inline void* wglGetProcAddress(const char* x)
+{
+ return (void*)glXGetProcAddress((const GLubyte*)x);
+}
+
+#endif
+
+extern u32 s_stencilfunc, s_stencilref, s_stencilmask;
+// Defines
+
+#ifndef GL_DEPTH24_STENCIL8_EXT // allows FBOs to support stencils
+# define GL_DEPTH_STENCIL_EXT 0x84F9
+# define GL_UNSIGNED_INT_24_8_EXT 0x84FA
+# define GL_DEPTH24_STENCIL8_EXT 0x88F0
+# define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1
+#endif
+
+#define GL_STENCILFUNC(func, ref, mask) { \
+ s_stencilfunc = func; \
+ s_stencilref = ref; \
+ s_stencilmask = mask; \
+ glStencilFunc(func, ref, mask); \
+}
+
+#define GL_STENCILFUNC_SET() glStencilFunc(s_stencilfunc, s_stencilref, s_stencilmask)
+
+
+// sets the data stream
+#define SET_STREAM() { \
+ glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(VertexGPU), (void*)8); \
+ glSecondaryColorPointerEXT(4, GL_UNSIGNED_BYTE, sizeof(VertexGPU), (void*)12); \
+ glTexCoordPointer(3, GL_FLOAT, sizeof(VertexGPU), (void*)16); \
+ glVertexPointer(4, GL_SHORT, sizeof(VertexGPU), (void*)0); \
+}
+
+
+// global alpha blending settings
+extern GLenum g_internalRGBAFloat16Fmt;
+
+#define SAFE_RELEASE_TEX(x) { if( (x) != 0 ) { glDeleteTextures(1, &(x)); x = 0; } }
+
+// inline for an extremely often used sequence
+// This is turning off all gl functions. Safe to do updates.
+inline void DisableAllgl()
+{
+ glDisable(GL_SCISSOR_TEST);
+ glDisable(GL_BLEND);
+ glDisable(GL_ALPHA_TEST);
+ glDisable(GL_DEPTH_TEST);
+ glDepthMask(0);
+ glDisable(GL_STENCIL_TEST);
+ glColorMask(1, 1, 1, 1);
+}
+
+//--------------------- Dummies
+
+#ifdef _WIN32
+extern void (__stdcall *zgsBlendEquationSeparateEXT)(GLenum, GLenum);
+extern void (__stdcall *zgsBlendFuncSeparateEXT)(GLenum, GLenum, GLenum, GLenum);
+#else
+extern void (APIENTRY *zgsBlendEquationSeparateEXT)(GLenum, GLenum);
+extern void (APIENTRY *zgsBlendFuncSeparateEXT)(GLenum, GLenum, GLenum, GLenum);
+#endif
+
+
+// ------------------------ Types -------------------------
+
+/////////////////////
+// graphics resources
+extern GLenum s_srcrgb, s_dstrgb, s_srcalpha, s_dstalpha; // set by zgsBlendFuncSeparateEXT
+
+// GL prototypes
+extern PFNGLISRENDERBUFFEREXTPROC glIsRenderbufferEXT;
+extern PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT;
+extern PFNGLDELETERENDERBUFFERSEXTPROC glDeleteRenderbuffersEXT;
+extern PFNGLGENRENDERBUFFERSEXTPROC glGenRenderbuffersEXT;
+extern PFNGLRENDERBUFFERSTORAGEEXTPROC glRenderbufferStorageEXT;
+extern PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC glGetRenderbufferParameterivEXT;
+extern PFNGLISFRAMEBUFFEREXTPROC glIsFramebufferEXT;
+extern PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT;
+extern PFNGLDELETEFRAMEBUFFERSEXTPROC glDeleteFramebuffersEXT;
+extern PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT;
+extern PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glCheckFramebufferStatusEXT;
+extern PFNGLFRAMEBUFFERTEXTURE1DEXTPROC glFramebufferTexture1DEXT;
+extern PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glFramebufferTexture2DEXT;
+extern PFNGLFRAMEBUFFERTEXTURE3DEXTPROC glFramebufferTexture3DEXT;
+extern PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC glFramebufferRenderbufferEXT;
+extern PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC glGetFramebufferAttachmentParameterivEXT;
+extern PFNGLGENERATEMIPMAPEXTPROC glGenerateMipmapEXT;
+extern PFNGLDRAWBUFFERSPROC glDrawBuffers;
+
+#endif // ZZGL_H_INCLUDED
diff --git a/plugins/zzogl-pg/opengl/ZZHacks.h b/plugins/zzogl-pg/opengl/ZZHacks.h
index f628cd9c36..2df9fd0981 100644
--- a/plugins/zzogl-pg/opengl/ZZHacks.h
+++ b/plugins/zzogl-pg/opengl/ZZHacks.h
@@ -1,5 +1,5 @@
-#ifndef ZZHACKS_H_INCLUDED
-#define ZZHACKS_H_INCLUDED
+#ifndef ZZHACKS_H_INCLUDED
+#define ZZHACKS_H_INCLUDED
#include "PS2Edefs.h"
@@ -42,7 +42,7 @@ enum GAME_HACK_OPTIONS
GAME_RESERVED_HACK = 0x80000000
};
-#define USEALPHATESTING (!(conf.settings().no_alpha_test))
+#define USEALPHATESTING (!(conf.settings().no_alpha_test))
typedef union
{
@@ -95,5 +95,5 @@ extern void ListHacks();
extern void DisplayHack(int hack);
extern void ChangeCurrentHack(int hack);
-
-#endif // ZZHACKS_H_INCLUDED
+
+#endif // ZZHACKS_H_INCLUDED
diff --git a/plugins/zzogl-pg/opengl/ZZoglFlushHack.h b/plugins/zzogl-pg/opengl/ZZoglFlushHack.h
index a23572e9e2..ef501296ce 100644
--- a/plugins/zzogl-pg/opengl/ZZoglFlushHack.h
+++ b/plugins/zzogl-pg/opengl/ZZoglFlushHack.h
@@ -23,7 +23,7 @@
* To avoid severals combo-box, the hack detects the game based on crc
*/
-#ifndef ZZOGL_FLUSH_HACK_H_INCLUDED
+#ifndef ZZOGL_FLUSH_HACK_H_INCLUDED
#define ZZOGL_FLUSH_HACK_H_INCLUDED
#include "GS.h"
diff --git a/plugins/zzogl-pg/opengl/ZZoglVB.h b/plugins/zzogl-pg/opengl/ZZoglVB.h
index 7b5684177e..890d985412 100644
--- a/plugins/zzogl-pg/opengl/ZZoglVB.h
+++ b/plugins/zzogl-pg/opengl/ZZoglVB.h
@@ -20,8 +20,8 @@
// Zerogs:VB implementation.
// VB stands for Visual Buffer, as I think
-#ifndef ZZOGLVB_H_INCLUDED
-#define ZZOGLVB_H_INCLUDED
+#ifndef ZZOGLVB_H_INCLUDED
+#define ZZOGLVB_H_INCLUDED
#include "targets.h"
@@ -150,9 +150,9 @@ class VB
CRenderTarget* prndr;
CDepthTarget* pdepth;
-};
+};
// VB variables
extern VB vb[2];
-
-#endif // ZZOGLVB_H_INCLUDED
+
+#endif // ZZOGLVB_H_INCLUDED
diff --git a/plugins/zzogl-pg/opengl/buildshaders.bat b/plugins/zzogl-pg/opengl/buildshaders.bat
index c7698558ae..a2ceb68b6e 100644
--- a/plugins/zzogl-pg/opengl/buildshaders.bat
+++ b/plugins/zzogl-pg/opengl/buildshaders.bat
@@ -1,3 +1,3 @@
-ZeroGSShaders.exe ps2hw.fx ps2hw.dat
-del Win32\ps2hw.dat Win32\Release\*.res Win32\Debug\*.res
+ZeroGSShaders.exe ps2hw.fx ps2hw.dat
+del Win32\ps2hw.dat Win32\Release\*.res Win32\Debug\*.res
move /y ps2hw.dat Win32\ps2hw.dat
\ No newline at end of file
diff --git a/plugins/zzogl-pg/opengl/ctx0/ps2hw_ctx.fx b/plugins/zzogl-pg/opengl/ctx0/ps2hw_ctx.fx
index 7988a22bb7..60e37ac4c0 100644
--- a/plugins/zzogl-pg/opengl/ctx0/ps2hw_ctx.fx
+++ b/plugins/zzogl-pg/opengl/ctx0/ps2hw_ctx.fx
@@ -1,24 +1,24 @@
-// main ps2 memory, each pixel is stored in 32bit color
-uniform samplerRECT g_sMemory : register(s0);
-
-// per context pixel shader constants
-uniform half4 fTexAlpha2 : register(c2);
-
-uniform float4 g_fTexOffset : register(c4); // converts the page and block offsets into the mem addr/1024
-uniform float4 g_fTexDims : register(c6); // mult by tex dims when accessing the block texture
-uniform float4 g_fTexBlock : register(c8);
-
-uniform float4 g_fClampExts : register(c10); // if clamping the texture, use (minu, minv, maxu, maxv)
-uniform float4 TexWrapMode : register(c12); // 0 - repeat/clamp, 1 - region rep (use fRegRepMask)
-
-uniform float4 g_fRealTexDims : register(c14); // tex dims used for linear filtering (w,h,1/w,1/h)
-
-// (alpha0, alpha1, 1 if highlight2 and tcc is rgba, 1-y)
-uniform half4 g_fTestBlack : register(c16); // used for aem bit
-
-uniform float4 g_fPageOffset : register(c18);
-
-uniform half4 fTexAlpha : register(c20);
-
-// vertex shader constants
+// main ps2 memory, each pixel is stored in 32bit color
+uniform samplerRECT g_sMemory : register(s0);
+
+// per context pixel shader constants
+uniform half4 fTexAlpha2 : register(c2);
+
+uniform float4 g_fTexOffset : register(c4); // converts the page and block offsets into the mem addr/1024
+uniform float4 g_fTexDims : register(c6); // mult by tex dims when accessing the block texture
+uniform float4 g_fTexBlock : register(c8);
+
+uniform float4 g_fClampExts : register(c10); // if clamping the texture, use (minu, minv, maxu, maxv)
+uniform float4 TexWrapMode : register(c12); // 0 - repeat/clamp, 1 - region rep (use fRegRepMask)
+
+uniform float4 g_fRealTexDims : register(c14); // tex dims used for linear filtering (w,h,1/w,1/h)
+
+// (alpha0, alpha1, 1 if highlight2 and tcc is rgba, 1-y)
+uniform half4 g_fTestBlack : register(c16); // used for aem bit
+
+uniform float4 g_fPageOffset : register(c18);
+
+uniform half4 fTexAlpha : register(c20);
+
+// vertex shader constants
uniform float4 g_fPosXY : register(c2);
\ No newline at end of file
diff --git a/plugins/zzogl-pg/opengl/ctx1/ps2hw_ctx.fx b/plugins/zzogl-pg/opengl/ctx1/ps2hw_ctx.fx
index c6332c1a59..58c755ea92 100644
--- a/plugins/zzogl-pg/opengl/ctx1/ps2hw_ctx.fx
+++ b/plugins/zzogl-pg/opengl/ctx1/ps2hw_ctx.fx
@@ -1,23 +1,23 @@
-uniform samplerRECT g_sMemory : register(s1);
-
-// per context pixel shader constants
-uniform half4 fTexAlpha2 : register(c3);
-
-uniform float4 g_fTexOffset : register(c5); // converts the page and block offsets into the mem addr/1024
-uniform float4 g_fTexDims : register(c7); // mult by tex dims when accessing the block texture
-uniform float4 g_fTexBlock : register(c9);
-
-uniform float4 g_fClampExts : register(c11); // if clamping the texture, use (minu, minv, maxu, maxv)
-uniform float4 TexWrapMode : register(c13); // 0 - repeat/clamp, 1 - region rep (use fRegRepMask)
-
-uniform float4 g_fRealTexDims : register(c15); // tex dims used for linear filtering (w,h,1/w,1/h)
-
-// (alpha0, alpha1, 1 if highlight2 and tcc is rgba, 1-y)
-uniform half4 g_fTestBlack : register(c17); // used for aem bit
-
-uniform float4 g_fPageOffset : register(c19);
-
-uniform half4 fTexAlpha : register(c21);
-
-// vertex shader constants
+uniform samplerRECT g_sMemory : register(s1);
+
+// per context pixel shader constants
+uniform half4 fTexAlpha2 : register(c3);
+
+uniform float4 g_fTexOffset : register(c5); // converts the page and block offsets into the mem addr/1024
+uniform float4 g_fTexDims : register(c7); // mult by tex dims when accessing the block texture
+uniform float4 g_fTexBlock : register(c9);
+
+uniform float4 g_fClampExts : register(c11); // if clamping the texture, use (minu, minv, maxu, maxv)
+uniform float4 TexWrapMode : register(c13); // 0 - repeat/clamp, 1 - region rep (use fRegRepMask)
+
+uniform float4 g_fRealTexDims : register(c15); // tex dims used for linear filtering (w,h,1/w,1/h)
+
+// (alpha0, alpha1, 1 if highlight2 and tcc is rgba, 1-y)
+uniform half4 g_fTestBlack : register(c17); // used for aem bit
+
+uniform float4 g_fPageOffset : register(c19);
+
+uniform half4 fTexAlpha : register(c21);
+
+// vertex shader constants
uniform float4 g_fPosXY : register(c3);
\ No newline at end of file
diff --git a/plugins/zzogl-pg/opengl/ps2hw.fx b/plugins/zzogl-pg/opengl/ps2hw.fx
index c76252ba26..43c14ca029 100644
--- a/plugins/zzogl-pg/opengl/ps2hw.fx
+++ b/plugins/zzogl-pg/opengl/ps2hw.fx
@@ -1,849 +1,849 @@
-// Cg Shaders for PS2 GS emulation
-
-// divides by z for every pixel, instead of in vertex shader
-// fixes kh textures
-#define PERSPECTIVE_CORRECT_TEX
-
-//#define TEST_AEM // tests AEM for black pixels
-//#define REGION_REPEAT // set if texture wrapping mode is region repeat
-//#define WRITE_DEPTH // set if depth is also written in a MRT
-//#define ACCURATE_DECOMPRESSION // set for less capable hardware ATI Radeon 9000 series
-//#define EXACT_COLOR // make sure the output color is clamped to 1/255 boundaries (for alpha testing)
-
-#ifdef PERSPECTIVE_CORRECT_TEX
-#define TEX_XY tex.xy/tex.z
-#define TEX_DECL float3
-#else
-#define TEX_XY tex.xy
-#define TEX_DECL float2
-#endif
-
-#ifdef WRITE_DEPTH
-#define DOZWRITE(x) x
-#else
-#define DOZWRITE(x)
-#endif
-
-#include "ps2hw_ctx.fx"
-
-// used to get the tiled offset into a page given the linear offset
-uniform samplerRECT g_sSrcFinal : register(s2);
-uniform sampler2D g_sBlocks : register(s3);
-uniform sampler2D g_sBilinearBlocks : register(s4);
-uniform sampler2D g_sConv16to32 : register(s4);
-uniform sampler3D g_sConv32to16 : register(s4);
-uniform samplerRECT g_sBitwiseANDX : register(s5);
-uniform samplerRECT g_sBitwiseANDY : register(s6);
-uniform samplerRECT g_sInterlace : register(s7);
-
-// used only on rare cases where the render target is PSMT8H
-uniform sampler2D g_sCLUT : register(s2);
-
-// global pixel shader constants
-uniform float4 g_fInvTexDims : register(c22); // similar to g_fClutOff
-uniform float4 g_fFogColor : register(c23);
-
-// used for rectblitting
-uniform float4 g_fBitBltZ : register(c24);
-
-uniform half4 g_fOneColor : register(c25); // col*.xxxy+.zzzw
-
-// vertex shader constants
-uniform float4 g_fBitBltPos : register(c4);
-uniform float4 g_fZ : register(c5); // transforms d3dcolor z into float z
-uniform float4 g_fZNorm : register(c6);
-uniform float4 g_fZMin: register(c26) = float4(0.0f, 1.0f, 0.0f, 0.0f);
-uniform float4 g_fBitBltTex : register(c7);
-
-// pixel shader consts
-// .z is used for the addressing fn
-uniform half4 g_fExactColor : register(c27) = half4(0.5,0.5/256.0f,0,1/255.0f);
-uniform float4 g_fBilinear : register(c28) = float4(-0.7f, -0.65f, 0.9,1/32767.0f);
-uniform float4 g_fZBias : register(c29) = half4(1.0f/256.0f, 1.0004f, 1, 0.5); // also for vs
-uniform float4 g_fc0 : register(c30) = float4(0,1, 0.001, 0.5f); // also for vs
-uniform float4 g_fMult : register(c31) = float4(1/1024.0f, 0.2f/1024.0f, 1/128.0f, 1/512.0f);
-
-// vertex shader consts
-uniform float4 g_fBitBltTrans : register(c31) = float4(0.5f, -0.5f, 0.5, 0.5 + 0.4/416.0f);
-
-// given a local tex coord, returns the coord in the memory
-float2 ps2memcoord(float2 realtex)
-{
- float4 off;
-
- // block off
- realtex.xy = realtex.xy * g_fTexDims.xy + g_fTexDims.zw;
- realtex.xy = (realtex.xy - frac(realtex.xy)) * g_fMult.zw;
- float2 fblock = frac(realtex.xy);
- off.xy = realtex.xy-fblock.xy;
-
-#ifdef ACCURATE_DECOMPRESSION
- off.zw = tex2D(g_sBlocks, g_fTexBlock.xy*fblock + g_fTexBlock.zw).ar;
- off.x = dot(off.xy, g_fTexOffset.xy);
- float r = g_fTexOffset.w;
- float f = frac(off.x);
- float fadd = g_fTexOffset.z * off.z;
- off.w = off.x + fadd + r;
- off.x = frac(f + fadd + r);
- off.w -= off.x ;
-#else
- off.z = tex2D(g_sBlocks, g_fTexBlock.xy*fblock + g_fTexBlock.zw).a;
-
- // combine the two
- off.x = dot(off.xyz, g_fTexOffset.xyz)+g_fTexOffset.w;
- off.x = modf(off.x, off.w);
-#endif
-
- off.xy = off.xw * g_fPageOffset.zy + g_fPageOffset.wx;
- //off.y = off.w * g_fPageOffset.y + g_fPageOffset.x;
- return off.xy;
-}
-
-// find all texcoords for bilinear filtering
-// assume that orgtex are already on boundaries
-void ps2memcoord4(float4 orgtex, out float4 off0, out float4 off1)
-{
- //float4 off0, off1, off2, off3;
- float4 realtex;
-
- // block off
- realtex = (orgtex * g_fTexDims.xyxy + g_fTexDims.zwzw);// * g_fMult.zwzw;
- float4 fblock = frac(realtex.xyzw);
- float4 ftransblock = g_fTexBlock.xyxy*fblock + g_fTexBlock.zwzw;
- realtex -= fblock;
-
- float4 transvals = g_fTexOffset.x * realtex.xzxz + g_fTexOffset.y * realtex.yyww + g_fTexOffset.w;
-
- float4 colors;// = tex2D(g_sBilinearBlocks, ftransblock.xy);
-
- // this is faster on ffx ingame
- colors.x = tex2D(g_sBlocks, ftransblock.xy).a;
- colors.y = tex2D(g_sBlocks, ftransblock.zy).a;
- colors.z = tex2D(g_sBlocks, ftransblock.xw).a;
- colors.w = tex2D(g_sBlocks, ftransblock.zw).a;
-
- float4 fr, rem;
-
-#ifdef ACCURATE_DECOMPRESSION
- fr = frac(transvals);
- float4 fadd = colors * g_fTexOffset.z;
- rem = transvals + fadd;
- fr = frac(fr + fadd);
- rem -= fr;
-#else
- transvals += colors * g_fTexOffset.z;
-
- fr = modf(transvals, rem);
-#endif
-
- rem = rem * g_fPageOffset.y + g_fPageOffset.x;
- fr = fr * g_fPageOffset.z + g_fPageOffset.w;
-
- // combine
- off0 = g_fc0.yxyx * fr.xxyy + g_fc0.xyxy * rem.xxyy;
- off1 = g_fc0.yxyx * fr.zzww + g_fc0.xyxy * rem.zzww;
-}
-
-void ps2memcoord4_fast(float4 orgtex, out float4 off0, out float4 off1)
-{
- float4 realtex;
-
- realtex = (orgtex * g_fTexDims.xyxy + g_fTexDims.zwzw);// * g_fMult.zwzw;
- float4 fblock = frac(realtex.xyzw);
- float2 ftransblock = g_fTexBlock.xy*fblock.xy + g_fTexBlock.zw;
- realtex -= fblock;
-
- float4 transvals = g_fTexOffset.x * realtex.xzxz + g_fTexOffset.y * realtex.yyww + g_fTexOffset.w;
-
- float4 colors = tex2D(g_sBilinearBlocks, ftransblock.xy);
- float4 fr, rem;
-
-#ifdef ACCURATE_DECOMPRESSION
- fr = frac(transvals);
- float4 fadd = colors * g_fTexOffset.z;
- rem = transvals + fadd;
- fr = frac(fr + fadd);
- rem -= fr;
-#else
- transvals += colors * g_fTexOffset.z;
-
- fr = modf(transvals, rem);
-#endif
-
- rem = rem * g_fPageOffset.y + g_fPageOffset.x;
- fr = fr * g_fPageOffset.z;
-
- off0 = g_fc0.yxyx * fr.xxyy + g_fc0.xyxy * rem.xxyy;
- off1 = g_fc0.yxyx * fr.zzww + g_fc0.xyxy * rem.zzww;
-}
-
-// Wrapping modes
-#if defined(REPEAT)
-
-float2 ps2addr(float2 coord)
-{
- return frac(coord.xy);
-}
-
-#elif defined(CLAMP)
-
-float2 ps2addr(float2 coord)
-{
- return clamp(coord.xy, g_fClampExts.xy, g_fClampExts.zw);
-}
-
-#elif defined(REGION_REPEAT)
-
-// computes the local tex coord along with addressing modes
-float2 ps2addr(float2 coord)
-{
- float2 final = frac(clamp(coord.xy, g_fClampExts.xy, g_fClampExts.zw));
-
- if( TexWrapMode.x > g_fBilinear.z ) // region repeat mode for x (umsk&x)|ufix
- final.x = texRECT(g_sBitwiseANDX, abs(coord.x)*TexWrapMode.zx).x * g_fClampExts.x + g_fClampExts.z;
- if( TexWrapMode.y > g_fBilinear.z ) // region repeat mode for x (vmsk&x)|vfix
- final.y = texRECT(g_sBitwiseANDY, abs(coord.y)*TexWrapMode.wy).x * g_fClampExts.y + g_fClampExts.w;
-
- return final;
-}
-
-#else
-
-float2 ps2addr(float2 coord)
-{
- return frac(clamp(coord.xy, g_fClampExts.xy, g_fClampExts.zw));
-}
-
-#endif
-
-half4 tex2DPS_32(float2 tex0)
-{
- return texRECT(g_sMemory, ps2memcoord(tex0).xy);
-}
-
-// use when texture is not tiled -- shader 1
-half4 tex2DPS_tex32(float2 tex0)
-{
- return texRECT(g_sMemory, g_fTexDims.xy*tex0+g_fTexDims.zw)*g_fZBias.zzzw+g_fPageOffset.w;
-}
-
-// use when texture is not tiled -- shader 2
-half4 tex2DPS_clut32(float2 tex0)
-{
- float index = texRECT(g_sMemory, g_fTexDims.xy*tex0+g_fTexDims.zw).a+g_fPageOffset.w;
- return tex2D(g_sCLUT, index*g_fExactColor.xz+g_fExactColor.yz);
-}
-
-// Shader 3
-// use when texture is not tiled and converting from 32bit to 16bit
-// don't convert on the block level, only on the column level
-// so every other 8 pixels, use the upper bits instead of lower
-half4 tex2DPS_tex32to16(float2 tex0)
-{
- bool upper = false;
- tex0.y += g_fPageOffset.z;
- float2 ffrac = fmod(tex0, g_fTexOffset.xy);
- tex0.xy = g_fc0.ww * (tex0.xy + ffrac);
- if( ffrac.x > g_fTexOffset.z ) {
- tex0.x -= g_fTexOffset.z;
- upper = true;
- }
- if( ffrac.y >= g_fTexOffset.w ) {
- tex0.y -= g_fTexOffset.w;
- tex0.x += g_fc0.w;
- }
-
- half4 color = texRECT(g_sMemory, g_fTexDims.xy*tex0+g_fTexDims.zw)*g_fZBias.zzzw+g_fPageOffset.w;
- float2 uv = upper ? color.xw : color.zy;
- return tex2D(g_sConv16to32, uv+g_fPageOffset.xy);
-}
-
-// Shader 4
-// used when a 16 bit texture is used an 8h
-half4 tex2DPS_tex16to8h(float2 tex0)
-{
- float4 final;
- float2 ffrac = fmod(tex0+g_fPageOffset.zw, g_fTexOffset.xy);
- tex0.xy = g_fPageOffset.xy * tex0.xy - ffrac * g_fc0.yw;
-
- if( ffrac.x > g_fTexOffset.x*g_fc0.w )
- tex0.x += g_fTexOffset.x*g_fc0.w;
- if( tex0.x >= g_fc0.y ) tex0 += g_fTexOffset.zw;
-
- float4 upper = texRECT(g_sMemory, g_fTexDims.xy*tex0+g_fTexDims.zw);
-
- // only need alpha
- float index = tex3D(g_sConv32to16, upper.zyx-g_fc0.z).y + upper.w*g_fc0.w*g_fc0.w;
- return tex2D(g_sCLUT, index+g_fExactColor.yz);
-}
-
-// Shader 5
-// used when a 16 bit texture is used a 32bit one
-half4 tex2DPS_tex16to32(float2 tex0)
-{
- float4 final;
- float2 ffrac = fmod(tex0+g_fPageOffset.zw, g_fTexOffset.xy);
- //tex0.xy = g_fPageOffset.xy * tex0.xy - ffrac * g_fc0.yw;
- tex0.y += g_fPageOffset.y * ffrac.y;
-
- if( ffrac.x > g_fTexOffset.z ) {
- tex0.x -= g_fTexOffset.z;
- tex0.y += g_fTexOffset.w;
- }
-
- float fconst = g_fc0.w*g_fc0.w;
- float4 lower = tex2D(g_sSrcFinal, g_fTexDims.xy*tex0);
- float4 upper = tex2D(g_sMemory, g_fTexDims.xy*tex0+g_fTexDims.zw);
-
- final.zy = tex3D(g_sConv32to16, lower.zyx).xy + lower.ww*fconst;
- final.xw = tex3D(g_sConv32to16, upper.zyx).xy + upper.ww*fconst;
- return final;
-}
-
-
-//half4 f;
-//f.w = old.y > (127.2f/255.0f) ? 1 : 0;
-//old.y -= 0.5f * f.w;
-//f.xyz = frac(old.yyx*half3(2.002*255.0f/256.0f, 64.025f*255.0f/256.0f, 8.002*255.0f/256.0f));
-//f.y += old.x * (0.25f*255.0f/256.0f);
-
-////////////////////////////////
-// calculates the texture color
-////////////////////////////////
-
-#define decl_ps2shade(num) \
-decl_ps2shade_##num(_32) \
-decl_ps2shade_##num(_tex32) \
-decl_ps2shade_##num(_clut32) \
-decl_ps2shade_##num(_tex32to16) \
-decl_ps2shade_##num(_tex16to8h) \
-decl_ps2shade_##num(_tex16to32h) \
-
-// nearest
-#define decl_ps2shade_0(bit) \
-float4 ps2shade0##bit( TEX_DECL tex) \
-{ \
- return tex2DPS##bit( ps2addr(TEX_XY)); \
-} \
-
-// do fast memcoord4 calcs when textures behave well
-#ifdef REPEAT
-#define PS2MEMCOORD4 ps2memcoord4
-#else
-#define PS2MEMCOORD4 ps2memcoord4
-#endif
-
-#define decl_BilinearFilter(bit, addrfn) \
-half4 BilinearFilter##bit(float2 tex0) \
-{ \
- float4 off0, off1; \
- float4 ftex; \
- float2 ffrac; \
- ftex.xy = tex0 + g_fBilinear.xy * g_fRealTexDims.zw; \
- ffrac = frac(ftex.xy*g_fRealTexDims.xy); \
- ftex.xy -= ffrac.xy * g_fRealTexDims.zw; \
- \
- ftex.zw = ps2addr(ftex.xy + g_fRealTexDims.zw); \
- ftex.xy = ps2addr(ftex.xy); \
- \
- PS2MEMCOORD4(ftex, off0, off1); \
- half4 c0 = texRECT(g_sMemory, off0.xy); \
- half4 c1 = texRECT(g_sMemory, off0.zw); \
- half4 c2 = texRECT(g_sMemory, off1.xy); \
- half4 c3 = texRECT(g_sMemory, off1.zw); \
- return lerp( lerp(c0, c1, ffrac.x), lerp(c2, c3, ffrac.x), ffrac.y ); \
-} \
-
-decl_BilinearFilter(_32, ps2addr)
-decl_BilinearFilter(_tex32, ps2addr)
-decl_BilinearFilter(_clut32, ps2addr)
-decl_BilinearFilter(_tex32to16, ps2addr)
-decl_BilinearFilter(_tex16to8h, ps2addr)
-decl_BilinearFilter(_tex16to32h, ps2addr)
-
-//TODO! For mip maps, only apply when LOD >= 0
-// lcm == 0, LOD = log(1/Q)*L + K, lcm == 1, LOD = K
-
-// bilinear
-#define decl_ps2shade_1(bit) \
-half4 ps2shade1##bit(TEX_DECL tex) \
-{ \
- return BilinearFilter##bit(TEX_XY); \
-} \
-
-// nearest, mip nearest
-#define decl_ps2shade_2(bit) \
-half4 ps2shade2##bit(TEX_DECL tex) \
-{ \
- return tex2DPS##bit( ps2addr(TEX_XY)); \
-} \
-
-// nearest, mip linear
-#define decl_ps2shade_3(bit) \
-half4 ps2shade3##bit(TEX_DECL tex) \
-{ \
- return tex2DPS##bit(ps2addr(TEX_XY)); \
-} \
-
-// linear, mip nearest
-#define decl_ps2shade_4(bit) \
-half4 ps2shade4##bit(TEX_DECL tex) \
-{ \
- return BilinearFilter##bit(TEX_XY); \
-} \
-
-// linear, mip linear
-#define decl_ps2shade_5(bit) \
-half4 ps2shade5##bit(TEX_DECL tex) \
-{ \
- return BilinearFilter##bit(TEX_XY); \
-} \
-
-decl_ps2shade(0)
-decl_ps2shade(1)
-decl_ps2shade(2)
-decl_ps2shade(3)
-decl_ps2shade(4)
-decl_ps2shade(5)
-
-half4 ps2CalcShade(half4 texcol, half4 color)
-{
-#ifdef TEST_AEM
- if( dot(texcol.xyzw, g_fTestBlack.xyzw) <= g_fc0.z )
- texcol.w = g_fc0.x;
- else
-#endif
- texcol.w = texcol.w * fTexAlpha.y + fTexAlpha.x;
-
- texcol = texcol * (fTexAlpha2.zzzw * color + fTexAlpha2.xxxy) + fTexAlpha.zzzw * color.wwww;
-
- return texcol;
-}
-
-// final ops on the color
-#ifdef EXACT_COLOR
-
-half4 ps2FinalColor(half4 col)
-{
- // g_fOneColor has to scale by 255
- half4 temp = col * g_fOneColor.xxxy + g_fOneColor.zzzw;
- temp.w = floor(temp.w)*g_fExactColor.w;
- return temp;
-}
-
-#else
-half4 ps2FinalColor(half4 col)
-{
- return col * g_fOneColor.xxxy + g_fOneColor.zzzw;
-}
-#endif
-
-////////////////
-// Techniques //
-////////////////
-
-// technique to copy a rectangle from source to target
-struct VSOUT_
-{
- float4 pos : POSITION;
- half4 color : COLOR0;
- DOZWRITE(float4 z : TEXCOORD0;)
-};
-
-struct VSOUT_T
-{
- float4 pos : POSITION;
- half4 color : COLOR0;
- TEX_DECL tex : TEXCOORD0;
- DOZWRITE(float4 z : TEXCOORD1;)
-};
-
-struct VSOUT_F
-{
- float4 pos : POSITION;
- half4 color : COLOR0;
- float fog : TEXCOORD0;
- DOZWRITE(float4 z : TEXCOORD1;)
-};
-
-struct VSOUT_TF
-{
- float4 pos : POSITION;
- half4 color : COLOR0;
- TEX_DECL tex : TEXCOORD0;
- half fog : TEXCOORD1;
- DOZWRITE(float4 z : TEXCOORD2;)
-};
-
-// just smooth shadering
-VSOUT_ RegularVS(float4 pos : POSITION,
- half4 color : COLOR0,
- float4 z : COLOR1
- )
-{
- VSOUT_ o;
-
- o.pos.xy = pos.xy*g_fPosXY.xy+g_fPosXY.zw;
- o.pos.z = (log(g_fc0.y+dot(g_fZ, z.zyxw))*g_fZNorm.x+g_fZNorm.y) * g_fZMin.y + dot(g_fZ, z.zyxw) * g_fZMin.x ;
- o.pos.w = g_fc0.y; // 1
- o.color = color;
-
- DOZWRITE(o.z = z*g_fZBias.x+g_fZBias.y; o.z.w = g_fc0.y;)
- return o;
-}
-
-void RegularPS(VSOUT_ i, out float4 c0 : COLOR0
-#ifdef WRITE_DEPTH
- , out float4 c1 : COLOR1
-#endif
- )
-{
- // whenever outputting depth, make sure to mult by 255/256 and 1
- c0 = ps2FinalColor(i.color);
- DOZWRITE(c1 = i.z;)
-}
-
-// diffuse texture mapping
-VSOUT_T TextureVS(float4 pos : POSITION,
- half4 color : COLOR0,
- float4 z : COLOR1,
- float3 tex0 : TEXCOORD0)
-{
- VSOUT_T o;
- o.pos.xy = pos.xy*g_fPosXY.xy+g_fPosXY.zw;
- o.pos.z = (log(g_fc0.y+dot(g_fZ, z.zyxw))*g_fZNorm.x + g_fZNorm.y) * g_fZMin.y + dot(g_fZ, z.zyxw) * g_fZMin.x ;
- o.pos.w = g_fc0.y;
- o.color = color;
- DOZWRITE(o.z = z*g_fZBias.x+g_fZBias.y; o.z.w = g_fc0.y;)
-#ifdef PERSPECTIVE_CORRECT_TEX
- o.tex = tex0;
-#else
- o.tex = tex0.xy/tex0.z;
-#endif
- return o;
-}
-
-#ifdef WRITE_DEPTH
-
-#define DECL_TEXPS(num, bit) \
-void Texture##num##bit##PS(VSOUT_T i, out half4 c0 : COLOR0, out float4 c1 : COLOR1) \
-{ \
- c0 = ps2FinalColor(ps2CalcShade(ps2shade##num##bit(i.tex), i.color)); \
- c1 = i.z; \
-} \
-
-#else
-
-#define DECL_TEXPS(num, bit) \
-void Texture##num##bit##PS(VSOUT_T i, out half4 c0 : COLOR0) \
-{ \
- c0 = ps2FinalColor(ps2CalcShade(ps2shade##num##bit(i.tex), i.color)); \
-} \
-
-#endif
-
-#define DECL_TEXPS_(num) \
-DECL_TEXPS(num, _32) \
-DECL_TEXPS(num, _tex32) \
-DECL_TEXPS(num, _clut32) \
-DECL_TEXPS(num, _tex32to16) \
-DECL_TEXPS(num, _tex16to8h) \
-
-DECL_TEXPS_(0)
-DECL_TEXPS_(1)
-DECL_TEXPS_(2)
-DECL_TEXPS_(3)
-DECL_TEXPS_(4)
-DECL_TEXPS_(5)
-
-VSOUT_F RegularFogVS(float4 pos : POSITION,
- half4 color : COLOR0,
- float4 z : COLOR1)
-{
- VSOUT_F o;
-
- o.pos.xy = pos.xy*g_fPosXY.xy+g_fPosXY.zw;
- o.pos.z = (log(g_fc0.y+dot(g_fZ, z.zyxw))*g_fZNorm.x+g_fZNorm.y) * g_fZMin.y + dot(g_fZ, z.zyxw) * g_fZMin.x ;
- o.pos.w = g_fc0.y;
- DOZWRITE(o.z = z*g_fZBias.x+g_fZBias.y; o.z.w = g_fc0.y;)
- o.color = color;
- o.fog = pos.z*g_fBilinear.w;
- return o;
-}
-
-void RegularFogPS(VSOUT_F i, out half4 c0 : COLOR0
-#ifdef WRITE_DEPTH
- , out float4 c1 : COLOR1
-#endif
- )
-{
- half4 c;
- c.xyz = lerp(g_fFogColor.xyz, i.color.xyz, i.fog);
- c.w = i.color.w;
- c0 = ps2FinalColor(c);
- DOZWRITE(c1 = i.z;)
-}
-
-VSOUT_TF TextureFogVS(float4 pos : POSITION,
- half4 color : COLOR0,
- float4 z : COLOR1,
- float3 tex0 : TEXCOORD0)
-{
- VSOUT_TF o;
-
- o.pos.xy = pos.xy*g_fPosXY.xy+g_fPosXY.zw;
- o.pos.z = (log(g_fc0.y+dot(g_fZ, z.zyxw))*g_fZNorm.x+g_fZNorm.y) * g_fZMin.y + dot(g_fZ, z.zyxw) * g_fZMin.x ;
- o.pos.w = g_fc0.y;
- o.color = color;
- o.fog = pos.z*g_fBilinear.w;
- DOZWRITE(o.z = z*g_fZBias.x+g_fZBias.y; o.z.w = g_fc0.y;)
-#ifdef PERSPECTIVE_CORRECT_TEX
- o.tex = tex0;
-#else
- o.tex = tex0.xy/tex0.z;
-#endif
- return o;
-}
-
-#ifdef WRITE_DEPTH
-
-#define DECL_TEXFOGPS(num, bit) \
-void TextureFog##num##bit##PS(VSOUT_TF i, out half4 c0 : COLOR0, out float4 c1 : COLOR1 ) \
-{ \
- half4 c = ps2CalcShade(ps2shade##num##bit(i.tex), i.color); \
- c.xyz = lerp(g_fFogColor.xyz, c.xyz, i.fog); \
- c0 = ps2FinalColor(c); \
- c1 = i.z; \
-} \
-
-#else
-
-#define DECL_TEXFOGPS(num, bit) \
-void TextureFog##num##bit##PS(VSOUT_TF i, out half4 c0 : COLOR0) \
-{ \
- half4 c = ps2CalcShade(ps2shade##num##bit(i.tex), i.color); \
- c.xyz = lerp(g_fFogColor.xyz, c.xyz, i.fog); \
- c0 = ps2FinalColor(c); \
-} \
-
-#endif
-
-#define DECL_TEXFOGPS_(num) \
-DECL_TEXFOGPS(num, _32) \
-DECL_TEXFOGPS(num, _tex32) \
-DECL_TEXFOGPS(num, _clut32) \
-DECL_TEXFOGPS(num, _tex32to16) \
-DECL_TEXFOGPS(num, _tex16to8h) \
-
-DECL_TEXFOGPS_(0)
-DECL_TEXFOGPS_(1)
-DECL_TEXFOGPS_(2)
-DECL_TEXFOGPS_(3)
-DECL_TEXFOGPS_(4)
-DECL_TEXFOGPS_(5)
-
-//-------------------------------------------------------
-// Techniques not related to the main primitive commands
-half4 BilinearBitBlt(float2 tex0)
-{
- float4 ftex;
- float2 ffrac;
-
- ffrac.xy = frac(tex0*g_fRealTexDims.xy);
- ftex.xy = tex0 - ffrac.xy * g_fRealTexDims.zw;
- ftex.zw = ftex.xy + g_fRealTexDims.zw;
-
- float4 off0, off1;
- ps2memcoord4_fast(ftex, off0, off1);
- half4 c0 = texRECT(g_sMemory, off0.xy);
- half4 c1 = texRECT(g_sMemory, off0.zw);
- half4 c2 = texRECT(g_sMemory, off1.xy);
- half4 c3 = texRECT(g_sMemory, off1.zw);
-
- return lerp( lerp(c0, c1, ffrac.x), lerp(c2, c3, ffrac.x), ffrac.y );
-}
-
-void BitBltVS(in float4 pos : POSITION,
- in half4 tex0 : COLOR1,
- in float3 tex : TEXCOORD0,
- out float4 opos : POSITION,
- out float2 otex0 : TEXCOORD0,
- out float2 ointerpos : TEXCOORD1)
-{
- opos.xy = pos.xy * g_fBitBltPos.xy + g_fBitBltPos.zw;
- ointerpos = opos.xy * g_fBitBltTrans.xy + g_fBitBltTrans.zw;
- opos.zw = g_fc0.xy;
- otex0 = tex.xy * g_fBitBltTex.xy + g_fBitBltTex.zw;
-}
-
-half4 BitBltPS(in float2 tex0 : TEXCOORD0) : COLOR
-{
- return texRECT(g_sMemory, ps2memcoord(tex0).xy)*g_fOneColor.xxxy;
-}
-
-// used when AA
-half4 BitBltAAPS(in float2 tex0 : TEXCOORD0) : COLOR
-{
- return BilinearBitBlt(tex0)*g_fOneColor.xxxy;
-}
-
-void BitBltDepthPS(in float2 tex0 : TEXCOORD0,
- out float4 c : COLOR0,
- out float depth : DEPTH)
-{
- c = texRECT(g_sMemory, ps2memcoord(tex0));
-
- depth = (log(g_fc0.y+dot(c, g_fBitBltZ))*g_fOneColor.w) * g_fZMin.y + dot(c, g_fBitBltZ) * g_fZMin.x ;
- c += g_fZBias.y;
-}
-
-void BitBltDepthMRTPS(in float2 tex0 : TEXCOORD0,
- out half4 c0 : COLOR0,
- out float4 c1 : COLOR1,
- out float depth : DEPTH)
-{
- c1 = texRECT(g_sMemory, ps2memcoord(tex0));
-
- depth = (log(g_fc0.y+dot(c1, g_fBitBltZ))*g_fOneColor.w) * g_fZMin.y + dot(c1, g_fBitBltZ) * g_fZMin.x ;
- c1 += g_fZBias.y;
- c0 = g_fc0.x;
-}
-
-/*static const float BlurKernel[9] = {
- 0.027601,
- 0.066213,
- 0.123701,
- 0.179952,
- 0.205065,
- 0.179952,
- 0.123701,
- 0.066213,
- 0.027601
-};*/
-
-half4 BilinearFloat16(float2 tex0)
-{
- return texRECT(g_sSrcFinal, tex0.xy);
-}
-
-half4 CRTCTargInterPS(in float2 tex0 : TEXCOORD0, in float2 ointerpos : TEXCOORD1) : COLOR
-{
- float finter = texRECT(g_sInterlace, ointerpos.yy).x * g_fOneColor.z + g_fOneColor.w + g_fc0.w;
- float4 c = BilinearFloat16(tex0);
- c.w = ( g_fc0.w*c.w * g_fOneColor.x + g_fOneColor.y ) * finter;
- return c;
-}
-
-half4 CRTCTargPS(in float2 tex0 : TEXCOORD0) : COLOR
-{
- float4 c = BilinearFloat16(tex0);
- c.w = g_fc0.w*c.w * g_fOneColor.x + g_fOneColor.y;
- return c;
-}
-
-half4 CRTCInterPS(in float2 tex0 : TEXCOORD0, in float2 ointerpos : TEXCOORD1) : COLOR
-{
- float finter = texRECT(g_sInterlace, ointerpos.yy).x * g_fOneColor.z + g_fOneColor.w + g_fc0.w;
- float2 filtcoord = (tex0-frac(tex0))*g_fInvTexDims.xy+g_fInvTexDims.zw;
- half4 c = BilinearBitBlt(filtcoord);
- c.w = (c.w * g_fOneColor.x + g_fOneColor.y)*finter;
-
- return c;
-}
-
-// simpler
-half4 CRTCInterPS_Nearest(in float2 tex0 : TEXCOORD0, in float2 ointerpos : TEXCOORD1) : COLOR
-{
- float finter = texRECT(g_sInterlace, ointerpos.yy).x * g_fOneColor.z + g_fOneColor.w + g_fc0.w;
- half4 c = texRECT(g_sMemory, ps2memcoord(tex0).xy);
- c.w = (c.w * g_fOneColor.x + g_fOneColor.y)*finter;
- return c;
-}
-
-half4 CRTCPS(in float2 tex0 : TEXCOORD0) : COLOR
-{
- float2 filtcoord = (tex0/*-frac(tex0)*/)*g_fInvTexDims.xy+g_fInvTexDims.zw;
- half4 c = BilinearBitBlt(filtcoord);
- c.w = c.w * g_fOneColor.x + g_fOneColor.y;
-
- return c;
-}
-
-// simpler
-half4 CRTCPS_Nearest(in float2 tex0 : TEXCOORD0) : COLOR
-{
- half4 c = texRECT(g_sMemory, ps2memcoord(tex0).xy);
- c.w = c.w * g_fOneColor.x + g_fOneColor.y;
- return c;
-}
-
-half4 CRTC24InterPS(in float2 tex0 : TEXCOORD0, in float2 ointerpos : TEXCOORD1) : COLOR
-{
- float finter = texRECT(g_sInterlace, ointerpos.yy).x * g_fOneColor.z + g_fOneColor.w + g_fc0.w;
- float2 filtcoord = (tex0-frac(tex0))*g_fInvTexDims.xy+g_fInvTexDims.zw;
-
- half4 c = texRECT(g_sMemory, ps2memcoord(filtcoord).xy).x;
- c.w = (c.w * g_fOneColor.x + g_fOneColor.y)*finter;
-
- return c;
-}
-
-half4 CRTC24PS(in float2 tex0 : TEXCOORD0) : COLOR
-{
- float2 filtcoord = (tex0-frac(tex0))*g_fInvTexDims.xy+g_fInvTexDims.zw;
- half4 c = texRECT(g_sMemory, ps2memcoord(filtcoord).xy).x;
- c.w = c.w * g_fOneColor.x + g_fOneColor.y;
-
- return c;
-}
-
-half4 ZeroPS() : COLOR
-{
- return g_fOneColor.x;
-}
-
-half4 BaseTexturePS(in float2 tex0 : TEXCOORD0) : COLOR
-{
- return texRECT(g_sSrcFinal, tex0) * g_fOneColor;
-}
-
-half4 Convert16to32PS(float2 tex0 : TEXCOORD0) : COLOR
-{
- float4 final;
- float2 ffrac = fmod(tex0+g_fTexDims.zw, g_fTexOffset.xy);
- tex0.xy = g_fTexDims.xy * tex0.xy - ffrac * g_fc0.yw;
-
- if( ffrac.x > g_fTexOffset.x*g_fc0.w )
- tex0.x += g_fTexOffset.x*g_fc0.w;
- if( tex0.x >= g_fc0.y ) tex0 += g_fTexOffset.zw;
-
- float4 lower = texRECT(g_sSrcFinal, tex0);
- float4 upper = texRECT(g_sSrcFinal, tex0+g_fPageOffset.xy);
-
- final.zy = tex3D(g_sConv32to16, lower.zyx).xy + lower.ww*g_fPageOffset.zw;
- final.xw = tex3D(g_sConv32to16, upper.zyx).xy + upper.ww*g_fPageOffset.zw;
-
- return final;
-}
-
-// use when texture is not tiled and converting from 32bit to 16bit
-// don't convert on the block level, only on the column level
-// so every other 8 pixels, use the upper bits instead of lower
-half4 Convert32to16PS(float2 tex0 : TEXCOORD0) : COLOR
-{
- bool upper = false;
- float2 ffrac = fmod(tex0+g_fTexDims.zw, g_fTexOffset.xy);
- tex0.xy = g_fc0.ww * (tex0.xy + ffrac);
- if( ffrac.x > g_fTexOffset.z ) {
- tex0.x -= g_fTexOffset.z;
- upper = true;
- }
- if( ffrac.y >= g_fTexOffset.w ) {
- tex0.y -= g_fTexOffset.w;
- tex0.x += g_fc0.w;
- }
-
- half4 color = texRECT(g_sSrcFinal, tex0*g_fTexDims.xy)*g_fc0.yyyw;
- float2 uv = upper ? color.xw : color.zy;
- return tex2D(g_sConv16to32, uv*g_fPageOffset.xy+g_fPageOffset.zw)*g_fTexDims.xxxy;
-}
+// Cg Shaders for PS2 GS emulation
+
+// divides by z for every pixel, instead of in vertex shader
+// fixes kh textures
+#define PERSPECTIVE_CORRECT_TEX
+
+//#define TEST_AEM // tests AEM for black pixels
+//#define REGION_REPEAT // set if texture wrapping mode is region repeat
+//#define WRITE_DEPTH // set if depth is also written in a MRT
+//#define ACCURATE_DECOMPRESSION // set for less capable hardware ATI Radeon 9000 series
+//#define EXACT_COLOR // make sure the output color is clamped to 1/255 boundaries (for alpha testing)
+
+#ifdef PERSPECTIVE_CORRECT_TEX
+#define TEX_XY tex.xy/tex.z
+#define TEX_DECL float3
+#else
+#define TEX_XY tex.xy
+#define TEX_DECL float2
+#endif
+
+#ifdef WRITE_DEPTH
+#define DOZWRITE(x) x
+#else
+#define DOZWRITE(x)
+#endif
+
+#include "ps2hw_ctx.fx"
+
+// used to get the tiled offset into a page given the linear offset
+uniform samplerRECT g_sSrcFinal : register(s2);
+uniform sampler2D g_sBlocks : register(s3);
+uniform sampler2D g_sBilinearBlocks : register(s4);
+uniform sampler2D g_sConv16to32 : register(s4);
+uniform sampler3D g_sConv32to16 : register(s4);
+uniform samplerRECT g_sBitwiseANDX : register(s5);
+uniform samplerRECT g_sBitwiseANDY : register(s6);
+uniform samplerRECT g_sInterlace : register(s7);
+
+// used only on rare cases where the render target is PSMT8H
+uniform sampler2D g_sCLUT : register(s2);
+
+// global pixel shader constants
+uniform float4 g_fInvTexDims : register(c22); // similar to g_fClutOff
+uniform float4 g_fFogColor : register(c23);
+
+// used for rectblitting
+uniform float4 g_fBitBltZ : register(c24);
+
+uniform half4 g_fOneColor : register(c25); // col*.xxxy+.zzzw
+
+// vertex shader constants
+uniform float4 g_fBitBltPos : register(c4);
+uniform float4 g_fZ : register(c5); // transforms d3dcolor z into float z
+uniform float4 g_fZNorm : register(c6);
+uniform float4 g_fZMin: register(c26) = float4(0.0f, 1.0f, 0.0f, 0.0f);
+uniform float4 g_fBitBltTex : register(c7);
+
+// pixel shader consts
+// .z is used for the addressing fn
+uniform half4 g_fExactColor : register(c27) = half4(0.5,0.5/256.0f,0,1/255.0f);
+uniform float4 g_fBilinear : register(c28) = float4(-0.7f, -0.65f, 0.9,1/32767.0f);
+uniform float4 g_fZBias : register(c29) = half4(1.0f/256.0f, 1.0004f, 1, 0.5); // also for vs
+uniform float4 g_fc0 : register(c30) = float4(0,1, 0.001, 0.5f); // also for vs
+uniform float4 g_fMult : register(c31) = float4(1/1024.0f, 0.2f/1024.0f, 1/128.0f, 1/512.0f);
+
+// vertex shader consts
+uniform float4 g_fBitBltTrans : register(c31) = float4(0.5f, -0.5f, 0.5, 0.5 + 0.4/416.0f);
+
+// given a local tex coord, returns the coord in the memory
+float2 ps2memcoord(float2 realtex)
+{
+ float4 off;
+
+ // block off
+ realtex.xy = realtex.xy * g_fTexDims.xy + g_fTexDims.zw;
+ realtex.xy = (realtex.xy - frac(realtex.xy)) * g_fMult.zw;
+ float2 fblock = frac(realtex.xy);
+ off.xy = realtex.xy-fblock.xy;
+
+#ifdef ACCURATE_DECOMPRESSION
+ off.zw = tex2D(g_sBlocks, g_fTexBlock.xy*fblock + g_fTexBlock.zw).ar;
+ off.x = dot(off.xy, g_fTexOffset.xy);
+ float r = g_fTexOffset.w;
+ float f = frac(off.x);
+ float fadd = g_fTexOffset.z * off.z;
+ off.w = off.x + fadd + r;
+ off.x = frac(f + fadd + r);
+ off.w -= off.x ;
+#else
+ off.z = tex2D(g_sBlocks, g_fTexBlock.xy*fblock + g_fTexBlock.zw).a;
+
+ // combine the two
+ off.x = dot(off.xyz, g_fTexOffset.xyz)+g_fTexOffset.w;
+ off.x = modf(off.x, off.w);
+#endif
+
+ off.xy = off.xw * g_fPageOffset.zy + g_fPageOffset.wx;
+ //off.y = off.w * g_fPageOffset.y + g_fPageOffset.x;
+ return off.xy;
+}
+
+// find all texcoords for bilinear filtering
+// assume that orgtex are already on boundaries
+void ps2memcoord4(float4 orgtex, out float4 off0, out float4 off1)
+{
+ //float4 off0, off1, off2, off3;
+ float4 realtex;
+
+ // block off
+ realtex = (orgtex * g_fTexDims.xyxy + g_fTexDims.zwzw);// * g_fMult.zwzw;
+ float4 fblock = frac(realtex.xyzw);
+ float4 ftransblock = g_fTexBlock.xyxy*fblock + g_fTexBlock.zwzw;
+ realtex -= fblock;
+
+ float4 transvals = g_fTexOffset.x * realtex.xzxz + g_fTexOffset.y * realtex.yyww + g_fTexOffset.w;
+
+ float4 colors;// = tex2D(g_sBilinearBlocks, ftransblock.xy);
+
+ // this is faster on ffx ingame
+ colors.x = tex2D(g_sBlocks, ftransblock.xy).a;
+ colors.y = tex2D(g_sBlocks, ftransblock.zy).a;
+ colors.z = tex2D(g_sBlocks, ftransblock.xw).a;
+ colors.w = tex2D(g_sBlocks, ftransblock.zw).a;
+
+ float4 fr, rem;
+
+#ifdef ACCURATE_DECOMPRESSION
+ fr = frac(transvals);
+ float4 fadd = colors * g_fTexOffset.z;
+ rem = transvals + fadd;
+ fr = frac(fr + fadd);
+ rem -= fr;
+#else
+ transvals += colors * g_fTexOffset.z;
+
+ fr = modf(transvals, rem);
+#endif
+
+ rem = rem * g_fPageOffset.y + g_fPageOffset.x;
+ fr = fr * g_fPageOffset.z + g_fPageOffset.w;
+
+ // combine
+ off0 = g_fc0.yxyx * fr.xxyy + g_fc0.xyxy * rem.xxyy;
+ off1 = g_fc0.yxyx * fr.zzww + g_fc0.xyxy * rem.zzww;
+}
+
+void ps2memcoord4_fast(float4 orgtex, out float4 off0, out float4 off1)
+{
+ float4 realtex;
+
+ realtex = (orgtex * g_fTexDims.xyxy + g_fTexDims.zwzw);// * g_fMult.zwzw;
+ float4 fblock = frac(realtex.xyzw);
+ float2 ftransblock = g_fTexBlock.xy*fblock.xy + g_fTexBlock.zw;
+ realtex -= fblock;
+
+ float4 transvals = g_fTexOffset.x * realtex.xzxz + g_fTexOffset.y * realtex.yyww + g_fTexOffset.w;
+
+ float4 colors = tex2D(g_sBilinearBlocks, ftransblock.xy);
+ float4 fr, rem;
+
+#ifdef ACCURATE_DECOMPRESSION
+ fr = frac(transvals);
+ float4 fadd = colors * g_fTexOffset.z;
+ rem = transvals + fadd;
+ fr = frac(fr + fadd);
+ rem -= fr;
+#else
+ transvals += colors * g_fTexOffset.z;
+
+ fr = modf(transvals, rem);
+#endif
+
+ rem = rem * g_fPageOffset.y + g_fPageOffset.x;
+ fr = fr * g_fPageOffset.z;
+
+ off0 = g_fc0.yxyx * fr.xxyy + g_fc0.xyxy * rem.xxyy;
+ off1 = g_fc0.yxyx * fr.zzww + g_fc0.xyxy * rem.zzww;
+}
+
+// Wrapping modes
+#if defined(REPEAT)
+
+float2 ps2addr(float2 coord)
+{
+ return frac(coord.xy);
+}
+
+#elif defined(CLAMP)
+
+float2 ps2addr(float2 coord)
+{
+ return clamp(coord.xy, g_fClampExts.xy, g_fClampExts.zw);
+}
+
+#elif defined(REGION_REPEAT)
+
+// computes the local tex coord along with addressing modes
+float2 ps2addr(float2 coord)
+{
+ float2 final = frac(clamp(coord.xy, g_fClampExts.xy, g_fClampExts.zw));
+
+ if( TexWrapMode.x > g_fBilinear.z ) // region repeat mode for x (umsk&x)|ufix
+ final.x = texRECT(g_sBitwiseANDX, abs(coord.x)*TexWrapMode.zx).x * g_fClampExts.x + g_fClampExts.z;
+ if( TexWrapMode.y > g_fBilinear.z ) // region repeat mode for x (vmsk&x)|vfix
+ final.y = texRECT(g_sBitwiseANDY, abs(coord.y)*TexWrapMode.wy).x * g_fClampExts.y + g_fClampExts.w;
+
+ return final;
+}
+
+#else
+
+float2 ps2addr(float2 coord)
+{
+ return frac(clamp(coord.xy, g_fClampExts.xy, g_fClampExts.zw));
+}
+
+#endif
+
+half4 tex2DPS_32(float2 tex0)
+{
+ return texRECT(g_sMemory, ps2memcoord(tex0).xy);
+}
+
+// use when texture is not tiled -- shader 1
+half4 tex2DPS_tex32(float2 tex0)
+{
+ return texRECT(g_sMemory, g_fTexDims.xy*tex0+g_fTexDims.zw)*g_fZBias.zzzw+g_fPageOffset.w;
+}
+
+// use when texture is not tiled -- shader 2
+half4 tex2DPS_clut32(float2 tex0)
+{
+ float index = texRECT(g_sMemory, g_fTexDims.xy*tex0+g_fTexDims.zw).a+g_fPageOffset.w;
+ return tex2D(g_sCLUT, index*g_fExactColor.xz+g_fExactColor.yz);
+}
+
+// Shader 3
+// use when texture is not tiled and converting from 32bit to 16bit
+// don't convert on the block level, only on the column level
+// so every other 8 pixels, use the upper bits instead of lower
+half4 tex2DPS_tex32to16(float2 tex0)
+{
+ bool upper = false;
+ tex0.y += g_fPageOffset.z;
+ float2 ffrac = fmod(tex0, g_fTexOffset.xy);
+ tex0.xy = g_fc0.ww * (tex0.xy + ffrac);
+ if( ffrac.x > g_fTexOffset.z ) {
+ tex0.x -= g_fTexOffset.z;
+ upper = true;
+ }
+ if( ffrac.y >= g_fTexOffset.w ) {
+ tex0.y -= g_fTexOffset.w;
+ tex0.x += g_fc0.w;
+ }
+
+ half4 color = texRECT(g_sMemory, g_fTexDims.xy*tex0+g_fTexDims.zw)*g_fZBias.zzzw+g_fPageOffset.w;
+ float2 uv = upper ? color.xw : color.zy;
+ return tex2D(g_sConv16to32, uv+g_fPageOffset.xy);
+}
+
+// Shader 4
+// used when a 16 bit texture is used an 8h
+half4 tex2DPS_tex16to8h(float2 tex0)
+{
+ float4 final;
+ float2 ffrac = fmod(tex0+g_fPageOffset.zw, g_fTexOffset.xy);
+ tex0.xy = g_fPageOffset.xy * tex0.xy - ffrac * g_fc0.yw;
+
+ if( ffrac.x > g_fTexOffset.x*g_fc0.w )
+ tex0.x += g_fTexOffset.x*g_fc0.w;
+ if( tex0.x >= g_fc0.y ) tex0 += g_fTexOffset.zw;
+
+ float4 upper = texRECT(g_sMemory, g_fTexDims.xy*tex0+g_fTexDims.zw);
+
+ // only need alpha
+ float index = tex3D(g_sConv32to16, upper.zyx-g_fc0.z).y + upper.w*g_fc0.w*g_fc0.w;
+ return tex2D(g_sCLUT, index+g_fExactColor.yz);
+}
+
+// Shader 5
+// used when a 16 bit texture is used a 32bit one
+half4 tex2DPS_tex16to32(float2 tex0)
+{
+ float4 final;
+ float2 ffrac = fmod(tex0+g_fPageOffset.zw, g_fTexOffset.xy);
+ //tex0.xy = g_fPageOffset.xy * tex0.xy - ffrac * g_fc0.yw;
+ tex0.y += g_fPageOffset.y * ffrac.y;
+
+ if( ffrac.x > g_fTexOffset.z ) {
+ tex0.x -= g_fTexOffset.z;
+ tex0.y += g_fTexOffset.w;
+ }
+
+ float fconst = g_fc0.w*g_fc0.w;
+ float4 lower = tex2D(g_sSrcFinal, g_fTexDims.xy*tex0);
+ float4 upper = tex2D(g_sMemory, g_fTexDims.xy*tex0+g_fTexDims.zw);
+
+ final.zy = tex3D(g_sConv32to16, lower.zyx).xy + lower.ww*fconst;
+ final.xw = tex3D(g_sConv32to16, upper.zyx).xy + upper.ww*fconst;
+ return final;
+}
+
+
+//half4 f;
+//f.w = old.y > (127.2f/255.0f) ? 1 : 0;
+//old.y -= 0.5f * f.w;
+//f.xyz = frac(old.yyx*half3(2.002*255.0f/256.0f, 64.025f*255.0f/256.0f, 8.002*255.0f/256.0f));
+//f.y += old.x * (0.25f*255.0f/256.0f);
+
+////////////////////////////////
+// calculates the texture color
+////////////////////////////////
+
+#define decl_ps2shade(num) \
+decl_ps2shade_##num(_32) \
+decl_ps2shade_##num(_tex32) \
+decl_ps2shade_##num(_clut32) \
+decl_ps2shade_##num(_tex32to16) \
+decl_ps2shade_##num(_tex16to8h) \
+decl_ps2shade_##num(_tex16to32h) \
+
+// nearest
+#define decl_ps2shade_0(bit) \
+float4 ps2shade0##bit( TEX_DECL tex) \
+{ \
+ return tex2DPS##bit( ps2addr(TEX_XY)); \
+} \
+
+// do fast memcoord4 calcs when textures behave well
+#ifdef REPEAT
+#define PS2MEMCOORD4 ps2memcoord4
+#else
+#define PS2MEMCOORD4 ps2memcoord4
+#endif
+
+#define decl_BilinearFilter(bit, addrfn) \
+half4 BilinearFilter##bit(float2 tex0) \
+{ \
+ float4 off0, off1; \
+ float4 ftex; \
+ float2 ffrac; \
+ ftex.xy = tex0 + g_fBilinear.xy * g_fRealTexDims.zw; \
+ ffrac = frac(ftex.xy*g_fRealTexDims.xy); \
+ ftex.xy -= ffrac.xy * g_fRealTexDims.zw; \
+ \
+ ftex.zw = ps2addr(ftex.xy + g_fRealTexDims.zw); \
+ ftex.xy = ps2addr(ftex.xy); \
+ \
+ PS2MEMCOORD4(ftex, off0, off1); \
+ half4 c0 = texRECT(g_sMemory, off0.xy); \
+ half4 c1 = texRECT(g_sMemory, off0.zw); \
+ half4 c2 = texRECT(g_sMemory, off1.xy); \
+ half4 c3 = texRECT(g_sMemory, off1.zw); \
+ return lerp( lerp(c0, c1, ffrac.x), lerp(c2, c3, ffrac.x), ffrac.y ); \
+} \
+
+decl_BilinearFilter(_32, ps2addr)
+decl_BilinearFilter(_tex32, ps2addr)
+decl_BilinearFilter(_clut32, ps2addr)
+decl_BilinearFilter(_tex32to16, ps2addr)
+decl_BilinearFilter(_tex16to8h, ps2addr)
+decl_BilinearFilter(_tex16to32h, ps2addr)
+
+//TODO! For mip maps, only apply when LOD >= 0
+// lcm == 0, LOD = log(1/Q)*L + K, lcm == 1, LOD = K
+
+// bilinear
+#define decl_ps2shade_1(bit) \
+half4 ps2shade1##bit(TEX_DECL tex) \
+{ \
+ return BilinearFilter##bit(TEX_XY); \
+} \
+
+// nearest, mip nearest
+#define decl_ps2shade_2(bit) \
+half4 ps2shade2##bit(TEX_DECL tex) \
+{ \
+ return tex2DPS##bit( ps2addr(TEX_XY)); \
+} \
+
+// nearest, mip linear
+#define decl_ps2shade_3(bit) \
+half4 ps2shade3##bit(TEX_DECL tex) \
+{ \
+ return tex2DPS##bit(ps2addr(TEX_XY)); \
+} \
+
+// linear, mip nearest
+#define decl_ps2shade_4(bit) \
+half4 ps2shade4##bit(TEX_DECL tex) \
+{ \
+ return BilinearFilter##bit(TEX_XY); \
+} \
+
+// linear, mip linear
+#define decl_ps2shade_5(bit) \
+half4 ps2shade5##bit(TEX_DECL tex) \
+{ \
+ return BilinearFilter##bit(TEX_XY); \
+} \
+
+decl_ps2shade(0)
+decl_ps2shade(1)
+decl_ps2shade(2)
+decl_ps2shade(3)
+decl_ps2shade(4)
+decl_ps2shade(5)
+
+half4 ps2CalcShade(half4 texcol, half4 color)
+{
+#ifdef TEST_AEM
+ if( dot(texcol.xyzw, g_fTestBlack.xyzw) <= g_fc0.z )
+ texcol.w = g_fc0.x;
+ else
+#endif
+ texcol.w = texcol.w * fTexAlpha.y + fTexAlpha.x;
+
+ texcol = texcol * (fTexAlpha2.zzzw * color + fTexAlpha2.xxxy) + fTexAlpha.zzzw * color.wwww;
+
+ return texcol;
+}
+
+// final ops on the color
+#ifdef EXACT_COLOR
+
+half4 ps2FinalColor(half4 col)
+{
+ // g_fOneColor has to scale by 255
+ half4 temp = col * g_fOneColor.xxxy + g_fOneColor.zzzw;
+ temp.w = floor(temp.w)*g_fExactColor.w;
+ return temp;
+}
+
+#else
+half4 ps2FinalColor(half4 col)
+{
+ return col * g_fOneColor.xxxy + g_fOneColor.zzzw;
+}
+#endif
+
+////////////////
+// Techniques //
+////////////////
+
+// technique to copy a rectangle from source to target
+struct VSOUT_
+{
+ float4 pos : POSITION;
+ half4 color : COLOR0;
+ DOZWRITE(float4 z : TEXCOORD0;)
+};
+
+struct VSOUT_T
+{
+ float4 pos : POSITION;
+ half4 color : COLOR0;
+ TEX_DECL tex : TEXCOORD0;
+ DOZWRITE(float4 z : TEXCOORD1;)
+};
+
+struct VSOUT_F
+{
+ float4 pos : POSITION;
+ half4 color : COLOR0;
+ float fog : TEXCOORD0;
+ DOZWRITE(float4 z : TEXCOORD1;)
+};
+
+struct VSOUT_TF
+{
+ float4 pos : POSITION;
+ half4 color : COLOR0;
+ TEX_DECL tex : TEXCOORD0;
+ half fog : TEXCOORD1;
+ DOZWRITE(float4 z : TEXCOORD2;)
+};
+
+// just smooth shadering
+VSOUT_ RegularVS(float4 pos : POSITION,
+ half4 color : COLOR0,
+ float4 z : COLOR1
+ )
+{
+ VSOUT_ o;
+
+ o.pos.xy = pos.xy*g_fPosXY.xy+g_fPosXY.zw;
+ o.pos.z = (log(g_fc0.y+dot(g_fZ, z.zyxw))*g_fZNorm.x+g_fZNorm.y) * g_fZMin.y + dot(g_fZ, z.zyxw) * g_fZMin.x ;
+ o.pos.w = g_fc0.y; // 1
+ o.color = color;
+
+ DOZWRITE(o.z = z*g_fZBias.x+g_fZBias.y; o.z.w = g_fc0.y;)
+ return o;
+}
+
+void RegularPS(VSOUT_ i, out float4 c0 : COLOR0
+#ifdef WRITE_DEPTH
+ , out float4 c1 : COLOR1
+#endif
+ )
+{
+ // whenever outputting depth, make sure to mult by 255/256 and 1
+ c0 = ps2FinalColor(i.color);
+ DOZWRITE(c1 = i.z;)
+}
+
+// diffuse texture mapping
+VSOUT_T TextureVS(float4 pos : POSITION,
+ half4 color : COLOR0,
+ float4 z : COLOR1,
+ float3 tex0 : TEXCOORD0)
+{
+ VSOUT_T o;
+ o.pos.xy = pos.xy*g_fPosXY.xy+g_fPosXY.zw;
+ o.pos.z = (log(g_fc0.y+dot(g_fZ, z.zyxw))*g_fZNorm.x + g_fZNorm.y) * g_fZMin.y + dot(g_fZ, z.zyxw) * g_fZMin.x ;
+ o.pos.w = g_fc0.y;
+ o.color = color;
+ DOZWRITE(o.z = z*g_fZBias.x+g_fZBias.y; o.z.w = g_fc0.y;)
+#ifdef PERSPECTIVE_CORRECT_TEX
+ o.tex = tex0;
+#else
+ o.tex = tex0.xy/tex0.z;
+#endif
+ return o;
+}
+
+#ifdef WRITE_DEPTH
+
+#define DECL_TEXPS(num, bit) \
+void Texture##num##bit##PS(VSOUT_T i, out half4 c0 : COLOR0, out float4 c1 : COLOR1) \
+{ \
+ c0 = ps2FinalColor(ps2CalcShade(ps2shade##num##bit(i.tex), i.color)); \
+ c1 = i.z; \
+} \
+
+#else
+
+#define DECL_TEXPS(num, bit) \
+void Texture##num##bit##PS(VSOUT_T i, out half4 c0 : COLOR0) \
+{ \
+ c0 = ps2FinalColor(ps2CalcShade(ps2shade##num##bit(i.tex), i.color)); \
+} \
+
+#endif
+
+#define DECL_TEXPS_(num) \
+DECL_TEXPS(num, _32) \
+DECL_TEXPS(num, _tex32) \
+DECL_TEXPS(num, _clut32) \
+DECL_TEXPS(num, _tex32to16) \
+DECL_TEXPS(num, _tex16to8h) \
+
+DECL_TEXPS_(0)
+DECL_TEXPS_(1)
+DECL_TEXPS_(2)
+DECL_TEXPS_(3)
+DECL_TEXPS_(4)
+DECL_TEXPS_(5)
+
+VSOUT_F RegularFogVS(float4 pos : POSITION,
+ half4 color : COLOR0,
+ float4 z : COLOR1)
+{
+ VSOUT_F o;
+
+ o.pos.xy = pos.xy*g_fPosXY.xy+g_fPosXY.zw;
+ o.pos.z = (log(g_fc0.y+dot(g_fZ, z.zyxw))*g_fZNorm.x+g_fZNorm.y) * g_fZMin.y + dot(g_fZ, z.zyxw) * g_fZMin.x ;
+ o.pos.w = g_fc0.y;
+ DOZWRITE(o.z = z*g_fZBias.x+g_fZBias.y; o.z.w = g_fc0.y;)
+ o.color = color;
+ o.fog = pos.z*g_fBilinear.w;
+ return o;
+}
+
+void RegularFogPS(VSOUT_F i, out half4 c0 : COLOR0
+#ifdef WRITE_DEPTH
+ , out float4 c1 : COLOR1
+#endif
+ )
+{
+ half4 c;
+ c.xyz = lerp(g_fFogColor.xyz, i.color.xyz, i.fog);
+ c.w = i.color.w;
+ c0 = ps2FinalColor(c);
+ DOZWRITE(c1 = i.z;)
+}
+
+VSOUT_TF TextureFogVS(float4 pos : POSITION,
+ half4 color : COLOR0,
+ float4 z : COLOR1,
+ float3 tex0 : TEXCOORD0)
+{
+ VSOUT_TF o;
+
+ o.pos.xy = pos.xy*g_fPosXY.xy+g_fPosXY.zw;
+ o.pos.z = (log(g_fc0.y+dot(g_fZ, z.zyxw))*g_fZNorm.x+g_fZNorm.y) * g_fZMin.y + dot(g_fZ, z.zyxw) * g_fZMin.x ;
+ o.pos.w = g_fc0.y;
+ o.color = color;
+ o.fog = pos.z*g_fBilinear.w;
+ DOZWRITE(o.z = z*g_fZBias.x+g_fZBias.y; o.z.w = g_fc0.y;)
+#ifdef PERSPECTIVE_CORRECT_TEX
+ o.tex = tex0;
+#else
+ o.tex = tex0.xy/tex0.z;
+#endif
+ return o;
+}
+
+#ifdef WRITE_DEPTH
+
+#define DECL_TEXFOGPS(num, bit) \
+void TextureFog##num##bit##PS(VSOUT_TF i, out half4 c0 : COLOR0, out float4 c1 : COLOR1 ) \
+{ \
+ half4 c = ps2CalcShade(ps2shade##num##bit(i.tex), i.color); \
+ c.xyz = lerp(g_fFogColor.xyz, c.xyz, i.fog); \
+ c0 = ps2FinalColor(c); \
+ c1 = i.z; \
+} \
+
+#else
+
+#define DECL_TEXFOGPS(num, bit) \
+void TextureFog##num##bit##PS(VSOUT_TF i, out half4 c0 : COLOR0) \
+{ \
+ half4 c = ps2CalcShade(ps2shade##num##bit(i.tex), i.color); \
+ c.xyz = lerp(g_fFogColor.xyz, c.xyz, i.fog); \
+ c0 = ps2FinalColor(c); \
+} \
+
+#endif
+
+#define DECL_TEXFOGPS_(num) \
+DECL_TEXFOGPS(num, _32) \
+DECL_TEXFOGPS(num, _tex32) \
+DECL_TEXFOGPS(num, _clut32) \
+DECL_TEXFOGPS(num, _tex32to16) \
+DECL_TEXFOGPS(num, _tex16to8h) \
+
+DECL_TEXFOGPS_(0)
+DECL_TEXFOGPS_(1)
+DECL_TEXFOGPS_(2)
+DECL_TEXFOGPS_(3)
+DECL_TEXFOGPS_(4)
+DECL_TEXFOGPS_(5)
+
+//-------------------------------------------------------
+// Techniques not related to the main primitive commands
+half4 BilinearBitBlt(float2 tex0)
+{
+ float4 ftex;
+ float2 ffrac;
+
+ ffrac.xy = frac(tex0*g_fRealTexDims.xy);
+ ftex.xy = tex0 - ffrac.xy * g_fRealTexDims.zw;
+ ftex.zw = ftex.xy + g_fRealTexDims.zw;
+
+ float4 off0, off1;
+ ps2memcoord4_fast(ftex, off0, off1);
+ half4 c0 = texRECT(g_sMemory, off0.xy);
+ half4 c1 = texRECT(g_sMemory, off0.zw);
+ half4 c2 = texRECT(g_sMemory, off1.xy);
+ half4 c3 = texRECT(g_sMemory, off1.zw);
+
+ return lerp( lerp(c0, c1, ffrac.x), lerp(c2, c3, ffrac.x), ffrac.y );
+}
+
+void BitBltVS(in float4 pos : POSITION,
+ in half4 tex0 : COLOR1,
+ in float3 tex : TEXCOORD0,
+ out float4 opos : POSITION,
+ out float2 otex0 : TEXCOORD0,
+ out float2 ointerpos : TEXCOORD1)
+{
+ opos.xy = pos.xy * g_fBitBltPos.xy + g_fBitBltPos.zw;
+ ointerpos = opos.xy * g_fBitBltTrans.xy + g_fBitBltTrans.zw;
+ opos.zw = g_fc0.xy;
+ otex0 = tex.xy * g_fBitBltTex.xy + g_fBitBltTex.zw;
+}
+
+half4 BitBltPS(in float2 tex0 : TEXCOORD0) : COLOR
+{
+ return texRECT(g_sMemory, ps2memcoord(tex0).xy)*g_fOneColor.xxxy;
+}
+
+// used when AA
+half4 BitBltAAPS(in float2 tex0 : TEXCOORD0) : COLOR
+{
+ return BilinearBitBlt(tex0)*g_fOneColor.xxxy;
+}
+
+void BitBltDepthPS(in float2 tex0 : TEXCOORD0,
+ out float4 c : COLOR0,
+ out float depth : DEPTH)
+{
+ c = texRECT(g_sMemory, ps2memcoord(tex0));
+
+ depth = (log(g_fc0.y+dot(c, g_fBitBltZ))*g_fOneColor.w) * g_fZMin.y + dot(c, g_fBitBltZ) * g_fZMin.x ;
+ c += g_fZBias.y;
+}
+
+void BitBltDepthMRTPS(in float2 tex0 : TEXCOORD0,
+ out half4 c0 : COLOR0,
+ out float4 c1 : COLOR1,
+ out float depth : DEPTH)
+{
+ c1 = texRECT(g_sMemory, ps2memcoord(tex0));
+
+ depth = (log(g_fc0.y+dot(c1, g_fBitBltZ))*g_fOneColor.w) * g_fZMin.y + dot(c1, g_fBitBltZ) * g_fZMin.x ;
+ c1 += g_fZBias.y;
+ c0 = g_fc0.x;
+}
+
+/*static const float BlurKernel[9] = {
+ 0.027601,
+ 0.066213,
+ 0.123701,
+ 0.179952,
+ 0.205065,
+ 0.179952,
+ 0.123701,
+ 0.066213,
+ 0.027601
+};*/
+
+half4 BilinearFloat16(float2 tex0)
+{
+ return texRECT(g_sSrcFinal, tex0.xy);
+}
+
+half4 CRTCTargInterPS(in float2 tex0 : TEXCOORD0, in float2 ointerpos : TEXCOORD1) : COLOR
+{
+ float finter = texRECT(g_sInterlace, ointerpos.yy).x * g_fOneColor.z + g_fOneColor.w + g_fc0.w;
+ float4 c = BilinearFloat16(tex0);
+ c.w = ( g_fc0.w*c.w * g_fOneColor.x + g_fOneColor.y ) * finter;
+ return c;
+}
+
+half4 CRTCTargPS(in float2 tex0 : TEXCOORD0) : COLOR
+{
+ float4 c = BilinearFloat16(tex0);
+ c.w = g_fc0.w*c.w * g_fOneColor.x + g_fOneColor.y;
+ return c;
+}
+
+half4 CRTCInterPS(in float2 tex0 : TEXCOORD0, in float2 ointerpos : TEXCOORD1) : COLOR
+{
+ float finter = texRECT(g_sInterlace, ointerpos.yy).x * g_fOneColor.z + g_fOneColor.w + g_fc0.w;
+ float2 filtcoord = (tex0-frac(tex0))*g_fInvTexDims.xy+g_fInvTexDims.zw;
+ half4 c = BilinearBitBlt(filtcoord);
+ c.w = (c.w * g_fOneColor.x + g_fOneColor.y)*finter;
+
+ return c;
+}
+
+// simpler
+half4 CRTCInterPS_Nearest(in float2 tex0 : TEXCOORD0, in float2 ointerpos : TEXCOORD1) : COLOR
+{
+ float finter = texRECT(g_sInterlace, ointerpos.yy).x * g_fOneColor.z + g_fOneColor.w + g_fc0.w;
+ half4 c = texRECT(g_sMemory, ps2memcoord(tex0).xy);
+ c.w = (c.w * g_fOneColor.x + g_fOneColor.y)*finter;
+ return c;
+}
+
+half4 CRTCPS(in float2 tex0 : TEXCOORD0) : COLOR
+{
+ float2 filtcoord = (tex0/*-frac(tex0)*/)*g_fInvTexDims.xy+g_fInvTexDims.zw;
+ half4 c = BilinearBitBlt(filtcoord);
+ c.w = c.w * g_fOneColor.x + g_fOneColor.y;
+
+ return c;
+}
+
+// simpler
+half4 CRTCPS_Nearest(in float2 tex0 : TEXCOORD0) : COLOR
+{
+ half4 c = texRECT(g_sMemory, ps2memcoord(tex0).xy);
+ c.w = c.w * g_fOneColor.x + g_fOneColor.y;
+ return c;
+}
+
+half4 CRTC24InterPS(in float2 tex0 : TEXCOORD0, in float2 ointerpos : TEXCOORD1) : COLOR
+{
+ float finter = texRECT(g_sInterlace, ointerpos.yy).x * g_fOneColor.z + g_fOneColor.w + g_fc0.w;
+ float2 filtcoord = (tex0-frac(tex0))*g_fInvTexDims.xy+g_fInvTexDims.zw;
+
+ half4 c = texRECT(g_sMemory, ps2memcoord(filtcoord).xy).x;
+ c.w = (c.w * g_fOneColor.x + g_fOneColor.y)*finter;
+
+ return c;
+}
+
+half4 CRTC24PS(in float2 tex0 : TEXCOORD0) : COLOR
+{
+ float2 filtcoord = (tex0-frac(tex0))*g_fInvTexDims.xy+g_fInvTexDims.zw;
+ half4 c = texRECT(g_sMemory, ps2memcoord(filtcoord).xy).x;
+ c.w = c.w * g_fOneColor.x + g_fOneColor.y;
+
+ return c;
+}
+
+half4 ZeroPS() : COLOR
+{
+ return g_fOneColor.x;
+}
+
+half4 BaseTexturePS(in float2 tex0 : TEXCOORD0) : COLOR
+{
+ return texRECT(g_sSrcFinal, tex0) * g_fOneColor;
+}
+
+half4 Convert16to32PS(float2 tex0 : TEXCOORD0) : COLOR
+{
+ float4 final;
+ float2 ffrac = fmod(tex0+g_fTexDims.zw, g_fTexOffset.xy);
+ tex0.xy = g_fTexDims.xy * tex0.xy - ffrac * g_fc0.yw;
+
+ if( ffrac.x > g_fTexOffset.x*g_fc0.w )
+ tex0.x += g_fTexOffset.x*g_fc0.w;
+ if( tex0.x >= g_fc0.y ) tex0 += g_fTexOffset.zw;
+
+ float4 lower = texRECT(g_sSrcFinal, tex0);
+ float4 upper = texRECT(g_sSrcFinal, tex0+g_fPageOffset.xy);
+
+ final.zy = tex3D(g_sConv32to16, lower.zyx).xy + lower.ww*g_fPageOffset.zw;
+ final.xw = tex3D(g_sConv32to16, upper.zyx).xy + upper.ww*g_fPageOffset.zw;
+
+ return final;
+}
+
+// use when texture is not tiled and converting from 32bit to 16bit
+// don't convert on the block level, only on the column level
+// so every other 8 pixels, use the upper bits instead of lower
+half4 Convert32to16PS(float2 tex0 : TEXCOORD0) : COLOR
+{
+ bool upper = false;
+ float2 ffrac = fmod(tex0+g_fTexDims.zw, g_fTexOffset.xy);
+ tex0.xy = g_fc0.ww * (tex0.xy + ffrac);
+ if( ffrac.x > g_fTexOffset.z ) {
+ tex0.x -= g_fTexOffset.z;
+ upper = true;
+ }
+ if( ffrac.y >= g_fTexOffset.w ) {
+ tex0.y -= g_fTexOffset.w;
+ tex0.x += g_fc0.w;
+ }
+
+ half4 color = texRECT(g_sSrcFinal, tex0*g_fTexDims.xy)*g_fc0.yyyw;
+ float2 uv = upper ? color.xw : color.zy;
+ return tex2D(g_sConv16to32, uv*g_fPageOffset.xy+g_fPageOffset.zw)*g_fTexDims.xxxy;
+}
diff --git a/plugins/zzogl-pg/opengl/x86-32.asm b/plugins/zzogl-pg/opengl/x86-32.asm
index 1507d2192d..0531e9542f 100644
--- a/plugins/zzogl-pg/opengl/x86-32.asm
+++ b/plugins/zzogl-pg/opengl/x86-32.asm
@@ -1,652 +1,652 @@
-; Copyright (C) 2003-2005 Gabest
-; http://www.gabest.org
-;
-; 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, 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 GNU Make; see the file COPYING. If not, write to
-; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-; http://www.gnu.org/copyleft/gpl.html
-;
-;
- .686
- .model flat
- .mmx
- .xmm
-
- .const
-
- __uvmin DD 0d01502f9r ; -1e+010
- __uvmax DD 0501502f9r ; +1e+010
-
- .code
-
-;
-; swizzling
-;
-
-punpck macro op, sd0, sd2, s1, s3, d1, d3
-
- movdqa @CatStr(xmm, %d1), @CatStr(xmm, %sd0)
- pshufd @CatStr(xmm, %d3), @CatStr(xmm, %sd2), 0e4h
-
- @CatStr(punpckl, op) @CatStr(xmm, %sd0), @CatStr(xmm, %s1)
- @CatStr(punpckh, op) @CatStr(xmm, %d1), @CatStr(xmm, %s1)
- @CatStr(punpckl, op) @CatStr(xmm, %sd2), @CatStr(xmm, %s3)
- @CatStr(punpckh, op) @CatStr(xmm, %d3), @CatStr(xmm, %s3)
-
- endm
-
-punpcknb macro
-
- movdqa xmm4, xmm0
- pshufd xmm5, xmm1, 0e4h
-
- psllq xmm1, 4
- psrlq xmm4, 4
-
- movdqa xmm6, xmm7
- pand xmm0, xmm7
- pandn xmm6, xmm1
- por xmm0, xmm6
-
- movdqa xmm6, xmm7
- pand xmm4, xmm7
- pandn xmm6, xmm5
- por xmm4, xmm6
-
- movdqa xmm1, xmm4
-
- movdqa xmm4, xmm2
- pshufd xmm5, xmm3, 0e4h
-
- psllq xmm3, 4
- psrlq xmm4, 4
-
- movdqa xmm6, xmm7
- pand xmm2, xmm7
- pandn xmm6, xmm3
- por xmm2, xmm6
-
- movdqa xmm6, xmm7
- pand xmm4, xmm7
- pandn xmm6, xmm5
- por xmm4, xmm6
-
- movdqa xmm3, xmm4
-
- punpck bw, 0, 2, 1, 3, 4, 6
-
- endm
-
-
-;
-; swizzling
-;
-
-;
-; SwizzleBlock32
-;
-
-@SwizzleBlock32_sse2@16 proc public
-
-
- push esi
- push edi
-
- mov edi, ecx
- mov esi, edx
- mov edx, [esp+4+8]
- mov ecx, 4
-
- mov eax, [esp+8+8]
- cmp eax, 0ffffffffh
- jne SwizzleBlock32_sse2@WM
-
- align 16
-@@:
- movdqa xmm0, [esi]
- movdqa xmm4, [esi+16]
- movdqa xmm1, [esi+edx]
- movdqa xmm5, [esi+edx+16]
-
- punpck qdq, 0, 4, 1, 5, 2, 6
-
- movntps [edi+16*0], xmm0
- movntps [edi+16*1], xmm2
- movntps [edi+16*2], xmm4
- movntps [edi+16*3], xmm6
-
- lea esi, [esi+edx*2]
- add edi, 64
-
- dec ecx
- jnz @B
-
- pop edi
- pop esi
-
- ret 8
-
-SwizzleBlock32_sse2@WM:
-
- movd xmm7, eax
- pshufd xmm7, xmm7, 0
-
- align 16
-@@:
- movdqa xmm0, [esi]
- movdqa xmm4, [esi+16]
- movdqa xmm1, [esi+edx]
- movdqa xmm5, [esi+edx+16]
-
- punpck qdq, 0, 4, 1, 5, 2, 6
-
- movdqa xmm3, xmm7
- pshufd xmm5, xmm7, 0e4h
-
- pandn xmm3, [edi+16*0]
- pand xmm0, xmm7
- por xmm0, xmm3
- movntps [edi+16*0], xmm0
-
- pandn xmm5, [edi+16*1]
- pand xmm2, xmm7
- por xmm2, xmm5
- movntps [edi+16*1], xmm2
-
- movdqa xmm3, xmm7
- pshufd xmm5, xmm7, 0e4h
-
- pandn xmm3, [edi+16*2]
- pand xmm4, xmm7
- por xmm4, xmm3
- movntps [edi+16*2], xmm4
-
- pandn xmm5, [edi+16*3]
- pand xmm6, xmm7
- por xmm6, xmm5
- movntps [edi+16*3], xmm6
-
- lea esi, [esi+edx*2]
- add edi, 64
-
- dec ecx
- jnz @B
-
- pop edi
- pop esi
-
- ret 8
-
-@SwizzleBlock32_sse2@16 endp
-
-;
-; SwizzleBlock16
-;
-
-@SwizzleBlock16_sse2@12 proc public
-
- push ebx
-
- mov ebx, [esp+4+4]
- mov eax, 4
-
- align 16
-@@:
- movdqa xmm0, [edx]
- movdqa xmm1, [edx+16]
- movdqa xmm2, [edx+ebx]
- movdqa xmm3, [edx+ebx+16]
-
- punpck wd, 0, 2, 1, 3, 4, 6
- punpck qdq, 0, 4, 2, 6, 1, 5
-
- movntps [ecx+16*0], xmm0
- movntps [ecx+16*1], xmm1
- movntps [ecx+16*2], xmm4
- movntps [ecx+16*3], xmm5
-
- lea edx, [edx+ebx*2]
- add ecx, 64
-
- dec eax
- jnz @B
-
- pop ebx
-
- ret 4
-
-@SwizzleBlock16_sse2@12 endp
-
-;
-; SwizzleBlock8
-;
-
-@SwizzleBlock8_sse2@12 proc public
-
- push ebx
-
- mov ebx, [esp+4+4]
- mov eax, 2
-
- align 16
-@@:
- ; col 0, 2
-
- movdqa xmm0, [edx]
- movdqa xmm2, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- pshufd xmm1, [edx], 0b1h
- pshufd xmm3, [edx+ebx], 0b1h
- lea edx, [edx+ebx*2]
-
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck wd, 0, 2, 4, 6, 1, 3
- punpck qdq, 0, 1, 2, 3, 4, 5
-
- movntps [ecx+16*0], xmm0
- movntps [ecx+16*1], xmm4
- movntps [ecx+16*2], xmm1
- movntps [ecx+16*3], xmm5
-
- ; col 1, 3
-
- pshufd xmm0, [edx], 0b1h
- pshufd xmm2, [edx+ebx], 0b1h
- lea edx, [edx+ebx*2]
-
- movdqa xmm1, [edx]
- movdqa xmm3, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck wd, 0, 2, 4, 6, 1, 3
- punpck qdq, 0, 1, 2, 3, 4, 5
-
- movntps [ecx+16*4], xmm0
- movntps [ecx+16*5], xmm4
- movntps [ecx+16*6], xmm1
- movntps [ecx+16*7], xmm5
-
- add ecx, 128
-
- dec eax
- jnz @B
-
- pop ebx
-
- ret 4
-
-@SwizzleBlock8_sse2@12 endp
-
-;
-; SwizzleBlock4
-;
-
-@SwizzleBlock4_sse2@12 proc public
-
- push ebx
-
- mov eax, 0f0f0f0fh
- movd xmm7, eax
- pshufd xmm7, xmm7, 0
-
- mov ebx, [esp+4+4]
- mov eax, 2
-
- align 16
-@@:
- ; col 0, 2
-
- movdqa xmm0, [edx]
- movdqa xmm2, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- movdqa xmm1, [edx]
- movdqa xmm3, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- pshuflw xmm1, xmm1, 0b1h
- pshuflw xmm3, xmm3, 0b1h
- pshufhw xmm1, xmm1, 0b1h
- pshufhw xmm3, xmm3, 0b1h
-
- punpcknb
- punpck bw, 0, 2, 4, 6, 1, 3
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck qdq, 0, 4, 2, 6, 1, 3
-
- movntps [ecx+16*0], xmm0
- movntps [ecx+16*1], xmm1
- movntps [ecx+16*2], xmm4
- movntps [ecx+16*3], xmm3
-
- ; col 1, 3
-
- movdqa xmm0, [edx]
- movdqa xmm2, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- movdqa xmm1, [edx]
- movdqa xmm3, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- pshuflw xmm0, xmm0, 0b1h
- pshuflw xmm2, xmm2, 0b1h
- pshufhw xmm0, xmm0, 0b1h
- pshufhw xmm2, xmm2, 0b1h
-
- punpcknb
- punpck bw, 0, 2, 4, 6, 1, 3
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck qdq, 0, 4, 2, 6, 1, 3
-
- movntps [ecx+16*4], xmm0
- movntps [ecx+16*5], xmm1
- movntps [ecx+16*6], xmm4
- movntps [ecx+16*7], xmm3
-
- add ecx, 128
-
- dec eax
- jnz @B
-
- pop ebx
-
- ret 4
-
-@SwizzleBlock4_sse2@12 endp
-
-;
-; swizzling with unaligned reads
-;
-
-;
-; SwizzleBlock32u
-;
-
-@SwizzleBlock32u_sse2@16 proc public
-
- push esi
- push edi
-
- mov edi, ecx
- mov esi, edx
- mov edx, [esp+4+8]
- mov ecx, 4
-
- mov eax, [esp+8+8]
- cmp eax, 0ffffffffh
- jne SwizzleBlock32u_sse2@WM
-
- align 16
-@@:
- movdqu xmm0, [esi]
- movdqu xmm4, [esi+16]
- movdqu xmm1, [esi+edx]
- movdqu xmm5, [esi+edx+16]
-
- punpck qdq, 0, 4, 1, 5, 2, 6
-
- movntps [edi+16*0], xmm0
- movntps [edi+16*1], xmm2
- movntps [edi+16*2], xmm4
- movntps [edi+16*3], xmm6
-
- lea esi, [esi+edx*2]
- add edi, 64
-
- dec ecx
- jnz @B
-
- pop edi
- pop esi
-
- ret 8
-
-SwizzleBlock32u_sse2@WM:
-
- movd xmm7, eax
- pshufd xmm7, xmm7, 0
-
- align 16
-@@:
- movdqu xmm0, [esi]
- movdqu xmm4, [esi+16]
- movdqu xmm1, [esi+edx]
- movdqu xmm5, [esi+edx+16]
-
- punpck qdq, 0, 4, 1, 5, 2, 6
-
- movdqa xmm3, xmm7
- pshufd xmm5, xmm7, 0e4h
-
- pandn xmm3, [edi+16*0]
- pand xmm0, xmm7
- por xmm0, xmm3
- movdqa [edi+16*0], xmm0
-
- pandn xmm5, [edi+16*1]
- pand xmm2, xmm7
- por xmm2, xmm5
- movdqa [edi+16*1], xmm2
-
- movdqa xmm3, xmm7
- pshufd xmm5, xmm7, 0e4h
-
- pandn xmm3, [edi+16*2]
- pand xmm4, xmm7
- por xmm4, xmm3
- movdqa [edi+16*2], xmm4
-
- pandn xmm5, [edi+16*3]
- pand xmm6, xmm7
- por xmm6, xmm5
- movdqa [edi+16*3], xmm6
-
- lea esi, [esi+edx*2]
- add edi, 64
-
- dec ecx
- jnz @B
-
- pop edi
- pop esi
-
- ret 8
-
-@SwizzleBlock32u_sse2@16 endp
-
-;
-; SwizzleBlock16u
-;
-
-@SwizzleBlock16u_sse2@12 proc public
-
- push ebx
-
- mov ebx, [esp+4+4]
- mov eax, 4
-
- align 16
-@@:
- movdqu xmm0, [edx]
- movdqu xmm1, [edx+16]
- movdqu xmm2, [edx+ebx]
- movdqu xmm3, [edx+ebx+16]
-
- punpck wd, 0, 2, 1, 3, 4, 6
- punpck qdq, 0, 4, 2, 6, 1, 5
-
- movntps [ecx+16*0], xmm0
- movntps [ecx+16*1], xmm1
- movntps [ecx+16*2], xmm4
- movntps [ecx+16*3], xmm5
-
- lea edx, [edx+ebx*2]
- add ecx, 64
-
- dec eax
- jnz @B
-
- pop ebx
-
- ret 4
-
-@SwizzleBlock16u_sse2@12 endp
-
-;
-; SwizzleBlock8u
-;
-
-@SwizzleBlock8u_sse2@12 proc public
-
- push ebx
-
- mov ebx, [esp+4+4]
- mov eax, 2
-
- align 16
-@@:
- ; col 0, 2
-
- movdqu xmm0, [edx]
- movdqu xmm2, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- movdqu xmm1, [edx]
- movdqu xmm3, [edx+ebx]
- pshufd xmm1, xmm1, 0b1h
- pshufd xmm3, xmm3, 0b1h
- lea edx, [edx+ebx*2]
-
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck wd, 0, 2, 4, 6, 1, 3
- punpck qdq, 0, 1, 2, 3, 4, 5
-
- movntps [ecx+16*0], xmm0
- movntps [ecx+16*1], xmm4
- movntps [ecx+16*2], xmm1
- movntps [ecx+16*3], xmm5
-
- ; col 1, 3
-
- movdqu xmm0, [edx]
- movdqu xmm2, [edx+ebx]
- pshufd xmm0, xmm0, 0b1h
- pshufd xmm2, xmm2, 0b1h
- lea edx, [edx+ebx*2]
-
- movdqu xmm1, [edx]
- movdqu xmm3, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck wd, 0, 2, 4, 6, 1, 3
- punpck qdq, 0, 1, 2, 3, 4, 5
-
- movntps [ecx+16*4], xmm0
- movntps [ecx+16*5], xmm4
- movntps [ecx+16*6], xmm1
- movntps [ecx+16*7], xmm5
-
- add ecx, 128
-
- dec eax
- jnz @B
-
- pop ebx
-
- ret 4
-
-@SwizzleBlock8u_sse2@12 endp
-
-;
-; SwizzleBlock4u
-;
-
-@SwizzleBlock4u_sse2@12 proc public
-
- push ebx
-
- mov eax, 0f0f0f0fh
- movd xmm7, eax
- pshufd xmm7, xmm7, 0
-
- mov ebx, [esp+4+4]
- mov eax, 2
-
- align 16
-@@:
- ; col 0, 2
-
- movdqu xmm0, [edx]
- movdqu xmm2, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- movdqu xmm1, [edx]
- movdqu xmm3, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- pshuflw xmm1, xmm1, 0b1h
- pshuflw xmm3, xmm3, 0b1h
- pshufhw xmm1, xmm1, 0b1h
- pshufhw xmm3, xmm3, 0b1h
-
- punpcknb
- punpck bw, 0, 2, 4, 6, 1, 3
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck qdq, 0, 4, 2, 6, 1, 3
-
- movntps [ecx+16*0], xmm0
- movntps [ecx+16*1], xmm1
- movntps [ecx+16*2], xmm4
- movntps [ecx+16*3], xmm3
-
- ; col 1, 3
-
- movdqu xmm0, [edx]
- movdqu xmm2, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- movdqu xmm1, [edx]
- movdqu xmm3, [edx+ebx]
- lea edx, [edx+ebx*2]
-
- pshuflw xmm0, xmm0, 0b1h
- pshuflw xmm2, xmm2, 0b1h
- pshufhw xmm0, xmm0, 0b1h
- pshufhw xmm2, xmm2, 0b1h
-
- punpcknb
- punpck bw, 0, 2, 4, 6, 1, 3
- punpck bw, 0, 2, 1, 3, 4, 6
- punpck qdq, 0, 4, 2, 6, 1, 3
-
- movntps [ecx+16*4], xmm0
- movntps [ecx+16*5], xmm1
- movntps [ecx+16*6], xmm4
- movntps [ecx+16*7], xmm3
-
- add ecx, 128
-
- dec eax
- jnz @B
-
- pop ebx
-
- ret 4
-
-@SwizzleBlock4u_sse2@12 endp
-
+; Copyright (C) 2003-2005 Gabest
+; http://www.gabest.org
+;
+; 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, 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 GNU Make; see the file COPYING. If not, write to
+; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+; http://www.gnu.org/copyleft/gpl.html
+;
+;
+ .686
+ .model flat
+ .mmx
+ .xmm
+
+ .const
+
+ __uvmin DD 0d01502f9r ; -1e+010
+ __uvmax DD 0501502f9r ; +1e+010
+
+ .code
+
+;
+; swizzling
+;
+
+punpck macro op, sd0, sd2, s1, s3, d1, d3
+
+ movdqa @CatStr(xmm, %d1), @CatStr(xmm, %sd0)
+ pshufd @CatStr(xmm, %d3), @CatStr(xmm, %sd2), 0e4h
+
+ @CatStr(punpckl, op) @CatStr(xmm, %sd0), @CatStr(xmm, %s1)
+ @CatStr(punpckh, op) @CatStr(xmm, %d1), @CatStr(xmm, %s1)
+ @CatStr(punpckl, op) @CatStr(xmm, %sd2), @CatStr(xmm, %s3)
+ @CatStr(punpckh, op) @CatStr(xmm, %d3), @CatStr(xmm, %s3)
+
+ endm
+
+punpcknb macro
+
+ movdqa xmm4, xmm0
+ pshufd xmm5, xmm1, 0e4h
+
+ psllq xmm1, 4
+ psrlq xmm4, 4
+
+ movdqa xmm6, xmm7
+ pand xmm0, xmm7
+ pandn xmm6, xmm1
+ por xmm0, xmm6
+
+ movdqa xmm6, xmm7
+ pand xmm4, xmm7
+ pandn xmm6, xmm5
+ por xmm4, xmm6
+
+ movdqa xmm1, xmm4
+
+ movdqa xmm4, xmm2
+ pshufd xmm5, xmm3, 0e4h
+
+ psllq xmm3, 4
+ psrlq xmm4, 4
+
+ movdqa xmm6, xmm7
+ pand xmm2, xmm7
+ pandn xmm6, xmm3
+ por xmm2, xmm6
+
+ movdqa xmm6, xmm7
+ pand xmm4, xmm7
+ pandn xmm6, xmm5
+ por xmm4, xmm6
+
+ movdqa xmm3, xmm4
+
+ punpck bw, 0, 2, 1, 3, 4, 6
+
+ endm
+
+
+;
+; swizzling
+;
+
+;
+; SwizzleBlock32
+;
+
+@SwizzleBlock32_sse2@16 proc public
+
+
+ push esi
+ push edi
+
+ mov edi, ecx
+ mov esi, edx
+ mov edx, [esp+4+8]
+ mov ecx, 4
+
+ mov eax, [esp+8+8]
+ cmp eax, 0ffffffffh
+ jne SwizzleBlock32_sse2@WM
+
+ align 16
+@@:
+ movdqa xmm0, [esi]
+ movdqa xmm4, [esi+16]
+ movdqa xmm1, [esi+edx]
+ movdqa xmm5, [esi+edx+16]
+
+ punpck qdq, 0, 4, 1, 5, 2, 6
+
+ movntps [edi+16*0], xmm0
+ movntps [edi+16*1], xmm2
+ movntps [edi+16*2], xmm4
+ movntps [edi+16*3], xmm6
+
+ lea esi, [esi+edx*2]
+ add edi, 64
+
+ dec ecx
+ jnz @B
+
+ pop edi
+ pop esi
+
+ ret 8
+
+SwizzleBlock32_sse2@WM:
+
+ movd xmm7, eax
+ pshufd xmm7, xmm7, 0
+
+ align 16
+@@:
+ movdqa xmm0, [esi]
+ movdqa xmm4, [esi+16]
+ movdqa xmm1, [esi+edx]
+ movdqa xmm5, [esi+edx+16]
+
+ punpck qdq, 0, 4, 1, 5, 2, 6
+
+ movdqa xmm3, xmm7
+ pshufd xmm5, xmm7, 0e4h
+
+ pandn xmm3, [edi+16*0]
+ pand xmm0, xmm7
+ por xmm0, xmm3
+ movntps [edi+16*0], xmm0
+
+ pandn xmm5, [edi+16*1]
+ pand xmm2, xmm7
+ por xmm2, xmm5
+ movntps [edi+16*1], xmm2
+
+ movdqa xmm3, xmm7
+ pshufd xmm5, xmm7, 0e4h
+
+ pandn xmm3, [edi+16*2]
+ pand xmm4, xmm7
+ por xmm4, xmm3
+ movntps [edi+16*2], xmm4
+
+ pandn xmm5, [edi+16*3]
+ pand xmm6, xmm7
+ por xmm6, xmm5
+ movntps [edi+16*3], xmm6
+
+ lea esi, [esi+edx*2]
+ add edi, 64
+
+ dec ecx
+ jnz @B
+
+ pop edi
+ pop esi
+
+ ret 8
+
+@SwizzleBlock32_sse2@16 endp
+
+;
+; SwizzleBlock16
+;
+
+@SwizzleBlock16_sse2@12 proc public
+
+ push ebx
+
+ mov ebx, [esp+4+4]
+ mov eax, 4
+
+ align 16
+@@:
+ movdqa xmm0, [edx]
+ movdqa xmm1, [edx+16]
+ movdqa xmm2, [edx+ebx]
+ movdqa xmm3, [edx+ebx+16]
+
+ punpck wd, 0, 2, 1, 3, 4, 6
+ punpck qdq, 0, 4, 2, 6, 1, 5
+
+ movntps [ecx+16*0], xmm0
+ movntps [ecx+16*1], xmm1
+ movntps [ecx+16*2], xmm4
+ movntps [ecx+16*3], xmm5
+
+ lea edx, [edx+ebx*2]
+ add ecx, 64
+
+ dec eax
+ jnz @B
+
+ pop ebx
+
+ ret 4
+
+@SwizzleBlock16_sse2@12 endp
+
+;
+; SwizzleBlock8
+;
+
+@SwizzleBlock8_sse2@12 proc public
+
+ push ebx
+
+ mov ebx, [esp+4+4]
+ mov eax, 2
+
+ align 16
+@@:
+ ; col 0, 2
+
+ movdqa xmm0, [edx]
+ movdqa xmm2, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ pshufd xmm1, [edx], 0b1h
+ pshufd xmm3, [edx+ebx], 0b1h
+ lea edx, [edx+ebx*2]
+
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck wd, 0, 2, 4, 6, 1, 3
+ punpck qdq, 0, 1, 2, 3, 4, 5
+
+ movntps [ecx+16*0], xmm0
+ movntps [ecx+16*1], xmm4
+ movntps [ecx+16*2], xmm1
+ movntps [ecx+16*3], xmm5
+
+ ; col 1, 3
+
+ pshufd xmm0, [edx], 0b1h
+ pshufd xmm2, [edx+ebx], 0b1h
+ lea edx, [edx+ebx*2]
+
+ movdqa xmm1, [edx]
+ movdqa xmm3, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck wd, 0, 2, 4, 6, 1, 3
+ punpck qdq, 0, 1, 2, 3, 4, 5
+
+ movntps [ecx+16*4], xmm0
+ movntps [ecx+16*5], xmm4
+ movntps [ecx+16*6], xmm1
+ movntps [ecx+16*7], xmm5
+
+ add ecx, 128
+
+ dec eax
+ jnz @B
+
+ pop ebx
+
+ ret 4
+
+@SwizzleBlock8_sse2@12 endp
+
+;
+; SwizzleBlock4
+;
+
+@SwizzleBlock4_sse2@12 proc public
+
+ push ebx
+
+ mov eax, 0f0f0f0fh
+ movd xmm7, eax
+ pshufd xmm7, xmm7, 0
+
+ mov ebx, [esp+4+4]
+ mov eax, 2
+
+ align 16
+@@:
+ ; col 0, 2
+
+ movdqa xmm0, [edx]
+ movdqa xmm2, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ movdqa xmm1, [edx]
+ movdqa xmm3, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ pshuflw xmm1, xmm1, 0b1h
+ pshuflw xmm3, xmm3, 0b1h
+ pshufhw xmm1, xmm1, 0b1h
+ pshufhw xmm3, xmm3, 0b1h
+
+ punpcknb
+ punpck bw, 0, 2, 4, 6, 1, 3
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck qdq, 0, 4, 2, 6, 1, 3
+
+ movntps [ecx+16*0], xmm0
+ movntps [ecx+16*1], xmm1
+ movntps [ecx+16*2], xmm4
+ movntps [ecx+16*3], xmm3
+
+ ; col 1, 3
+
+ movdqa xmm0, [edx]
+ movdqa xmm2, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ movdqa xmm1, [edx]
+ movdqa xmm3, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ pshuflw xmm0, xmm0, 0b1h
+ pshuflw xmm2, xmm2, 0b1h
+ pshufhw xmm0, xmm0, 0b1h
+ pshufhw xmm2, xmm2, 0b1h
+
+ punpcknb
+ punpck bw, 0, 2, 4, 6, 1, 3
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck qdq, 0, 4, 2, 6, 1, 3
+
+ movntps [ecx+16*4], xmm0
+ movntps [ecx+16*5], xmm1
+ movntps [ecx+16*6], xmm4
+ movntps [ecx+16*7], xmm3
+
+ add ecx, 128
+
+ dec eax
+ jnz @B
+
+ pop ebx
+
+ ret 4
+
+@SwizzleBlock4_sse2@12 endp
+
+;
+; swizzling with unaligned reads
+;
+
+;
+; SwizzleBlock32u
+;
+
+@SwizzleBlock32u_sse2@16 proc public
+
+ push esi
+ push edi
+
+ mov edi, ecx
+ mov esi, edx
+ mov edx, [esp+4+8]
+ mov ecx, 4
+
+ mov eax, [esp+8+8]
+ cmp eax, 0ffffffffh
+ jne SwizzleBlock32u_sse2@WM
+
+ align 16
+@@:
+ movdqu xmm0, [esi]
+ movdqu xmm4, [esi+16]
+ movdqu xmm1, [esi+edx]
+ movdqu xmm5, [esi+edx+16]
+
+ punpck qdq, 0, 4, 1, 5, 2, 6
+
+ movntps [edi+16*0], xmm0
+ movntps [edi+16*1], xmm2
+ movntps [edi+16*2], xmm4
+ movntps [edi+16*3], xmm6
+
+ lea esi, [esi+edx*2]
+ add edi, 64
+
+ dec ecx
+ jnz @B
+
+ pop edi
+ pop esi
+
+ ret 8
+
+SwizzleBlock32u_sse2@WM:
+
+ movd xmm7, eax
+ pshufd xmm7, xmm7, 0
+
+ align 16
+@@:
+ movdqu xmm0, [esi]
+ movdqu xmm4, [esi+16]
+ movdqu xmm1, [esi+edx]
+ movdqu xmm5, [esi+edx+16]
+
+ punpck qdq, 0, 4, 1, 5, 2, 6
+
+ movdqa xmm3, xmm7
+ pshufd xmm5, xmm7, 0e4h
+
+ pandn xmm3, [edi+16*0]
+ pand xmm0, xmm7
+ por xmm0, xmm3
+ movdqa [edi+16*0], xmm0
+
+ pandn xmm5, [edi+16*1]
+ pand xmm2, xmm7
+ por xmm2, xmm5
+ movdqa [edi+16*1], xmm2
+
+ movdqa xmm3, xmm7
+ pshufd xmm5, xmm7, 0e4h
+
+ pandn xmm3, [edi+16*2]
+ pand xmm4, xmm7
+ por xmm4, xmm3
+ movdqa [edi+16*2], xmm4
+
+ pandn xmm5, [edi+16*3]
+ pand xmm6, xmm7
+ por xmm6, xmm5
+ movdqa [edi+16*3], xmm6
+
+ lea esi, [esi+edx*2]
+ add edi, 64
+
+ dec ecx
+ jnz @B
+
+ pop edi
+ pop esi
+
+ ret 8
+
+@SwizzleBlock32u_sse2@16 endp
+
+;
+; SwizzleBlock16u
+;
+
+@SwizzleBlock16u_sse2@12 proc public
+
+ push ebx
+
+ mov ebx, [esp+4+4]
+ mov eax, 4
+
+ align 16
+@@:
+ movdqu xmm0, [edx]
+ movdqu xmm1, [edx+16]
+ movdqu xmm2, [edx+ebx]
+ movdqu xmm3, [edx+ebx+16]
+
+ punpck wd, 0, 2, 1, 3, 4, 6
+ punpck qdq, 0, 4, 2, 6, 1, 5
+
+ movntps [ecx+16*0], xmm0
+ movntps [ecx+16*1], xmm1
+ movntps [ecx+16*2], xmm4
+ movntps [ecx+16*3], xmm5
+
+ lea edx, [edx+ebx*2]
+ add ecx, 64
+
+ dec eax
+ jnz @B
+
+ pop ebx
+
+ ret 4
+
+@SwizzleBlock16u_sse2@12 endp
+
+;
+; SwizzleBlock8u
+;
+
+@SwizzleBlock8u_sse2@12 proc public
+
+ push ebx
+
+ mov ebx, [esp+4+4]
+ mov eax, 2
+
+ align 16
+@@:
+ ; col 0, 2
+
+ movdqu xmm0, [edx]
+ movdqu xmm2, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ movdqu xmm1, [edx]
+ movdqu xmm3, [edx+ebx]
+ pshufd xmm1, xmm1, 0b1h
+ pshufd xmm3, xmm3, 0b1h
+ lea edx, [edx+ebx*2]
+
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck wd, 0, 2, 4, 6, 1, 3
+ punpck qdq, 0, 1, 2, 3, 4, 5
+
+ movntps [ecx+16*0], xmm0
+ movntps [ecx+16*1], xmm4
+ movntps [ecx+16*2], xmm1
+ movntps [ecx+16*3], xmm5
+
+ ; col 1, 3
+
+ movdqu xmm0, [edx]
+ movdqu xmm2, [edx+ebx]
+ pshufd xmm0, xmm0, 0b1h
+ pshufd xmm2, xmm2, 0b1h
+ lea edx, [edx+ebx*2]
+
+ movdqu xmm1, [edx]
+ movdqu xmm3, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck wd, 0, 2, 4, 6, 1, 3
+ punpck qdq, 0, 1, 2, 3, 4, 5
+
+ movntps [ecx+16*4], xmm0
+ movntps [ecx+16*5], xmm4
+ movntps [ecx+16*6], xmm1
+ movntps [ecx+16*7], xmm5
+
+ add ecx, 128
+
+ dec eax
+ jnz @B
+
+ pop ebx
+
+ ret 4
+
+@SwizzleBlock8u_sse2@12 endp
+
+;
+; SwizzleBlock4u
+;
+
+@SwizzleBlock4u_sse2@12 proc public
+
+ push ebx
+
+ mov eax, 0f0f0f0fh
+ movd xmm7, eax
+ pshufd xmm7, xmm7, 0
+
+ mov ebx, [esp+4+4]
+ mov eax, 2
+
+ align 16
+@@:
+ ; col 0, 2
+
+ movdqu xmm0, [edx]
+ movdqu xmm2, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ movdqu xmm1, [edx]
+ movdqu xmm3, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ pshuflw xmm1, xmm1, 0b1h
+ pshuflw xmm3, xmm3, 0b1h
+ pshufhw xmm1, xmm1, 0b1h
+ pshufhw xmm3, xmm3, 0b1h
+
+ punpcknb
+ punpck bw, 0, 2, 4, 6, 1, 3
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck qdq, 0, 4, 2, 6, 1, 3
+
+ movntps [ecx+16*0], xmm0
+ movntps [ecx+16*1], xmm1
+ movntps [ecx+16*2], xmm4
+ movntps [ecx+16*3], xmm3
+
+ ; col 1, 3
+
+ movdqu xmm0, [edx]
+ movdqu xmm2, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ movdqu xmm1, [edx]
+ movdqu xmm3, [edx+ebx]
+ lea edx, [edx+ebx*2]
+
+ pshuflw xmm0, xmm0, 0b1h
+ pshuflw xmm2, xmm2, 0b1h
+ pshufhw xmm0, xmm0, 0b1h
+ pshufhw xmm2, xmm2, 0b1h
+
+ punpcknb
+ punpck bw, 0, 2, 4, 6, 1, 3
+ punpck bw, 0, 2, 1, 3, 4, 6
+ punpck qdq, 0, 4, 2, 6, 1, 3
+
+ movntps [ecx+16*4], xmm0
+ movntps [ecx+16*5], xmm1
+ movntps [ecx+16*6], xmm4
+ movntps [ecx+16*7], xmm3
+
+ add ecx, 128
+
+ dec eax
+ jnz @B
+
+ pop ebx
+
+ ret 4
+
+@SwizzleBlock4u_sse2@12 endp
+
end
\ No newline at end of file
diff --git a/tools/GSDumpGUI/Core/Program.cs b/tools/GSDumpGUI/Core/Program.cs
index b69d45a89c..327c9c04b3 100644
--- a/tools/GSDumpGUI/Core/Program.cs
+++ b/tools/GSDumpGUI/Core/Program.cs
@@ -1,450 +1,450 @@
-using System;
-using System.Collections.Generic;
-using System.Windows.Forms;
-using Specialized = System.Collections.Specialized;
-using Reflection = System.Reflection;
-using System.Runtime.InteropServices;
-using System.Threading;
-using System.Diagnostics;
-using GSDumpGUI.Properties;
-using System.IO;
-using TCPLibrary.MessageBased.Core;
-using System.Drawing;
-
-namespace GSDumpGUI
-{
- static class Program
- {
- static public GSDumpGUI frmMain;
- static public TCPLibrary.MessageBased.Core.BaseMessageServer Server;
- static public List Clients;
-
- static public TCPLibrary.MessageBased.Core.BaseMessageClient Client;
- static private Boolean ChangeIcon;
- static private GSDump dump;
- static private GSDXWrapper wrap;
-
- static private TreeNode CurrentNode;
-
- [STAThread]
- static void Main(String[] args)
- {
- if (args.Length == 4)
- {
- // do this first, else racy mess ;)
- wrap = new GSDXWrapper();
-
- try
- {
- Client = new TCPLibrary.MessageBased.Core.BaseMessageClient();
- Client.OnMessageReceived += new TCPLibrary.MessageBased.Core.BaseMessageClient.MessageReceivedHandler(Client_OnMessageReceived);
- Client.Connect("localhost", 9999);
- }
- catch (Exception)
- {
- Client = null;
- }
-
- Thread thd = new Thread(new ThreadStart(delegate
- {
- while (true)
- {
- IntPtr pt = Process.GetCurrentProcess().MainWindowHandle;
- if (ChangeIcon)
- {
- if (pt.ToInt64() != 0)
- {
- NativeMethods.SetClassLong(pt, -14, Resources.AppIcon.Handle.ToInt64());
- ChangeIcon = false;
- }
- }
-
- Int32 tmp = NativeMethods.GetAsyncKeyState(0x1b) & 0xf;
- if (tmp != 0)
- Process.GetCurrentProcess().Kill();
- Thread.Sleep(16);
- }
- }));
- thd.IsBackground = true;
- thd.Start();
-
- // Retrieve parameters
- String DLLPath = args[0];
- String DumpPath = args[1];
- String Operation = args[2];
- Int32 Renderer = Convert.ToInt32(args[3]);
-
- wrap.Load(DLLPath);
- Directory.SetCurrentDirectory(Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory + "GSDumpGSDXConfigs\\" + Path.GetFileName(DLLPath) + "\\"));
- if (Operation == "GSReplay")
- {
- dump = GSDump.LoadDump(DumpPath);
-
- if (Client != null)
- {
- SendStatistics();
- SendDumpSize();
- }
-
- wrap.Run(dump, Renderer);
- ChangeIcon = true;
- }
- else
- wrap.GSConfig();
- wrap.Unload();
-
- if (GSDXWrapper.DumpTooOld)
- {
- if (Client != null)
- {
- TCPMessage msg = new TCPMessage();
- msg.MessageType = MessageType.StateOld;
- Client.Send(msg);
- }
- }
-
- if (Client != null)
- Client.Disconnect();
- }
- else
- {
- Clients = new List();
-
- Server = new TCPLibrary.MessageBased.Core.BaseMessageServer();
- Server.OnClientMessageReceived += new BaseMessageServer.MessageReceivedHandler(Server_OnClientMessageReceived);
- Server.OnClientAfterConnect += new TCPLibrary.Core.Server.ConnectedHandler(Server_OnClientAfterConnect);
- Server.OnClientAfterDisconnected += new TCPLibrary.Core.Server.DisconnectedHandler(Server_OnClientAfterDisconnected);
- Server.Port = 9999;
- Server.Enabled = true;
-
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- frmMain = new GSDumpGUI();
- Application.Run(frmMain);
-
- Server.Enabled = false;
- }
- }
-
- static void Server_OnClientAfterDisconnected(TCPLibrary.Core.Server server, TCPLibrary.Core.ClientS sender)
- {
- Clients.Remove((TCPLibrary.MessageBased.Core.BaseMessageClientS)sender);
- RefreshList(false);
- }
-
- static void Server_OnClientMessageReceived(BaseMessageServer server, BaseMessageClientS sender, TCPMessage Mess)
- {
- switch (Mess.MessageType)
- {
- case MessageType.Connect:
- break;
- case MessageType.MaxUsers:
- break;
- case MessageType.SizeDump:
- frmMain.Invoke(new Action