18 changes: 9 additions & 9 deletions Source/Core/AudioCommon/Src/NullSoundStream.h
Expand Up @@ -25,24 +25,24 @@

class NullSound : public SoundStream
{
// playback position
short realtimeBuffer[BUF_SIZE / sizeof(short)];
// playback position
short realtimeBuffer[BUF_SIZE / sizeof(short)];

public:
NullSound(CMixer *mixer, void *hWnd = NULL)
: SoundStream(mixer)
{}

virtual ~NullSound() {}
virtual ~NullSound() {}

virtual bool Start();
virtual void SoundLoop();
virtual void SoundLoop();
virtual void SetVolume(int volume);
virtual void Stop();
virtual void Stop();
virtual void Clear(bool mute);
static bool isValid() { return true; }
virtual bool usesMixer() const { return true; }
virtual void Update();
static bool isValid() { return true; }
virtual bool usesMixer() const { return true; }
virtual void Update();
};

#endif //_NULLSOUNDSTREAM_H_
2 changes: 0 additions & 2 deletions Source/Core/AudioCommon/Src/OpenALStream.cpp
Expand Up @@ -295,7 +295,6 @@ void OpenALStream::SoundLoop()
{
ERROR_LOG(AUDIO, "Error occurred while buffering float32 data: %08x", err);
}

}
#endif
if (!float32_capable)
Expand All @@ -308,7 +307,6 @@ void OpenALStream::SoundLoop()
stereo[i * 2 + 1] = (short)((float)sampleBuffer[i * 2 + 1] * (1 << 16));
}
alBufferData(uiBufferTemp[iBuffersFilled], AL_FORMAT_STEREO16, stereo, nSamples * 2 * 2, ulFrequency);

}
}

Expand Down
10 changes: 5 additions & 5 deletions Source/Core/AudioCommon/Src/SoundStream.h
Expand Up @@ -27,17 +27,17 @@ class SoundStream
protected:

CMixer *m_mixer;
// We set this to shut down the sound thread.
// 0=keep playing, 1=stop playing NOW.
volatile int threadData;
bool m_logAudio;
// We set this to shut down the sound thread.
// 0=keep playing, 1=stop playing NOW.
volatile int threadData;
bool m_logAudio;
WaveFileWriter g_wave_writer;
bool m_muted;

public:
SoundStream(CMixer *mixer) : m_mixer(mixer), threadData(0), m_logAudio(false), m_muted(false) {}
virtual ~SoundStream() { delete m_mixer;}

static bool isValid() { return false; }
virtual CMixer *GetMixer() const { return m_mixer; }
virtual bool Start() { return false; }
Expand Down
10 changes: 5 additions & 5 deletions Source/Core/AudioCommon/Src/WaveFile.cpp
Expand Up @@ -104,21 +104,21 @@ void WaveFileWriter::AddStereoSamples(const short *sample_data, u32 count)
{
if (!file)
PanicAlertT("WaveFileWriter - file not open.");

if (skip_silence)
{
bool all_zero = true;

for (u32 i = 0; i < count * 2; i++)
{
if (sample_data[i])
all_zero = false;
}

if (all_zero)
return;
}

file.WriteBytes(sample_data, count * 4);
audio_size += count * 4;
}
Expand All @@ -134,7 +134,7 @@ void WaveFileWriter::AddStereoSamplesBE(const short *sample_data, u32 count)
if (skip_silence)
{
bool all_zero = true;

for (u32 i = 0; i < count * 2; i++)
{
if (sample_data[i])
Expand Down
6 changes: 3 additions & 3 deletions Source/Core/AudioCommon/Src/XAudio2Stream.cpp
Expand Up @@ -95,10 +95,10 @@ void StreamingVoiceContext::OnBufferEnd(void* context)

if (!m_source_voice || !context)
return;

//m_sound_sync_event->Wait(); // sync
//m_sound_sync_event->Spin(); // or tight sync

m_mixer->Mix(static_cast<short*>(context), SAMPLES_PER_BUFFER);
SubmitBuffer(static_cast<BYTE*>(context));
}
Expand Down Expand Up @@ -183,6 +183,6 @@ void XAudio2::Stop()
m_mastering_voice->DestroyVoice();
m_mastering_voice = nullptr;
}

m_xaudio2.reset(); // release interface
}
14 changes: 7 additions & 7 deletions Source/Core/Common/Src/ArmCPUDetect.cpp
Expand Up @@ -33,7 +33,7 @@ char *GetCPUString()
auto const fp = file.GetHandle();
if (!fp)
return 0;

while (fgets(buf, sizeof(buf), fp))
{
if (strncmp(buf, marker, sizeof(marker) - 1))
Expand Down Expand Up @@ -74,12 +74,12 @@ int GetCoreCount()
const char marker[] = "processor\t: ";
int cores = 0;
char buf[1024];

File::IOFile file(procfile, "r");
auto const fp = file.GetHandle();
if (!fp)
return 0;

while (fgets(buf, sizeof(buf), fp))
{
if (strncmp(buf, marker, sizeof(marker) - 1))
Expand All @@ -103,12 +103,12 @@ void CPUInfo::Detect()
HTT = false;
OS64bit = false;
CPU64bit = false;
Mode64bit = false;
Mode64bit = false;
vendor = VENDOR_ARM;

// Get the information about the CPU
strncpy(cpu_string, GetCPUString(), sizeof(cpu_string));
num_cores = GetCoreCount();
num_cores = GetCoreCount();
bSwp = CheckCPUFeature("swp");
bHalf = CheckCPUFeature("half");
bThumb = CheckCPUFeature("thumb");
Expand All @@ -122,7 +122,7 @@ void CPUInfo::Detect()
bVFPv4 = CheckCPUFeature("vfpv4");
bIDIVa = CheckCPUFeature("idiva");
bIDIVt = CheckCPUFeature("idivt");

// On some buggy kernels(Qualcomm) they show that they support VFPv4 but not IDIVa
// All VFPv4 CPUs will support IDIVa
if (bVFPv4)
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Common/Src/ArmEmitter.cpp
Expand Up @@ -157,7 +157,7 @@ void ARMXEmitter::MOVI2R(ARMReg reg, u32 val, bool optimize)
{
Operand2 op2;
bool inverse;

if (cpu_info.bArmV7 && !optimize)
{
// For backpatching on ARMv7
Expand Down
28 changes: 14 additions & 14 deletions Source/Core/Common/Src/ArmEmitter.h
Expand Up @@ -136,7 +136,7 @@ class Operand2
u32 Value;

private:
OpType Type;
OpType Type;

// IMM types
u8 Rotation; // Only for u8 values
Expand All @@ -154,7 +154,7 @@ class Operand2
{
Type = type;
Value = imm;
Rotation = 0;
Rotation = 0;
}

Operand2(ARMReg Reg)
Expand Down Expand Up @@ -297,7 +297,7 @@ class Operand2
u32 Imm24()
{
_assert_msg_(DYNA_REC, (Type == TYPE_IMM), "Imm16 not IMM");
return (Value & 0x0FFFFFFF);
return (Value & 0x0FFFFFFF);
}
// NEON and ASIMD specific
u32 Imm8ASIMD()
Expand Down Expand Up @@ -336,9 +336,9 @@ struct FixupBranch

struct LiteralPool
{
s32 loc;
u8* ldr_address;
u32 val;
s32 loc;
u8* ldr_address;
u32 val;
};

typedef const u8* JumpTarget;
Expand All @@ -357,7 +357,7 @@ class ARMXEmitter
void WriteShiftedDataOp(u32 op, bool SetFlags, ARMReg dest, ARMReg src, ARMReg op2);
void WriteShiftedDataOp(u32 op, bool SetFlags, ARMReg dest, ARMReg src, Operand2 op2);
void WriteSignedMultiply(u32 Op, u32 Op2, u32 Op3, ARMReg dest, ARMReg r1, ARMReg r2);

u32 EncodeVd(ARMReg Vd);
u32 EncodeVn(ARMReg Vn);
u32 EncodeVm(ARMReg Vm);
Expand Down Expand Up @@ -407,10 +407,10 @@ class ARMXEmitter

// Hint instruction
void YIELD();

// Do nothing
void NOP(int count = 1); //nop padding - TODO: fast nop slides, for amd and intel (check their manuals)

#ifdef CALL
#undef CALL
#endif
Expand All @@ -422,7 +422,7 @@ class ARMXEmitter
FixupBranch BL();
FixupBranch BL_CC(CCFlags Cond);
void SetJumpTarget(FixupBranch const &branch);

void B (const void *fnptr);
void B (ARMReg src);
void BL(const void *fnptr);
Expand Down Expand Up @@ -468,7 +468,7 @@ class ARMXEmitter
void BICS(ARMReg dest, ARMReg src, Operand2 op2);
void MVN (ARMReg dest, Operand2 op2);
void MVNS(ARMReg dest, Operand2 op2);
void MOVW(ARMReg dest, Operand2 op2);
void MOVW(ARMReg dest, Operand2 op2);
void MOVT(ARMReg dest, Operand2 op2, bool TopBits = false);

// UDIV and SDIV are only available on CPUs that have
Expand Down Expand Up @@ -510,7 +510,7 @@ class ARMXEmitter

void STMFD(ARMReg dest, bool WriteBack, const int Regnum, ...);
void LDMFD(ARMReg dest, bool WriteBack, const int Regnum, ...);

// Exclusive Access operations
void LDREX(ARMReg dest, ARMReg base);
// result contains the result if the instruction managed to store the value
Expand All @@ -528,7 +528,7 @@ class ARMXEmitter
// NEON Only
void VADD(IntegerSize Size, ARMReg Vd, ARMReg Vn, ARMReg Vm);
void VSUB(IntegerSize Size, ARMReg Vd, ARMReg Vn, ARMReg Vm);

// VFP Only
void VLDR(ARMReg Dest, ARMReg Base, s16 offset);
void VSTR(ARMReg Src, ARMReg Base, s16 offset);
Expand All @@ -539,7 +539,7 @@ class ARMXEmitter
void VCMPE(ARMReg Vd);
void VDIV(ARMReg Vd, ARMReg Vn, ARMReg Vm);
void VSQRT(ARMReg Vd, ARMReg Vm);

// NEON and VFP
void VADD(ARMReg Vd, ARMReg Vn, ARMReg Vm);
void VSUB(ARMReg Vd, ARMReg Vn, ARMReg Vm);
Expand Down
8 changes: 4 additions & 4 deletions Source/Core/Common/Src/BreakPoints.h
Expand Up @@ -27,9 +27,9 @@ class DebugInterface;

struct TBreakPoint
{
u32 iAddress;
u32 iAddress;
bool bOn;
bool bTemporary;
bool bTemporary;
};

struct TMemCheck
Expand Down Expand Up @@ -96,9 +96,9 @@ class MemChecks
typedef std::vector<std::string> TMemChecksStr;

TMemChecks m_MemChecks;

const TMemChecks& GetMemChecks() { return m_MemChecks; }

TMemChecksStr GetStrings() const;
void AddFromStrings(const TMemChecksStr& mcs);

Expand Down
10 changes: 5 additions & 5 deletions Source/Core/Common/Src/CPUDetect.h
Expand Up @@ -32,13 +32,13 @@ enum CPUVendor
struct CPUInfo
{
CPUVendor vendor;

char cpu_string[0x21];
char brand_string[0x41];
bool OS64bit;
bool CPU64bit;
bool Mode64bit;

bool HTT;
int num_cores;
int logical_cpu_count;
Expand All @@ -56,7 +56,7 @@ struct CPUInfo
bool bAES;
bool bLAHFSAHF64;
bool bLongMode;

// ARM specific CPUInfo
bool bSwp;
bool bHalf;
Expand All @@ -72,14 +72,14 @@ struct CPUInfo
bool bIDIVa;
bool bIDIVt;
bool bArmV7; // enable MOVT, MOVW etc

// ARMv8 specific
bool bFP;
bool bASIMD;

// Call Detect()
explicit CPUInfo();

// Turn the cpu info into a string we can show
std::string Summarize();

Expand Down
52 changes: 26 additions & 26 deletions Source/Core/Common/Src/ChunkFile.h
Expand Up @@ -69,7 +69,7 @@ class PointerWrap
{
u32 count = (u32)x.size();
Do(count);

switch (mode)
{
case MODE_READ:
Expand All @@ -81,7 +81,7 @@ class PointerWrap
x.insert(pair);
}
break;

case MODE_WRITE:
case MODE_MEASURE:
case MODE_VERIFY:
Expand All @@ -93,14 +93,14 @@ class PointerWrap
break;
}
}

template <typename T>
void DoContainer(T& x)
{
u32 size = (u32)x.size();
Do(size);
x.resize(size);

for (auto itr = x.begin(); itr != x.end(); ++itr)
Do(*itr);
}
Expand All @@ -110,32 +110,32 @@ class PointerWrap
{
DoContainer(x);
}

template <typename T>
void Do(std::list<T>& x)
{
DoContainer(x);
}

template <typename T>
void Do(std::deque<T>& x)
{
DoContainer(x);
}

template <typename T>
void Do(std::basic_string<T>& x)
{
DoContainer(x);
}

template <typename T>
template <typename T>
void DoArray(T* x, u32 count)
{
for (u32 i = 0; i != count; ++i)
Do(x[i]);
}
}

template <typename T>
void Do(T& x)
{
Expand Down Expand Up @@ -220,15 +220,15 @@ class PointerWrap
{
u32 cookie = arbitraryNumber;
Do(cookie);

if (mode == PointerWrap::MODE_READ && cookie != arbitraryNumber)
{
PanicAlertT("Error: After \"%s\", found %d (0x%X) instead of save marker %d (0x%X). Aborting savestate load...",
prevName, cookie, cookie, arbitraryNumber, arbitraryNumber);
mode = PointerWrap::MODE_MEASURE;
}
}

private:
__forceinline void DoByte(u8& x)
{
Expand All @@ -237,27 +237,27 @@ class PointerWrap
case MODE_READ:
x = **ptr;
break;

case MODE_WRITE:
**ptr = x;
break;

case MODE_MEASURE:
break;

case MODE_VERIFY:
_dbg_assert_msg_(COMMON, (x == **ptr),
"Savestate verification failure: %d (0x%X) (at %p) != %d (0x%X) (at %p).\n",
x, x, &x, **ptr, **ptr, *ptr);
break;

default:
break;
}

++(*ptr);
}

void DoVoid(void *data, u32 size)
{
for(u32 i = 0; i != size; ++i)
Expand Down Expand Up @@ -300,15 +300,15 @@ class CChunkFileReader
ERROR_LOG(COMMON,"ChunkReader: Bad header size");
return false;
}

// Check revision
if (header.Revision != _Revision)
{
ERROR_LOG(COMMON,"ChunkReader: Wrong file revision, got %d expected %d",
header.Revision, _Revision);
return false;
}

// get size
const u32 sz = (u32)(fileSize - headerSize);
if (header.ExpectedSize != sz)
Expand All @@ -317,7 +317,7 @@ class CChunkFileReader
sz, header.ExpectedSize);
return false;
}

// read the state
std::vector<u8> buffer(sz);
if (!pFile.ReadArray(&buffer[0], sz))
Expand All @@ -333,7 +333,7 @@ class CChunkFileReader
INFO_LOG(COMMON, "ChunkReader: Done loading %s" , _rFilename.c_str());
return true;
}

