mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2026-04-21 01:16:50 +00:00
Start incorporating CPP core guidelines (as an experiment!)
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
+74
@@ -0,0 +1,74 @@
|
||||
#include "stdafx.h"
|
||||
#include "Bus.h"
|
||||
|
||||
EightBit::register16_t& EightBit::Bus::ADDRESS() {
|
||||
return m_address;
|
||||
}
|
||||
|
||||
uint8_t& EightBit::Bus::DATA() {
|
||||
return *m_data;
|
||||
}
|
||||
|
||||
uint8_t& EightBit::Bus::placeDATA(uint8_t value) {
|
||||
m_temporary = value;
|
||||
m_data = &m_temporary;
|
||||
return DATA();
|
||||
}
|
||||
|
||||
uint8_t& EightBit::Bus::referenceDATA(uint8_t& value) {
|
||||
m_data = &value;
|
||||
return DATA();
|
||||
}
|
||||
|
||||
uint8_t EightBit::Bus::peek(uint16_t address) {
|
||||
bool rom;
|
||||
return reference(address, rom);
|
||||
}
|
||||
|
||||
void EightBit::Bus::poke(uint16_t address, uint8_t value) {
|
||||
bool rom;
|
||||
reference(address, rom) = value;
|
||||
}
|
||||
|
||||
uint16_t EightBit::Bus::peekWord(uint16_t address) {
|
||||
register16_t returned;
|
||||
returned.low = peek(address);
|
||||
returned.high = peek(address + 1);
|
||||
return returned.word;
|
||||
}
|
||||
|
||||
uint8_t EightBit::Bus::read() {
|
||||
ReadingByte.fire(ADDRESS().word);
|
||||
return reference();
|
||||
}
|
||||
|
||||
uint8_t EightBit::Bus::read(uint16_t offset) {
|
||||
ADDRESS().word = offset;
|
||||
return read();
|
||||
}
|
||||
|
||||
uint8_t EightBit::Bus::read(register16_t address) {
|
||||
ADDRESS() = address;
|
||||
return read();
|
||||
}
|
||||
|
||||
void EightBit::Bus::write(uint8_t value) {
|
||||
reference() = value;
|
||||
WrittenByte.fire(ADDRESS().word);
|
||||
}
|
||||
|
||||
void EightBit::Bus::write(uint16_t offset, uint8_t value) {
|
||||
ADDRESS().word = offset;
|
||||
write(value);
|
||||
}
|
||||
|
||||
void EightBit::Bus::write(register16_t address, uint8_t value) {
|
||||
ADDRESS() = address;
|
||||
write(value);
|
||||
}
|
||||
|
||||
uint8_t& EightBit::Bus::reference() {
|
||||
bool rom;
|
||||
auto& value = reference(ADDRESS().word, rom);
|
||||
return rom ? placeDATA(value) : referenceDATA(value);
|
||||
}
|
||||
@@ -152,6 +152,7 @@
|
||||
<ClInclude Include="stdafx.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Bus.cpp" />
|
||||
<ClCompile Include="EventArgs.cpp" />
|
||||
<ClCompile Include="InputOutput.cpp" />
|
||||
<ClCompile Include="IntelProcessor.cpp" />
|
||||
|
||||
@@ -67,5 +67,8 @@
|
||||
<ClCompile Include="InputOutput.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Bus.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
EightBit::IntelProcessor::IntelProcessor(Bus& bus)
|
||||
: Processor(bus) {
|
||||
SP().word = Mask16;
|
||||
}
|
||||
|
||||
void EightBit::IntelProcessor::initialise() {
|
||||
|
||||
+1
-5
@@ -2,11 +2,7 @@
|
||||
#include "Processor.h"
|
||||
|
||||
EightBit::Processor::Processor(Bus& bus)
|
||||
: m_bus(bus),
|
||||
m_cycles(0),
|
||||
m_halted(false),
|
||||
m_power(false) {
|
||||
PC().word = MEMPTR().word = 0;
|
||||
: m_bus(bus) {
|
||||
}
|
||||
|
||||
void EightBit::Processor::reset() {
|
||||
|
||||
Reference in New Issue
Block a user