| 253 | // |
| 254 | //***************************************************************************** |
| 255 | bool ROMFileCache::GetChunk( u32 rom_offset, u8 ** p_p_chunk_base, u32 * p_chunk_offset, u32 * p_chunk_size ) |
| 256 | { |
| 257 | u32 chunk_map_idx( AddressToChunkMapIndex( rom_offset ) ); |
| 258 | |
| 259 | if(chunk_map_idx < mChunkMapEntries) |
| 260 | { |
| 261 | CacheIdx idx( GetCacheIndex( rom_offset ) ); |
| 262 | #ifdef DAEDALUS_ENABLE_ASSERTS |
| 263 | DAEDALUS_ASSERT( idx < CACHE_SIZE, "Invalid chunk index!" ); |
| 264 | #endif |
| 265 | |
| 266 | const SChunkInfo & chunk_info( mpChunkInfo[ idx ] ); |
| 267 | |
| 268 | #ifdef DAEDALUS_ENABLE_ASSERTS |
| 269 | DAEDALUS_ASSERT( AddressToChunkMapIndex( chunk_info.StartOffset ) == chunk_map_idx, "Inconsistant map indices" ); |
| 270 | DAEDALUS_ASSERT( chunk_info.ContainsAddress( rom_offset ), "Address is out of range for chunk" ); |
| 271 | #endif |
| 272 | |
| 273 | u32 storage_offset( idx * CHUNK_SIZE ); |
| 274 | |
| 275 | *p_p_chunk_base = mpStorage + storage_offset; |
| 276 | *p_chunk_offset = chunk_info.StartOffset; |
| 277 | *p_chunk_size = CHUNK_SIZE; // XXXX if last chunk, adjust this? |
| 278 | |
| 279 | chunk_info.LastUseIdx = ++mMRUIdx; |
| 280 | return true; |
| 281 | } |
| 282 | else |
| 283 | { |
| 284 | // Invalid address, no chunk available |
| 285 | return false; |
| 286 | } |
| 287 | } |
no test coverage detected