MCPcopy Create free account
hub / github.com/DaedalusX64/daedalus / CopyToRam

Method CopyToRam

Source/Core/ROMBuffer.cpp:445–487  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

443//
444//*****************************************************************************
445void RomBuffer::CopyToRam( u8 * p_dst, u32 dst_offset, u32 dst_size, u32 src_offset, u32 length )
446{
447 if( sRomFixed )
448 {
449 const u8 * p_src( (const u8 *)spRomData );
450 u32 src_size( sRomSize );
451
452 DMA_HandleTransfer( p_dst, dst_offset, dst_size, p_src, src_offset, src_size, length );
453 }
454 else
455 {
456 while(length > 0)
457 {
458 u8 * p_chunk_base {};
459 u32 chunk_offset {};
460 u32 chunk_size {};
461
462 if( !spRomFileCache->GetChunk( src_offset, &p_chunk_base, &chunk_offset, &chunk_size ) )
463 {
464 // Out of range
465 break;
466 }
467
468 // Calculate how many bytes we can transfer this pass
469 u32 offset_into_chunk( src_offset - chunk_offset );
470 u32 bytes_remaining_in_chunk( chunk_size - offset_into_chunk );
471 u32 bytes_this_pass( Min( length, bytes_remaining_in_chunk ) );
472 #ifdef DAEDALUS_ENABLE_ASSERTS
473 DAEDALUS_ASSERT( s32( bytes_this_pass ) > 0, "How come we're trying to copy <= 0 bytes across?" );
474 #endif
475 // Copy this chunk across
476 if( !DMA_HandleTransfer( p_dst, dst_offset, dst_size, p_chunk_base, offset_into_chunk, chunk_size, bytes_this_pass ) )
477 {
478 break;
479 }
480
481 // Update the src/dst pointers and reduce length by the number of copied bytes
482 dst_offset += bytes_this_pass;
483 src_offset += bytes_this_pass;
484 length -= bytes_this_pass;
485 }
486 }
487}
488
489//*****************************************************************************
490//

Callers

nothing calls this directly

Calls 2

DMA_HandleTransferFunction · 0.85
GetChunkMethod · 0.80

Tested by

no test coverage detected