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

This commit is contained in:
Admiral H. Curtiss 2018-11-19 00:27:31 +01:00
parent eb6cc3dbab
commit 4d4b5442bd
2 changed files with 6 additions and 4 deletions

View File

@ -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;
}

View File

@ -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;