Use double instead of float for FPRs

This commit is contained in:
container1234 2018-01-13 16:46:44 +09:00
parent b6138b9408
commit 025d9383ac
3 changed files with 29 additions and 5 deletions

View File

@ -74,6 +74,12 @@ void RegisterColumn::SetValue()
std::memcpy(&value, &f, sizeof(u32));
break;
}
case RegisterDisplay::Double:
{
double f = text().toDouble(&valid);
std::memcpy(&value, &f, sizeof(u64));
break;
}
}
if (!valid)
@ -117,6 +123,13 @@ void RegisterColumn::Update()
text = QString::number(tmp);
break;
}
case RegisterDisplay::Double:
{
double tmp;
std::memcpy(&tmp, &m_value, sizeof(double));
text = QString::number(tmp);
break;
}
}
setText(text);

View File

@ -13,7 +13,7 @@
enum class RegisterType
{
gpr, // General purpose registers, int (r0-r31)
fpr, // General purpose registers, float (f0-f31)
fpr, // Floating point registers, double (f0-f31)
ibat, // Instruction BATs (IBAT0-IBAT7)
dbat, // Data BATs (DBAT0-DBAT7)
tb, // Time base register
@ -40,7 +40,8 @@ enum class RegisterDisplay
Hex,
SInt32,
UInt32,
Float
Float,
Double
};
constexpr int DATA_TYPE = Qt::UserRole;

View File

@ -131,8 +131,9 @@ void RegisterWidget::ShowContextMenu()
auto* view_int = menu->addAction(tr("Signed Integer"));
auto* view_uint = menu->addAction(tr("Unsigned Integer"));
auto* view_float = menu->addAction(tr("Float"));
auto* view_double = menu->addAction(tr("Double"));
for (auto* action : {view_hex, view_int, view_uint, view_float})
for (auto* action : {view_hex, view_int, view_uint, view_float, view_double})
{
action->setCheckable(true);
action->setVisible(false);
@ -153,6 +154,9 @@ void RegisterWidget::ShowContextMenu()
case RegisterDisplay::Float:
view_float->setChecked(true);
break;
case RegisterDisplay::Double:
view_double->setChecked(true);
break;
}
switch (type)
@ -165,7 +169,7 @@ void RegisterWidget::ShowContextMenu()
break;
case RegisterType::fpr:
view_hex->setVisible(true);
view_float->setVisible(true);
view_double->setVisible(true);
break;
default:
break;
@ -195,6 +199,12 @@ void RegisterWidget::ShowContextMenu()
m_updating = false;
});
connect(view_double, &QAction::triggered, [this, item] {
m_updating = true;
item->SetDisplay(RegisterDisplay::Double);
m_updating = false;
});
menu->addSeparator();
}
}
@ -212,7 +222,7 @@ void RegisterWidget::PopulateTable()
AddRegister(i, 0, RegisterType::gpr, "r" + std::to_string(i), [i] { return GPR(i); },
[i](u64 value) { GPR(i) = value; });
// General purpose registers (float)
// Floating point registers (double)
AddRegister(i, 2, RegisterType::fpr, "f" + std::to_string(i), [i] { return riPS0(i); },
[i](u64 value) { riPS0(i) = value; });