2017-11-10 22:41:50 +00:00
|
|
|
#include "stdafx.h"
|
|
|
|
#include "Bus.h"
|
|
|
|
|
2017-11-20 19:17:49 +00:00
|
|
|
#include "EightBitCompilerDefinitions.h"
|
|
|
|
|
2018-06-09 23:40:56 +00:00
|
|
|
uint8_t EightBit::Bus::peek(const uint16_t address) const {
|
2017-11-10 22:41:50 +00:00
|
|
|
bool rom;
|
|
|
|
return reference(address, rom);
|
|
|
|
}
|
|
|
|
|
2018-04-14 08:39:06 +00:00
|
|
|
void EightBit::Bus::poke(const uint16_t address, const uint8_t value) {
|
2017-11-10 22:41:50 +00:00
|
|
|
bool rom;
|
|
|
|
reference(address, rom) = value;
|
|
|
|
}
|
|
|
|
|
2018-06-09 23:40:56 +00:00
|
|
|
uint16_t EightBit::Bus::peekWord(const uint16_t address) const {
|
2017-11-10 22:41:50 +00:00
|
|
|
register16_t returned;
|
|
|
|
returned.low = peek(address);
|
|
|
|
returned.high = peek(address + 1);
|
|
|
|
return returned.word;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t EightBit::Bus::read() {
|
|
|
|
ReadingByte.fire(ADDRESS().word);
|
2018-06-09 23:40:56 +00:00
|
|
|
DATA() = reference();
|
2018-02-07 23:00:38 +00:00
|
|
|
ReadByte.fire(ADDRESS().word);
|
2018-06-09 23:40:56 +00:00
|
|
|
return DATA();
|
2017-11-10 22:41:50 +00:00
|
|
|
}
|
|
|
|
|
2018-04-14 08:39:06 +00:00
|
|
|
uint8_t EightBit::Bus::read(const uint16_t offset) {
|
2017-11-10 22:41:50 +00:00
|
|
|
ADDRESS().word = offset;
|
|
|
|
return read();
|
|
|
|
}
|
|
|
|
|
2018-04-14 08:39:06 +00:00
|
|
|
uint8_t EightBit::Bus::read(const register16_t address) {
|
2017-11-10 22:41:50 +00:00
|
|
|
ADDRESS() = address;
|
|
|
|
return read();
|
|
|
|
}
|
|
|
|
|
2018-06-09 23:40:56 +00:00
|
|
|
void EightBit::Bus::write() {
|
2018-02-07 23:00:38 +00:00
|
|
|
WritingByte.fire(ADDRESS().word);
|
2018-06-09 23:40:56 +00:00
|
|
|
reference() = DATA();
|
2017-11-10 22:41:50 +00:00
|
|
|
WrittenByte.fire(ADDRESS().word);
|
|
|
|
}
|
|
|
|
|
2018-06-09 23:40:56 +00:00
|
|
|
void EightBit::Bus::write(const uint8_t value) {
|
|
|
|
DATA() = value;
|
|
|
|
write();
|
|
|
|
}
|
|
|
|
|
2018-04-14 08:39:06 +00:00
|
|
|
void EightBit::Bus::write(const uint16_t offset, const uint8_t value) {
|
2017-11-10 22:41:50 +00:00
|
|
|
ADDRESS().word = offset;
|
|
|
|
write(value);
|
|
|
|
}
|
|
|
|
|
2018-04-14 08:39:06 +00:00
|
|
|
void EightBit::Bus::write(const register16_t address, const uint8_t value) {
|
2017-11-10 22:41:50 +00:00
|
|
|
ADDRESS() = address;
|
|
|
|
write(value);
|
|
|
|
}
|
|
|
|
|
2018-06-09 23:40:56 +00:00
|
|
|
uint8_t EightBit::Bus::reference() const {
|
|
|
|
bool rom;
|
|
|
|
return reference(ADDRESS().word, rom);
|
|
|
|
}
|
|
|
|
|
2017-11-10 22:41:50 +00:00
|
|
|
uint8_t& EightBit::Bus::reference() {
|
|
|
|
bool rom;
|
2018-06-09 23:40:56 +00:00
|
|
|
return reference(ADDRESS().word, rom);
|
2017-11-30 23:21:48 +00:00
|
|
|
}
|