Small simplifications to base Processor class.

Signed-off-by: Adrian.Conlon <adrian.conlon@gmail.com>
This commit is contained in:
Adrian.Conlon 2017-06-10 12:42:55 +01:00
parent 49d7a4c169
commit b1aa523dcc
3 changed files with 9 additions and 13 deletions

View File

@ -1,11 +1,8 @@
#pragma once
#include <cstdint>
#include <array>
#include <functional>
#include "Memory.h"
#include "Signal.h"
namespace EightBit {
class Processor {
@ -81,8 +78,7 @@ namespace EightBit {
void popWord(register16_t& output);
uint8_t fetchByte() {
m_memory.ADDRESS() = pc;
pc.word++;
m_memory.ADDRESS().word = pc.word++;
return m_memory.reference();
}

View File

@ -7,7 +7,9 @@
#include <algorithm>
EightBit::Memory::Memory(uint16_t addressMask)
: m_addressMask(addressMask) {
: m_addressMask(addressMask),
m_temporary(0) {
clear();
m_address.word = 0;
m_data = &(m_bus[m_address.word]);
}

View File

@ -2,9 +2,9 @@
#include "Processor.h"
EightBit::Processor::Processor(Memory& memory)
: m_memory(memory),
cycles(0),
m_halted(false) {
: m_memory(memory),
cycles(0),
m_halted(false) {
sp.word = 0xffff;
pc.word = 0;
}
@ -19,8 +19,7 @@ void EightBit::Processor::initialise() {
}
void EightBit::Processor::push(uint8_t value) {
sp.word--;
m_memory.ADDRESS() = sp;
m_memory.ADDRESS().word = --sp.word;
m_memory.reference() = value;
}
@ -30,8 +29,7 @@ void EightBit::Processor::pushWord(register16_t value) {
}
uint8_t EightBit::Processor::pop() {
m_memory.ADDRESS() = sp;
sp.word++;
m_memory.ADDRESS().word = sp.word++;
return m_memory.reference();
}