// Save file template
template<class T>
static bool Save(const std::string& _rFilename, u32 _Revision, T& _class)
Expand All @@ -355,12 +355,12 @@ class CChunkFileReader
ptr = &buffer[0];
p.SetMode(PointerWrap::MODE_WRITE);
_class.DoState(p);

// Create header
SChunkHeader header;
header.Revision = _Revision;
header.ExpectedSize = (u32)sz;

// Write to file
if (!pFile.WriteArray(&header, 1))
{
Expand All @@ -373,11 +373,11 @@ class CChunkFileReader
ERROR_LOG(COMMON,"ChunkReader: Failed writing data");
return false;
}

INFO_LOG(COMMON,"ChunkReader: Done writing %s", _rFilename.c_str());
return true;
}

private:
struct SChunkHeader
{
Expand Down
12 changes: 6 additions & 6 deletions Source/Core/Common/Src/CommonFuncs.h
Expand Up @@ -68,9 +68,9 @@ _mm_shuffle_epi8(__m128i a, __m128i mask)
#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))

inline u32 _rotl(u32 x, int shift) {
shift &= 31;
if (!shift) return x;
return (x << shift) | (x >> (32 - shift));
shift &= 31;
if (!shift) return x;
return (x << shift) | (x >> (32 - shift));
}

inline u64 _rotl64(u64 x, unsigned int shift){
Expand All @@ -79,9 +79,9 @@ inline u64 _rotl64(u64 x, unsigned int shift){
}

inline u32 _rotr(u32 x, int shift) {
shift &= 31;
if (!shift) return x;
return (x >> shift) | (x << (32 - shift));
shift &= 31;
if (!shift) return x;
return (x >> shift) | (x << (32 - shift));
}

inline u64 _rotr64(u64 x, unsigned int shift){
Expand Down
6 changes: 3 additions & 3 deletions Source/Core/Common/Src/CommonPaths.h
Expand Up @@ -56,7 +56,7 @@
#define SHARED_USER_DIR File::GetBundleDirectory() + \
DIR_SEP USERDATA_DIR DIR_SEP
#elif defined ANDROID
#define SYSDATA_DIR "/sdcard/dolphin-emu"
#define SYSDATA_DIR "/sdcard/dolphin-emu"
#else
#ifdef DATA_DIR
#define SYSDATA_DIR DATA_DIR "sys"
Expand Down Expand Up @@ -127,9 +127,9 @@
#define GC_MEMCARDA "MemoryCardA"
#define GC_MEMCARDB "MemoryCardB"

#define WII_STATE "state.dat"
#define WII_STATE "state.dat"

#define WII_SETTING "setting.txt"
#define WII_SETTING "setting.txt"
#define WII_EUR_SETTING "setting-eur.txt"
#define WII_USA_SETTING "setting-usa.txt"
#define WII_JAP_SETTING "setting-jpn.txt"
Expand Down
8 changes: 4 additions & 4 deletions Source/Core/Common/Src/ConsoleListener.cpp
Expand Up @@ -227,7 +227,7 @@ void ConsoleListener::PixelSpace(int Left, int Top, int Width, int Height, bool
LetterSpace(LBufWidth, LBufHeight);


ClearScreen(true);
ClearScreen(true);
coordScreen.Y = 0;
coordScreen.X = 0;
DWORD cCharsWritten = 0;
Expand Down Expand Up @@ -270,7 +270,7 @@ void ConsoleListener::Log(LogTypes::LOG_LEVELS Level, const char *Text)
*/
DWORD cCharsWritten;
WORD Color;

switch (Level)
{
case NOTICE_LEVEL: // light green
Expand Down Expand Up @@ -334,9 +334,9 @@ void ConsoleListener::ClearScreen(bool Cursor)
DWORD cCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi;
DWORD dwConSize;

HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);

GetConsoleScreenBufferInfo(hConsole, &csbi);
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
// Write space to the entire console
Expand Down
10 changes: 5 additions & 5 deletions Source/Core/Common/Src/ExtendedTrace.h
Expand Up @@ -25,7 +25,7 @@
#pragma comment( lib, "imagehlp.lib" )

#define EXTENDEDTRACEINITIALIZE( IniSymbolPath ) InitSymInfo( IniSymbolPath )
#define EXTENDEDTRACEUNINITIALIZE() UninitSymInfo()
#define EXTENDEDTRACEUNINITIALIZE() UninitSymInfo()
#define STACKTRACE(file) StackTrace( GetCurrentThread(), "", file)
#define STACKTRACE2(file, eip, esp, ebp) StackTrace(GetCurrentThread(), "", file, eip, esp, ebp)
// class File;
Expand All @@ -43,10 +43,10 @@ extern char g_uefbuf[UEFBUFSIZE];

#else // not WIN32

#define EXTENDEDTRACEINITIALIZE( IniSymbolPath ) ((void)0)
#define EXTENDEDTRACEUNINITIALIZE() ((void)0)
#define STACKTRACE(file) ((void)0)
#define STACKTRACE2(file, eip, esp, ebp) ((void)0)
#define EXTENDEDTRACEINITIALIZE( IniSymbolPath ) ((void)0)
#define EXTENDEDTRACEUNINITIALIZE() ((void)0)
#define STACKTRACE(file) ((void)0)
#define STACKTRACE2(file, eip, esp, ebp) ((void)0)

#endif // WIN32

Expand Down
11 changes: 6 additions & 5 deletions Source/Core/Common/Src/FPURoundMode.h
Expand Up @@ -38,11 +38,12 @@ namespace FPURoundMode

void SetSIMDMode(u32 mode);

/*
There are two different flavors of float to int conversion:
_mm_cvtps_epi32() and _mm_cvttps_epi32(). The first rounds
according to the MXCSR rounding bits. The second one always
uses round towards zero.
/*
* There are two different flavors of float to int conversion:
* _mm_cvtps_epi32() and _mm_cvttps_epi32().
*
* The first rounds according to the MXCSR rounding bits.
* The second one always uses round towards zero.
*/
void SaveSIMDState();
void LoadSIMDState();
Expand Down
16 changes: 8 additions & 8 deletions Source/Core/Common/Src/FileUtil.cpp
Expand Up @@ -190,7 +190,7 @@ bool CreateFullPath(const std::string &fullPath)
{
int panicCounter = 100;
INFO_LOG(COMMON, "CreateFullPath: path %s", fullPath.c_str());

if (File::Exists(fullPath))
{
INFO_LOG(COMMON, "CreateFullPath: path exists %s", fullPath.c_str());
Expand All @@ -206,7 +206,7 @@ bool CreateFullPath(const std::string &fullPath)
// we're done, yay!
if (position == fullPath.npos)
return true;

// Include the '/' so the first call is CreateDir("/") rather than CreateDir("")
std::string const subPath(fullPath.substr(0, position + 1));
if (!File::IsDirectory(subPath))
Expand Down Expand Up @@ -486,7 +486,7 @@ u32 ScanDirectoryTree(const std::string &directory, FSTEntry& parentEntry)
return foundEntries;
}


// Deletes the given directory and anything under it. Returns true on success.
bool DeleteDirRecursively(const std::string &directory)
{
Expand All @@ -501,7 +501,7 @@ bool DeleteDirRecursively(const std::string &directory)
FindClose(hFind);
return false;
}

// windows loop
do
{
Expand Down Expand Up @@ -532,7 +532,7 @@ bool DeleteDirRecursively(const std::string &directory)
#ifndef _WIN32
closedir(dirp);
#endif

return false;
}
}
Expand All @@ -543,7 +543,7 @@ bool DeleteDirRecursively(const std::string &directory)
#ifndef _WIN32
closedir(dirp);
#endif

return false;
}
}
Expand Down Expand Up @@ -605,7 +605,7 @@ std::string GetCurrentDir()
if (!(dir = __getcwd(NULL, 0))) {

ERROR_LOG(COMMON, "GetCurrentDirectory failed: %s",
GetLastErrorMsg());
GetLastErrorMsg());
return NULL;
}
std::string strDir = dir;
Expand Down Expand Up @@ -849,7 +849,7 @@ bool IOFile::Seek(s64 off, int origin)
}

