mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 13:57:57 -07:00
GCMemcard: Use BigEndianValue for DEntry.m_first_block.
This commit is contained in:
parent
929fd2b41d
commit
675a549628
@ -511,7 +511,7 @@ u16 GCMemcard::DEntry_FirstBlock(u8 index) const
|
||||
if (!m_valid || index >= DIRLEN)
|
||||
return 0xFFFF;
|
||||
|
||||
u16 block = BE16(CurrentDir->m_dir_entries[index].m_first_block);
|
||||
u16 block = CurrentDir->m_dir_entries[index].m_first_block;
|
||||
if (block > (u16)maxBlock)
|
||||
return 0xFFFF;
|
||||
return block;
|
||||
@ -542,7 +542,7 @@ std::string GCMemcard::GetSaveComment1(u8 index) const
|
||||
return "";
|
||||
|
||||
u32 Comment1 = BE32(CurrentDir->m_dir_entries[index].m_comments_address);
|
||||
u32 DataBlock = BE16(CurrentDir->m_dir_entries[index].m_first_block) - MC_FST_BLOCKS;
|
||||
u32 DataBlock = CurrentDir->m_dir_entries[index].m_first_block - MC_FST_BLOCKS;
|
||||
if ((DataBlock > maxBlock) || (Comment1 == 0xFFFFFFFF))
|
||||
{
|
||||
return "";
|
||||
@ -557,7 +557,7 @@ std::string GCMemcard::GetSaveComment2(u8 index) const
|
||||
|
||||
u32 Comment1 = BE32(CurrentDir->m_dir_entries[index].m_comments_address);
|
||||
u32 Comment2 = Comment1 + DENTRY_STRLEN;
|
||||
u32 DataBlock = BE16(CurrentDir->m_dir_entries[index].m_first_block) - MC_FST_BLOCKS;
|
||||
u32 DataBlock = CurrentDir->m_dir_entries[index].m_first_block - MC_FST_BLOCKS;
|
||||
if ((DataBlock > maxBlock) || (Comment1 == 0xFFFFFFFF))
|
||||
{
|
||||
return "";
|
||||
@ -682,7 +682,7 @@ u32 GCMemcard::ImportFile(const DEntry& direntry, std::vector<GCMBlock>& saveBlo
|
||||
if (BE32(UpdatedDir.m_dir_entries[i].m_gamecode) == 0xFFFFFFFF)
|
||||
{
|
||||
UpdatedDir.m_dir_entries[i] = direntry;
|
||||
*(u16*)&UpdatedDir.m_dir_entries[i].m_first_block = BE16(firstBlock);
|
||||
UpdatedDir.m_dir_entries[i].m_first_block = firstBlock;
|
||||
UpdatedDir.m_dir_entries[i].m_copy_counter = UpdatedDir.m_dir_entries[i].m_copy_counter + 1;
|
||||
break;
|
||||
}
|
||||
@ -748,7 +748,7 @@ u32 GCMemcard::RemoveFile(u8 index) // index in the directory array
|
||||
if (index >= DIRLEN)
|
||||
return DELETE_FAIL;
|
||||
|
||||
u16 startingblock = BE16(CurrentDir->m_dir_entries[index].m_first_block);
|
||||
u16 startingblock = CurrentDir->m_dir_entries[index].m_first_block;
|
||||
u16 numberofblocks = BE16(CurrentDir->m_dir_entries[index].m_block_count);
|
||||
|
||||
BlockAlloc UpdatedBat = *CurrentBat;
|
||||
@ -1060,7 +1060,11 @@ void GCMemcard::Gcs_SavConvert(DEntry& tempDEntry, int saveType, int length)
|
||||
memcpy(&tempDEntry.m_animation_speed, tmp.data(), 2);
|
||||
|
||||
ByteSwap(&tempDEntry.m_file_permissions, &tempDEntry.m_copy_counter);
|
||||
ArrayByteSwap((tempDEntry.m_first_block));
|
||||
|
||||
memcpy(tmp.data(), &tempDEntry.m_first_block, 2);
|
||||
ByteSwap(&tmp[0], &tmp[1]);
|
||||
memcpy(&tempDEntry.m_first_block, tmp.data(), 2);
|
||||
|
||||
ArrayByteSwap((tempDEntry.m_block_count));
|
||||
ArrayByteSwap((tempDEntry.m_unused_2));
|
||||
ArrayByteSwap((tempDEntry.m_comments_address));
|
||||
@ -1088,7 +1092,7 @@ bool GCMemcard::ReadBannerRGBA8(u8 index, u32* buffer) const
|
||||
return false;
|
||||
|
||||
u32 DataOffset = CurrentDir->m_dir_entries[index].m_image_offset;
|
||||
u32 DataBlock = BE16(CurrentDir->m_dir_entries[index].m_first_block) - MC_FST_BLOCKS;
|
||||
u32 DataBlock = CurrentDir->m_dir_entries[index].m_first_block - MC_FST_BLOCKS;
|
||||
|
||||
if ((DataBlock > maxBlock) || (DataOffset == 0xFFFFFFFF))
|
||||
{
|
||||
@ -1135,7 +1139,7 @@ u32 GCMemcard::ReadAnimRGBA8(u8 index, u32* buffer, u8* delays) const
|
||||
int bnrFormat = (flags & 3);
|
||||
|
||||
u32 DataOffset = CurrentDir->m_dir_entries[index].m_image_offset;
|
||||
u32 DataBlock = BE16(CurrentDir->m_dir_entries[index].m_first_block) - MC_FST_BLOCKS;
|
||||
u32 DataBlock = CurrentDir->m_dir_entries[index].m_first_block - MC_FST_BLOCKS;
|
||||
|
||||
if ((DataBlock > maxBlock) || (DataOffset == 0xFFFFFFFF))
|
||||
{
|
||||
|
@ -212,8 +212,9 @@ struct DEntry
|
||||
// 3 no copy File cannot be copied by the IPL
|
||||
// 2 public Can be read by any game
|
||||
//
|
||||
u8 m_copy_counter; // 0x35 0x01 Copy counter (*2)
|
||||
u8 m_first_block[2]; // 0x36 0x02 Block no of first block of file (0 == offset 0)
|
||||
u8 m_copy_counter; // 0x35 0x01 Copy counter (*2)
|
||||
Common::BigEndianValue<u16>
|
||||
m_first_block; // 0x36 0x02 Block no of first block of file (0 == offset 0)
|
||||
u8 m_block_count[2]; // 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
|
||||
@ -281,7 +282,7 @@ struct BlockAlloc
|
||||
m_last_allocated_block = BE16(current);
|
||||
m_free_blocks = BE16(BE16(m_free_blocks) - length);
|
||||
fixChecksums();
|
||||
return BE16(starting);
|
||||
return starting;
|
||||
}
|
||||
};
|
||||
static_assert(sizeof(BlockAlloc) == BLOCK_SIZE);
|
||||
|
@ -108,7 +108,7 @@ int GCMemcardDirectory::LoadGCI(const std::string& file_name, bool current_game_
|
||||
file_name.c_str());
|
||||
return NO_INDEX;
|
||||
}
|
||||
*(u16*)&gci.m_gci_header.m_first_block = first_block;
|
||||
gci.m_gci_header.m_first_block = first_block;
|
||||
if (gci.HasCopyProtection() && gci.LoadSaveBlocks())
|
||||
{
|
||||
GCMemcard::PSO_MakeSaveGameValid(m_hdr, gci.m_gci_header, gci.m_save_data);
|
||||
@ -452,8 +452,8 @@ inline void GCMemcardDirectory::SyncSaves()
|
||||
m_saves[i].m_dirty = true;
|
||||
u32 gamecode = BE32(m_saves[i].m_gci_header.m_gamecode);
|
||||
u32 new_gamecode = BE32(current->m_dir_entries[i].m_gamecode);
|
||||
u32 old_start = BE16(m_saves[i].m_gci_header.m_first_block);
|
||||
u32 new_start = BE16(current->m_dir_entries[i].m_first_block);
|
||||
u32 old_start = m_saves[i].m_gci_header.m_first_block;
|
||||
u32 new_start = current->m_dir_entries[i].m_first_block;
|
||||
|
||||
if ((gamecode != 0xFFFFFFFF) && (gamecode != new_gamecode))
|
||||
{
|
||||
@ -551,7 +551,7 @@ bool GCMemcardDirectory::SetUsedBlocks(int save_index)
|
||||
else
|
||||
current_bat = &m_bat1;
|
||||
|
||||
u16 block = BE16(m_saves[save_index].m_gci_header.m_first_block);
|
||||
u16 block = m_saves[save_index].m_gci_header.m_first_block;
|
||||
while (block != 0xFFFF)
|
||||
{
|
||||
m_saves[save_index].m_used_blocks.push_back(block);
|
||||
|
Loading…
Reference in New Issue
Block a user