Fire pre/post memory read/write events

Signed-off-by: Adrian.Conlon <adrian.conlon@gmail.com>
This commit is contained in:
Adrian.Conlon 2017-09-14 15:00:57 +01:00
parent a77e57e5fc
commit b445457b37
2 changed files with 6 additions and 20 deletions

View File

@ -51,9 +51,9 @@ namespace EightBit {
} }
uint8_t read() { uint8_t read() {
fireReadingBusEvent(); ReadingByte.fire(ADDRESS().word);
auto content = reference(); auto content = reference();
fireReadBusEvent(); ReadByte.fire(ADDRESS().word);
return content; return content;
} }
@ -68,9 +68,9 @@ namespace EightBit {
} }
void write(uint8_t value) { void write(uint8_t value) {
fireWritingBusEvent(); WritingByte.fire(ADDRESS().word);
reference() = value; reference() = value;
fireWrittenBusEvent(); WrittenByte.fire(ADDRESS().word);
} }
void write(uint16_t offset, uint8_t value) { void write(uint16_t offset, uint8_t value) {
@ -84,22 +84,6 @@ namespace EightBit {
} }
protected: protected:
void fireReadingBusEvent() {
ReadingByte.fire(ADDRESS().word);
}
void fireReadBusEvent() {
ReadByte.fire(ADDRESS().word);
}
void fireWritingBusEvent() {
WritingByte.fire(ADDRESS().word);
}
void fireWrittenBusEvent() {
WrittenByte.fire(ADDRESS().word);
}
virtual uint8_t& reference(uint16_t address, bool& rom) = 0; virtual uint8_t& reference(uint16_t address, bool& rom) = 0;
uint8_t& reference() { uint8_t& reference() {

View File

@ -10,6 +10,8 @@ namespace EightBit {
: m_bytes(size) { : m_bytes(size) {
} }
size_t size() const { return m_bytes.size(); }
int load(const std::string& path, int writeOffset = 0, int readOffset = 0, int limit = -1) { int load(const std::string& path, int writeOffset = 0, int readOffset = 0, int limit = -1) {
const auto maximumSize = (int)m_bytes.size() - writeOffset; const auto maximumSize = (int)m_bytes.size() - writeOffset;
return loadBinary(path, m_bytes, writeOffset, readOffset, limit, maximumSize); return loadBinary(path, m_bytes, writeOffset, readOffset, limit, maximumSize);