GCMemcard: Const-correctness changes

A few function reference and pointer parameters are only read from.
This commit is contained in:
Lioncash 2017-01-12 19:44:36 -05:00
parent 5790f15be8
commit 0035a4ef3d
6 changed files with 18 additions and 18 deletions

View File

@ -250,7 +250,7 @@ bool GCMemcard::Save()
return mcdFile.Close();
}
void calc_checksumsBE(u16* buf, u32 length, u16* csum, u16* inv_csum)
void calc_checksumsBE(const u16* buf, u32 length, u16* csum, u16* inv_csum)
{
*csum = *inv_csum = 0;
@ -639,7 +639,7 @@ u32 GCMemcard::GetSaveData(u8 index, std::vector<GCMBlock>& Blocks) const
}
// End DEntry functions
u32 GCMemcard::ImportFile(DEntry& direntry, std::vector<GCMBlock>& saveBlocks)
u32 GCMemcard::ImportFile(const DEntry& direntry, std::vector<GCMBlock>& saveBlocks)
{
if (!m_valid)
return NOMEMCARD;
@ -1271,7 +1271,7 @@ bool GCMemcard::Format(bool shift_jis, u16 SizeMb)
/* Returns: Error code */
/*************************************************************/
s32 GCMemcard::FZEROGX_MakeSaveGameValid(Header& cardheader, DEntry& direntry,
s32 GCMemcard::FZEROGX_MakeSaveGameValid(const Header& cardheader, const DEntry& direntry,
std::vector<GCMBlock>& FileBuffer)
{
u32 i, j;
@ -1280,7 +1280,7 @@ s32 GCMemcard::FZEROGX_MakeSaveGameValid(Header& cardheader, DEntry& direntry,
int block = 0;
// check for F-Zero GX system file
if (strcmp((char*)direntry.Filename, "f_zero.dat") != 0)
if (strcmp(reinterpret_cast<const char*>(direntry.Filename), "f_zero.dat") != 0)
return 0;
// get encrypted destination memory card serial numbers
@ -1324,7 +1324,7 @@ s32 GCMemcard::FZEROGX_MakeSaveGameValid(Header& cardheader, DEntry& direntry,
/* Returns: Error code */
/***********************************************************/
s32 GCMemcard::PSO_MakeSaveGameValid(Header& cardheader, DEntry& direntry,
s32 GCMemcard::PSO_MakeSaveGameValid(const Header& cardheader, const DEntry& direntry,
std::vector<GCMBlock>& FileBuffer)
{
u32 i, j;
@ -1334,10 +1334,10 @@ s32 GCMemcard::PSO_MakeSaveGameValid(Header& cardheader, DEntry& direntry,
u32 pso3offset = 0x00;
// check for PSO1&2 system file
if (strcmp((char*)direntry.Filename, "PSO_SYSTEM") != 0)
if (strcmp(reinterpret_cast<const char*>(direntry.Filename), "PSO_SYSTEM") != 0)
{
// check for PSO3 system file
if (strcmp((char*)direntry.Filename, "PSO3_SYSTEM") == 0)
if (strcmp(reinterpret_cast<const char*>(direntry.Filename), "PSO3_SYSTEM") == 0)
{
// PSO3 data block size adjustment
pso3offset = 0x10;

View File

@ -76,7 +76,7 @@ public:
}
virtual ~MemoryCardBase() {}
virtual s32 Read(u32 address, s32 length, u8* destaddress) = 0;
virtual s32 Write(u32 destaddress, s32 length, u8* srcaddress) = 0;
virtual s32 Write(u32 destaddress, s32 length, const u8* srcaddress) = 0;
virtual void ClearBlock(u32 address) = 0;
virtual void ClearAll() = 0;
virtual void DoState(PointerWrap& p) = 0;
@ -95,7 +95,7 @@ struct GCMBlock
u8 block[BLOCK_SIZE];
};
void calc_checksumsBE(u16* buf, u32 length, u16* csum, u16* inv_csum);
void calc_checksumsBE(const u16* buf, u32 length, u16* csum, u16* inv_csum);
#pragma pack(push, 1)
struct Header // Offset Size Description
@ -321,9 +321,9 @@ public:
bool Save();
bool Format(bool shift_jis = false, u16 SizeMb = MemCard2043Mb);
static bool Format(u8* card_data, bool shift_jis = false, u16 SizeMb = MemCard2043Mb);
static s32 FZEROGX_MakeSaveGameValid(Header& cardheader, DEntry& direntry,
static s32 FZEROGX_MakeSaveGameValid(const Header& cardheader, const DEntry& direntry,
std::vector<GCMBlock>& FileBuffer);
static s32 PSO_MakeSaveGameValid(Header& cardheader, DEntry& direntry,
static s32 PSO_MakeSaveGameValid(const Header& cardheader, const DEntry& direntry,
std::vector<GCMBlock>& FileBuffer);
u32 TestChecksums() const;
@ -364,7 +364,7 @@ public:
u32 GetSaveData(u8 index, std::vector<GCMBlock>& saveBlocks) const;
// adds the file to the directory and copies its contents
u32 ImportFile(DEntry& direntry, std::vector<GCMBlock>& saveBlocks);
u32 ImportFile(const DEntry& direntry, std::vector<GCMBlock>& saveBlocks);
// delete a file from the directory
u32 RemoveFile(u8 index);

View File

@ -270,7 +270,7 @@ s32 GCMemcardDirectory::Read(u32 address, s32 length, u8* destaddress)
return length + extra;
}
s32 GCMemcardDirectory::Write(u32 destaddress, s32 length, u8* srcaddress)
s32 GCMemcardDirectory::Write(u32 destaddress, s32 length, const u8* srcaddress)
{
std::unique_lock<std::mutex> l(m_write_mutex);
if (length != 0x80)
@ -475,7 +475,7 @@ inline s32 GCMemcardDirectory::SaveAreaRW(u32 block, bool writing)
return -1;
}
s32 GCMemcardDirectory::DirectoryWrite(u32 destaddress, u32 length, u8* srcaddress)
s32 GCMemcardDirectory::DirectoryWrite(u32 destaddress, u32 length, const u8* srcaddress)
{
u32 block = destaddress / BLOCK_SIZE;
u32 offset = destaddress % BLOCK_SIZE;

View File

@ -28,7 +28,7 @@ public:
void FlushToFile();
void FlushThread();
s32 Read(u32 address, s32 length, u8* destaddress) override;
s32 Write(u32 destaddress, s32 length, u8* srcaddress) override;
s32 Write(u32 destaddress, s32 length, const u8* srcaddress) override;
void ClearBlock(u32 address) override;
void ClearAll() override {}
void DoState(PointerWrap& p) override;
@ -37,7 +37,7 @@ private:
int LoadGCI(const std::string& fileName, DiscIO::Region card_region, bool currentGameOnly);
inline s32 SaveAreaRW(u32 block, bool writing = false);
// s32 DirectoryRead(u32 offset, u32 length, u8* destaddress);
s32 DirectoryWrite(u32 destaddress, u32 length, u8* srcaddress);
s32 DirectoryWrite(u32 destaddress, u32 length, const u8* srcaddress);
inline void SyncSaves();
bool SetUsedBlocks(int saveIndex);

View File

@ -157,7 +157,7 @@ s32 MemoryCard::Read(u32 srcaddress, s32 length, u8* destaddress)
return length;
}
s32 MemoryCard::Write(u32 destaddress, s32 length, u8* srcaddress)
s32 MemoryCard::Write(u32 destaddress, s32 length, const u8* srcaddress)
{
if (!IsAddressInBounds(destaddress))
{

View File

@ -23,7 +23,7 @@ public:
void MakeDirty();
s32 Read(u32 address, s32 length, u8* destaddress) override;
s32 Write(u32 destaddress, s32 length, u8* srcaddress) override;
s32 Write(u32 destaddress, s32 length, const u8* srcaddress) override;
void ClearBlock(u32 address) override;
void ClearAll() override;
void DoState(PointerWrap& p) override;