From 848f2f27da8be9fb0f2ca9efd11a87ede42d1488 Mon Sep 17 00:00:00 2001 From: JP Cimalando Date: Mon, 25 Feb 2019 00:12:50 +0100 Subject: opal: registers $Ax $Bx affect both channels in 4op --- src/chips/opal/opal.hpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/chips/opal/opal.hpp b/src/chips/opal/opal.hpp index c383bd5..1aa0c7d 100644 --- a/src/chips/opal/opal.hpp +++ b/src/chips/opal/opal.hpp @@ -142,6 +142,7 @@ class Opal { uint16_t GetOctave() const { return Octave; } uint16_t GetKeyScaleNumber() const { return KeyScaleNumber; } uint16_t GetModulationType() const { return ModulationType; } + Channel * GetChannelPair() const { return ChannelPair; } /* libADLMIDI */ void ComputeKeyScaleNumber(); @@ -475,20 +476,28 @@ void Opal::Port(uint16_t reg_num, uint8_t val) { Channel &chan = Chan[chan_num]; + /* libADLMIDI: registers Ax and Cx affect both channels */ + Channel *chans[2] = {&chan, chan.GetChannelPair()}; + unsigned numchans = chans[1] ? 2 : 1; + // Do specific registers switch (reg_num & 0xF0) { // Frequency low case 0xA0: { - chan.SetFrequencyLow(val); + for (unsigned i = 0; i < numchans; ++i) { /* libADLMIDI */ + chans[i]->SetFrequencyLow(val); + } break; } // Key-on / Octave / Frequency High case 0xB0: { - chan.SetKeyOn((val & 0x20) != 0); - chan.SetOctave(val >> 2 & 7); - chan.SetFrequencyHigh(val & 3); + for (unsigned i = 0; i < numchans; ++i) { /* libADLMIDI */ + chans[i]->SetKeyOn((val & 0x20) != 0); + chans[i]->SetOctave(val >> 2 & 7); + chans[i]->SetFrequencyHigh(val & 3); + } break; } -- cgit v1.2.3