#ifndef __ALE_RAM_HPP__
#define __ALE_RAM_HPP__
#include <cstring>
namespace ale {
using byte_t = unsigned char;
#define RAM_SIZE (128)
class ALERAM {
public:
ALERAM();
ALERAM(const ALERAM& rhs);
ALERAM& operator=(const ALERAM& rhs);
byte_t get(unsigned int x) const;
byte_t* byte(unsigned int x);
byte_t* array() const { return (byte_t*)(m_ram); }
size_t size() const { return sizeof(m_ram); }
bool equals(const ALERAM& rhs) const;
protected:
byte_t m_ram[RAM_SIZE];
};
inline ALERAM::ALERAM() {}
inline ALERAM::ALERAM(const ALERAM& rhs) {
memcpy(m_ram, rhs.m_ram, sizeof(m_ram));
}
inline ALERAM& ALERAM::operator=(const ALERAM& rhs) {
memcpy(m_ram, rhs.m_ram, sizeof(m_ram));
return *this;
}
inline bool ALERAM::equals(const ALERAM& rhs) const {
return (memcmp(m_ram, rhs.m_ram, size()) == 0);
}
inline byte_t ALERAM::get(unsigned int x) const {
return m_ram[x & 0x7F];
}
inline byte_t* ALERAM::byte(unsigned int x) { return &m_ram[x & 0x7F]; }
}
#endif