2016-07-06 20:14:12 +00:00
|
|
|
/****************************************************************************
|
|
|
|
* *
|
|
|
|
* Project64 - A Nintendo 64 emulator. *
|
|
|
|
* http://www.pj64-emu.com/ *
|
|
|
|
* Copyright (C) 2012 Project64. All rights reserved. *
|
|
|
|
* *
|
|
|
|
* License: *
|
|
|
|
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
|
|
|
|
* *
|
|
|
|
****************************************************************************/
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include <Project64-core/N64System/Recompiler/RegBase.h>
|
|
|
|
|
|
|
|
CRegBase::CRegBase() :
|
2016-07-20 12:22:56 +00:00
|
|
|
m_CycleCount(0),
|
2016-09-24 22:29:45 +00:00
|
|
|
m_Fpu_Used(false),
|
|
|
|
m_RoundingModel(RoundUnknown)
|
2016-07-06 20:14:12 +00:00
|
|
|
{
|
2016-07-20 12:22:56 +00:00
|
|
|
for (int32_t i = 0; i < 32; i++)
|
2016-07-06 20:14:12 +00:00
|
|
|
{
|
|
|
|
m_MIPS_RegState[i] = STATE_UNKNOWN;
|
|
|
|
m_MIPS_RegVal[i].DW = 0;
|
|
|
|
}
|
2016-07-20 12:22:56 +00:00
|
|
|
m_MIPS_RegState[0] = STATE_CONST_32_SIGN;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CRegBase::operator==(const CRegBase& right) const
|
|
|
|
{
|
|
|
|
for (uint32_t count = 0; count < 32; count++)
|
|
|
|
{
|
|
|
|
if (m_MIPS_RegState[count] != right.m_MIPS_RegState[count])
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (m_MIPS_RegState[count] == STATE_UNKNOWN)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (m_MIPS_RegVal[count].DW != right.m_MIPS_RegVal[count].DW)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (m_CycleCount != right.m_CycleCount) { return false; }
|
|
|
|
if (m_Fpu_Used != right.m_Fpu_Used) { return false; }
|
2016-11-14 07:15:24 +00:00
|
|
|
if (GetRoundingModel() != right.GetRoundingModel()) { return false; }
|
2016-07-20 12:22:56 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CRegBase::operator!=(const CRegBase& right) const
|
|
|
|
{
|
|
|
|
return !(right == *this);
|
|
|
|
}
|
|
|
|
|
|
|
|
CRegBase& CRegBase::operator=(const CRegBase& right)
|
|
|
|
{
|
|
|
|
memcpy(&m_MIPS_RegState, &right.m_MIPS_RegState, sizeof(m_MIPS_RegState));
|
|
|
|
memcpy(&m_MIPS_RegVal, &right.m_MIPS_RegVal, sizeof(m_MIPS_RegVal));
|
|
|
|
m_CycleCount = right.m_CycleCount;
|
|
|
|
m_Fpu_Used = right.m_Fpu_Used;
|
2016-09-24 22:29:45 +00:00
|
|
|
m_RoundingModel = right.m_RoundingModel;
|
2016-07-20 12:22:56 +00:00
|
|
|
#ifdef _DEBUG
|
|
|
|
if (*this != right)
|
|
|
|
{
|
|
|
|
g_Notify->BreakPoint(__FILE__, __LINE__);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return *this;
|
2016-09-24 22:29:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const char * CRegBase::RoundingModelName(FPU_ROUND RoundType)
|
|
|
|
{
|
|
|
|
switch (RoundType)
|
|
|
|
{
|
|
|
|
case RoundUnknown: return "RoundUnknown";
|
|
|
|
case RoundDefault: return "RoundDefault";
|
|
|
|
case RoundTruncate: return "RoundTruncate";
|
|
|
|
case RoundNearest: return "RoundNearest";
|
|
|
|
case RoundDown: return "RoundDown";
|
|
|
|
case RoundUp: return "RoundUp";
|
|
|
|
}
|
|
|
|
return "** Invalid **";
|
|
|
|
}
|