Esempio n. 1
0
void IMuseDigital::refreshScripts() {
	Common::StackLock lock(_mutex, "IMuseDigital::refreshScripts()");
	debug(6, "refreshScripts()");

	if (_stopingSequence) {
		// prevent start new music, only fade out old one
		if (_vm->isSmushActive()) {
			fadeOutMusic(60);
			return;
		}
		// small delay, it seems help for fix bug #1757010
		if (_stopingSequence++ > 120) {
			debug(5, "refreshScripts() Force restore music state");
			parseScriptCmds(0x1001, 0, 0, 0, 0, 0, 0, 0);
			_stopingSequence = 0;
		}
	}

	bool found = false;
	for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
		Track *track = _track[l];
		if (track->used && !track->toBeRemoved && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) {
			found = true;
			break;
		}
	}

	if (!found && _curMusicState) {
		debug(5, "refreshScripts() Restore music state");
		parseScriptCmds(0x1001, 0, 0, 0, 0, 0, 0, 0);
	}
}
Esempio n. 2
0
void KyraEngine_MR::playVQA(const char *name) {
	VQAMovie vqa(this, _system);

	Common::String filename = Common::String::format("%s%d.VQA", name, _configVQAQuality);

	if (vqa.open(filename.c_str())) {
		for (int i = 0; i < 4; ++i) {
			if (i != _musicSoundChannel)
				_soundDigital->stopSound(i);
		}

		_screen->hideMouse();
		_screen->copyPalette(1, 0);
		fadeOutMusic(60);
		_screen->fadeToBlack(60);
		_screen->clearPage(0);

		vqa.setDrawPage(0);
		vqa.play();
		vqa.close();

		_soundDigital->stopAllSounds();
		_screen->showMouse();

		// Taken from original, it used '1' here too
		_screen->getPalette(0).fill(0, 256, 1);
		_screen->setScreenPalette(_screen->getPalette(0));
		_screen->clearPage(0);
		_screen->copyPalette(0, 1);
		_wasPlayingVQA = true;
	}
}
Esempio n. 3
0
void SoundManager::fadeOutAndPlayMusic(const std::string &fileName,
                                       const int ms)
{
    if (!mPlayMusic)
        return;

    mNextMusicFile = fileName;
    fadeOutMusic(ms);
}
Esempio n. 4
0
static void die()
{
	self->flags &= ~FLY;

	self->weight = 1;

	playSoundToMap("sound/boss/chaos/die", BOSS_CHANNEL, self->x, self->y, 0);

	setEntityAnimation(self, "DIE_1");

	self->animationCallback = NULL;

	activateEntitiesWithObjectiveName("CHAOS_VINES", FALSE);

	self->x = self->startX;

	if (self->flags & GRABBING)
	{
		if (self->face == LEFT)
		{
			player.x = self->x + self->w - player.w - self->offsetX;
		}

		else
		{
			player.x = self->x + self->offsetX;
		}

		player.y = self->y + self->offsetY;

		setCustomAction(&player, &invulnerable, 60, 0, 0);

		setPlayerStunned(30);

		player.x -= player.dirX;
		player.y -= player.dirY;

		player.dirX = (10 + prand() % 3) * (self->face == LEFT ? -1 : 1);
		player.dirY = -3;

		self->touch = &entityTouch;
	}

	self->mental = 0;

	self->thinkTime = 420;

	self->damage = 0;

	self->takeDamage = NULL;

	self->action = &dieWait;

	fadeOutMusic(3000);

	checkToMap(self);
}
void IMuseDigital::playDigMusic(const char *songName, const imuseDigTable *table, int atribPos, bool sequence) {
	int hookId = 0;

	if (songName != NULL) {
		if ((_attributes[DIG_SEQ_OFFSET + 38] != 0) && (_attributes[DIG_SEQ_OFFSET + 41] == _attributes[DIG_SEQ_OFFSET + 38])) {
			if ((atribPos == 43) || (atribPos == 44))
				hookId = 3;
		}

		if ((_attributes[DIG_SEQ_OFFSET + 46] != 0) && (_attributes[DIG_SEQ_OFFSET + 48] == 0)) {
			if ((atribPos == 38) || (atribPos == 39))
				hookId = 3;
		}

		if ((_attributes[DIG_SEQ_OFFSET + 53] != 0)) {
			if ((atribPos == 50) || (atribPos == 51))
				hookId = 3;
		}

		if ((atribPos != 0) && (hookId == 0)) {
			if (table->atribPos != 0)
				atribPos = table->atribPos;
			hookId = _attributes[DIG_STATE_OFFSET + atribPos];
			if (table->hookId != 0) {
				if ((hookId != 0) && (table->hookId > 1)) {
					_attributes[DIG_STATE_OFFSET + atribPos] = 2;
				} else {
					_attributes[DIG_STATE_OFFSET + atribPos] = hookId + 1;
					if (table->hookId < hookId + 1)
						_attributes[DIG_STATE_OFFSET + atribPos] = 1;
				}
			}
		}
	}

	fadeOutMusic(120);

	switch(table->opcode) {
		case 0:
		case 5:
		case 6:
			break;
		case 3:
		case 4:
			if (table->filename[0] == 0) {
				return;
			}
			if ((!sequence) && (table->atribPos != 0) &&
					(table->atribPos == _digStateMusicTable[_curMusicState].atribPos)) {
				startMusic(table->filename, table->soundId, 0, 127);
				return;
			}
			startMusic(table->filename, table->soundId, hookId, 127);
			break;
	}
}
Esempio n. 6
0
static void quitToTitle()
{
	menu.index = 0;

	pauseGame();

	setTransition(TRANSITION_OUT, &titleScreen);

	fadeOutMusic(500);
}
Esempio n. 7
0
static void initialise()
{
	if (self->active == TRUE)
	{
		fadeOutMusic(500);

		self->x = self->startX;
		self->y = self->startY;

		self->touch = &touch;

		self->flags &= ~(NO_DRAW|FLY);

		self->flags |= ATTACKING;

		self->action = &drop;
	}
}
Esempio n. 8
0
void IMuseDigital::playFtMusic(const char *songName, int opcode, int volume) {
	fadeOutMusic(200);

	switch (opcode) {
	case 0:
	case 4:
		break;
	case 1:
	case 2:
	case 3:
		{
			int soundId = getSoundIdByName(songName);
			if (soundId != -1) {
				startMusic(soundId, volume);
			}
		}
		break;
	}
}
Esempio n. 9
0
void IMuseDigital::playComiMusic(const char *songName, const imuseComiTable *table, int attribPos, bool sequence) {
	int hookId = 0;

	if ((songName != NULL) && (attribPos != 0)) {
		if (table->attribPos != 0)
			attribPos = table->attribPos;
		hookId = _attributes[COMI_STATE_OFFSET + attribPos];
		if (table->hookId != 0) {
			if ((hookId != 0) && (table->hookId > 1)) {
				_attributes[COMI_STATE_OFFSET + attribPos] = 2;
			} else {
				_attributes[COMI_STATE_OFFSET + attribPos] = hookId + 1;
				if (table->hookId < hookId + 1)
					_attributes[COMI_STATE_OFFSET + attribPos] = 1;
			}
		}
	}

	if (!songName) {
		fadeOutMusic(120);
		return;
	}

	switch (table->transitionType) {
	case 0:
		break;
	case 8:
		setHookIdForMusic(table->hookId);
		break;
	case 9:
		_stopingSequence = 1;
		setHookIdForMusic(table->hookId);
		break;
	case 2:
	case 3:
	case 4:
	case 12:
		if (table->filename[0] == 0) {
			fadeOutMusic(60);
			return;
		}
		if (getCurMusicSoundId() == table->soundId)
			return;
		if (table->transitionType == 4)
			_stopingSequence = 1;
		if (table->transitionType == 2) {
			fadeOutMusic(table->fadeOutDelay);
			startMusic(table->filename, table->soundId, table->hookId, 127);
			return;
		}
		if ((!sequence) && (table->attribPos != 0) &&
				(table->attribPos == _comiStateMusicTable[_curMusicState].attribPos)) {
			fadeOutMusicAndStartNew(table->fadeOutDelay, table->filename, table->soundId);
		} else if (table->transitionType == 12) {
			TriggerParams trigger;
			strcpy(trigger.marker, "exit"); trigger.fadeOutDelay = table->fadeOutDelay;
			strcpy(trigger.filename, table->filename); trigger.soundId = table->soundId;
			trigger.hookId = table->hookId; trigger.volume = 127;
			setTrigger(&trigger);
		} else {
			fadeOutMusic(table->fadeOutDelay);
			startMusic(table->filename, table->soundId, hookId, 127);
		}
		break;
	}
}
Esempio n. 10
0
void Imuse::playMusic(const ImuseTable *table, int atribPos, bool sequence) {
	int hookId = 0;

	if (atribPos) {
		if (table->atribPos)
			atribPos = table->atribPos;
		hookId = _attributes[atribPos];
		if (table->hookId) {
			if (hookId && table->hookId > 1) {
				_attributes[atribPos] = 2;
			} else {
				_attributes[atribPos] = hookId + 1;
				if (table->hookId < hookId + 1)
					_attributes[atribPos] = 1;
			}
		}
	}
	if (hookId == 0)
		hookId = 100;

	if (table->opcode == 0) {
		fadeOutMusic(120);
		return;
	}

	if (table->opcode == 2 || table->opcode == 3) {
		if (table->filename[0] == 0) {
			fadeOutMusic(60);
			return;
		}
		char *soundName = getCurMusicSoundName();
		int pan;

		if (table->pan == 0)
			pan = 64;
		else
			pan = table->pan;
		if (!soundName) {
			startMusic(table->filename, hookId, 0, pan);
			setVolume(table->filename, 0);
			setFadeVolume(table->filename, table->volume, table->fadeOut60TicksDelay);
			return;
		}
		int old_pan = getCurMusicPan();
		int old_vol = getCurMusicVol();
		if (old_pan == -1)
			old_pan = 64;
		if (old_vol == -1)
			old_vol = 127;

		if (table->opcode == 2) {
			fadeOutMusic(table->fadeOut60TicksDelay);
			startMusic(table->filename, hookId, table->volume, pan);
			setVolume(table->filename, 0);
			setFadeVolume(table->filename, table->volume, table->fadeOut60TicksDelay);
			setFadePan(table->filename, pan, table->fadeOut60TicksDelay);
			return;
		}
		if (strcmp(soundName, table->filename) == 0) {
			setFadeVolume(soundName, table->volume, table->fadeOut60TicksDelay);
			setFadePan(soundName, pan, table->fadeOut60TicksDelay);
			return;
		}

		if (!sequence && table->atribPos && table->atribPos == _stateMusicTable[_curMusicState].atribPos) {
			fadeOutMusicAndStartNew(table->fadeOut60TicksDelay, table->filename, hookId, old_vol, old_pan);
			setVolume(table->filename, 0);
			setFadeVolume(table->filename, table->volume, table->fadeOut60TicksDelay);
			setFadePan(table->filename, pan, table->fadeOut60TicksDelay);
		} else {
			fadeOutMusic(table->fadeOut60TicksDelay);
			startMusic(table->filename, hookId, table->volume, pan);
			setVolume(table->filename, 0);
			setFadeVolume(table->filename, table->volume, table->fadeOut60TicksDelay);
		}
	}
}
Esempio n. 11
0
void loadGameOverMusic()
{
    fadeOutMusic(2000);

    Mix_HookMusicFinished(playGameOverMusic);
}
Esempio n. 12
0
void fadeBossMusic()
{
    fadeOutMusic(4000);

    Mix_HookMusicFinished(resumeMusic);
}
Esempio n. 13
0
Common::Error KyraEngine_MR::go() {
	bool running = true;
	preinit();
	_screen->hideMouse();
	initMainMenu();

	_screen->clearPage(0);
	_screen->clearPage(2);

	const bool firstTimeGame = !saveFileLoadable(0);

	if (firstTimeGame) {
		playVQA("K3INTRO");
		_wasPlayingVQA = false;
	}

	if (_gameToLoad != -1 || firstTimeGame) {
		while (!_screen->isMouseVisible())
			_screen->showMouse();

		uninitMainMenu();
		_musicSoundChannel = -1;
		startup();
		runLoop();
		running = false;
	}

	while (running && !shouldQuit()) {
		_screen->_curPage = 0;
		_screen->clearPage(0);

		_screen->setScreenPalette(_screen->getPalette(0));

		playMenuAudioFile();

		for (int i = 0; i < 64 && !shouldQuit(); ++i) {
			uint32 nextRun = _system->getMillis() + 3 * _tickLength;
			_menuAnim->displayFrame(i, 0, 0, 0, 0, 0, 0);
			_screen->updateScreen();
			delayUntil(nextRun);
		}

		for (int i = 64; i > 29 && !shouldQuit(); --i) {
			uint32 nextRun = _system->getMillis() + 3 * _tickLength;
			_menuAnim->displayFrame(i, 0, 0, 0, 0, 0, 0);
			_screen->updateScreen();
			delayUntil(nextRun);
		}

		_eventList.clear();

		switch (_menu->handle(3)) {
		case 2:
			_menuDirectlyToLoad = true;
			// fall through

		case 0:
			uninitMainMenu();

			fadeOutMusic(60);
			_screen->fadeToBlack(60);
			_musicSoundChannel = -1;
			startup();
			runLoop();
			running = false;
			break;

		case 1:
			playVQA("K3INTRO");
			_wasPlayingVQA = false;
			_screen->hideMouse();
			break;

		case 3:
			fadeOutMusic(60);
			_screen->fadeToBlack(60);
			uninitMainMenu();
			quitGame();
			running = false;
			break;

		default:
			break;
		}
	}

	if (_showOutro && !shouldQuit())
		playVQA("CREDITS");

	return Common::kNoError;
}
Esempio n. 14
0
int game_welcome_page(GraphicsData graphicsData, AudioData audioData){

   InitData initData;

   int menuRunning = 1;
   SDL_Event event;
   UI_Element *element;
   UI_Element *element2;

   int win_x,win_y;

   initData.graphicsData = graphicsData;
   initData.audioData = audioData;

/*   gameData.graphicsData = graphicsData; */

   /* create a black background*/


   /* create box 1 (title), size fixed*/

   SDL_GetWindowSize(graphicsData.window,&win_x,&win_y);

   initUIData(&initData.uiData);

   initData.uiData.graphicsData = &initData.graphicsData;

   initData.uiData.root = UIElement_Create(0,0,win_x,win_y,2);
   UIConfigure_DisplayImage(initData.uiData.root,&initData.uiData.root->actions[0],graphicsData.mainMenuImage);
   UIConfigure_PercOffsetRect(initData.uiData.root,&initData.uiData.root->actions[1],0.0,0.0,1.0,1.0,
                                                                                     0,  0,  0,  0,  0);

   element = UIElement_Create(0,0,0,0,3);
   UIConfigure_Counter(element,&element->actions[0],1,0);
   UIConfigure_LeftClickRect(element,&element->actions[1]);
       UITrigger_Bind(&element->actions[1],&element->actions[0],-1,UITRIGGER_PLUSONE);
   UIConfigure_PercOffsetRect(element,&element->actions[2],0.55, 0.69, 0.9, 0.82,
                                                           0,    0,  0,0,0);

   UIElement_Reparent(element,initData.uiData.root);

    /*element = UIElement_Create((win_x *3)/4 - 100, (win_y * 3)/4, 150, 50, 1);
    UIConfigure_FillRect(element,&element->actions[0],100,100,0);
    UIElement_Reparent(element,initData.uiData.root);*/

    element2 = UIElement_Create((win_x - 30), win_y - 30, 30, 30, 4);
    UIConfigure_FillRect(element2, &element2->actions[0],228,240,3);
	UIConfigure_PercPosition(element2, &element2->actions[1],1.0,1.0,-30,-30,0);
	UIConfigure_LeftClickRect(element2, &element2->actions[2]);
		UITrigger_Bind(&element2->actions[2],&element2->actions[3],0,1);
	UIConfigure_MuteSound(element2,&element2->actions[3]);
    UIElement_Reparent(element2,initData.uiData.root);
	UIRoot_Pack(&initData.uiData);

	initData.uiData.audioData = &initData.audioData;

   playMusic(&initData.audioData,0);

   while(menuRunning){

      /*UIRoot_Execute(&initData.uiData,UPDATE,0);*/

      //paintBackground(&initData.graphicsData,0,200,100);
      UIRoot_Execute(&initData.uiData,UPDATE,0);
      SDL_RenderPresent(initData.graphicsData.renderer);
    	while (SDL_PollEvent(&event))
    	{
        initData.uiData.event = &event;
    		switch (event.type)
    		{
  				case SDL_WINDOWEVENT:
  					switch (event.window.event){
  						case SDL_WINDOWEVENT_RESIZED:
  							UIRoot_Execute(&initData.uiData,WINDOW_RESIZE,0);
  							break;
  					}
            break;
    			/* Closing the Window will exit the program */
    			case SDL_MOUSEBUTTONDOWN:
   				   UIRoot_ExecuteUpwards(&initData.uiData,LEFT_CLICK,1);
   				   break;
    			case SDL_QUIT:
    				exit(0);
    				break;
    		}
    	}
		if (Mix_Playing(1) == 0) {
			playMusic(&initData.audioData,0);
		}
      menuRunning = (!initData.uiData.root->child->actions[0].status);
   }

   UIRoot_Destroy(&initData.uiData);

   fadeOutMusic(&initData.audioData);

   return 0;
}
void IMuseDigital::playComiMusic(const char *songName, const imuseComiTable *table, int atribPos, bool sequence) {
	int hookId = 0;

	if ((songName != NULL) && (atribPos != 0)) {
		if (table->atribPos != 0)
			atribPos = table->atribPos;
		hookId = _attributes[COMI_STATE_OFFSET + atribPos];
		if (table->hookId != 0) {
			if ((hookId != 0) && (table->hookId > 1)) {
				_attributes[COMI_STATE_OFFSET + atribPos] = 2;
			} else {
				_attributes[COMI_STATE_OFFSET + atribPos] = hookId + 1;
				if (table->hookId < hookId + 1)
					_attributes[COMI_STATE_OFFSET + atribPos] = 1;
			}
		}
	}

	switch (table->opcode) {
		case 0:
			fadeOutMusic(120);
			break;
		case 8:
		case 9:
			setHookId(table->soundId, table->soundId);
			break;
		case 1:
			if (table->filename[0] == 0) {
				fadeOutMusic(120);
				return;
			}
			fadeOutMusic(120);
			startMusic(table->filename, table->soundId, 0, 1);
			setFade(table->soundId, 127, 120);
			break;
		case 2:
			if (table->filename[0] == 0) {
				fadeOutMusic(60);
				return;
			}
			fadeOutMusic(table->fadeOut60TicksDelay);
			startMusic(table->filename, table->soundId, table->hookId, 127);
			break;
		case 3:
		case 4:
		case 12:
			if (table->filename[0] == 0) {
				fadeOutMusic(60);
				return;
			}
			fadeOutMusic(table->fadeOut60TicksDelay);
			if ((!sequence) && (table->atribPos != 0) &&
					(table->atribPos == _comiStateMusicTable[_curMusicState].atribPos)) {
				startMusic(table->filename, table->soundId, 0, 127);
				return;
			}
			if (table->opcode == 12) {
				startMusic(table->filename, table->soundId, table->hookId, 127);
			} else {
				startMusic(table->filename, table->soundId, hookId, 127);
			}
			break;
	}
}
Esempio n. 16
0
void IMuseDigital::parseScriptCmds(int cmd, int b, int c, int d, int e, int f, int g, int h) {
	int soundId = b;
	int sub_cmd = c;

	if (!cmd)
		return;

	switch (cmd) {
	case 10: // ImuseStopAllSounds
		stopAllSounds();
		break;
	case 12: // ImuseSetParam
		switch (sub_cmd) {
		case 0x400: // select group volume
			selectVolumeGroup(soundId, d);
			break;
		case 0x500: // set priority
			setPriority(soundId, d);
			break;
		case 0x600: // set volume
			setVolume(soundId, d);
			break;
		case 0x700: // set pan
			setPan(soundId, d);
			break;
		default:
			warning("IMuseDigital::doCommand SetParam DEFAULT command %d", sub_cmd);
			break;
		}
		break;
	case 14: // ImuseFadeParam
		switch (sub_cmd) {
		case 0x600: // set volume fading
			if ((d != 0) && (e == 0))
				setVolume(soundId, d);
			else if ((d == 0) && (e == 0))
				stopSound(soundId);
			else
				setFade(soundId, d, e);
			break;
		default:
			warning("IMuseDigital::doCommand FadeParam DEFAULT sub command %d", sub_cmd);
			break;
		}
		break;
	case 25: // ImuseStartStream
		debug(3, "ImuseStartStream (%d, %d, %d)", soundId, c, d);
		break;
	case 26: // ImuseSwitchStream
		debug(3, "ImuseSwitchStream (%d, %d, %d, %d, %d)", soundId, c, d, e, f);
		break;
	case 0x1000: // ImuseSetState
		debug(5, "ImuseSetState (%d)", b);
		if ((_vm->_game.id == GID_DIG) && (_vm->_game.features & GF_DEMO)) {
			if (b == 1) {
				fadeOutMusic(200);
				startMusic(1, 127);
			} else {
				if (getSoundStatus(2) == 0) {
					fadeOutMusic(200);
					startMusic(2, 127);
				}
			}
		} else if ((_vm->_game.id == GID_CMI) && (_vm->_game.features & GF_DEMO)) {
			if (b == 2) {
				fadeOutMusic(108);
				startMusic("in1.imx", 1100, 0, 127);
			} else if (b == 4) {
				fadeOutMusic(108);
				startMusic("in2.imx", 1120, 0, 127);
			} else if (b == 8) {
				fadeOutMusic(108);
				startMusic("out1.imx", 1140, 0, 127);
			} else if (b == 9) {
				fadeOutMusic(108);
				startMusic("out2.imx", 1150, 0, 127);
			} else if (b == 16) {
				fadeOutMusic(108);
				startMusic("gun.imx", 1210, 0, 127);
			} else {
				fadeOutMusic(120);
			}
		} else if (_vm->_game.id == GID_DIG) {
			setDigMusicState(b);
		} else if (_vm->_game.id == GID_CMI) {
			setComiMusicState(b);
		} else if (_vm->_game.id == GID_FT) {
			setFtMusicState(b);
		}
		break;
	case 0x1001: // ImuseSetSequence
		debug(5, "ImuseSetSequence (%d)", b);
		if (_vm->_game.id == GID_DIG) {
			setDigMusicSequence(b);
		} else if (_vm->_game.id == GID_CMI) {
			setComiMusicSequence(b);
		} else if (_vm->_game.id == GID_FT) {
			setFtMusicSequence(b);
		}
		break;
	case 0x1002: // ImuseSetCuePoint
		debug(5, "ImuseSetCuePoint (%d)", b);
		if (_vm->_game.id == GID_FT) {
			setFtMusicCuePoint(b);
		}
		break;
	case 0x1003: // ImuseSetAttribute
		debug(5, "ImuseSetAttribute (%d, %d)", b, c);
		assert((_vm->_game.id == GID_DIG) || (_vm->_game.id == GID_FT));
		if (_vm->_game.id == GID_DIG) {
			_attributes[b] = c;
		}
		break;
	case 0x2000: // ImuseSetGroupSfxVolume
		break;
	case 0x2001: // ImuseSetGroupVoiceVolume
		break;
	case 0x2002: // ImuseSetGroupMusicVolume
		break;
	default:
		error("IMuseDigital::doCommand DEFAULT command %d", cmd);
	}
}
Esempio n. 17
0
void Sound::fadeOutAndPlayMusic(const std::string &fileName, int ms)
{
    mNextMusicFile = fileName;
    fadeOutMusic(ms);
}