u64 IOFile::Tell()
{
{
if (IsOpen())
return ftello(m_file);
else
Expand Down
172 changes: 88 additions & 84 deletions Source/Core/Common/Src/Hash.cpp
Expand Up @@ -119,121 +119,121 @@ u32 HashEctor(const u8* ptr, int length)

inline u64 getblock(const u64 * p, int i)
{
return p[i];
return p[i];
}

//----------
// Block mix - combine the key bits with the hash bits and scramble everything

inline void bmix64(u64 & h1, u64 & h2, u64 & k1, u64 & k2, u64 & c1, u64 & c2)
{
k1 *= c1;
k1 = _rotl64(k1,23);
k1 *= c2;
h1 ^= k1;
h1 += h2;
k1 *= c1;
k1 = _rotl64(k1,23);
k1 *= c2;
h1 ^= k1;
h1 += h2;

h2 = _rotl64(h2,41);
h2 = _rotl64(h2,41);

k2 *= c2;
k2 = _rotl64(k2,23);
k2 *= c1;
h2 ^= k2;
h2 += h1;
k2 *= c2;
k2 = _rotl64(k2,23);
k2 *= c1;
h2 ^= k2;
h2 += h1;

h1 = h1*3+0x52dce729;
h2 = h2*3+0x38495ab5;
h1 = h1*3+0x52dce729;
h2 = h2*3+0x38495ab5;

c1 = c1*5+0x7b7d159c;
c2 = c2*5+0x6bce6396;
c1 = c1*5+0x7b7d159c;
c2 = c2*5+0x6bce6396;
}

//----------
// Finalization mix - avalanches all bits to within 0.05% bias

inline u64 fmix64(u64 k)
{
k ^= k >> 33;
k *= 0xff51afd7ed558ccd;
k ^= k >> 33;
k *= 0xc4ceb9fe1a85ec53;
k ^= k >> 33;
k ^= k >> 33;
k *= 0xff51afd7ed558ccd;
k ^= k >> 33;
k *= 0xc4ceb9fe1a85ec53;
k ^= k >> 33;

return k;
return k;
}

u64 GetMurmurHash3(const u8 *src, int len, u32 samples)
{
const u8 * data = (const u8*)src;
const int nblocks = len / 16;
const u8 * data = (const u8*)src;
const int nblocks = len / 16;
u32 Step = (len / 8);
if(samples == 0) samples = max(Step, 1u);
Step = Step / samples;
if(Step < 1) Step = 1;

u64 h1 = 0x9368e53c2f6af274;
u64 h2 = 0x586dcd208f7cd3fd;
u64 h1 = 0x9368e53c2f6af274;
u64 h2 = 0x586dcd208f7cd3fd;

u64 c1 = 0x87c37b91114253d5;
u64 c2 = 0x4cf5ad432745937f;
u64 c1 = 0x87c37b91114253d5;
u64 c2 = 0x4cf5ad432745937f;


//----------
// body

const u64 * blocks = (const u64 *)(data);
//----------
// body

for(int i = 0; i < nblocks; i+=Step)
{
u64 k1 = getblock(blocks,i*2+0);
u64 k2 = getblock(blocks,i*2+1);
const u64 * blocks = (const u64 *)(data);

bmix64(h1,h2,k1,k2,c1,c2);
}
for(int i = 0; i < nblocks; i+=Step)
{
u64 k1 = getblock(blocks,i*2+0);
u64 k2 = getblock(blocks,i*2+1);

//----------
// tail
bmix64(h1,h2,k1,k2,c1,c2);
}

const u8 * tail = (const u8*)(data + nblocks*16);
//----------
// tail

u64 k1 = 0;
u64 k2 = 0;
const u8 * tail = (const u8*)(data + nblocks*16);

switch(len & 15)
{
case 15: k2 ^= u64(tail[14]) << 48;
case 14: k2 ^= u64(tail[13]) << 40;
case 13: k2 ^= u64(tail[12]) << 32;
case 12: k2 ^= u64(tail[11]) << 24;
case 11: k2 ^= u64(tail[10]) << 16;
case 10: k2 ^= u64(tail[ 9]) << 8;
case 9: k2 ^= u64(tail[ 8]) << 0;
u64 k1 = 0;
u64 k2 = 0;

case 8: k1 ^= u64(tail[ 7]) << 56;
case 7: k1 ^= u64(tail[ 6]) << 48;
case 6: k1 ^= u64(tail[ 5]) << 40;
case 5: k1 ^= u64(tail[ 4]) << 32;
case 4: k1 ^= u64(tail[ 3]) << 24;
case 3: k1 ^= u64(tail[ 2]) << 16;
case 2: k1 ^= u64(tail[ 1]) << 8;
case 1: k1 ^= u64(tail[ 0]) << 0;
bmix64(h1,h2,k1,k2,c1,c2);
};
switch(len & 15)
{
case 15: k2 ^= u64(tail[14]) << 48;
case 14: k2 ^= u64(tail[13]) << 40;
case 13: k2 ^= u64(tail[12]) << 32;
case 12: k2 ^= u64(tail[11]) << 24;
case 11: k2 ^= u64(tail[10]) << 16;
case 10: k2 ^= u64(tail[ 9]) << 8;
case 9: k2 ^= u64(tail[ 8]) << 0;

case 8: k1 ^= u64(tail[ 7]) << 56;
case 7: k1 ^= u64(tail[ 6]) << 48;
case 6: k1 ^= u64(tail[ 5]) << 40;
case 5: k1 ^= u64(tail[ 4]) << 32;
case 4: k1 ^= u64(tail[ 3]) << 24;
case 3: k1 ^= u64(tail[ 2]) << 16;
case 2: k1 ^= u64(tail[ 1]) << 8;
case 1: k1 ^= u64(tail[ 0]) << 0;
bmix64(h1,h2,k1,k2,c1,c2);
};

//----------
// finalization
//----------
// finalization

h2 ^= len;
h2 ^= len;

h1 += h2;
h2 += h1;
h1 += h2;
h2 += h1;

h1 = fmix64(h1);
h2 = fmix64(h2);
h1 = fmix64(h1);
h2 = fmix64(h2);

h1 += h2;
h1 += h2;

return h1;
return h1;
}


Expand Down Expand Up @@ -262,11 +262,13 @@ u64 GetCRC32(const u8 *src, int len, u32 samples)
}


/* NOTE: This hash function is used for custom texture loading/dumping, so
it should not be changed, which would require all custom textures to be
recalculated for their new hash values. If the hashing function is
changed, make sure this one is still used when the legacy parameter is
true. */
/*
* NOTE: This hash function is used for custom texture loading/dumping, so
* it should not be changed, which would require all custom textures to be
* recalculated for their new hash values. If the hashing function is
* changed, make sure this one is still used when the legacy parameter is
* true.
*/
u64 GetHashHiresTexture(const u8 *src, int len, u32 samples)
{
const u64 m = 0xc6a4a7935bd1e995;
Expand All @@ -282,11 +284,11 @@ u64 GetHashHiresTexture(const u8 *src, int len, u32 samples)
{
u64 k = data[0];
data+=Step;
k *= m;
k *= m;
k ^= k >> r;
k *= m;
k *= m;
h ^= k;
h *= m;
h *= m;
}

const u8 * data2 = (const u8*)end;
Expand Down Expand Up @@ -453,9 +455,11 @@ u64 GetMurmurHash3(const u8* src, int len, u32 samples)
return *((u64 *)&out);
}

/* FIXME: The old 32-bit version of this hash made different hashes than the
64-bit version. Until someone can make a new version of the 32-bit one that
makes identical hashes, this is just a c/p of the 64-bit one. */
/*
* FIXME: The old 32-bit version of this hash made different hashes than the
* 64-bit version. Until someone can make a new version of the 32-bit one that
* makes identical hashes, this is just a c/p of the 64-bit one.
*/
u64 GetHashHiresTexture(const u8 *src, int len, u32 samples)
{
const u64 m = 0xc6a4a7935bd1e995ULL;
Expand All @@ -473,7 +477,7 @@ u64 GetHashHiresTexture(const u8 *src, int len, u32 samples)
data+=Step;
k *= m;
k ^= k >> r;
k *= m;
k *= m;
h ^= k;
h *= m;
}
Expand Down Expand Up @@ -502,7 +506,7 @@ u64 GetHashHiresTexture(const u8 *src, int len, u32 samples)

u64 GetHash64(const u8 *src, int len, u32 samples)
{
return ptrHashFunction(src, len, samples);
return ptrHashFunction(src, len, samples);
}

// sets the hash function used for the texture cache
Expand Down
20 changes: 10 additions & 10 deletions Source/Core/Common/Src/LogManager.cpp
Expand Up @@ -45,9 +45,9 @@ LogManager::LogManager()
m_Log[LogTypes::MASTER_LOG] = new LogContainer("*", "Master Log");
m_Log[LogTypes::BOOT] = new LogContainer("BOOT", "Boot");
m_Log[LogTypes::COMMON] = new LogContainer("COMMON", "Common");
m_Log[LogTypes::DISCIO] = new LogContainer("DIO", "Disc IO");
m_Log[LogTypes::DISCIO] = new LogContainer("DIO", "Disc IO");
m_Log[LogTypes::FILEMON] = new LogContainer("FileMon", "File Monitor");
m_Log[LogTypes::PAD] = new LogContainer("PAD", "Pad");
m_Log[LogTypes::PAD] = new LogContainer("PAD", "Pad");
m_Log[LogTypes::PIXELENGINE] = new LogContainer("PE", "PixelEngine");
m_Log[LogTypes::COMMANDPROCESSOR] = new LogContainer("CP", "CommandProc");
m_Log[LogTypes::VIDEOINTERFACE] = new LogContainer("VI", "VideoInt");
Expand All @@ -63,15 +63,15 @@ LogManager::LogManager()
m_Log[LogTypes::AUDIO_INTERFACE] = new LogContainer("AI", "AudioInt");
m_Log[LogTypes::POWERPC] = new LogContainer("PowerPC", "IBM CPU");
m_Log[LogTypes::OSHLE] = new LogContainer("HLE", "HLE");
m_Log[LogTypes::DSPHLE] = new LogContainer("DSPHLE", "DSP HLE");
m_Log[LogTypes::DSPLLE] = new LogContainer("DSPLLE", "DSP LLE");
m_Log[LogTypes::DSP_MAIL] = new LogContainer("DSPMails", "DSP Mails");
m_Log[LogTypes::VIDEO] = new LogContainer("Video", "Video Backend");
m_Log[LogTypes::AUDIO] = new LogContainer("Audio", "Audio Emulator");
m_Log[LogTypes::DSPHLE] = new LogContainer("DSPHLE", "DSP HLE");
m_Log[LogTypes::DSPLLE] = new LogContainer("DSPLLE", "DSP LLE");
m_Log[LogTypes::DSP_MAIL] = new LogContainer("DSPMails", "DSP Mails");
m_Log[LogTypes::VIDEO] = new LogContainer("Video", "Video Backend");
m_Log[LogTypes::AUDIO] = new LogContainer("Audio", "Audio Emulator");
m_Log[LogTypes::DYNA_REC] = new LogContainer("JIT", "Dynamic Recompiler");
m_Log[LogTypes::CONSOLE] = new LogContainer("CONSOLE", "Dolphin Console");
m_Log[LogTypes::OSREPORT] = new LogContainer("OSREPORT", "OSReport");
m_Log[LogTypes::WIIMOTE] = new LogContainer("Wiimote", "Wiimote");
m_Log[LogTypes::OSREPORT] = new LogContainer("OSREPORT", "OSReport");
m_Log[LogTypes::WIIMOTE] = new LogContainer("Wiimote", "Wiimote");
m_Log[LogTypes::WII_IOB] = new LogContainer("WII_IOB", "WII IO Bridge");
m_Log[LogTypes::WII_IPC] = new LogContainer("WII_IPC", "WII IPC");
m_Log[LogTypes::WII_IPC_HLE] = new LogContainer("WII_IPC_HLE", "WII IPC HLE");
Expand All @@ -82,7 +82,7 @@ LogManager::LogManager()
m_Log[LogTypes::WII_IPC_STM] = new LogContainer("WII_IPC_STM", "WII IPC STM");
m_Log[LogTypes::WII_IPC_NET] = new LogContainer("WII_IPC_NET", "WII IPC NET");
m_Log[LogTypes::WII_IPC_WIIMOTE] = new LogContainer("WII_IPC_WIIMOTE","WII IPC WIIMOTE");
m_Log[LogTypes::ACTIONREPLAY] = new LogContainer("ActionReplay", "ActionReplay");
m_Log[LogTypes::ACTIONREPLAY] = new LogContainer("ActionReplay", "ActionReplay");
m_Log[LogTypes::MEMCARD_MANAGER] = new LogContainer("MemCard Manager", "MemCard Manager");
m_Log[LogTypes::NETPLAY] = new LogContainer("NETPLAY", "Netplay");

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Common/Src/LogManager.h
Expand Up @@ -26,7 +26,7 @@
#include <set>
#include <string.h>

#define MAX_MESSAGES 8000
#define MAX_MESSAGES 8000
#define MAX_MSGLEN 1024


Expand Down
124 changes: 62 additions & 62 deletions Source/Core/Common/Src/MathUtil.cpp
Expand Up @@ -88,7 +88,7 @@ u32 ClassifyFloat(float fvalue)
else
{
// Denormalized number.
return sign ? PPC_FPCLASS_ND : PPC_FPCLASS_PD;
return sign ? PPC_FPCLASS_ND : PPC_FPCLASS_PD;
}
}
else if (exp)
Expand All @@ -101,26 +101,26 @@ u32 ClassifyFloat(float fvalue)
//Zero
return sign ? PPC_FPCLASS_NZ : PPC_FPCLASS_PZ;
}
}
}
}


} // namespace

