Skip to content
Permalink
Browse files

GCMemcard: Use BigEndianValue for DEntry.m_animation_speed.

  • Loading branch information...
AdmiralCurtiss committed Nov 18, 2018
1 parent c3e9f53 commit 929fd2b41df9e9626f3de747defcebd950ae2bd2
@@ -471,12 +471,14 @@ std::string GCMemcard::DEntry_AnimSpeed(u8 index) const
if (!m_valid || index >= DIRLEN)
return "";

int x = CurrentDir->m_dir_entries[index].m_animation_speed[0];
std::array<u8, 2> tmp;
memcpy(tmp.data(), &CurrentDir->m_dir_entries[index].m_animation_speed, 2);
int x = tmp[0];
std::string speed;
for (int i = 0; i < 16; i++)
{
if (i == 8)
x = CurrentDir->m_dir_entries[index].m_animation_speed[1];
x = tmp[1];
speed.push_back((x & 0x80) ? '1' : '0');
x = x << 1;
}
@@ -1053,7 +1055,10 @@ void GCMemcard::Gcs_SavConvert(DEntry& tempDEntry, int saveType, int length)
ByteSwap(&tmp[0], &tmp[1]);
memcpy(&tempDEntry.m_icon_format, tmp.data(), 2);

ArrayByteSwap((tempDEntry.m_animation_speed));
memcpy(tmp.data(), &tempDEntry.m_animation_speed, 2);
ByteSwap(&tmp[0], &tmp[1]);
memcpy(&tempDEntry.m_animation_speed, tmp.data(), 2);

ByteSwap(&tempDEntry.m_file_permissions, &tempDEntry.m_copy_counter);
ArrayByteSwap((tempDEntry.m_first_block));
ArrayByteSwap((tempDEntry.m_block_count));
@@ -1118,7 +1123,7 @@ u32 GCMemcard::ReadAnimRGBA8(u8 index, u32* buffer, u8* delays) const
// int fmtCheck = 0;

int formats = CurrentDir->m_dir_entries[index].m_icon_format;
int fdelays = BE16(CurrentDir->m_dir_entries[index].m_animation_speed);
int fdelays = CurrentDir->m_dir_entries[index].m_animation_speed;

int flags = CurrentDir->m_dir_entries[index].m_banner_and_icon_flags;
// Timesplitters 2 and 3 is the only game that I see this in
@@ -198,7 +198,8 @@ struct DEntry
// 10 RGB5A3
// 11 CI8 with a unique color palette after itself
//
u8 m_animation_speed[2]; // 0x32 0x02 Animation speed (2bits per icon) (*1)
Common::BigEndianValue<u16>
m_animation_speed; // 0x32 0x02 Animation speed (2bits per icon) (*1)
// Bits Description
// 00 No icon
// 01 Icon lasts for 4 frames
@@ -202,7 +202,10 @@ void GCMemcardManager::UpdateSlotTable(int slot)
DEntry d;
memcard->GetDEntry(file_index, d);

const auto speed = ((d.m_animation_speed[0] & 1) << 2) + (d.m_animation_speed[1] & 1);
// TODO: This is wrong, the animation speed is not static and is already correctly calculated in
// GetIconFromSaveFile(), just not returned
const u16 animation_speed = d.m_animation_speed;
const auto speed = (((animation_speed >> 8) & 1) << 2) + (animation_speed & 1);

m_slot_active_icons[slot].push_back({speed, frames});

0 comments on commit 929fd2b

Please sign in to comment.
You can’t perform that action at this time.