GCMemcard: Rewrite DEntry_IconFmt() and DEntry_AnimSpeed() to make more sense.

This commit is contained in:
Admiral H. Curtiss 2018-12-09 23:41:17 +01:00
parent 2351a60567
commit ca2c7679df
1 changed files with 7 additions and 16 deletions

View File

@ -9,6 +9,7 @@
#include <cstring> #include <cstring>
#include <vector> #include <vector>
#include "Common/BitUtils.h"
#include "Common/ColorUtil.h" #include "Common/ColorUtil.h"
#include "Common/CommonFuncs.h" #include "Common/CommonFuncs.h"
#include "Common/CommonPaths.h" #include "Common/CommonPaths.h"
@ -480,16 +481,11 @@ std::string GCMemcard::DEntry_IconFmt(u8 index) const
if (!m_valid || index >= DIRLEN) if (!m_valid || index >= DIRLEN)
return ""; return "";
std::array<u8, 2> tmp; u16 x = GetActiveDirectory().m_dir_entries[index].m_icon_format;
memcpy(tmp.data(), &GetActiveDirectory().m_dir_entries[index].m_icon_format, 2);
int x = tmp[0];
std::string format; std::string format;
for (int i = 0; i < 16; i++) for (size_t i = 0; i < 16; ++i)
{ {
if (i == 8) format.push_back(Common::ExtractBit(x, 15 - i) ? '1' : '0');
x = tmp[1];
format.push_back((x & 0x80) ? '1' : '0');
x = x << 1;
} }
return format; return format;
} }
@ -499,16 +495,11 @@ std::string GCMemcard::DEntry_AnimSpeed(u8 index) const
if (!m_valid || index >= DIRLEN) if (!m_valid || index >= DIRLEN)
return ""; return "";
std::array<u8, 2> tmp; u16 x = GetActiveDirectory().m_dir_entries[index].m_animation_speed;
memcpy(tmp.data(), &GetActiveDirectory().m_dir_entries[index].m_animation_speed, 2);
int x = tmp[0];
std::string speed; std::string speed;
for (int i = 0; i < 16; i++) for (size_t i = 0; i < 16; ++i)
{ {
if (i == 8) speed.push_back(Common::ExtractBit(x, 15 - i) ? '1' : '0');
x = tmp[1];
speed.push_back((x & 0x80) ? '1' : '0');
x = x << 1;
} }
return speed; return speed;
} }