mirror of https://github.com/PCSX2/pcsx2.git
FolderMemoryCard: Fix a bug where the cache wouldn't be populated properly on first write to any given page.
I'm kinda surprised this didn't horribly break things, honestly. I guess it's because memory card data is always written in blocks, but still.
This commit is contained in:
parent
8e92d25b75
commit
3a55360572
|
@ -729,14 +729,7 @@ s32 FolderMemoryCard::Read( u8 *dest, u32 adr, int size ) {
|
||||||
if ( it != m_cache.end() ) {
|
if ( it != m_cache.end() ) {
|
||||||
memcpy( dest, &it->second.raw[offset], dataLength );
|
memcpy( dest, &it->second.raw[offset], dataLength );
|
||||||
} else {
|
} else {
|
||||||
u8* src = GetSystemBlockPointer( adr );
|
ReadDataWithoutCache( dest, adr, dataLength );
|
||||||
if ( src != nullptr ) {
|
|
||||||
memcpy( dest, src, dataLength );
|
|
||||||
} else {
|
|
||||||
if ( !ReadFromFile( dest, adr, dataLength ) ) {
|
|
||||||
memset( dest, 0xFF, dataLength );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -765,6 +758,17 @@ s32 FolderMemoryCard::Read( u8 *dest, u32 adr, int size ) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FolderMemoryCard::ReadDataWithoutCache( u8* const dest, const u32 adr, const u32 dataLength ) {
|
||||||
|
u8* src = GetSystemBlockPointer( adr );
|
||||||
|
if ( src != nullptr ) {
|
||||||
|
memcpy( dest, src, dataLength );
|
||||||
|
} else {
|
||||||
|
if ( !ReadFromFile( dest, adr, dataLength ) ) {
|
||||||
|
memset( dest, 0xFF, dataLength );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
s32 FolderMemoryCard::Save( const u8 *src, u32 adr, int size ) {
|
s32 FolderMemoryCard::Save( const u8 *src, u32 adr, int size ) {
|
||||||
const u32 block = adr / BlockSizeRaw;
|
const u32 block = adr / BlockSizeRaw;
|
||||||
const u32 cluster = adr / ClusterSizeRaw;
|
const u32 cluster = adr / ClusterSizeRaw;
|
||||||
|
@ -790,7 +794,7 @@ s32 FolderMemoryCard::Save( const u8 *src, u32 adr, int size ) {
|
||||||
if ( it == m_cache.end() ) {
|
if ( it == m_cache.end() ) {
|
||||||
cachePage = &m_cache[page];
|
cachePage = &m_cache[page];
|
||||||
const u32 adrLoad = page * PageSizeRaw;
|
const u32 adrLoad = page * PageSizeRaw;
|
||||||
Read( &cachePage->raw[0], adrLoad, PageSize );
|
ReadDataWithoutCache( &cachePage->raw[0], adrLoad, PageSize );
|
||||||
} else {
|
} else {
|
||||||
cachePage = &it->second;
|
cachePage = &it->second;
|
||||||
}
|
}
|
||||||
|
|
|
@ -402,6 +402,11 @@ protected:
|
||||||
// creates a reference to a directory entry, so it can be passed as parent to other files/directories
|
// creates a reference to a directory entry, so it can be passed as parent to other files/directories
|
||||||
MemoryCardFileMetadataReference* AddDirEntryToMetadataQuickAccess( MemoryCardFileEntry* const entry, MemoryCardFileMetadataReference* const parent );
|
MemoryCardFileMetadataReference* AddDirEntryToMetadataQuickAccess( MemoryCardFileEntry* const entry, MemoryCardFileMetadataReference* const parent );
|
||||||
|
|
||||||
|
|
||||||
|
// read data from the memory card, ignoring the cache
|
||||||
|
// do NOT attempt to read ECC with this method, it will not work
|
||||||
|
void ReadDataWithoutCache( u8* const dest, const u32 adr, const u32 dataLength );
|
||||||
|
|
||||||
|
|
||||||
bool ReadFromFile( u8 *dest, u32 adr, u32 dataLength );
|
bool ReadFromFile( u8 *dest, u32 adr, u32 dataLength );
|
||||||
bool WriteToFile( const u8* src, u32 adr, u32 dataLength );
|
bool WriteToFile( const u8* src, u32 adr, u32 dataLength );
|
||||||
|
|
Loading…
Reference in New Issue