Skip to content
Permalink
Browse files

GCMemcard: Use std::array and BigEndianValue for BlockAlloc.m_map.

  • Loading branch information...
AdmiralCurtiss committed Nov 18, 2018
1 parent eb6cc3d commit 4d4b5442bd2ecfaab2dad22be315fdf236dcbf9e
Showing with 6 additions and 4 deletions.
  1. +2 −2 Source/Core/Core/HW/GCMemcard/GCMemcard.cpp
  2. +4 −2 Source/Core/Core/HW/GCMemcard/GCMemcard.h
@@ -586,7 +586,7 @@ u16 BlockAlloc::GetNextBlock(u16 Block) const
if ((Block < MC_FST_BLOCKS) || (Block > 4091))
return 0;

return Common::swap16(m_map[Block - MC_FST_BLOCKS]);
return m_map[Block - MC_FST_BLOCKS];
}

// Parameters and return value are expected as memory card block index,
@@ -723,7 +723,7 @@ u32 GCMemcard::ImportFile(const DEntry& direntry, std::vector<GCMBlock>& saveBlo
nextBlock = 0xFFFF;
else
nextBlock = UpdatedBat.NextFreeBlock(maxBlock, firstBlock + 1);
UpdatedBat.m_map[firstBlock - MC_FST_BLOCKS] = BE16(nextBlock);
UpdatedBat.m_map[firstBlock - MC_FST_BLOCKS] = nextBlock;
UpdatedBat.m_last_allocated_block = firstBlock;
firstBlock = nextBlock;
}
@@ -258,7 +258,9 @@ struct BlockAlloc
Common::BigEndianValue<u16> m_update_counter; // 0x0004 2 Update Counter
Common::BigEndianValue<u16> m_free_blocks; // 0x0006 2 Free Blocks
Common::BigEndianValue<u16> m_last_allocated_block; // 0x0008 2 Last allocated Block
u16 m_map[BAT_SIZE]; // 0x000a 0x1ff8 Map of allocated Blocks
std::array<Common::BigEndianValue<u16>, BAT_SIZE>
m_map; // 0x000a 0x1ff8 Map of allocated Blocks

u16 GetNextBlock(u16 Block) const;
u16 NextFreeBlock(u16 MaxBlock, u16 StartingBlock = MC_FST_BLOCKS) const;
bool ClearBlocks(u16 StartingBlock, u16 Length);
@@ -281,7 +283,7 @@ struct BlockAlloc
u16 current = starting;
while ((current - starting + 1) < length)
{
m_map[current - 5] = BE16(current + 1);
m_map[current - 5] = current + 1;
current++;
}
m_map[current - 5] = 0xFFFF;

0 comments on commit 4d4b544

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