Ian Burgmyer
4 years ago
5 changed files with 98 additions and 30 deletions
@ -0,0 +1,29 @@
|
||||
/* 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); |
||||
} |
||||
|
||||
PlipMemoryRom::~PlipMemoryRom() { |
||||
delete m_data; |
||||
} |
||||
|
||||
uint8_t PlipMemoryRom::GetByte(uint32_t address) { |
||||
return m_data[address]; |
||||
} |
||||
|
||||
uint32_t PlipMemoryRom::GetLength() { |
||||
return m_length; |
||||
} |
||||
} |
@ -0,0 +1,24 @@
|
||||
/* PlipMemoryRom.h
|
||||
* |
||||
* A read-only memory implementation. |
||||
*/ |
||||
|
||||
#pragma once |
||||
|
||||
#include "PlipMemory.h" |
||||
|
||||
namespace Plip { |
||||
class PlipMemoryRom : public PlipMemory { |
||||
public: |
||||
explicit PlipMemoryRom(void *data, uint32_t length); |
||||
~PlipMemoryRom(); |
||||
|
||||
uint8_t GetByte(uint32_t address) override; |
||||
uint32_t GetLength() override; |
||||
void SetByte(uint32_t address, uint8_t value) override {}; |
||||
|
||||
private: |
||||
uint32_t m_length; |
||||
uint8_t *m_data; |
||||
}; |
||||
} |
Loading…
Reference in new issue