Example #1
0
        byte Struct10OnTimer(Struct10 s10, Struct11 s11)
        {
            byte result = 0;
            int i;

            if (s10.Count != 0 && (s10.Count -= 17) <= 0)
            {
                s10.Active = 0;
                return 0;
            }

            i = s10.CurVal + s10.SpeedHi;
            s10.SpeedLoCounter += s10.SpeedLo;
            if (s10.SpeedLoCounter >= s10.SpeedLoMax)
            {
                s10.SpeedLoCounter -= s10.SpeedLoMax;
                i += s10.Direction;
            }
            if (s10.CurVal != i || s10.ModWheel != s10.ModWheelLast)
            {
                s10.CurVal = (short)i;
                s10.ModWheelLast = s10.ModWheel;
                i = LookupVolume(i, s10.ModWheelLast);
                if (i != s11.ModifyVal)
                {
                    s11.ModifyVal = (short)i;
                    result = 1;
                }
            }

            if (--s10.NumSteps == 0)
            {
                s10.Active++;
                if (s10.Active > 4)
                {
                    if (s10.Loop != 0)
                    {
                        s10.Active = 1;
                        result |= 2;
                        Struct10Setup(s10);
                    }
                    else
                    {
                        s10.Active = 0;
                    }
                }
                else
                {
                    Struct10Setup(s10);
                }
            }

            return result;
        }
Example #2
0
        void McInitStuff(AdLibVoice voice, Struct10 s10, Struct11 s11, byte flags, InstrumentExtra ie)
        {
            var part = voice.Part;
            s11.ModifyVal = 0;
            s11.Flag0x40 = (byte)(flags & 0x40);
            s10.Loop = (byte)(flags & 0x20);
            s11.Flag0x10 = (byte)(flags & 0x10);
            s11.Param = paramTable1[flags & 0xF];
            s10.MaxValue = maxValTable[flags & 0xF];
            s10.Unk3 = 31;
            if (s11.Flag0x40 != 0)
            {
                s10.ModWheel = (sbyte)(part._modWheel >> 2);
            }
            else
            {
                s10.ModWheel = 31;
            }

            switch (s11.Param)
            {
                case 0:
                    s10.StartValue = voice.Vol2;
                    break;
                case 13:
                    s10.StartValue = voice.Vol1;
                    break;
                case 30:
                    s10.StartValue = 31;
                    s11.S10.ModWheel = 0;
                    break;
                case 31:
                    s10.StartValue = 0;
                    s11.S10.Unk3 = 0;
                    break;
                default:
                    s10.StartValue = (short)AdlibGetRegValueParam(voice.Channel, s11.Param);
                    break;
            }

            Struct10Init(s10, ie);
        }
Example #3
0
        void McIncStuff(AdLibVoice voice, Struct10 s10, Struct11 s11)
        {
            byte code;
            AdLibPart part = voice.Part;

            code = Struct10OnTimer(s10, s11);

            if ((code & 1) != 0)
            {
                switch (s11.Param)
                {
                    case 0:
                        voice.Vol2 = (byte)(s10.StartValue + s11.ModifyVal);
                        if (!_scummSmallHeader)
                        {
                            AdlibSetParam(voice.Channel, 0,
                                volumeTable[volumeLookupTable[voice.Vol2, part._volEff >> 2]]);
                        }
                        else
                        {
                            AdlibSetParam(voice.Channel, 0, voice.Vol2);
                        }
                        break;
                    case 13:
                        voice.Vol1 = (byte)(s10.StartValue + s11.ModifyVal);
                        if (voice.TwoChan != 0 && !_scummSmallHeader)
                        {
                            AdlibSetParam(voice.Channel, 13,
                                volumeTable[volumeLookupTable[voice.Vol1, part._volEff >> 2]]);
                        }
                        else
                        {
                            AdlibSetParam(voice.Channel, 13, voice.Vol1);
                        }
                        break;
                    case 30:
                        s11.S10.ModWheel = (sbyte)s11.ModifyVal;
                        break;
                    case 31:
                        s11.S10.Unk3 = (sbyte)s11.ModifyVal;
                        break;
                    default:
                        AdlibSetParam(voice.Channel, s11.Param,
                            s10.StartValue + s11.ModifyVal);
                        break;
                }
            }

            if ((code & 2) != 0 && s11.Flag0x10 != 0)
                AdlibKeyOnOff(voice.Channel);
        }
Example #4
0
 public AdLibVoice()
 {
     S10a = new Struct10();
     S11a = new Struct11();
     S10b = new Struct10();
     S11b = new Struct11();
 }