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; }
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); }
void Struct10Setup(Struct10 s10) { int b, c, d, e, f, g, h; byte t; b = s10.Unk3; f = s10.Active - 1; t = s10.TableA[f]; e = numStepsTable[volumeLookupTable[t & 0x7F, b]]; if ((t & 0x80) != 0) { e = RandomNr(e); } if (e == 0) e++; s10.NumSteps = s10.SpeedLoMax = (ushort)e; if (f != 2) { c = s10.MaxValue; g = s10.StartValue; t = s10.TableB[f]; d = LookupVolume(c, (t & 0x7F) - 31); if ((t & 0x80) != 0) { d = RandomNr(d); } if (d + g > c) { h = c - g; } else { h = d; if (d + g < 0) h = -g; } h -= s10.CurVal; } else { h = 0; } s10.SpeedHi = (short)(h / e); if (h < 0) { h = -h; s10.Direction = -1; } else { s10.Direction = 1; } s10.SpeedLo = (ushort)(h % e); s10.SpeedLoCounter = 0; }
void Struct10Init(Struct10 s10, InstrumentExtra ie) { s10.Active = 1; if (!_scummSmallHeader) { s10.CurVal = 0; } else { s10.CurVal = s10.StartValue; s10.StartValue = 0; } s10.ModWheelLast = 31; s10.Count = ie.A; if (s10.Count != 0) s10.Count *= 63; s10.TableA[0] = ie.B; s10.TableA[1] = ie.D; s10.TableA[2] = ie.F; s10.TableA[3] = ie.G; s10.TableB[0] = ie.C; s10.TableB[1] = ie.E; s10.TableB[2] = 0; s10.TableB[3] = ie.H; Struct10Setup(s10); }
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); }
public AdLibVoice() { S10a = new Struct10(); S11a = new Struct11(); S10b = new Struct10(); S11b = new Struct11(); }