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() {
fireReadingBusEvent();
ReadingByte.fire(ADDRESS().word);
auto content = reference();
fireReadBusEvent();
ReadByte.fire(ADDRESS().word);
return content;
}
@ -68,9 +68,9 @@ namespace EightBit {
}
void write(uint8_t value) {
fireWritingBusEvent();
WritingByte.fire(ADDRESS().word);
reference() = value;
fireWrittenBusEvent();
WrittenByte.fire(ADDRESS().word);
}
void write(uint16_t offset, uint8_t value) {
@ -84,22 +84,6 @@ namespace EightBit {
}
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;
uint8_t& reference() {

View File

@ -10,6 +10,8 @@ namespace EightBit {
: 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) {
const auto maximumSize = (int)m_bytes.size() - writeOffset;
return loadBinary(path, m_bytes, writeOffset, readOffset, limit, maximumSize);