Emu?
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

61 lines
1.4 KiB

/* PlipMemoryRom.cpp
*
* A read-only memory implementation.
*/
#include <cstring>
#include "PlipMemoryRom.h"
namespace Plip {
PlipMemoryRom::PlipMemoryRom(void *data, uint32_t length) {
m_length = length;
m_data = new uint8_t[m_length];
std::memcpy(m_data, data, m_length);
m_writtenData = new uint8_t[m_length];
}
PlipMemoryRom::~PlipMemoryRom() {
delete m_data;
delete m_writtenData;
}
uint8_t PlipMemoryRom::GetByte(uint32_t address, bool privileged) {
return m_readable || privileged ? m_data[address] : m_unprivileged;
}
bool PlipMemoryRom::GetReadable() const {
return m_readable;
}
uint8_t PlipMemoryRom::GetUnprivilegedValue() const {
return m_unprivileged;
}
bool PlipMemoryRom::GetWritable() const {
return false;
}
uint8_t PlipMemoryRom::GetWrittenByte(uint32_t address) {
return m_writtenData[address];
}
uint32_t PlipMemoryRom::GetLength() {
return m_length;
}
void PlipMemoryRom::SetByte(uint32_t address, uint8_t value, bool privileged) {
m_writtenData[address] = value;
}
void PlipMemoryRom::SetReadable(bool value) {
m_readable = value;
}
void PlipMemoryRom::SetUnprivilegedValue(uint8_t value) {
m_unprivileged = value;
}
void PlipMemoryRom::SetWritable(bool value) {}
}