Example #1
0
	void operator()()
	{
		while (_flcPlayer->getFrameCount() >= introSoundTrack[trackPosition].frameNumber)
		{
			int command = introSoundTrack[trackPosition].sound;

			if (command & 0x200)
			{
#ifndef __NO_MUSIC
				switch(command)
				{
				case 0x200:
					Log(LOG_DEBUG) << "Playing gmintro1";
					m = mod->getMusic("GMINTRO1");
					m->play(1);
					break;
				case 0x201:
					Log(LOG_DEBUG) << "Playing gmintro2";
					m = mod->getMusic("GMINTRO2");
					m->play(1);
					break;
				case 0x202:
					Log(LOG_DEBUG) << "Playing gmintro3";
					m = mod->getMusic("GMINTRO3");
					m->play(1);
					//Mix_HookMusicFinished(_FlcPlayer::stop);
					break;
				}
#endif
			}
			else if (command & 0x400)
			{
				int newSpeed = (command & 0xff);
				_flcPlayer->setHeaderSpeed(newSpeed);
				Log(LOG_DEBUG) << "Frame delay now: " << newSpeed;
			}
			else if (command <= 0x19)
			{
				for (soundInFile **sounds = introSounds; *sounds; ++sounds) // try hybrid sound set, then intro.cat or sample3.cat alone
				{
					soundInFile *sf = (*sounds) + command;
					int channel = trackPosition % 4; // use at most four channels to play sound effects
					double ratio = (double)Options::soundVolume / MIX_MAX_VOLUME;
					Log(LOG_DEBUG) << "playing: " << sf->catFile << ":" << sf->sound << " for index " << command;
					s = mod->getSound(sf->catFile, sf->sound, false);
					if (s)
					{
						s->play(channel);
						Mix_Volume(channel, sf->volume * ratio);
						break;
					}
					else Log(LOG_DEBUG) << "Couldn't play " << sf->catFile << ":" << sf->sound;
				}
			}
			++trackPosition;
		}

	}