Exemplo n.º 1
0
int BEE::Sound::fade_in(int ticks) {
	if (!is_loaded) {
		if (!has_play_failed) {
			game->messenger_send({"engine", "sound"}, BEE_MESSAGE_WARNING, "Failed to fade in sound \"" + name + "\" because it is not loaded");
			has_play_failed = true;
		}
		return 1;
	}

	if (is_music) {
		Mix_FadeInMusic(music, 1, ticks);
	} else {
		int c = Mix_FadeInChannel(-1, chunk, 0, ticks);
		if (c >= 0) {
			current_channels.remove(c);
			current_channels.push_back(c);
		} else {
			game->messenger_send({"engine", "sound"}, BEE_MESSAGE_WARNING, "Failed to play sound \"" + name + "\": " + Mix_GetError());
			return 1;
		}

		set_pan_internal(c);
		effect_set(c, sound_effects);
	}

	is_playing = true;
	is_looping = false;

	return 0;
}
Exemplo n.º 2
0
int BEE::Sound::rewind() {
	if (!is_loaded) {
		if (!has_play_failed) {
			game->messenger_send({"engine", "sound"}, BEE_MESSAGE_WARNING, "Failed to rewind sound \"" + name + "\" because it is not loaded");
			has_play_failed = true;
		}
		return 1;
	}

	if (is_music) {
		// Mix_RewindMusic(); // Only works for MOD, OGG, MP3, and MIDI
		Mix_HaltMusic();
		if (is_looping) {
			Mix_PlayMusic(music, -1);
		} else {
			Mix_PlayMusic(music, 1);
		}
		effect_set_post(sound_effects);
	} else {
		for (auto i=current_channels.begin(); i != current_channels.end(); ++i) {
			Mix_HaltChannel(*i);
			if (is_looping) {
				Mix_PlayChannel(*i, chunk, -1);
			} else {
				Mix_PlayChannel(*i, chunk, 0);
			}
			effect_set(*i, sound_effects);
		}
	}

	return 0;
}
Exemplo n.º 3
0
int BEE::Sound::effect_add(int new_sound_effects) {
	if (is_loaded) {
		int old_sound_effects = sound_effects;
		sound_effects = new_sound_effects;

		if (is_music) {
			effect_remove_post(old_sound_effects ^ sound_effects);
			effect_set_post(sound_effects);
		} else {
			std::list<int> tmp_channels = current_channels;
			for (auto i=tmp_channels.begin(); i != tmp_channels.end(); ++i) {
				effect_remove(*i, old_sound_effects ^ sound_effects);
				effect_set(*i, sound_effects);
			}
		}

		return 0;
	}
	return 1;
}
Exemplo n.º 4
0
int BEE::Sound::stop() {
	if (is_loaded) {
		is_playing = false;
		is_looping = false;

		if (is_music) {
			effect_set_post(0);
			Mix_HaltMusic();
		} else {
			std::list<int> tmp_channels = current_channels;
			for (auto i=tmp_channels.begin(); i != tmp_channels.end(); ++i) {
				effect_set(*i, 0);
				Mix_HaltChannel(*i);
			}
		}

		return 0;
	}
	return 1;
}
Exemplo n.º 5
0
// GP : グラフィックのコピー Nonaka.K, T.Yui
int isfcmd_57(SCR_OPE *op) {

	BYTE	cmd;
	SINT32	src;
	RECT_U	scrn;
	SINT32	param;
	POINT_T	pt;
	EFFECT	ef;

	ef = &gamecore.ef;
	if ((scr_getbyte(op, &cmd) != SUCCESS) ||
		(scr_getval(op, &src) != SUCCESS) ||
		(scr_getrect(op, &scrn) != SUCCESS) ||
		(scr_getval(op, &param) != SUCCESS) ||
		(scr_getpt(op, &pt) != SUCCESS)) {
		return(GAMEEV_WRONGLENG);
	}
	if ((gamecore.dispwin.flag & DISPWIN_VRAM) &&
		(src >= 0) && (src < GAMECORE_MAXVRAM) && (gamecore.vram[src])) {
		ZeroMemory(ef, sizeof(EFFECT_T));
		ef->cmd = cmd;
		ef->param = param;
		ef->src = gamecore.vram[src];
#ifdef SIZE_QVGA
		vramdraw_halfpoint(&pt);
#endif
		ef->pt = pt;
		vramdraw_scrn2rect(&scrn.s, &ef->r);
		ef->r2.left = pt.x;
		ef->r2.top = pt.y;
#ifndef SIZE_QVGA
		ef->r2.right = pt.x + scrn.s.width;
		ef->r2.bottom = pt.y + scrn.s.height;
#else
		ef->r2.right = pt.x + (ef->r.right - ef->r.left);
		ef->r2.bottom = pt.y + (ef->r.bottom - ef->r.top);
#endif
		return(effect_set(op));
	}
	return(GAMEEV_SUCCESS);
}