Skip to content
Permalink
Browse files

GCMemcard: Use BigEndianValue for DEntry.m_comments_address.

  • Loading branch information...
AdmiralCurtiss committed Nov 18, 2018
1 parent 8a920da commit 443729d2c31af894f8e0d0d118de3afceced29f9
Showing with 13 additions and 9 deletions.
  1. +8 −5 Source/Core/Core/HW/GCMemcard/GCMemcard.cpp
  2. +5 −4 Source/Core/Core/HW/GCMemcard/GCMemcard.h
@@ -533,15 +533,15 @@ u32 GCMemcard::DEntry_CommentsAddress(u8 index) const
if (!m_valid || index >= DIRLEN)
return 0xFFFF;

return BE32(CurrentDir->m_dir_entries[index].m_comments_address);
return CurrentDir->m_dir_entries[index].m_comments_address;
}

std::string GCMemcard::GetSaveComment1(u8 index) const
{
if (!m_valid || index >= DIRLEN)
return "";

u32 Comment1 = BE32(CurrentDir->m_dir_entries[index].m_comments_address);
u32 Comment1 = CurrentDir->m_dir_entries[index].m_comments_address;
u32 DataBlock = CurrentDir->m_dir_entries[index].m_first_block - MC_FST_BLOCKS;
if ((DataBlock > maxBlock) || (Comment1 == 0xFFFFFFFF))
{
@@ -555,7 +555,7 @@ std::string GCMemcard::GetSaveComment2(u8 index) const
if (!m_valid || index >= DIRLEN)
return "";

u32 Comment1 = BE32(CurrentDir->m_dir_entries[index].m_comments_address);
u32 Comment1 = CurrentDir->m_dir_entries[index].m_comments_address;
u32 Comment2 = Comment1 + DENTRY_STRLEN;
u32 DataBlock = CurrentDir->m_dir_entries[index].m_first_block - MC_FST_BLOCKS;
if ((DataBlock > maxBlock) || (Comment1 == 0xFFFFFFFF))
@@ -1070,8 +1070,11 @@ void GCMemcard::Gcs_SavConvert(DEntry& tempDEntry, int saveType, int length)
memcpy(&tempDEntry.m_block_count, tmp.data(), 2);

ArrayByteSwap((tempDEntry.m_unused_2));
ArrayByteSwap((tempDEntry.m_comments_address));
ArrayByteSwap(&(tempDEntry.m_comments_address[2]));

memcpy(tmp.data(), &tempDEntry.m_comments_address, 4);
ByteSwap(&tmp[0], &tmp[1]);
ByteSwap(&tmp[2], &tmp[3]);
memcpy(&tempDEntry.m_comments_address, tmp.data(), 4);
break;
default:
break;
@@ -216,10 +216,11 @@ struct DEntry
Common::BigEndianValue<u16>
m_first_block; // 0x36 0x02 Block no of first block of file (0 == offset 0)
Common::BigEndianValue<u16>
m_block_count; // 0x38 0x02 File-length (number of blocks in file)
u8 m_unused_2[2]; // 0x3a 0x02 Reserved/unused (always 0xffff, has no effect)
u8 m_comments_address[4]; // 0x3c 0x04 Address of the two comments within the file data
// (*3)
m_block_count; // 0x38 0x02 File-length (number of blocks in file)
u8 m_unused_2[2]; // 0x3a 0x02 Reserved/unused (always 0xffff, has no effect)
Common::BigEndianValue<u32>
m_comments_address; // 0x3c 0x04 Address of the two comments within the file data
// (*3)
};
static_assert(sizeof(DEntry) == DENTRY_SIZE);

0 comments on commit 443729d

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