mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2024-12-23 15:29:24 +00:00
Correct ROM loading issue discovered while resurrecting NES support.
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
parent
2a223a5acd
commit
722888ae66
@ -59,9 +59,16 @@ int EightBit::Rom::load(const std::string& path, const int writeOffset, const in
|
||||
}
|
||||
|
||||
int EightBit::Rom::load(const std::vector<uint8_t>& bytes, const int writeOffset, const int readOffset, int limit) {
|
||||
|
||||
if (limit < 0)
|
||||
limit = bytes.size() - readOffset;
|
||||
std::copy(bytes.cbegin() + readOffset, bytes.cbegin() + limit, m_bytes.begin() + writeOffset);
|
||||
|
||||
const size_t extent = limit + writeOffset;
|
||||
if (m_bytes.size() < extent)
|
||||
m_bytes.resize(extent);
|
||||
|
||||
std::copy(bytes.cbegin() + readOffset, bytes.cbegin() + readOffset + limit, m_bytes.begin() + writeOffset);
|
||||
|
||||
return limit;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user