inline void MatrixMul(int n, const float *a, const float *b, float *result)
{
for (int i = 0; i < n; ++i)
{
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < n; ++j)
for (int j = 0; j < n; ++j)
{
float temp = 0;
for (int k = 0; k < n; ++k)
float temp = 0;
for (int k = 0; k < n; ++k)
{
temp += a[i * n + k] * b[k * n + j];
}
result[i * n + j] = temp;
}
}
temp += a[i * n + k] * b[k * n + j];
}
result[i * n + j] = temp;
}
}
}

// Calculate sum of a float list
Expand All @@ -131,94 +131,94 @@ float MathFloatVectorSum(const std::vector<float>& Vec)

void Matrix33::LoadIdentity(Matrix33 &mtx)
{
memset(mtx.data, 0, sizeof(mtx.data));
mtx.data[0] = 1.0f;
mtx.data[4] = 1.0f;
mtx.data[8] = 1.0f;
memset(mtx.data, 0, sizeof(mtx.data));
mtx.data[0] = 1.0f;
mtx.data[4] = 1.0f;
mtx.data[8] = 1.0f;
}

void Matrix33::RotateX(Matrix33 &mtx, float rad)
{
float s = sin(rad);
float c = cos(rad);
memset(mtx.data, 0, sizeof(mtx.data));
mtx.data[0] = 1;
mtx.data[4] = c;
mtx.data[5] = -s;
mtx.data[7] = s;
mtx.data[8] = c;
float s = sin(rad);
float c = cos(rad);
memset(mtx.data, 0, sizeof(mtx.data));
mtx.data[0] = 1;
mtx.data[4] = c;
mtx.data[5] = -s;
mtx.data[7] = s;
mtx.data[8] = c;
}
void Matrix33::RotateY(Matrix33 &mtx, float rad)
{
float s = sin(rad);
float c = cos(rad);
memset(mtx.data, 0, sizeof(mtx.data));
mtx.data[0] = c;
mtx.data[2] = s;
mtx.data[4] = 1;
mtx.data[6] = -s;
mtx.data[8] = c;
float s = sin(rad);
float c = cos(rad);
memset(mtx.data, 0, sizeof(mtx.data));
mtx.data[0] = c;
mtx.data[2] = s;
mtx.data[4] = 1;
mtx.data[6] = -s;
mtx.data[8] = c;
}

void Matrix33::Multiply(const Matrix33 &a, const Matrix33 &b, Matrix33 &result)
{
MatrixMul(3, a.data, b.data, result.data);
MatrixMul(3, a.data, b.data, result.data);
}

void Matrix33::Multiply(const Matrix33 &a, const float vec[3], float result[3])
{
for (int i = 0; i < 3; ++i) {
result[i] = 0;
for (int k = 0; k < 3; ++k) {
result[i] += a.data[i * 3 + k] * vec[k];
}
}
for (int i = 0; i < 3; ++i) {
result[i] = 0;
for (int k = 0; k < 3; ++k) {
result[i] += a.data[i * 3 + k] * vec[k];
}
}
}

void Matrix44::LoadIdentity(Matrix44 &mtx)
{
memset(mtx.data, 0, sizeof(mtx.data));
mtx.data[0] = 1.0f;
mtx.data[5] = 1.0f;
mtx.data[10] = 1.0f;
mtx.data[15] = 1.0f;
memset(mtx.data, 0, sizeof(mtx.data));
mtx.data[0] = 1.0f;
mtx.data[5] = 1.0f;
mtx.data[10] = 1.0f;
mtx.data[15] = 1.0f;
}

void Matrix44::LoadMatrix33(Matrix44 &mtx, const Matrix33 &m33)
{
for (int i = 0; i < 3; ++i)
for (int i = 0; i < 3; ++i)
{
for (int j = 0; j < 3; ++j)
for (int j = 0; j < 3; ++j)
{
mtx.data[i * 4 + j] = m33.data[i * 3 + j];
}
}
mtx.data[i * 4 + j] = m33.data[i * 3 + j];
}
}

for (int i = 0; i < 3; ++i)
for (int i = 0; i < 3; ++i)
{
mtx.data[i * 4 + 3] = 0;
mtx.data[i + 12] = 0;
}
mtx.data[15] = 1.0f;
mtx.data[i * 4 + 3] = 0;
mtx.data[i + 12] = 0;
}
mtx.data[15] = 1.0f;
}

void Matrix44::Set(Matrix44 &mtx, const float mtxArray[16])
{
for(int i = 0; i < 16; ++i) {
mtx.data[i] = mtxArray[i];
}
for(int i = 0; i < 16; ++i) {
mtx.data[i] = mtxArray[i];
}
}

void Matrix44::Translate(Matrix44 &mtx, const float vec[3])
{
LoadIdentity(mtx);
mtx.data[3] = vec[0];
mtx.data[7] = vec[1];
mtx.data[11] = vec[2];
LoadIdentity(mtx);
mtx.data[3] = vec[0];
mtx.data[7] = vec[1];
mtx.data[11] = vec[2];
}

void Matrix44::Multiply(const Matrix44 &a, const Matrix44 &b, Matrix44 &result)
{
MatrixMul(4, a.data, b.data, result.data);
MatrixMul(4, a.data, b.data, result.data);
}

