NScumm.Sky.Music.AdLibChannel.SetupInstrument C# (CSharp) Method

SetupInstrument() public method

public SetupInstrument ( byte opcode ) : void
opcode byte
return void
        void SetupInstrument(byte opcode)
        {
            ushort nextNote;
            if (_channelData.tremoVibro != 0)
            {
                byte newInstrument = _instrumentMap[opcode];
                if (newInstrument != _channelData.assignedInstrument)
                {
                    _channelData.assignedInstrument = newInstrument;
                    _channelData.instrumentData = _instruments[newInstrument];
                    AdlibSetupInstrument();
                }
                _channelData.lastCommand = _channelData.instrumentData.bindedEffect;
                nextNote = GetNextNote(_channelData.lastCommand);
            }
            else
            {
                nextNote = GetNextNote((byte)(opcode - 0x18 + _channelData.instrumentData.bindedEffect));
            }
            _channelData.frequency = nextNote;
            SetRegister((byte)(0xA0 | _channelData.adlibChannelNumber), (byte)nextNote);
            SetRegister((byte)(0xB0 | _channelData.adlibChannelNumber), (byte)((nextNote >> 8) | 0x20));
            _channelData.note = (byte)((nextNote >> 8) | 0x20);
        }