public void FnStartFx(uint sound, byte channel)
{
SaveSounds[channel] = 0xFFFF;
if (sound < 256 || sound > MaxFxNumber || SystemVars.Instance.SystemFlags.HasFlag(SystemFlags.FxOff))
return;
var screen = (byte)(Logic.ScriptVariables[Logic.SCREEN] & 0xff);
if (sound == 278 && screen == 25) // is this weld in room 25
sound = 394;
unchecked
{
sound &= (uint)~(1 << 8);
}
var sfx = MusicList[sound];
var roomList = sfx.RoomList;
var i = 0;
if (roomList[i].RoomNo != 0xff) // if room list empty then do all rooms
while (roomList[i].RoomNo != screen)
{
// check rooms
i++;
if (roomList[i].RoomNo == 0xff)
return;
}
// get fx volume
var volume = _mainSfxVolume; // start with standard vol
if (SystemVars.Instance.SystemFlags.HasFlag(SystemFlags.Sblaster))
volume = roomList[i].AdlibVolume;
if (SystemVars.Instance.SystemFlags.HasFlag(SystemFlags.Roland))
volume = roomList[i].RolandVolume;
volume = (byte)((volume * _mainSfxVolume) >> 8);
// Check the flags, the sound may come on after a delay.
if ((sfx.Flags & SfxfStartDelay) != 0)
{
for (var cnt = 0; cnt < MaxQueuedFx; cnt++)
{
if (SfxQueue[cnt].Count == 0)
{
SfxQueue[cnt].Chan = channel;
SfxQueue[cnt].FxNo = sfx.SoundNo;
SfxQueue[cnt].Vol = volume;
SfxQueue[cnt].Count = (byte)(sfx.Flags & 0x7F);
return;
}
}
return; // ignore sound if it can't be queued
}
if ((sfx.Flags & SfxfSave) != 0)
SaveSounds[channel] = (ushort)(sfx.SoundNo | (volume << 8));
PlaySound(sfx.SoundNo, volume, channel);
}