GCMemcard: Use BigEndianValue for BlockAlloc.m_free_blocks.
This commit is contained in:
parent
88bdab6fe6
commit
d3b61c3ff0
|
@ -359,7 +359,7 @@ u16 GCMemcard::GetFreeBlocks() const
|
|||
if (!m_valid)
|
||||
return 0;
|
||||
|
||||
return BE16(CurrentBat->m_free_blocks);
|
||||
return CurrentBat->m_free_blocks;
|
||||
}
|
||||
|
||||
u8 GCMemcard::TitlePresent(const DEntry& d) const
|
||||
|
@ -593,7 +593,7 @@ u16 BlockAlloc::GetNextBlock(u16 Block) const
|
|||
// not BAT index; that is, block 5 is the first file data block.
|
||||
u16 BlockAlloc::NextFreeBlock(u16 MaxBlock, u16 StartingBlock) const
|
||||
{
|
||||
if (m_free_blocks)
|
||||
if (m_free_blocks > 0)
|
||||
{
|
||||
StartingBlock = MathUtil::Clamp<u16>(StartingBlock, MC_FST_BLOCKS, BAT_SIZE + MC_FST_BLOCKS);
|
||||
MaxBlock = MathUtil::Clamp<u16>(MaxBlock, MC_FST_BLOCKS, BAT_SIZE + MC_FST_BLOCKS);
|
||||
|
@ -625,7 +625,7 @@ bool BlockAlloc::ClearBlocks(u16 FirstBlock, u16 BlockCount)
|
|||
}
|
||||
for (unsigned int i = 0; i < length; ++i)
|
||||
m_map[blocks.at(i) - MC_FST_BLOCKS] = 0;
|
||||
m_free_blocks = BE16(BE16(m_free_blocks) + BlockCount);
|
||||
m_free_blocks = m_free_blocks + BlockCount;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -667,7 +667,7 @@ u32 GCMemcard::ImportFile(const DEntry& direntry, std::vector<GCMBlock>& saveBlo
|
|||
{
|
||||
return OUTOFDIRENTRIES;
|
||||
}
|
||||
if (BE16(CurrentBat->m_free_blocks) < direntry.m_block_count)
|
||||
if (CurrentBat->m_free_blocks < direntry.m_block_count)
|
||||
{
|
||||
return OUTOFBLOCKS;
|
||||
}
|
||||
|
@ -729,7 +729,7 @@ u32 GCMemcard::ImportFile(const DEntry& direntry, std::vector<GCMBlock>& saveBlo
|
|||
firstBlock = nextBlock;
|
||||
}
|
||||
|
||||
UpdatedBat.m_free_blocks = BE16(BE16(UpdatedBat.m_free_blocks) - fileBlocks);
|
||||
UpdatedBat.m_free_blocks = UpdatedBat.m_free_blocks - fileBlocks;
|
||||
UpdatedBat.m_update_counter = UpdatedBat.m_update_counter + 1;
|
||||
*PreviousBat = UpdatedBat;
|
||||
if (PreviousBat == &bat)
|
||||
|
|
|
@ -256,7 +256,7 @@ struct BlockAlloc
|
|||
u16 m_checksum; // 0x0000 2 Additive Checksum
|
||||
u16 m_checksum_inv; // 0x0002 2 Inverse Checksum
|
||||
Common::BigEndianValue<u16> m_update_counter; // 0x0004 2 Update Counter
|
||||
u16 m_free_blocks; // 0x0006 2 Free Blocks
|
||||
Common::BigEndianValue<u16> m_free_blocks; // 0x0006 2 Free Blocks
|
||||
u16 m_last_allocated_block; // 0x0008 2 Last allocated Block
|
||||
u16 m_map[BAT_SIZE]; // 0x000a 0x1ff8 Map of allocated Blocks
|
||||
u16 GetNextBlock(u16 Block) const;
|
||||
|
@ -269,14 +269,14 @@ struct BlockAlloc
|
|||
explicit BlockAlloc(u16 sizeMb = MemCard2043Mb)
|
||||
{
|
||||
memset(this, 0, BLOCK_SIZE);
|
||||
m_free_blocks = BE16((sizeMb * MBIT_TO_BLOCKS) - MC_FST_BLOCKS);
|
||||
m_free_blocks = (sizeMb * MBIT_TO_BLOCKS) - MC_FST_BLOCKS;
|
||||
m_last_allocated_block = BE16(4);
|
||||
fixChecksums();
|
||||
}
|
||||
u16 AssignBlocksContiguous(u16 length)
|
||||
{
|
||||
u16 starting = BE16(m_last_allocated_block) + 1;
|
||||
if (length > BE16(m_free_blocks))
|
||||
if (length > m_free_blocks)
|
||||
return 0xFFFF;
|
||||
u16 current = starting;
|
||||
while ((current - starting + 1) < length)
|
||||
|
@ -286,7 +286,7 @@ struct BlockAlloc
|
|||
}
|
||||
m_map[current - 5] = 0xFFFF;
|
||||
m_last_allocated_block = BE16(current);
|
||||
m_free_blocks = BE16(BE16(m_free_blocks) - length);
|
||||
m_free_blocks = m_free_blocks - length;
|
||||
fixChecksums();
|
||||
return starting;
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ int GCMemcardDirectory::LoadGCI(const std::string& file_name, bool current_game_
|
|||
return NO_INDEX;
|
||||
}
|
||||
int total_blocks = m_hdr.m_size_mb * MBIT_TO_BLOCKS - MC_FST_BLOCKS;
|
||||
int free_blocks = BE16(m_bat1.m_free_blocks);
|
||||
int free_blocks = m_bat1.m_free_blocks;
|
||||
if (total_blocks > free_blocks * 10)
|
||||
{
|
||||
PanicAlertT("%s\nwas not loaded because there is less than 10%% free blocks available on "
|
||||
|
|
Loading…
Reference in New Issue