34 changes: 17 additions & 17 deletions Source/Core/Common/Src/MathUtil.h
Expand Up @@ -159,12 +159,12 @@ inline u64 Log2(u64 val)
{
#if defined(__GNUC__)
return 63 - __builtin_clzll(val);

#elif defined(_MSC_VER) && defined(_M_X64)
unsigned long result = -1;
_BitScanReverse64(&result, val);
return result;

#else
u64 result = -1;
while (val != 0)
Expand All @@ -182,32 +182,32 @@ inline u64 Log2(u64 val)
class Matrix33
{
public:
static void LoadIdentity(Matrix33 &mtx);
static void LoadIdentity(Matrix33 &mtx);

// set mtx to be a rotation matrix around the x axis
static void RotateX(Matrix33 &mtx, float rad);
// set mtx to be a rotation matrix around the y axis
static void RotateY(Matrix33 &mtx, float rad);
// set mtx to be a rotation matrix around the x axis
static void RotateX(Matrix33 &mtx, float rad);
// set mtx to be a rotation matrix around the y axis
static void RotateY(Matrix33 &mtx, float rad);

// set result = a x b
static void Multiply(const Matrix33 &a, const Matrix33 &b, Matrix33 &result);
static void Multiply(const Matrix33 &a, const float vec[3], float result[3]);
// set result = a x b
static void Multiply(const Matrix33 &a, const Matrix33 &b, Matrix33 &result);
static void Multiply(const Matrix33 &a, const float vec[3], float result[3]);

float data[9];
float data[9];
};

class Matrix44
{
public:
static void LoadIdentity(Matrix44 &mtx);
static void LoadMatrix33(Matrix44 &mtx, const Matrix33 &m33);
static void Set(Matrix44 &mtx, const float mtxArray[16]);
static void LoadIdentity(Matrix44 &mtx);
static void LoadMatrix33(Matrix44 &mtx, const Matrix33 &m33);
static void Set(Matrix44 &mtx, const float mtxArray[16]);

static void Translate(Matrix44 &mtx, const float vec[3]);
static void Translate(Matrix44 &mtx, const float vec[3]);

static void Multiply(const Matrix44 &a, const Matrix44 &b, Matrix44 &result);
static void Multiply(const Matrix44 &a, const Matrix44 &b, Matrix44 &result);

float data[16];
float data[16];
};

#endif // _MATH_UTIL_H_
4 changes: 2 additions & 2 deletions Source/Core/Common/Src/MemArena.cpp
Expand Up @@ -47,10 +47,10 @@ int AshmemCreateFileMapping(const char *name, size_t size)
fd = open(ASHMEM_DEVICE, O_RDWR);
if (fd < 0)
return fd;

// We don't really care if we can't set the name, it is optional
ret = ioctl(fd, ASHMEM_SET_NAME, name);

ret = ioctl(fd, ASHMEM_SET_SIZE, size);
if (ret < 0)
{
Expand Down
4 changes: 1 addition & 3 deletions Source/Core/Common/Src/MemoryUtil.cpp
Expand Up @@ -155,9 +155,7 @@ void FreeAlignedMemory(void* ptr)
if (ptr)
{
#ifdef _WIN32

_aligned_free(ptr);

_aligned_free(ptr);
#else
free(ptr);
#endif
Expand Down
15 changes: 7 additions & 8 deletions Source/Core/Common/Src/MsgHandler.cpp
Expand Up @@ -102,15 +102,14 @@ bool MsgAlert(bool yes_no, int Style, const char* format, ...)
bool DefaultMsgHandler(const char* caption, const char* text, bool yes_no, int Style)
{
#ifdef _WIN32
int STYLE = MB_ICONINFORMATION;
if (Style == QUESTION) STYLE = MB_ICONQUESTION;
if (Style == WARNING) STYLE = MB_ICONWARNING;

return IDYES == MessageBox(0, UTF8ToTStr(text).c_str(), UTF8ToTStr(caption).c_str(), STYLE | (yes_no ? MB_YESNO : MB_OK));

int STYLE = MB_ICONINFORMATION;
if (Style == QUESTION) STYLE = MB_ICONQUESTION;
if (Style == WARNING) STYLE = MB_ICONWARNING;

return IDYES == MessageBox(0, UTF8ToTStr(text).c_str(), UTF8ToTStr(caption).c_str(), STYLE | (yes_no ? MB_YESNO : MB_OK));
#else
printf("%s\n", text);
return true;
printf("%s\n", text);
return true;
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Common/Src/StdConditionVariable.h
Expand Up @@ -133,7 +133,7 @@ class condition_variable
// bool wait_for(unique_lock<mutex>& lock,
// const chrono::duration<Rep, Period>& rel_time,
// Predicate pred);

native_handle_type native_handle()
{
#ifdef USE_EVENTS
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Common/Src/StdThread.h
Expand Up @@ -88,7 +88,7 @@ class thread
{
return !(*this == rhs);
}

bool operator<(const id& rhs) const
{
return m_thread < rhs.m_thread;
Expand Down
12 changes: 6 additions & 6 deletions Source/Core/Common/Src/StringUtil.cpp
Expand Up @@ -435,10 +435,10 @@ template <typename T>
std::string CodeToUTF8(const char* fromcode, const std::basic_string<T>& input)
{
std::string result;

#if defined(ANDROID)
result = "Not implemented on Android!";

#else
iconv_t const conv_desc = iconv_open("UTF-8", fromcode);
if ((iconv_t)-1 == conv_desc)
Expand All @@ -449,20 +449,20 @@ std::string CodeToUTF8(const char* fromcode, const std::basic_string<T>& input)
{
size_t const in_bytes = sizeof(T) * input.size();
size_t const out_buffer_size = 4 * in_bytes;

std::string out_buffer;
out_buffer.resize(out_buffer_size);

auto src_buffer = &input[0];
size_t src_bytes = in_bytes;
auto dst_buffer = &out_buffer[0];
size_t dst_bytes = out_buffer.size();

while (src_bytes != 0)
{
size_t const iconv_result = iconv(conv_desc, (char**)(&src_buffer), &src_bytes,
&dst_buffer, &dst_bytes);

if ((size_t)-1 == iconv_result)
{
if (EILSEQ == errno || EINVAL == errno)
Expand Down Expand Up @@ -512,7 +512,7 @@ std::string UTF16ToUTF8(const std::wstring& input)
// CodeToUTF8("UCS-2LE", input);
// CodeToUTF8("UTF-16", input);
CodeToUTF8("UTF-16LE", input);

// TODO: why is this needed?
result.erase(std::remove(result.begin(), result.end(), 0x00), result.end());
return result;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Common/Src/Thread.h
Expand Up @@ -62,7 +62,7 @@ class Event
m_condvar.notify_one();
}
}

void Wait()
{
std::unique_lock<std::mutex> lk(m_mutex);
Expand Down
96 changes: 48 additions & 48 deletions Source/Core/Common/Src/x64ABI.cpp
Expand Up @@ -226,11 +226,11 @@ void XEmitter::ABI_CallFunction(void *func) {
u64 distance = u64(func) - (u64(code) + 5);
if (distance >= 0x0000000080000000ULL
&& distance < 0xFFFFFFFF80000000ULL) {
// Far call
MOV(64, R(RAX), Imm64((u64)func));
CALLptr(R(RAX));
// Far call
MOV(64, R(RAX), Imm64((u64)func));
CALLptr(R(RAX));
} else {
CALL(func);
CALL(func);
}
}

Expand All @@ -239,11 +239,11 @@ void XEmitter::ABI_CallFunctionC16(void *func, u16 param1) {
u64 distance = u64(func) - (u64(code) + 5);
if (distance >= 0x0000000080000000ULL
&& distance < 0xFFFFFFFF80000000ULL) {
// Far call
MOV(64, R(RAX), Imm64((u64)func));
CALLptr(R(RAX));
// Far call
MOV(64, R(RAX), Imm64((u64)func));
CALLptr(R(RAX));
} else {
CALL(func);
CALL(func);
}
}

Expand All @@ -266,11 +266,11 @@ void XEmitter::ABI_CallFunctionC(void *func, u32 param1) {
u64 distance = u64(func) - (u64(code) + 5);
if (distance >= 0x0000000080000000ULL
&& distance < 0xFFFFFFFF80000000ULL) {
// Far call
MOV(64, R(RAX), Imm64((u64)func));
CALLptr(R(RAX));
// Far call
MOV(64, R(RAX), Imm64((u64)func));
CALLptr(R(RAX));
} else {
CALL(func);
CALL(func);
}
}

Expand All @@ -280,11 +280,11 @@ void XEmitter::ABI_CallFunctionCC(void *func, u32 param1, u32 param2) {
u64 distance = u64(func) - (u64(code) + 5);
if (distance >= 0x0000000080000000ULL
&& distance < 0xFFFFFFFF80000000ULL) {
// Far call
MOV(64, R(RAX), Imm64((u64)func));
CALLptr(R(RAX));
// Far call
MOV(64, R(RAX), Imm64((u64)func));
CALLptr(R(RAX));
} else {
CALL(func);
CALL(func);
}
}

Expand All @@ -295,11 +295,11 @@ void XEmitter::ABI_CallFunctionCCC(void *func, u32 param1, u32 param2, u32 param
u64 distance = u64(func) - (u64(code) + 5);
if (distance >= 0x0000000080000000ULL
&& distance < 0xFFFFFFFF80000000ULL) {
// Far call
MOV(64, R(RAX), Imm64((u64)func));
CALLptr(R(RAX));
// Far call
MOV(64, R(RAX), Imm64((u64)func));
CALLptr(R(RAX));
} else {
CALL(func);
CALL(func);
}
}

Expand All @@ -310,11 +310,11 @@ void XEmitter::ABI_CallFunctionCCP(void *func, u32 param1, u32 param2, void *par
u64 distance = u64(func) - (u64(code) + 5);
if (distance >= 0x0000000080000000ULL
&& distance < 0xFFFFFFFF80000000ULL) {
// Far call
MOV(64, R(RAX), Imm64((u64)func));
CALLptr(R(RAX));
// Far call
MOV(64, R(RAX), Imm64((u64)func));
CALLptr(R(RAX));
} else {
CALL(func);
CALL(func);
}
}

Expand All @@ -326,11 +326,11 @@ void XEmitter::ABI_CallFunctionCCCP(void *func, u32 param1, u32 param2, u32 para
u64 distance = u64(func) - (u64(code) + 5);
if (distance >= 0x0000000080000000ULL
&& distance < 0xFFFFFFFF80000000ULL) {
// Far call
MOV(64, R(RAX), Imm64((u64)func));
CALLptr(R(RAX));
// Far call
MOV(64, R(RAX), Imm64((u64)func));
CALLptr(R(RAX));
} else {
CALL(func);
CALL(func);
}
}

Expand All @@ -341,11 +341,11 @@ void XEmitter::ABI_CallFunctionPPC(void *func, void *param1, void *param2, u32 p
u64 distance = u64(func) - (u64(code) + 5);
if (distance >= 0x0000000080000000ULL
&& distance < 0xFFFFFFFF80000000ULL) {
// Far call
MOV(64, R(RAX), Imm64((u64)func));
CALLptr(R(RAX));
// Far call
MOV(64, R(RAX), Imm64((u64)func));
CALLptr(R(RAX));
} else {
CALL(func);
CALL(func);
}
}

Expand All @@ -356,11 +356,11 @@ void XEmitter::ABI_CallFunctionR(void *func, X64Reg reg1) {
u64 distance = u64(func) - (u64(code) + 5);
if (distance >= 0x0000000080000000ULL
&& distance < 0xFFFFFFFF80000000ULL) {
// Far call
MOV(64, R(RAX), Imm64((u64)func));
CALLptr(R(RAX));
// Far call
MOV(64, R(RAX), Imm64((u64)func));
CALLptr(R(RAX));
} else {
CALL(func);
CALL(func);
}
}

Expand All @@ -380,11 +380,11 @@ void XEmitter::ABI_CallFunctionRR(void *func, X64Reg reg1, X64Reg reg2) {
u64 distance = u64(func) - (u64(code) + 5);
if (distance >= 0x0000000080000000ULL
&& distance < 0xFFFFFFFF80000000ULL) {
// Far call
MOV(64, R(RAX), Imm64((u64)func));
CALLptr(R(RAX));
// Far call
MOV(64, R(RAX), Imm64((u64)func));
CALLptr(R(RAX));
} else {
CALL(func);
CALL(func);
}
}

Expand All @@ -396,11 +396,11 @@ void XEmitter::ABI_CallFunctionAC(void *func, const Gen::OpArg &arg1, u32 param2
u64 distance = u64(func) - (u64(code) + 5);
if (distance >= 0x0000000080000000ULL
&& distance < 0xFFFFFFFF80000000ULL) {
// Far call
MOV(64, R(RAX), Imm64((u64)func));
CALLptr(R(RAX));
// Far call
MOV(64, R(RAX), Imm64((u64)func));
CALLptr(R(RAX));
} else {
CALL(func);
CALL(func);
}
}

Expand All @@ -411,11 +411,11 @@ void XEmitter::ABI_CallFunctionA(void *func, const Gen::OpArg &arg1)
u64 distance = u64(func) - (u64(code) + 5);
if (distance >= 0x0000000080000000ULL
&& distance < 0xFFFFFFFF80000000ULL) {
// Far call
MOV(64, R(RAX), Imm64((u64)func));
CALLptr(R(RAX));
// Far call
MOV(64, R(RAX), Imm64((u64)func));
CALLptr(R(RAX));
} else {
CALL(func);
CALL(func);
}
}

Expand Down
42 changes: 21 additions & 21 deletions Source/Core/Common/Src/x64Analyzer.cpp
Expand Up @@ -60,39 +60,39 @@ bool DisassembleMov(const unsigned char *codePtr, InstructionInfo &info, int acc

codeByte = *codePtr++;

// Skip two-byte opcode byte
bool twoByte = false;
if(codeByte == 0x0F)
{
twoByte = true;
// Skip two-byte opcode byte
bool twoByte = false;
if(codeByte == 0x0F)
{
twoByte = true;
codeByte2 = *codePtr++;
}
}

if (!twoByte)
{
if ((codeByte & 0xF0) == 0x80 ||
((codeByte & 0xF8) == 0xC0 && (codeByte & 0x0E) != 0x02))
if ((codeByte & 0xF0) == 0x80 ||
((codeByte & 0xF8) == 0xC0 && (codeByte & 0x0E) != 0x02))
{
modRMbyte = *codePtr++;
hasModRM = true;
}
}
else
{
if (((codeByte2 & 0xF0) == 0x00 && (codeByte2 & 0x0F) >= 0x04 && (codeByte2 & 0x0D) != 0x0D) ||
(codeByte2 & 0xF0) == 0x30 ||
codeByte2 == 0x77 ||
(codeByte2 & 0xF0) == 0x80 ||
((codeByte2 & 0xF0) == 0xA0 && (codeByte2 & 0x07) <= 0x02) ||
(codeByte2 & 0xF8) == 0xC8)
{
// No mod R/M byte
}
else
{
if (((codeByte2 & 0xF0) == 0x00 && (codeByte2 & 0x0F) >= 0x04 && (codeByte2 & 0x0D) != 0x0D) ||
(codeByte2 & 0xF0) == 0x30 ||
codeByte2 == 0x77 ||
(codeByte2 & 0xF0) == 0x80 ||
((codeByte2 & 0xF0) == 0xA0 && (codeByte2 & 0x07) <= 0x02) ||
(codeByte2 & 0xF8) == 0xC8)
{
// No mod R/M byte
}
else
{
modRMbyte = *codePtr++;
hasModRM = true;
}
}
}

if (hasModRM)
Expand Down Expand Up @@ -130,7 +130,7 @@ bool DisassembleMov(const unsigned char *codePtr, InstructionInfo &info, int acc
info.displacement = *((s32 *)codePtr);
codePtr += displacementSize;


if (accessType == 1)
{
info.isMemoryWrite = true;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Common/Src/x64Analyzer.h
Expand Up @@ -51,7 +51,7 @@ enum{
MOVZX_SHORT = 0xB7, //movzx on short
MOVSX_BYTE = 0xBE, //movsx on byte
MOVSX_SHORT = 0xBF, //movsx on short
MOVE_8BIT = 0xC6, //move 8-bit immediate
MOVE_8BIT = 0xC6, //move 8-bit immediate
MOVE_16_32BIT = 0xC7, //move 16 or 32-bit immediate
MOVE_REG_TO_MEM = 0x89, //move reg to memory
};
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Common/Src/x64CPUDetect.cpp
Expand Up @@ -39,7 +39,7 @@
#include <machine/cpufunc.h>
#else
static inline void do_cpuid(unsigned int *eax, unsigned int *ebx,
unsigned int *ecx, unsigned int *edx)
unsigned int *ecx, unsigned int *edx)
{
#if defined _M_GENERIC
(*eax) = (*ebx) = (*ecx) = (*edx) = 0;
Expand Down
216 changes: 108 additions & 108 deletions Source/Core/Common/Src/x64Emitter.cpp
Expand Up @@ -51,13 +51,13 @@ static const NormalOpDef nops[11] =

enum NormalSSEOps
{
sseCMP = 0xC2,
sseADD = 0x58, //ADD
sseCMP = 0xC2,
sseADD = 0x58, //ADD
sseSUB = 0x5C, //SUB
sseAND = 0x54, //AND
sseANDN = 0x55, //ANDN
sseOR = 0x56,
sseXOR = 0x57,
sseOR = 0x56,
sseXOR = 0x57,
sseMUL = 0x59, //MUL,
sseDIV = 0x5E, //DIV
sseMIN = 0x5D, //MIN
Expand Down Expand Up @@ -143,18 +143,18 @@ void OpArg::WriteRex(XEmitter *emit, int opBits, int bits, int customOp) const
if (indexReg & 8) op |= 2;
if (offsetOrBaseReg & 8) op |= 1; //TODO investigate if this is dangerous
if (op != 0x40 ||
(bits == 8 && (offsetOrBaseReg & 0x10c) == 4) ||
(opBits == 8 && (customOp & 0x10c) == 4)) {
(bits == 8 && (offsetOrBaseReg & 0x10c) == 4) ||
(opBits == 8 && (customOp & 0x10c) == 4)) {
emit->Write8(op);
_dbg_assert_(DYNA_REC, (offsetOrBaseReg & 0x100) == 0 || bits != 8);
_dbg_assert_(DYNA_REC, (customOp & 0x100) == 0 || opBits != 8);
} else {
_dbg_assert_(DYNA_REC, (offsetOrBaseReg & 0x10c) == 0 ||
(offsetOrBaseReg & 0x10c) == 0x104 ||
bits != 8);
(offsetOrBaseReg & 0x10c) == 0x104 ||
bits != 8);
_dbg_assert_(DYNA_REC, (customOp & 0x10c) == 0 ||
(customOp & 0x10c) == 0x104 ||
opBits != 8);
(customOp & 0x10c) == 0x104 ||
opBits != 8);
}

#else
Expand Down Expand Up @@ -969,15 +969,15 @@ void OpArg::WriteNormalOp(XEmitter *emit, bool toRM, NormalOp op, const OpArg &o
immToWrite = 8;
}
else if ((operand.scale == SCALE_IMM16 && bits == 16) ||
(operand.scale == SCALE_IMM32 && bits == 32) ||
(operand.scale == SCALE_IMM32 && bits == 64))
(operand.scale == SCALE_IMM32 && bits == 32) ||
(operand.scale == SCALE_IMM32 && bits == 64))
{
emit->Write8(nops[op].imm32);
immToWrite = bits == 16 ? 16 : 32;
}
else if ((operand.scale == SCALE_IMM8 && bits == 16) ||
(operand.scale == SCALE_IMM8 && bits == 32) ||
(operand.scale == SCALE_IMM8 && bits == 64))
(operand.scale == SCALE_IMM8 && bits == 32) ||
(operand.scale == SCALE_IMM8 && bits == 64))
{
emit->Write8(nops[op].simm8);
immToWrite = 8;
Expand Down Expand Up @@ -1471,142 +1471,142 @@ void XEmitter::RTDSC() { Write8(0x0F); Write8(0x31); }
// helper routines for setting pointers
void XEmitter::CallCdeclFunction3(void* fnptr, u32 arg0, u32 arg1, u32 arg2)
{
using namespace Gen;
using namespace Gen;
#ifdef _M_X64

#ifdef _MSC_VER
MOV(32, R(RCX), Imm32(arg0));
MOV(32, R(RDX), Imm32(arg1));
MOV(32, R(R8), Imm32(arg2));
CALL(fnptr);
MOV(32, R(RCX), Imm32(arg0));
MOV(32, R(RDX), Imm32(arg1));
MOV(32, R(R8), Imm32(arg2));
CALL(fnptr);
#else
MOV(32, R(RDI), Imm32(arg0));
MOV(32, R(RSI), Imm32(arg1));
MOV(32, R(RDX), Imm32(arg2));
CALL(fnptr);
MOV(32, R(RDI), Imm32(arg0));
MOV(32, R(RSI), Imm32(arg1));
MOV(32, R(RDX), Imm32(arg2));
CALL(fnptr);
#endif

#else
ABI_AlignStack(3 * 4);
PUSH(32, Imm32(arg2));
PUSH(32, Imm32(arg1));
PUSH(32, Imm32(arg0));
CALL(fnptr);
ABI_AlignStack(3 * 4);
PUSH(32, Imm32(arg2));
PUSH(32, Imm32(arg1));
PUSH(32, Imm32(arg0));
CALL(fnptr);
#ifdef _WIN32
// don't inc stack
// don't inc stack
#else
ABI_RestoreStack(3 * 4);
ABI_RestoreStack(3 * 4);
#endif
#endif
}

void XEmitter::CallCdeclFunction4(void* fnptr, u32 arg0, u32 arg1, u32 arg2, u32 arg3)
{
using namespace Gen;
using namespace Gen;
#ifdef _M_X64

#ifdef _MSC_VER
MOV(32, R(RCX), Imm32(arg0));
MOV(32, R(RDX), Imm32(arg1));
MOV(32, R(R8), Imm32(arg2));
MOV(32, R(R9), Imm32(arg3));
CALL(fnptr);
MOV(32, R(RCX), Imm32(arg0));
MOV(32, R(RDX), Imm32(arg1));
MOV(32, R(R8), Imm32(arg2));
MOV(32, R(R9), Imm32(arg3));
CALL(fnptr);
#else
MOV(32, R(RDI), Imm32(arg0));
MOV(32, R(RSI), Imm32(arg1));
MOV(32, R(RDX), Imm32(arg2));
MOV(32, R(RCX), Imm32(arg3));
CALL(fnptr);
MOV(32, R(RDI), Imm32(arg0));
MOV(32, R(RSI), Imm32(arg1));
MOV(32, R(RDX), Imm32(arg2));
MOV(32, R(RCX), Imm32(arg3));
CALL(fnptr);
#endif

#else
ABI_AlignStack(4 * 4);
PUSH(32, Imm32(arg3));
PUSH(32, Imm32(arg2));
PUSH(32, Imm32(arg1));
PUSH(32, Imm32(arg0));
CALL(fnptr);
ABI_AlignStack(4 * 4);
PUSH(32, Imm32(arg3));
PUSH(32, Imm32(arg2));
PUSH(32, Imm32(arg1));
PUSH(32, Imm32(arg0));
CALL(fnptr);
#ifdef _WIN32
// don't inc stack
// don't inc stack
#else
ABI_RestoreStack(4 * 4);
ABI_RestoreStack(4 * 4);
#endif
#endif
}

void XEmitter::CallCdeclFunction5(void* fnptr, u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 arg4)
{
using namespace Gen;
using namespace Gen;
#ifdef _M_X64

#ifdef _MSC_VER
MOV(32, R(RCX), Imm32(arg0));
MOV(32, R(RDX), Imm32(arg1));
MOV(32, R(R8), Imm32(arg2));
MOV(32, R(R9), Imm32(arg3));
MOV(32, R(RCX), Imm32(arg0));
MOV(32, R(RDX), Imm32(arg1));
MOV(32, R(R8), Imm32(arg2));
MOV(32, R(R9), Imm32(arg3));
MOV(32, MDisp(RSP, 0x20), Imm32(arg4));
CALL(fnptr);
CALL(fnptr);
#else
MOV(32, R(RDI), Imm32(arg0));
MOV(32, R(RSI), Imm32(arg1));
MOV(32, R(RDX), Imm32(arg2));
MOV(32, R(RCX), Imm32(arg3));
MOV(32, R(R8), Imm32(arg4));
CALL(fnptr);
MOV(32, R(RDI), Imm32(arg0));
MOV(32, R(RSI), Imm32(arg1));
MOV(32, R(RDX), Imm32(arg2));
MOV(32, R(RCX), Imm32(arg3));
MOV(32, R(R8), Imm32(arg4));
CALL(fnptr);
#endif

#else
ABI_AlignStack(5 * 4);
PUSH(32, Imm32(arg4));
PUSH(32, Imm32(arg3));
PUSH(32, Imm32(arg2));
PUSH(32, Imm32(arg1));
PUSH(32, Imm32(arg0));
CALL(fnptr);
ABI_AlignStack(5 * 4);
PUSH(32, Imm32(arg4));
PUSH(32, Imm32(arg3));
PUSH(32, Imm32(arg2));
PUSH(32, Imm32(arg1));
PUSH(32, Imm32(arg0));
CALL(fnptr);
#ifdef _WIN32
// don't inc stack
// don't inc stack
#else
ABI_RestoreStack(5 * 4);
ABI_RestoreStack(5 * 4);
#endif
#endif
}

void XEmitter::CallCdeclFunction6(void* fnptr, u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 arg4, u32 arg5)
{
using namespace Gen;
using namespace Gen;
#ifdef _M_X64

#ifdef _MSC_VER
MOV(32, R(RCX), Imm32(arg0));
MOV(32, R(RDX), Imm32(arg1));
MOV(32, R(R8), Imm32(arg2));
MOV(32, R(R9), Imm32(arg3));
MOV(32, R(RCX), Imm32(arg0));
MOV(32, R(RDX), Imm32(arg1));
MOV(32, R(R8), Imm32(arg2));
MOV(32, R(R9), Imm32(arg3));
MOV(32, MDisp(RSP, 0x20), Imm32(arg4));
MOV(32, MDisp(RSP, 0x28), Imm32(arg5));
CALL(fnptr);
CALL(fnptr);
#else
MOV(32, R(RDI), Imm32(arg0));
MOV(32, R(RSI), Imm32(arg1));
MOV(32, R(RDX), Imm32(arg2));
MOV(32, R(RCX), Imm32(arg3));
MOV(32, R(R8), Imm32(arg4));
MOV(32, R(R9), Imm32(arg5));
CALL(fnptr);
MOV(32, R(RDI), Imm32(arg0));
MOV(32, R(RSI), Imm32(arg1));
MOV(32, R(RDX), Imm32(arg2));
MOV(32, R(RCX), Imm32(arg3));
MOV(32, R(R8), Imm32(arg4));
MOV(32, R(R9), Imm32(arg5));
CALL(fnptr);
#endif

#else
ABI_AlignStack(6 * 4);
PUSH(32, Imm32(arg5));
PUSH(32, Imm32(arg4));
PUSH(32, Imm32(arg3));
PUSH(32, Imm32(arg2));
PUSH(32, Imm32(arg1));
PUSH(32, Imm32(arg0));
CALL(fnptr);
ABI_AlignStack(6 * 4);
PUSH(32, Imm32(arg5));
PUSH(32, Imm32(arg4));
PUSH(32, Imm32(arg3));
PUSH(32, Imm32(arg2));
PUSH(32, Imm32(arg1));
PUSH(32, Imm32(arg0));
CALL(fnptr);
#ifdef _WIN32
// don't inc stack
// don't inc stack
#else
ABI_RestoreStack(6 * 4);
ABI_RestoreStack(6 * 4);
#endif
#endif
}
Expand All @@ -1615,31 +1615,31 @@ void XEmitter::CallCdeclFunction6(void* fnptr, u32 arg0, u32 arg1, u32 arg2, u32

// See header
void XEmitter::___CallCdeclImport3(void* impptr, u32 arg0, u32 arg1, u32 arg2) {
MOV(32, R(RCX), Imm32(arg0));
MOV(32, R(RDX), Imm32(arg1));
MOV(32, R(R8), Imm32(arg2));
MOV(32, R(RCX), Imm32(arg0));
MOV(32, R(RDX), Imm32(arg1));
MOV(32, R(R8), Imm32(arg2));
CALLptr(M(impptr));
}
void XEmitter::___CallCdeclImport4(void* impptr, u32 arg0, u32 arg1, u32 arg2, u32 arg3) {
MOV(32, R(RCX), Imm32(arg0));
MOV(32, R(RDX), Imm32(arg1));
MOV(32, R(R8), Imm32(arg2));
MOV(32, R(R9), Imm32(arg3));
MOV(32, R(RCX), Imm32(arg0));
MOV(32, R(RDX), Imm32(arg1));
MOV(32, R(R8), Imm32(arg2));
MOV(32, R(R9), Imm32(arg3));
CALLptr(M(impptr));
}
void XEmitter::___CallCdeclImport5(void* impptr, u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 arg4) {
MOV(32, R(RCX), Imm32(arg0));
MOV(32, R(RDX), Imm32(arg1));
MOV(32, R(R8), Imm32(arg2));
MOV(32, R(R9), Imm32(arg3));
MOV(32, R(RCX), Imm32(arg0));
MOV(32, R(RDX), Imm32(arg1));
MOV(32, R(R8), Imm32(arg2));
MOV(32, R(R9), Imm32(arg3));
MOV(32, MDisp(RSP, 0x20), Imm32(arg4));
CALLptr(M(impptr));
}
void XEmitter::___CallCdeclImport6(void* impptr, u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 arg4, u32 arg5) {
MOV(32, R(RCX), Imm32(arg0));
MOV(32, R(RDX), Imm32(arg1));
MOV(32, R(R8), Imm32(arg2));
MOV(32, R(R9), Imm32(arg3));
MOV(32, R(RCX), Imm32(arg0));
MOV(32, R(RDX), Imm32(arg1));
MOV(32, R(R8), Imm32(arg2));
MOV(32, R(R9), Imm32(arg3));
MOV(32, MDisp(RSP, 0x20), Imm32(arg4));
MOV(32, MDisp(RSP, 0x28), Imm32(arg5));
CALLptr(M(impptr));
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Common/Src/x64Emitter.h
Expand Up @@ -766,7 +766,7 @@ class XCodeBlock : public XEmitter
// Start over if you need to change the code (call FreeCodeSpace(), AllocCodeSpace()).
void WriteProtect()
{
WriteProtectMemory(region, region_size, true);
WriteProtectMemory(region, region_size, true);
}

void ResetCodePtr()
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Common/Src/x64FPURoundMode.cpp
Expand Up @@ -68,7 +68,7 @@ namespace FPURoundMode
}

void SetPrecisionMode(u32 mode)
{
{
#ifdef _M_IX86
// sets the floating-point lib to 53-bit
// PowerPC has a 53bit floating pipeline only
Expand Down Expand Up @@ -104,7 +104,7 @@ namespace FPURoundMode
u32 csr = ssetable[mode];
_mm_setcsr(csr);
}

void SaveSIMDState()
{
saved_sse_state = _mm_getcsr();
Expand Down
884 changes: 442 additions & 442 deletions Source/Core/VideoCommon/Src/BPMemory.h

Large diffs are not rendered by default.

260 changes: 130 additions & 130 deletions Source/Core/VideoCommon/Src/CPMemory.h
Expand Up @@ -25,18 +25,18 @@ enum
{
ARRAY_POSITION = 0,
ARRAY_NORMAL = 1,
ARRAY_COLOR = 2,
ARRAY_COLOR2 = 3,
ARRAY_TEXCOORD0 = 4,
ARRAY_COLOR = 2,
ARRAY_COLOR2 = 3,
ARRAY_TEXCOORD0 = 4,
};

// Vertex components
enum
{
NOT_PRESENT = 0,
DIRECT = 1,
INDEX8 = 2,
INDEX16 = 3,
DIRECT = 1,
INDEX8 = 2,
INDEX16 = 3,
};

enum
Expand Down Expand Up @@ -74,171 +74,171 @@ union TVtxDesc
// 0: not present
// 1: present
u32 PosMatIdx : 1;
u32 Tex0MatIdx : 1;
u32 Tex1MatIdx : 1;
u32 Tex2MatIdx : 1;
u32 Tex3MatIdx : 1;
u32 Tex4MatIdx : 1;
u32 Tex5MatIdx : 1;
u32 Tex6MatIdx : 1;
u32 Tex7MatIdx : 1;
u32 Tex0MatIdx : 1;
u32 Tex1MatIdx : 1;
u32 Tex2MatIdx : 1;
u32 Tex3MatIdx : 1;
u32 Tex4MatIdx : 1;
u32 Tex5MatIdx : 1;
u32 Tex6MatIdx : 1;
u32 Tex7MatIdx : 1;

// 00: not present
// 01: direct
// 10: 8 bit index
// 11: 16 bit index
u32 Position : 2;
u32 Normal : 2;
u32 Color0 : 2;
u32 Color1 : 2;
u32 Tex0Coord : 2;
u32 Tex1Coord : 2;
u32 Tex2Coord : 2;
u32 Tex3Coord : 2;
u32 Tex4Coord : 2;
u32 Tex5Coord : 2;
u32 Tex6Coord : 2;
u32 Tex7Coord : 2;
u32 Color0 : 2;
u32 Color1 : 2;
u32 Tex0Coord : 2;
u32 Tex1Coord : 2;
u32 Tex2Coord : 2;
u32 Tex3Coord : 2;
u32 Tex4Coord : 2;
u32 Tex5Coord : 2;
u32 Tex6Coord : 2;
u32 Tex7Coord : 2;
u32 :31;
};
struct {
u32 Hex0, Hex1;
};
struct {
u32 Hex0, Hex1;
};
};

union UVAT_group0
{
u32 Hex;
struct
{
// 0:8
u32 PosElements : 1;
u32 PosFormat : 3;
u32 PosFrac : 5;
// 9:12
u32 NormalElements : 1;
u32 NormalFormat : 3;
// 13:16
u32 Color0Elements : 1;
u32 Color0Comp : 3;
// 17:20
u32 Color1Elements : 1;
u32 Color1Comp : 3;
// 21:29
u32 Tex0CoordElements : 1;
u32 Tex0CoordFormat : 3;
u32 Tex0Frac : 5;
// 30:31
u32 ByteDequant : 1;
u32 NormalIndex3 : 1;
};
u32 Hex;
struct
{
// 0:8
u32 PosElements : 1;
u32 PosFormat : 3;
u32 PosFrac : 5;
// 9:12
u32 NormalElements : 1;
u32 NormalFormat : 3;
// 13:16
u32 Color0Elements : 1;
u32 Color0Comp : 3;
// 17:20
u32 Color1Elements : 1;
u32 Color1Comp : 3;
// 21:29
u32 Tex0CoordElements : 1;
u32 Tex0CoordFormat : 3;
u32 Tex0Frac : 5;
// 30:31
u32 ByteDequant : 1;
u32 NormalIndex3 : 1;
};
};

union UVAT_group1
{
u32 Hex;
struct
{
// 0:8
u32 Tex1CoordElements : 1;
u32 Tex1CoordFormat : 3;
u32 Tex1Frac : 5;
// 9:17
u32 Tex2CoordElements : 1;
u32 Tex2CoordFormat : 3;
u32 Tex2Frac : 5;
// 18:26
u32 Tex3CoordElements : 1;
u32 Tex3CoordFormat : 3;
u32 Tex3Frac : 5;
// 27:30
u32 Tex4CoordElements : 1;
u32 Tex4CoordFormat : 3;
//
u32 : 1;
};
u32 Hex;
struct
{
// 0:8
u32 Tex1CoordElements : 1;
u32 Tex1CoordFormat : 3;
u32 Tex1Frac : 5;
// 9:17
u32 Tex2CoordElements : 1;
u32 Tex2CoordFormat : 3;
u32 Tex2Frac : 5;
// 18:26
u32 Tex3CoordElements : 1;
u32 Tex3CoordFormat : 3;
u32 Tex3Frac : 5;
// 27:30
u32 Tex4CoordElements : 1;
u32 Tex4CoordFormat : 3;
//
u32 : 1;
};
};

union UVAT_group2
{
u32 Hex;
struct
{
// 0:4
u32 Tex4Frac : 5;
// 5:13
u32 Tex5CoordElements : 1;
u32 Tex5CoordFormat : 3;
u32 Tex5Frac : 5;
// 14:22
u32 Tex6CoordElements : 1;
u32 Tex6CoordFormat : 3;
u32 Tex6Frac : 5;
// 23:31
u32 Tex7CoordElements : 1;
u32 Tex7CoordFormat : 3;
u32 Tex7Frac : 5;
};
u32 Hex;
struct
{
// 0:4
u32 Tex4Frac : 5;
// 5:13
u32 Tex5CoordElements : 1;
u32 Tex5CoordFormat : 3;
u32 Tex5Frac : 5;
// 14:22
u32 Tex6CoordElements : 1;
u32 Tex6CoordFormat : 3;
u32 Tex6Frac : 5;
// 23:31
u32 Tex7CoordElements : 1;
u32 Tex7CoordFormat : 3;
u32 Tex7Frac : 5;
};
};

struct ColorAttr
{
u8 Elements;
u8 Comp;
u8 Elements;
u8 Comp;
};

struct TexAttr
{
u8 Elements;
u8 Format;
u8 Frac;
u8 Elements;
u8 Format;
u8 Frac;
};

struct TVtxAttr
{
u8 PosElements;
u8 PosFormat;
u8 PosFrac;
u8 NormalElements;
u8 NormalFormat;
ColorAttr color[2];
TexAttr texCoord[8];
u8 ByteDequant;
u8 NormalIndex3;
{
u8 PosElements;
u8 PosFormat;
u8 PosFrac;
u8 NormalElements;
u8 NormalFormat;
ColorAttr color[2];
TexAttr texCoord[8];
u8 ByteDequant;
u8 NormalIndex3;
};

// Matrix indices
union TMatrixIndexA
{
struct
{
u32 PosNormalMtxIdx : 6;
u32 Tex0MtxIdx : 6;
u32 Tex1MtxIdx : 6;
u32 Tex2MtxIdx : 6;
u32 Tex3MtxIdx : 6;
};
struct
{
u32 Hex : 30;
u32 unused : 2;
};
struct
{
u32 PosNormalMtxIdx : 6;
u32 Tex0MtxIdx : 6;
u32 Tex1MtxIdx : 6;
u32 Tex2MtxIdx : 6;
u32 Tex3MtxIdx : 6;
};
struct
{
u32 Hex : 30;
u32 unused : 2;
};
};

union TMatrixIndexB
{
struct
{
u32 Tex4MtxIdx : 6;
u32 Tex5MtxIdx : 6;
u32 Tex6MtxIdx : 6;
u32 Tex7MtxIdx : 6;
};
struct
{
u32 Hex : 24;
u32 unused : 8;
};
struct
{
u32 Tex4MtxIdx : 6;
u32 Tex5MtxIdx : 6;
u32 Tex6MtxIdx : 6;
u32 Tex7MtxIdx : 6;
};
struct
{
u32 Hex : 24;
u32 unused : 8;
};
};

#pragma pack()
Expand Down
43 changes: 21 additions & 22 deletions Source/Core/VideoCommon/Src/CommandProcessor.cpp
Expand Up @@ -325,7 +325,7 @@ void Write16(const u16 _Value, const u32 _Address)
case CLEAR_REGISTER:
{
UCPClearReg tmpCtrl(_Value);
m_CPClearReg.Hex = tmpCtrl.Hex;
m_CPClearReg.Hex = tmpCtrl.Hex;
DEBUG_LOG(COMMANDPROCESSOR,"\t write to CLEAR_REGISTER : %04x", _Value);
SetCpClearRegister();
}
Expand Down Expand Up @@ -414,7 +414,7 @@ void Write16(const u16 _Value, const u32 _Address)
}
else
{
ResetVideoBuffer();
ResetVideoBuffer();
}
IncrementCheckContextId();
DEBUG_LOG(COMMANDPROCESSOR,"try to write to FIFO_RW_DISTANCE_HI : %04x", _Value);
Expand Down Expand Up @@ -462,7 +462,6 @@ void STACKALIGN GatherPipeBursted()
ProcessFifoAllDistance();
waitingForPEInterruptDisable = false;
}

}
return;
}
Expand Down Expand Up @@ -492,19 +491,19 @@ void STACKALIGN GatherPipeBursted()

void UpdateInterrupts(u64 userdata)
{
if (userdata)
if (userdata)
{
interruptSet = true;
INFO_LOG(COMMANDPROCESSOR,"Interrupt set");
ProcessorInterface::SetInterrupt(INT_CAUSE_CP, true);
INFO_LOG(COMMANDPROCESSOR,"Interrupt set");
ProcessorInterface::SetInterrupt(INT_CAUSE_CP, true);
}
else
{
interruptSet = false;
INFO_LOG(COMMANDPROCESSOR,"Interrupt cleared");
ProcessorInterface::SetInterrupt(INT_CAUSE_CP, false);
}
interruptWaiting = false;
interruptWaiting = false;
}

void UpdateInterruptsFromVideoBackend(u64 userdata)
Expand All @@ -520,11 +519,11 @@ void AbortFrame()

void SetCpStatus(bool isCPUThread)
{
// overflow & underflow check
// overflow & underflow check
fifo.bFF_HiWatermark = (fifo.CPReadWriteDistance > fifo.CPHiWatermark);
fifo.bFF_LoWatermark = (fifo.CPReadWriteDistance < fifo.CPLoWatermark);
fifo.bFF_LoWatermark = (fifo.CPReadWriteDistance < fifo.CPLoWatermark);

// breakpoint
// breakpoint
if (!isCPUThread)
{
if (fifo.bFF_BPEnable)
Expand Down Expand Up @@ -562,12 +561,12 @@ void SetCpStatus(bool isCPUThread)
isHiWatermarkActive = ovfInt && m_CPCtrlReg.GPReadEnable;
isLoWatermarkActive = undfInt && m_CPCtrlReg.GPReadEnable;

if (interrupt != interruptSet && !interruptWaiting)
{
u64 userdata = interrupt?1:0;
if (IsOnThread())
{
if (!interrupt || bpInt || undfInt || ovfInt)
if (interrupt != interruptSet && !interruptWaiting)
{
u64 userdata = interrupt?1:0;
if (IsOnThread())
{
if (!interrupt || bpInt || undfInt || ovfInt)
{
if (!isCPUThread)
{
Expand All @@ -579,14 +578,14 @@ void SetCpStatus(bool isCPUThread)
{
// CPU thread:
interruptSet = interrupt;
INFO_LOG(COMMANDPROCESSOR,"Interrupt set");
ProcessorInterface::SetInterrupt(INT_CAUSE_CP, interrupt);
INFO_LOG(COMMANDPROCESSOR,"Interrupt set");
ProcessorInterface::SetInterrupt(INT_CAUSE_CP, interrupt);
}
}
}
else
CommandProcessor::UpdateInterrupts(userdata);
}
}
else
CommandProcessor::UpdateInterrupts(userdata);
}
}

void ProcessFifoToLoWatermark()
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/VideoCommon/Src/EmuWindow.cpp
Expand Up @@ -80,7 +80,7 @@ void FreeLookInput( UINT iMsg, WPARAM wParam )
static bool mouseLookEnabled = false;
static bool mouseMoveEnabled = false;
static float lastMouse[2];
POINT point;
POINT point;
switch(iMsg)
{
case WM_USER_KEYDOWN:
Expand Down Expand Up @@ -133,7 +133,7 @@ void FreeLookInput( UINT iMsg, WPARAM wParam )
lastMouse[1] = (float)point.y;
mouseLookEnabled= true;
break;
case WM_MBUTTONDOWN:
case WM_MBUTTONDOWN:
GetCursorPos(&point);
lastMouse[0] = (float)point.x;
lastMouse[1] = (float)point.y;
Expand Down
40 changes: 20 additions & 20 deletions Source/Core/VideoCommon/Src/Fifo.cpp
Expand Up @@ -43,10 +43,10 @@ static int size = 0;

void Fifo_DoState(PointerWrap &p)
{
p.DoArray(videoBuffer, FIFO_SIZE);
p.Do(size);
p.DoPointer(g_pVideoData, videoBuffer);
p.Do(g_bSkipCurrentFrame);
p.DoArray(videoBuffer, FIFO_SIZE);
p.Do(size);
p.DoPointer(g_pVideoData, videoBuffer);
p.Do(g_bSkipCurrentFrame);
}

void Fifo_PauseAndLock(bool doLock, bool unpauseOnUnlock)
Expand All @@ -69,8 +69,8 @@ void Fifo_PauseAndLock(bool doLock, bool unpauseOnUnlock)


void Fifo_Init()
{
videoBuffer = (u8*)AllocateMemoryPages(FIFO_SIZE);
{
videoBuffer = (u8*)AllocateMemoryPages(FIFO_SIZE);
size = 0;
GpuRunningState = false;
Common::AtomicStore(CommandProcessor::VITicks, CommandProcessor::m_cpClockOrigin);
Expand All @@ -79,12 +79,12 @@ void Fifo_Init()
void Fifo_Shutdown()
{
if (GpuRunningState) PanicAlert("Fifo shutting down while active");
FreeMemoryPages(videoBuffer, FIFO_SIZE);
FreeMemoryPages(videoBuffer, FIFO_SIZE);
}

u8* GetVideoBufferStartPtr()
{
return videoBuffer;
return videoBuffer;
}

u8* GetVideoBufferEndPtr()
Expand Down Expand Up @@ -119,20 +119,20 @@ void EmulatorState(bool running)
// Description: RunGpuLoop() sends data through this function.
void ReadDataFromFifo(u8* _uData, u32 len)
{
if (size + len >= FIFO_SIZE)
{
if (size + len >= FIFO_SIZE)
{
int pos = (int)(g_pVideoData - videoBuffer);
size -= pos;
if (size + len > FIFO_SIZE)
{
PanicAlert("FIFO out of bounds (sz = %i, len = %i at %08x)", size, len, pos);
}
memmove(&videoBuffer[0], &videoBuffer[pos], size);
if (size + len > FIFO_SIZE)
{
PanicAlert("FIFO out of bounds (sz = %i, len = %i at %08x)", size, len, pos);
}
memmove(&videoBuffer[0], &videoBuffer[pos], size);
g_pVideoData = videoBuffer;
}
}
// Copy new video instructions to videoBuffer for future use in rendering the new picture
memcpy(videoBuffer + size, _uData, len);
size += len;
memcpy(videoBuffer + size, _uData, len);
size += len;
}

void ResetVideoBuffer()
Expand All @@ -153,7 +153,7 @@ void RunGpuLoop()

while (GpuRunningState)
{
g_video_backend->PeekMessages();
g_video_backend->PeekMessages();

VideoFifo_CheckAsyncRequest();

Expand Down Expand Up @@ -240,7 +240,7 @@ void RunGpu()
while (fifo.bFF_GPReadEnable && fifo.CPReadWriteDistance && !AtBreakpoint() )
{
u8 *uData = Memory::GetPointer(fifo.CPReadPointer);

FPURoundMode::SaveSIMDState();
FPURoundMode::LoadDefaultSIMDState();
ReadDataFromFifo(uData, 32);
Expand Down
12 changes: 6 additions & 6 deletions Source/Core/VideoCommon/Src/FramebufferManagerBase.cpp
Expand Up @@ -60,12 +60,12 @@ const XFBSourceBase* const* FramebufferManagerBase::GetRealXFBSource(u32 xfbAddr
m_realXFBSource->texHeight = fbHeight;

// TODO: stuff only used by OGL... :/
// OpenGL texture coordinates originate at the lower left, which is why
// sourceRc.top = fbHeight and sourceRc.bottom = 0.
m_realXFBSource->sourceRc.left = 0;
m_realXFBSource->sourceRc.top = fbHeight;
m_realXFBSource->sourceRc.right = fbWidth;
m_realXFBSource->sourceRc.bottom = 0;
// OpenGL texture coordinates originate at the lower left, which is why
// sourceRc.top = fbHeight and sourceRc.bottom = 0.
m_realXFBSource->sourceRc.left = 0;
m_realXFBSource->sourceRc.top = fbHeight;
m_realXFBSource->sourceRc.right = fbWidth;
m_realXFBSource->sourceRc.bottom = 0;

// Decode YUYV data from GameCube RAM
m_realXFBSource->DecodeToTexture(xfbAddr, fbWidth, fbHeight);
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/VideoCommon/Src/GenericDLCache.cpp
Expand Up @@ -23,7 +23,7 @@

namespace DLCache
{

void Init()
{
}
Expand All @@ -33,7 +33,7 @@ void Shutdown()
}

void Clear()
{
{
}

void ProgressiveCleanup()
Expand Down