From ba3622a4cd8cca68e0f3970dcb5cf2e10f257b1c Mon Sep 17 00:00:00 2001 From: tantricity Date: Wed, 17 Nov 2010 18:44:13 +0000 Subject: [PATCH] only bypass cache fill on write for nds. this is sub-optimal on wii/gc. --- source/cache.c | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/source/cache.c b/source/cache.c index 8429299..2b12b70 100644 --- a/source/cache.c +++ b/source/cache.c @@ -264,7 +264,7 @@ bool _FAT_cache_eraseWritePartialSector (CACHE* cache, const void* buffer, sec_t return true; } - +#ifndef GEKKO static CACHE_ENTRY* _FAT_cache_findPage(CACHE *cache, sec_t sector, sec_t count) { unsigned int i; @@ -291,6 +291,7 @@ static CACHE_ENTRY* _FAT_cache_findPage(CACHE *cache, sec_t sector, sec_t count) return entry; } +#endif bool _FAT_cache_writeSectors (CACHE* cache, sec_t sector, sec_t numSectors, const void* buffer) { @@ -301,37 +302,35 @@ bool _FAT_cache_writeSectors (CACHE* cache, sec_t sector, sec_t numSectors, cons while(numSectors>0) { +#ifdef GEKKO + entry = _FAT_cache_getPage(cache,sector); + if(entry==NULL) return false; +#else 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); - src += (secs_to_write*BYTES_PER_READ); - sector += secs_to_write; - numSectors -= secs_to_write; - } - - sec = sector - entry->sector; - secs_to_write = entry->count - sec; - - if(secs_to_write>numSectors) secs_to_write = numSectors; - - memcpy(entry->cache + (sec*BYTES_PER_READ),src,(secs_to_write*BYTES_PER_READ)); - + _FAT_disc_writeSectors(cache->disc,sector,secs_to_write,src); src += (secs_to_write*BYTES_PER_READ); sector += secs_to_write; numSectors -= secs_to_write; - - entry->dirty = true; - - } else { - _FAT_disc_writeSectors(cache->disc,sector,numSectors,src); - numSectors=0; } +#endif + sec = sector - entry->sector; + secs_to_write = entry->count - sec; + if(secs_to_write>numSectors) secs_to_write = numSectors; + + memcpy(entry->cache + (sec*BYTES_PER_READ),src,(secs_to_write*BYTES_PER_READ)); + + src += (secs_to_write*BYTES_PER_READ); + sector += secs_to_write; + numSectors -= secs_to_write; + + entry->dirty = true; } return true; }