aboutsummaryrefslogtreecommitdiff
path: root/src/chips/opal/opal.hpp
diff options
context:
space:
mode:
authorJP Cimalando <jpcima@users.noreply.github.com>2019-02-25 00:12:50 +0100
committerJP Cimalando <jpcima@users.noreply.github.com>2019-02-25 00:13:43 +0100
commit848f2f27da8be9fb0f2ca9efd11a87ede42d1488 (patch)
treef4f3c1bf613d3bd796fb604bef5cd77de68684c2 /src/chips/opal/opal.hpp
parentbdc982ef4263fcc4283921a2a375eab4c9073271 (diff)
downloadlibADLMIDI-848f2f27da8be9fb0f2ca9efd11a87ede42d1488.tar.gz
libADLMIDI-848f2f27da8be9fb0f2ca9efd11a87ede42d1488.tar.bz2
libADLMIDI-848f2f27da8be9fb0f2ca9efd11a87ede42d1488.zip
opal: registers $Ax $Bx affect both channels in 4op
Diffstat (limited to 'src/chips/opal/opal.hpp')
-rw-r--r--src/chips/opal/opal.hpp17
1 files changed, 13 insertions, 4 deletions
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;
}