GCMemcard: Use BigEndianValue for DEntry.m_icon_format.

This commit is contained in:
Admiral H. Curtiss 2018-11-18 17:50:06 +01:00
parent 65f6250faa
commit c3e9f53480
2 changed files with 10 additions and 5 deletions

View File

@ -452,12 +452,14 @@ std::string GCMemcard::DEntry_IconFmt(u8 index) const
if (!m_valid || index >= DIRLEN)
return "";
int x = CurrentDir->m_dir_entries[index].m_icon_format[0];
std::array<u8, 2> tmp;
memcpy(tmp.data(), &CurrentDir->m_dir_entries[index].m_icon_format, 2);
int x = tmp[0];
std::string format;
for (int i = 0; i < 16; i++)
{
if (i == 8)
x = CurrentDir->m_dir_entries[index].m_icon_format[1];
x = tmp[1];
format.push_back((x & 0x80) ? '1' : '0');
x = x << 1;
}
@ -1047,7 +1049,10 @@ void GCMemcard::Gcs_SavConvert(DEntry& tempDEntry, int saveType, int length)
ByteSwap(&tmp[2], &tmp[3]);
memcpy(&tempDEntry.m_image_offset, tmp.data(), 4);
ArrayByteSwap((tempDEntry.m_icon_format));
memcpy(tmp.data(), &tempDEntry.m_icon_format, 2);
ByteSwap(&tmp[0], &tmp[1]);
memcpy(&tempDEntry.m_icon_format, tmp.data(), 2);
ArrayByteSwap((tempDEntry.m_animation_speed));
ByteSwap(&tempDEntry.m_file_permissions, &tempDEntry.m_copy_counter);
ArrayByteSwap((tempDEntry.m_first_block));
@ -1112,7 +1117,7 @@ u32 GCMemcard::ReadAnimRGBA8(u8 index, u32* buffer, u8* delays) const
// Sonic Heroes it the only game I have seen that tries to use a CI8 and RGB5A3 icon
// int fmtCheck = 0;
int formats = BE16(CurrentDir->m_dir_entries[index].m_icon_format);
int formats = CurrentDir->m_dir_entries[index].m_icon_format;
int fdelays = BE16(CurrentDir->m_dir_entries[index].m_animation_speed);
int flags = CurrentDir->m_dir_entries[index].m_banner_and_icon_flags;

View File

@ -191,7 +191,7 @@ struct DEntry
m_modification_time; // 0x28 0x04 Time of file's last modification in seconds since
// 12am, January 1st, 2000
Common::BigEndianValue<u32> m_image_offset; // 0x2c 0x04 image data offset
u8 m_icon_format[2]; // 0x30 0x02 icon gfx format (2bits per icon)
Common::BigEndianValue<u16> m_icon_format; // 0x30 0x02 icon gfx format (2bits per icon)
// Bits Description
// 00 No icon
// 01 CI8 with a shared color palette after the last frame