private bool NextPart(ushort[] data, ref int i)
{
// return false means cancel intro
var command = data[i++];
switch (command)
{
case SHOWSCREEN:
_skyScreen.ShowScreen(data[i++]);
return true;
case FADEUP:
_skyScreen.PaletteFadeUp(data[i++]);
_relDelay += 32 * 20; // hack: the screen uses a seperate delay function for the
// blocking fadeups. So add 32*20 msecs to out delay counter.
return true;
case FADEDOWN:
_skyScreen.FnFadeDown(0);
_relDelay += 32 * 20; // hack: see above.
return true;
case DELAY:
if (!EscDelay(data[i++]))
return false;
return true;
case DOFLIRT:
_skyScreen.StartSequence(data[i++]);
while (_skyScreen.SequenceRunning())
if (!EscDelay(50))
return false;
return true;
case SCROLLFLIRT:
return FloppyScrollFlirt();
case COMMANDFLIRT:
return CommandFlirt(data, ref i);
case STOPFLIRT:
_skyScreen.StopSequence();
return true;
case STARTMUSIC:
_skyMusic.StartMusic(data[i++]);
return true;
case WAITMUSIC:
while (_skyMusic.IsPlaying)
if (!EscDelay(50))
return false;
return true;
case BGFLIRT:
_skyScreen.StartSequence(data[i++]);
return true;
case WAITFLIRT:
while (_skyScreen.SequenceRunning())
if (!EscDelay(50))
return false;
return true;
case PLAYVOICE:
{
if (!EscDelay(200))
return false;
var vData = _skyDisk.LoadFile(data[i++]);
// HACK: Fill the header with silence. We should
// probably use _skySound instead of calling playStream()
// directly, but this will have to do for now.
vData.Set(0, 127, ServiceLocator.Platform.SizeOf<DataFileHeader>());
var stream = new RawStream(AudioFlags.Unsigned, 11025, true, new MemoryStream(vData));
_voice = _mixer.PlayStream(SoundType.Speech, stream, Sound.SoundVoice);
}
return true;
case WAITVOICE:
while (_mixer.IsSoundHandleActive(_voice))
if (!EscDelay(50))
return false;
return true;
case LOADBG:
_mixer.StopID(Sound.SoundBg);
_bgBuf = _skyDisk.LoadFile(data[i++]);
return true;
case LOOPBG:
{
_mixer.StopID(Sound.SoundBg);
var stream = new RawStream(AudioFlags.Unsigned, 11025, false, new MemoryStream(_bgBuf, 256, _bgBuf.Length - 768));
_bgSfx = _mixer.PlayStream(SoundType.SFX, new LoopingAudioStream(stream, 0), Sound.SoundBg);
}
return true;
case PLAYBG:
{
_mixer.StopID(Sound.SoundBg);
var stream = new RawStream(AudioFlags.Unsigned, 11025, false, new MemoryStream(_bgBuf, 256, _bgBuf.Length - 768));
_bgSfx = _mixer.PlayStream(SoundType.SFX, stream, Sound.SoundBg);
}
return true;
case STOPBG:
_mixer.StopID(Sound.SoundBg);
return true;
default:
throw new NotSupportedException(string.Format("Unknown intro command {0:X2}", command));
}
}