mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-09-21 20:01:40 +02:00
GCMemcard: Use std::array and BigEndianValue for BlockAlloc.m_map.
This commit is contained in:
parent
eb6cc3dbab
commit
4d4b5442bd
2 changed files with 6 additions and 4 deletions
|
@ -586,7 +586,7 @@ u16 BlockAlloc::GetNextBlock(u16 Block) const
|
||||||
if ((Block < MC_FST_BLOCKS) || (Block > 4091))
|
if ((Block < MC_FST_BLOCKS) || (Block > 4091))
|
||||||
return 0;
|
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,
|
// 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;
|
nextBlock = 0xFFFF;
|
||||||
else
|
else
|
||||||
nextBlock = UpdatedBat.NextFreeBlock(maxBlock, firstBlock + 1);
|
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;
|
UpdatedBat.m_last_allocated_block = firstBlock;
|
||||||
firstBlock = nextBlock;
|
firstBlock = nextBlock;
|
||||||
}
|
}
|
||||||
|
|
|
@ -258,7 +258,9 @@ struct BlockAlloc
|
||||||
Common::BigEndianValue<u16> m_update_counter; // 0x0004 2 Update Counter
|
Common::BigEndianValue<u16> m_update_counter; // 0x0004 2 Update Counter
|
||||||
Common::BigEndianValue<u16> m_free_blocks; // 0x0006 2 Free Blocks
|
Common::BigEndianValue<u16> m_free_blocks; // 0x0006 2 Free Blocks
|
||||||
Common::BigEndianValue<u16> m_last_allocated_block; // 0x0008 2 Last allocated Block
|
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 GetNextBlock(u16 Block) const;
|
||||||
u16 NextFreeBlock(u16 MaxBlock, u16 StartingBlock = MC_FST_BLOCKS) const;
|
u16 NextFreeBlock(u16 MaxBlock, u16 StartingBlock = MC_FST_BLOCKS) const;
|
||||||
bool ClearBlocks(u16 StartingBlock, u16 Length);
|
bool ClearBlocks(u16 StartingBlock, u16 Length);
|
||||||
|
@ -281,7 +283,7 @@ struct BlockAlloc
|
||||||
u16 current = starting;
|
u16 current = starting;
|
||||||
while ((current - starting + 1) < length)
|
while ((current - starting + 1) < length)
|
||||||
{
|
{
|
||||||
m_map[current - 5] = BE16(current + 1);
|
m_map[current - 5] = current + 1;
|
||||||
current++;
|
current++;
|
||||||
}
|
}
|
||||||
m_map[current - 5] = 0xFFFF;
|
m_map[current - 5] = 0xFFFF;
|
||||||
|
|
Loading…
Reference in a new issue