From 4d4b5442bd2ecfaab2dad22be315fdf236dcbf9e Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Mon, 19 Nov 2018 00:27:31 +0100 Subject: [PATCH] GCMemcard: Use std::array and BigEndianValue for BlockAlloc.m_map. --- Source/Core/Core/HW/GCMemcard/GCMemcard.cpp | 4 ++-- Source/Core/Core/HW/GCMemcard/GCMemcard.h | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Source/Core/Core/HW/GCMemcard/GCMemcard.cpp b/Source/Core/Core/HW/GCMemcard/GCMemcard.cpp index a88bf9ad12..99a87e68bd 100644 --- a/Source/Core/Core/HW/GCMemcard/GCMemcard.cpp +++ b/Source/Core/Core/HW/GCMemcard/GCMemcard.cpp @@ -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& 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; } diff --git a/Source/Core/Core/HW/GCMemcard/GCMemcard.h b/Source/Core/Core/HW/GCMemcard/GCMemcard.h index 026e3a43e6..d23d1001bc 100644 --- a/Source/Core/Core/HW/GCMemcard/GCMemcard.h +++ b/Source/Core/Core/HW/GCMemcard/GCMemcard.h @@ -258,7 +258,9 @@ struct BlockAlloc Common::BigEndianValue m_update_counter; // 0x0004 2 Update Counter Common::BigEndianValue m_free_blocks; // 0x0006 2 Free Blocks Common::BigEndianValue m_last_allocated_block; // 0x0008 2 Last allocated Block - u16 m_map[BAT_SIZE]; // 0x000a 0x1ff8 Map of allocated Blocks + std::array, 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;