uint16_t PICadillo35t::colorAt(int16_t x, int16_t y) { if((x < 0) ||(x >= _width) || (y < 0) || (y >= _height)) return 0; loadCacheBlock(x, y); int16_t xo = x & ((1 << PICadillo35t::cacheDimension) - 1); int16_t yo = y & ((1 << PICadillo35t::cacheDimension) - 1); uint32_t offset = yo * (1 << PICadillo35t::cacheDimension) + xo; return _cacheData[offset]; }
inline uint32_t FileLoader::getCacheBlock(uint32_t pos) { bool found = false; uint32_t i, base_pos = pos & ~(m_cache_size - 1); for(i = 0; i < CACHE_BLOCKS; ++i) { if(!m_cached_data[i].loaded || m_cached_data[i].base != base_pos) continue; found = true; break; } if(!found) i = loadCacheBlock(pos); return i; }
inline unsigned long FileLoader::getCacheBlock(unsigned long pos) { bool found = false; unsigned long i; unsigned long base_pos = pos & ~(m_cache_size - 1); for(i = 0; i < CACHE_BLOCKS; i++){ if(m_cached_data[i].loaded){ if(m_cached_data[i].base == base_pos){ found = true; break; } } } if(!found){ i = loadCacheBlock(pos); } return i; }
inline uint32_t FileLoader::getCacheBlock(uint32_t pos) { bool found = false; uint32_t i; uint32_t base_pos = pos & ~(m_cache_size - 1); for(i = 0; i < CACHE_BLOCKS; i++) { if(m_cached_data[i].loaded) { if(m_cached_data[i].base == base_pos) { found = true; break; } } } if(!found) i = loadCacheBlock(pos); return i; }