diff --git a/Components/AY38910/AY38910.cpp b/Components/AY38910/AY38910.cpp index c32df440e..0984b94ac 100644 --- a/Components/AY38910/AY38910.cpp +++ b/Components/AY38910/AY38910.cpp @@ -376,6 +376,19 @@ void AY38910SampleSource::set_control_lines(ControlLines control_line update_bus(); } +template +void AY38910SampleSource::reset() { + // TODO: the below is a guess. Look up real answers. + + selected_register_ = 0; + std::fill(registers_, registers_ + 16, 0); + + task_queue_.enqueue([&] { + std::fill(output_registers_, output_registers_ + 16, 0); + evaluate_output_volume(); + }); +} + template void AY38910SampleSource::update_bus() { // Assume no output, unless this turns out to be a read. diff --git a/Components/AY38910/AY38910.hpp b/Components/AY38910/AY38910.hpp index acdc945b7..755861dcf 100644 --- a/Components/AY38910/AY38910.hpp +++ b/Components/AY38910/AY38910.hpp @@ -81,6 +81,9 @@ template class AY38910SampleSource { /// Sets the current control line state, as a bit field. void set_control_lines(ControlLines control_lines); + /// Strobes the reset line. + void reset(); + /*! Gets the value that would appear on the requested interface port if it were in output mode. @parameter port_b @c true to get the value for Port B, @c false to get the value for Port A. @@ -116,12 +119,12 @@ template class AY38910SampleSource { Concurrency::AsyncTaskQueue &task_queue_; int selected_register_ = 0; - uint8_t registers_[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - uint8_t output_registers_[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + uint8_t registers_[16]{}; + uint8_t output_registers_[16]{}; - int tone_periods_[3] = {0, 0, 0}; - int tone_counters_[3] = {0, 0, 0}; - int tone_outputs_[3] = {0, 0, 0}; + int tone_periods_[3]{}; + int tone_counters_[3]{}; + int tone_outputs_[3]{}; int noise_period_ = 0; int noise_counter_ = 0; diff --git a/Machines/Apple/AppleII/Mockingboard.hpp b/Machines/Apple/AppleII/Mockingboard.hpp index b3a3c1dcf..afb7555ce 100644 --- a/Machines/Apple/AppleII/Mockingboard.hpp +++ b/Machines/Apple/AppleII/Mockingboard.hpp @@ -107,8 +107,9 @@ class Mockingboard: public Card { ) ); - // TODO: all lines disabled sees to map to reset? Possibly? - // Cf. https://gswv.apple2.org.za/a2zine/Docs/Mockingboard_MiniManual.html + if(!value) { + ay.reset(); + } } else { ay.set_data_input(value); }