From b971e2a42c36787507e92ed935cc5c4695ac82d4 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 29 Feb 2020 19:58:25 -0500 Subject: [PATCH] Adds get_is_resetting to the Z80, eliminating the CPC's custom version. --- Machines/AmstradCPC/AmstradCPC.cpp | 3 +-- Processors/6502/Implementation/6502Implementation.hpp | 2 +- Processors/Z80/Implementation/Z80Storage.cpp | 4 ++++ Processors/Z80/Z80.hpp | 7 +++++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Machines/AmstradCPC/AmstradCPC.cpp b/Machines/AmstradCPC/AmstradCPC.cpp index 243aef88c..71e659ab3 100644 --- a/Machines/AmstradCPC/AmstradCPC.cpp +++ b/Machines/AmstradCPC/AmstradCPC.cpp @@ -1052,7 +1052,6 @@ template class ConcreteMachine: /// Wires virtual-dispatched CRTMachine run_for requests to the static Z80 method. void run_for(const Cycles cycles) final { - has_run_ = true; z80_.run_for(cycles); } @@ -1088,7 +1087,7 @@ template class ConcreteMachine: } HalfCycles get_typer_delay() final { - return has_run_ ? Cycles(0) : Cycles(3'400'000); + return z80_.get_is_resetting() ? Cycles(3'400'000) : Cycles(0); } HalfCycles get_typer_frequency() final { diff --git a/Processors/6502/Implementation/6502Implementation.hpp b/Processors/6502/Implementation/6502Implementation.hpp index c32f544e2..be8c07d66 100644 --- a/Processors/6502/Implementation/6502Implementation.hpp +++ b/Processors/6502/Implementation/6502Implementation.hpp @@ -705,7 +705,7 @@ void ProcessorBase::set_reset_line(bool active) { } bool ProcessorBase::get_is_resetting() { - return !!(interrupt_requests_ & (InterruptRequestFlags::Reset | InterruptRequestFlags::PowerOn)); + return interrupt_requests_ & (InterruptRequestFlags::Reset | InterruptRequestFlags::PowerOn); } void ProcessorBase::set_power_on(bool active) { diff --git a/Processors/Z80/Implementation/Z80Storage.cpp b/Processors/Z80/Implementation/Z80Storage.cpp index 66c13cb62..14bb76de8 100644 --- a/Processors/Z80/Implementation/Z80Storage.cpp +++ b/Processors/Z80/Implementation/Z80Storage.cpp @@ -550,3 +550,7 @@ bool ProcessorBase::is_starting_new_instruction() { current_instruction_page_ == &base_page_ && scheduled_program_counter_ == &base_page_.fetch_decode_execute[0]; } + +bool ProcessorBase::get_is_resetting() { + return request_status_ & (Interrupt::PowerOn | Interrupt::Reset); +} diff --git a/Processors/Z80/Z80.hpp b/Processors/Z80/Z80.hpp index d0ee4a1a9..718ebea27 100644 --- a/Processors/Z80/Z80.hpp +++ b/Processors/Z80/Z80.hpp @@ -219,6 +219,13 @@ class ProcessorBase: public ProcessorStorage { */ inline void set_reset_line(bool value); + /*! + Gets whether the Z80 would reset at the next opportunity. + + @returns @c true if the line is logically active; @c false otherwise. + */ + bool get_is_resetting(); + /*! This emulation automatically sets itself up in power-on state at creation, which has the effect of triggering a reset at the first opportunity. Use @c reset_power_on to disable that behaviour.