From 21bd8a06e684af2272d78c71a30e073d1cfe6651 Mon Sep 17 00:00:00 2001 From: Adrian Conlon Date: Thu, 18 Jan 2018 17:50:15 +0000 Subject: [PATCH] Power on conditions are chip specific and *not* directly related to construction/destruction. Signed-off-by: Adrian Conlon --- M6502/inc/mos6502.h | 11 ++++++----- M6502/src/mos6502.cpp | 6 +++++- inc/Processor.h | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/M6502/inc/mos6502.h b/M6502/inc/mos6502.h index 20d4c44..21f9a5a 100644 --- a/M6502/inc/mos6502.h +++ b/M6502/inc/mos6502.h @@ -31,6 +31,7 @@ namespace EightBit { virtual int execute(uint8_t opcode) final; virtual int step() final; + virtual void powerOn() override; uint8_t& X() { return x; } uint8_t& Y() { return y; } @@ -316,11 +317,11 @@ namespace EightBit { const uint8_t RSTvector = 0xfc; const uint8_t NMIvector = 0xfa; - uint8_t x; // index register X - uint8_t y; // index register Y - uint8_t a; // accumulator - uint8_t s; // stack pointer - uint8_t p; // processor status + uint8_t x = 0; // index register X + uint8_t y = 0; // index register Y + uint8_t a = 0; // accumulator + uint8_t s = 0; // stack pointer + uint8_t p = 0; // processor status PinLevel m_soLine = Low; }; diff --git a/M6502/src/mos6502.cpp b/M6502/src/mos6502.cpp index f6ba620..57984e2 100644 --- a/M6502/src/mos6502.cpp +++ b/M6502/src/mos6502.cpp @@ -2,7 +2,9 @@ #include "mos6502.h" EightBit::MOS6502::MOS6502(Bus& bus) -: Processor(bus) { +: Processor(bus) {} + +void EightBit::MOS6502::powerOn() { X() = Bit7; Y() = 0; @@ -11,6 +13,8 @@ EightBit::MOS6502::MOS6502(Bus& bus) S() = Mask8; raise(SO()); + + Processor::powerOn(); } int EightBit::MOS6502::step() { diff --git a/inc/Processor.h b/inc/Processor.h index cc6859f..9449140 100644 --- a/inc/Processor.h +++ b/inc/Processor.h @@ -76,7 +76,7 @@ namespace EightBit { PinLevel& POWER() { return m_powerLine; } // In bool powered() { return raised(POWER()); } - void powerOn() { raise(POWER()); raise(HALT()); reset(); } + virtual void powerOn() { raise(POWER()); raise(HALT()); reset(); } void powerOff() { lower(POWER()); } int run(int limit);