| 1 |
#include "EmptyPatch.hh" |
| 2 |
|
| 3 |
#include "ranges.hh" |
| 4 |
|
| 5 |
#include <algorithm> |
| 6 |
#include <cassert> |
| 7 |
|
| 8 |
namespace openmsx { |
| 9 |
|
| 10 |
void EmptyPatch::copyBlock(size_t src, std::span<uint8_t> dst) const |
| 11 |
{ |
| 12 |
auto size = block.size(); |
| 13 |
if ((src + dst.size()) > size) { |
| 14 |
|
| 15 |
if (size <= src) { |
| 16 |
|
| 17 |
std::ranges::fill(dst, 0); |
| 18 |
} else { |
| 19 |
auto part1 = size - src; |
| 20 |
auto part2 = dst.size() - part1; |
| 21 |
assert(dst.data() != &block[src]); |
| 22 |
copy_to_range(block.subspan(src, part1), dst); |
| 23 |
std::ranges::fill(dst.subspan(part1, part2), 0); |
| 24 |
} |
| 25 |
} else { |
| 26 |
if (dst.data() != &block[src]) { |
| 27 |
|
| 28 |
|
| 29 |
copy_to_range(block.subspan(src, dst.size()), dst); |
| 30 |
} |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
} |