예제 #1
0
bool C4MusicFileOgg::Play(bool loop)
{
	// Load Song
	size_t iFileSize;
	if (!C4Group_ReadFile(FileName, &Data, &iFileSize))
		return false;

	// init fsound
	int loop_flag = loop ? FSOUND_LOOP_NORMAL : 0;
	stream = FSOUND_Stream_Open(Data, FSOUND_LOADMEMORY | FSOUND_NORMAL | FSOUND_2D | loop_flag, 0, iFileSize);

	if (!stream) return false;

	// Play Song
	Channel = FSOUND_Stream_Play(FSOUND_FREE, stream);
	if (Channel == -1) return false;

	// Set highest priority
	if (!FSOUND_SetPriority(Channel, 255))
		return false;

	Playing = true;

	FSOUND_Stream_SetEndCallback(stream, &C4MusicFileOgg::OnEnd, this);

	return true;
}
예제 #2
0
void LLAudioEngine_FMOD::stopInternetStream()
{
	if (mInternetStreamChannel != -1)
	{
		FSOUND_SetPaused(mInternetStreamChannel, true);
		FSOUND_SetPriority(mInternetStreamChannel, 0);
		mInternetStreamChannel = -1;
	}

	if (mCurrentInternetStreamp)
	{
		llinfos << "Stopping internet stream: " << mCurrentInternetStreamp->getURL() << llendl;
		if (mCurrentInternetStreamp->stopStream())
		{
			delete mCurrentInternetStreamp;
		}
		else
		{
			llwarns << "Pushing stream to dead list: " << mCurrentInternetStreamp->getURL() << llendl;
			mDeadStreams.push_back(mCurrentInternetStreamp);
		}
		mCurrentInternetStreamp = NULL;
		//mInternetStreamURL.clear();
	}
}
예제 #3
0
bool C4MusicFileMP3::Play(bool loop)
{
#ifndef USE_MP3
	return false;
#endif

	// Load Song
	size_t iFileSize;
	if (!C4Group_ReadFile(FileName, &Data, &iFileSize))
		return false;

	// init fsound
	int loop_flag = loop ? FSOUND_LOOP_NORMAL : 0;
	stream = FSOUND_Stream_Open(Data, FSOUND_LOADMEMORY | FSOUND_NORMAL | FSOUND_2D | loop_flag, 0, iFileSize);

	if (!stream) return false;

	// Play Song
	Channel = FSOUND_Stream_Play(FSOUND_FREE, stream);
	if (Channel == -1) return false;

	// Set highest priority
	if (!FSOUND_SetPriority(Channel, 255))
		return false;

	return true;
}
bool InitApp(HINSTANCE hInstance, int nCmdShow)
{
	WNDCLASS			WinClass;

	//------------------------------------------------------------------
	//			Histoire d'avoir un joli fichier log
	//------------------------------------------------------------------

	debug << "---------------------------------------------------------------\n";
	debug << "Blip & Blop - (c) LOADED Studio - " << __DATE__ << "\n";
	debug << "---------------------------------------------------------------\n";

	//------------------------------------------------------------------
	//			Precalculs mathématiques
	//------------------------------------------------------------------

	preCalcMathsFunctions();


	//------------------------------------------------------------------
	//			FMOD / Sons
	//------------------------------------------------------------------

	if (!FSOUND_Init(22050, CHANNEL_NUMBER, 0)) {
		Warning("Cannot initialise FMOD. Sound will be turned off.");
		LOGI("BUG AUDIO");
		sound_on = false;
		music_on = false;
	} else {
		// Pour éviter que les musiques ne se fassent écraser par les sons
		//
		FSOUND_SetPriority(0, 255);
	}


	//------------------------------------------------------------------
	//			Timer
	//------------------------------------------------------------------

	LInitTimer();


	//------------------------------------------------------------------
	//			Charge la configuration
	//------------------------------------------------------------------


	load_BB3_config(CONFIG_FILE);

	//------------------------------------------------------------------
	//			Charge les hi scores
	//------------------------------------------------------------------

	hi_scores.init();

	if (!hi_scores.load(HISCORES_FILE)) {
		debug << "Cannot load hi-scores file. Use default hi-scores\n";
		hi_scores.init();
	} else {
		debug << "Using " << HISCORES_FILE << " as hiscores file\n";
	}


	//------------------------------------------------------------------
	//			Les fichiers textes
	//------------------------------------------------------------------

	if (lang_type == LANG_UK) {
		if (!loadTxtData("data/uk.dat")) {
			Bug("Cannot open the file 'data/uk.dat'");
			ReleaseAll();
			return false;
		}
	} else {
		if (!loadTxtData("data/fr.dat")) {
			Bug("Cannot open the file 'data/fr.dat'");
			ReleaseAll();
			return false;
		}
	}


	//------------------------------------------------------------------
	//			Direct Input
	//------------------------------------------------------------------


	if (!in.open(WinHandle, hInstance)) {
		Bug("Cannot initialise DirectInput. Make sure DirectX 7 or better is installed.");
		ReleaseAll();
		return false;
	}

	debug << "DI Initialized\n";

	//------------------------------------------------------------------
	//			Direct Draw (1ère partie)
	//------------------------------------------------------------------
	LOGI("first");
	if (!DDInitDirectDraw()) {
		Bug("Cannot initialise DirectDraw. Make sure DirectX 7 or better is installed.");
		ReleaseAll();
		return false;
	}

	debug << "DD Initialized\n";


	active = true;	//Activate the game loop
	LOGI("second");

	if (!DDSetCooperativeLevel(WinHandle)) {
		Bug("Cannot get EXCLUSIVE MODE. Close all other applications and launch Blip'n Blop again");
		ReleaseAll();
		return false;
	}

	debug << "Exclusive mode set\n";
	LOGI("third");

	static const int BEST_RATE = 85;

	if (safeMode) {
		debug << "Safe mode enabled, using default 640x480x16 refresh rate.\n";
		winSet = false;

		if (!DDSetGfxMode(640, 480, 16)) {
			Bug("Cannot set display mode to 640x480x16. Are you sure your video card meets the requirements ?");
			ReleaseAll();
			return false;
		}
	} else {

			debug << "Trying to create window\n";
			if (!DDSetGfxMode(640, 480, 16)) {
				Bug("Cannot set display mode to 640x480x16. Are you sure your video card meets the requirements ?");
				ReleaseAll();
				return false;
			}
			debug << "Window creation done\n";

	}

	LOGI("fouth");



	//------------------------------------------------------------------
	//			Direct Draw (suite)
	//------------------------------------------------------------------

	// Crée la surface primaire avec double buffer
	debug << "Creating primSurface\n";
	primSurface = DDCreatePrimary(backSurface);

	if (primSurface == NULL || backSurface == NULL) {
		Bug("Cannot get a primary surface. Please reboot your PC and try to launch Blip'n Blop again.\nBe sure you have at least 2 Mb of video memory on your video card.");
		ReleaseAll();
		return false;
	}
	debug << "primSurface created\n";

	LOGI("fifth");

	//------------------------------------------------------------------
	//			Surface système
	//------------------------------------------------------------------
	debug << "Creating systemSurface\n";
	systemSurface = DDCreateSurface(640, 480, DDSURF_SYSTEM);

	if (systemSurface == NULL) {
		Bug("Not enough memory. Blip'n Blop needs 32 Mo of free memory. Try to close all other applications and launch Blip'n Blop again.");
		ReleaseAll();
		return false;
	}
	debug << "systemSurface created\n";
	LOGI("sixth");


	//------------------------------------------------------------------
	//			LGX paker
	//------------------------------------------------------------------
	debug << "Initializing LGXpaker\n";
	if (!LGXpaker.init(primSurface)) {
		Bug("Cannot initialise LGX paker. Please get the latest drivers for your video card.");
		ReleaseAll();
		return false;
	}
	debug << "LGXpaker initialized\n";
	LOGI("seventh");

	//------------------------------------------------------------------
	//			Scroll buffers
	//------------------------------------------------------------------

	debug << "Creating video buffer of size " << (WANTED_VBUFFER_WIDE) << "...";
	videoA = DDCreateSurface(WANTED_VBUFFER_WIDE, 480, DDSURF_VIDEO);

	if (videoA == NULL) {
		debug << "Failed\n";
		debug << "Creating video buffer of size " << (WANTED_VBUFFER_WIDE - 100) << "...";
		videoA = DDCreateSurface(WANTED_VBUFFER_WIDE - 100, 480, DDSURF_VIDEO);

		if (videoA == NULL) {
			debug << "Failed\n";
			debug << "Creating video buffer (" << (WANTED_VBUFFER_WIDE - 200) << ")...";
			videoA = DDCreateSurface(WANTED_VBUFFER_WIDE - 200, 480, DDSURF_VIDEO);

			if (videoA == NULL) {
				debug << "Failed\n";
				videoA = DDCreateSurface(WANTED_VBUFFER_WIDE, 480, DDSURF_SYSTEM);

				if (videoA == NULL) {
					Bug("Not enough memory. Blip'n Blop needs 32 Mo of free memory. Try to close all other applications and launch Blip'n Blop again.");
					ReleaseAll();
					return false;
				}

				debug << "Cannot create video buffer. Use system buffer instead.\n";
				vbuffer_wide = WANTED_VBUFFER_WIDE;
				mem_flag = DDSURF_SYSTEM;
				video_buffer_on = false;
			} else {
				debug << "Ok\n";
				vbuffer_wide = WANTED_VBUFFER_WIDE - 200;
			}
		} else {
			debug << "Ok\n";
			vbuffer_wide = WANTED_VBUFFER_WIDE - 100;
		}
	} else {
		debug << "Ok\n";
		vbuffer_wide = WANTED_VBUFFER_WIDE;
	}

	LOGI("eighth");

	//------------------------------------------------------------------
	//			Chargement des fontes init
	//------------------------------------------------------------------

	if (!fnt_menu.load("data/menu.lft", mem_flag)) {
		Bug("Cannot open the file data/menu.lft");
		ReleaseAll();
		return false;
	}

	LOGI("nineth");

	if (!fnt_menus.load("data/menus.lft", mem_flag)) {
		Bug("Cannot open the file data/menus.lft");
		ReleaseAll();
		return false;
	}

	if (!fnt_cool.load("data/cool.lft", mem_flag)) {
		Bug("Cannot open the file data/cool.lft");
		ReleaseAll();
		return false;
	}

	if (!fnt_rpg.load("data/rpg.lft", mem_flag)) {
		Bug("Cannot open the file data/rpg.lft");
		ReleaseAll();
		return false;
	}

	LOGI("erz");

	//------------------------------------------------------------------
	//			Chargement de l'interface
	//------------------------------------------------------------------

	if (!pbk_inter.loadGFX("data/inter.gfx", DDSURF_BEST)) {
		debug << "Cannot load interface.\n";
		return false;
	} else {
		debug << "Successfully loaded interface.\n";
	}

	if (!mbk_inter.open("data/inter.mbk", false)) {
		debug << "Cannot load interface musics.\n";
		return false;
	}

	if (!mbk_interl.open("data/interl.mbk", true)) {
		debug << "Cannot load interface musics (p2).\n";
		return false;
	}
	LOGI("END");

	//------------------------------------------------------------------
	//			Mémoire video restante
	//------------------------------------------------------------------

	//------------------------------------------------------------------
	//			Mise en place du TIMER pour obtenir les FPS
	//------------------------------------------------------------------

	SetTimer(WinHandle, 1, 1000, NULL);

	return true; // C'est fini!

} // Init ---------------------------