only bypass cache fill on write for nds. this is sub-optimal on wii/gc.

This commit is contained in:
tantricity 2010-11-17 18:44:13 +00:00
parent 639836914a
commit ba3622a4cd

View File

@ -264,7 +264,7 @@ bool _FAT_cache_eraseWritePartialSector (CACHE* cache, const void* buffer, sec_t
return true; return true;
} }
#ifndef GEKKO
static CACHE_ENTRY* _FAT_cache_findPage(CACHE *cache, sec_t sector, sec_t count) { static CACHE_ENTRY* _FAT_cache_findPage(CACHE *cache, sec_t sector, sec_t count) {
unsigned int i; unsigned int i;
@ -291,6 +291,7 @@ static CACHE_ENTRY* _FAT_cache_findPage(CACHE *cache, sec_t sector, sec_t count)
return entry; return entry;
} }
#endif
bool _FAT_cache_writeSectors (CACHE* cache, sec_t sector, sec_t numSectors, const void* buffer) bool _FAT_cache_writeSectors (CACHE* cache, sec_t sector, sec_t numSectors, const void* buffer)
{ {
@ -301,12 +302,16 @@ bool _FAT_cache_writeSectors (CACHE* cache, sec_t sector, sec_t numSectors, cons
while(numSectors>0) while(numSectors>0)
{ {
#ifdef GEKKO
entry = _FAT_cache_getPage(cache,sector);
if(entry==NULL) return false;
#else
entry = _FAT_cache_findPage(cache,sector,numSectors); entry = _FAT_cache_findPage(cache,sector,numSectors);
if(entry!=NULL) { if(entry==NULL)
return _FAT_disc_writeSectors(cache->disc,sector,numSectors,src);
if ( entry->sector > sector) { if ( entry->sector > sector) {
secs_to_write = entry->sector - sector; secs_to_write = entry->sector - sector;
_FAT_disc_writeSectors(cache->disc,sector,secs_to_write,src); _FAT_disc_writeSectors(cache->disc,sector,secs_to_write,src);
@ -314,10 +319,9 @@ bool _FAT_cache_writeSectors (CACHE* cache, sec_t sector, sec_t numSectors, cons
sector += secs_to_write; sector += secs_to_write;
numSectors -= secs_to_write; numSectors -= secs_to_write;
} }
#endif
sec = sector - entry->sector; sec = sector - entry->sector;
secs_to_write = entry->count - sec; secs_to_write = entry->count - sec;
if(secs_to_write>numSectors) secs_to_write = numSectors; if(secs_to_write>numSectors) secs_to_write = numSectors;
memcpy(entry->cache + (sec*BYTES_PER_READ),src,(secs_to_write*BYTES_PER_READ)); memcpy(entry->cache + (sec*BYTES_PER_READ),src,(secs_to_write*BYTES_PER_READ));
@ -327,11 +331,6 @@ bool _FAT_cache_writeSectors (CACHE* cache, sec_t sector, sec_t numSectors, cons
numSectors -= secs_to_write; numSectors -= secs_to_write;
entry->dirty = true; entry->dirty = true;
} else {
_FAT_disc_writeSectors(cache->disc,sector,numSectors,src);
numSectors=0;
}
} }
return true; return true;
} }