Ian Burgmyer
4 years ago
5 changed files with 62 additions and 2 deletions
@ -0,0 +1,29 @@
|
||||
/* PlipMemoryRam.cpp
|
||||
* |
||||
* A random access memory implementation. |
||||
*/ |
||||
|
||||
#include "PlipMemoryRam.h" |
||||
|
||||
namespace Plip { |
||||
PlipMemoryRam::PlipMemoryRam(uint32_t amount) { |
||||
m_data = new uint8_t[amount] {}; |
||||
m_length = amount; |
||||
} |
||||
|
||||
PlipMemoryRam::~PlipMemoryRam() { |
||||
delete m_data; |
||||
} |
||||
|
||||
uint8_t PlipMemoryRam::GetByte(uint32_t address) { |
||||
return m_data[address]; |
||||
} |
||||
|
||||
uint32_t PlipMemoryRam::GetLength() { |
||||
return m_length; |
||||
} |
||||
|
||||
void PlipMemoryRam::SetByte(uint32_t address, uint8_t value) { |
||||
m_data[address] = value; |
||||
} |
||||
} |
@ -0,0 +1,24 @@
|
||||
/* PlipMemoryRam.h
|
||||
* |
||||
* A random access memory implementation. |
||||
*/ |
||||
|
||||
#pragma once |
||||
|
||||
#include "PlipMemory.h" |
||||
|
||||
namespace Plip { |
||||
class PlipMemoryRam : public PlipMemory { |
||||
public: |
||||
explicit PlipMemoryRam(uint32_t amount); |
||||
~PlipMemoryRam(); |
||||
|
||||
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