Exemple #1
0
Menu::Menu(int m_x, int m_y, int m_w, int m_h)
{
	this->m_x = m_x;
	this->m_y = m_y;
	this->m_w = m_w;
	this->m_h = m_h;

	running = true;

	bgrect.x = m_x;
	bgrect.y = m_y;
	bgrect.h = m_h;
	bgrect.w = m_w;
	int sliderCount = 1;
	int offset = (m_h/sliderCount+1)/(sliderCount+1);
	printf("%d", offset);
	for(int n = 0; n < sliderCount; ++n){
		sliders.push_back(new Slider(m_x + 20, m_y + offset*((n)) + offset/2 + (m_h/(sliderCount+1))*n, m_w - 40, m_h / (sliderCount + 1)));
	}
	sliders[0]->setValue(getMusicVolume());
	setMusicVolume(sliders[0]->getValue());
	//sliders[1]->setValue(66);


	/*sliders.push_back(new Slider(m_x + 20, m_y + offset, m_w -40, m_h / (sliderCount+1))); // Pushback Slider* 
	sliders.push_back(new Slider(m_x + 20, m_y + offset + 1*m_h /(sliderCount+1)+(offset*1), m_w -40, m_h/(sliderCount+1)));
	sliders.push_back(new Slider(m_x + 20, m_y + offset + 2*m_h /(sliderCount+1)+(offset*2), m_w -40, m_h/(sliderCount+1)));
	sliders.push_back(new Slider(m_x + 20, m_y + offset + 3*m_h /(sliderCount+1)+(offset*3), m_w -40, m_h/(sliderCount+1)));
	sliders.push_back(new Slider(m_x + 20, m_y + offset + 4*m_h /(sliderCount+1)+(offset*4), m_w -40, m_h/(sliderCount+1)));
	*/
}
/*
-------------------- Initialization functions for the SoundManager2 class --------------------
*/
bool SoundManager2::initialize( bool debug_flag ){
    setDebug( debug_flag );
    activate();
    setMusicVolume(255);
    setSoundEffectVolume(255);
    setMusicChannel(1);
    setSwapMusicChannel(2);
    setInitialSoundEffectChannel(3);    
    setSoundEffectChannel(getInitialSoundEffectChannel());
    setMaxChannels(64);

    bool initialized = FSOUND_Init (44100, getMaxChannels(), 0);

    if(isDebug()){
        printf("SoundManager Initialization (debug: %i):\n", isDebug());
        printf("\tActive: %i\n", isActive());
        printf("\tMusic Volume: %i\n", getMusicVolume());
        printf("\tSound Effect Volume: %i\n", getSoundEffectVolume());
        printf("\tSound Effect Channel: %i\n", getSoundEffectChannel());
        printf("\tMusic Channel: %i\n", getMusicChannel());
        printf("\tSwap Music Channel: %i\n", getSwapMusicChannel());
        printf("\tInitial Sound Effect Channel: %i\n", getInitialSoundEffectChannel());
        printf("\tMusic Channel: %i\n", getMusicChannel());
    }

    return initialized;

}
Exemple #3
0
bool playMOD (int f, int a, int fromTrack) {
	if (soundOK) {

		stopMOD (a);

		setResourceForFatal (f);
		uint32_t length = openFileFromNum (f);
		if (length == 0) return NULL;

		char * memImage;
		memImage = loadEntireFileToMemory (bigDataFile, length);
		if (! memImage) return fatal (ERROR_MUSIC_MEMORY_LOW);

		mod[a] = BASS_MusicLoad (true, memImage, 0, length, BASS_MUSIC_LOOP|BASS_MUSIC_RAMP/*|BASS_MUSIC_PRESCAN needed too if we're going to set the position in bytes*/, 0);
		delete memImage;

		if (! mod[a]) {

		}
		else
		{
			setMusicVolume (a, defVol);

			if (! BASS_ChannelPlay (mod[a], true) )
				debugOut("playMOD: Error %d!\n", BASS_ErrorGetCode());

			BASS_ChannelSetPosition (mod[a], MAKELONG(fromTrack, 0), BASS_POS_MUSIC_ORDER);
			BASS_ChannelFlags(mod[a], BASS_SAMPLE_LOOP|BASS_MUSIC_RAMP, BASS_SAMPLE_LOOP|BASS_MUSIC_RAMP);
		}
		setResourceForFatal (-1);
	}
    return true;
}
Exemple #4
0
int WINAPI wWinMain(HINSTANCE _hInstance, HINSTANCE _hPrevInstance, LPWSTR _lpCmdLine, int _nCmdShow)
{
	_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
	srand((unsigned)time(0));

	// Load config into config file class
	g_configFile = new ConfigFile();
	g_configFile->load();

	// Init window
	HWND hwnd = 0;
	if((hwnd = InitWindow(_hInstance, _nCmdShow, g_configFile->getScreenSize())) == 0)
	{
		return 0;
	}
	
	initSoundEngine();
	
	setMusicVolume(g_configFile->getMusicVolume());
	setSoundVolume(g_configFile->getSoundVolume());
	
	ClientHandler* clientHandler = new ClientHandler(hwnd);
	HRESULT hr = clientHandler->run();
	delete clientHandler;
	
	deleteSoundEngine();

	return hr;
}
void SDLSound::playMusic(const char* directory)
{
    // Part1: scan directory for music files
    char **list = filesystem::enumerateFiles(directory);
    setMusicVolume(gameconfig->sound.getMusicVol());

    musicfiles.clear();
    for (char **i = list; *i != NULL; i++) {
        std::string filename = directory;
        filename.append(*i);
        if (!filesystem::isDirectory(filename.c_str())) {
            musicfiles.push_back(filename);
        }
    }
    filesystem::freeList(list);

    if(musicfiles.size() == 0) {
        LOGGER.info("Couldn't find any music in '%s'", directory);
        return;
    }

    // Part2: play music :)
    currentsong = musicfiles.end();
    nextSong();
    Mix_HookMusicFinished(nextSong);
}
Sound::Sound()
    : currentMusic(0)
{
    assert( soundPtr == 0);
    soundPtr = this;
    loaderThread = 0;

    //Load Sound
    audioOpen = false;
    /* Open the audio device */
    if (Mix_OpenAudio( MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 2, 2048) < 0) {
        fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError());
        return;
    } else {
        audioOpen = true;
        loaderThread = SDL_CreateThread(soundThread, this);
    }

    setMusicVolume(getConfig()->musicVolume);
    setSoundVolume(getConfig()->soundVolume);

    // for now...
    //playMusic("01 - pronobozo - lincity.ogg");
    playMusic( getConfig()->playSongName );
}
        void SettingsMenu::doSave()
        {
            auto settings = Game::getInstance()->settings();
            settings->setCombatDifficulty(((UI::MultistateImageButton*)getUI("combat_difficulty"))->state());
            settings->setGameDifficulty(((UI::MultistateImageButton*)getUI("game_difficulty"))->state());
            settings->setViolenceLevel(((UI::MultistateImageButton*)getUI("violence_level"))->state());
            settings->setTargetHighlight(((UI::MultistateImageButton*)getUI("target_highlight"))->state());
            settings->setCombatLooks(((UI::MultistateImageButton*)getUI("combat_looks"))->state());
            settings->setCombatMessages(((UI::MultistateImageButton*)getUI("combat_messages"))->state());
            settings->setCombatTaunts(((UI::MultistateImageButton*)getUI("combat_taunts"))->state());
            settings->setLanguageFilter(((UI::MultistateImageButton*)getUI("language_filter"))->state());
            settings->setRunning(((UI::MultistateImageButton*)getUI("running"))->state());
            settings->setSubtitles(((UI::MultistateImageButton*)getUI("subtitles"))->state());
            settings->setItemHighlight(((UI::MultistateImageButton*)getUI("item_highlight"))->state());

            settings->setMasterVolume(((UI::Slider*)getUI("master_volume"))->value());
            settings->setMusicVolume(((UI::Slider*)getUI("music_volume"))->value());
            settings->setVoiceVolume(((UI::Slider*)getUI("voice_volume"))->value());
            settings->setSfxVolume(((UI::Slider*)getUI("sfx_volume"))->value());

            settings->setTextDelay(((UI::Slider*)getUI("text_delay"))->value());
            settings->setCombatSpeed(((UI::Slider*)getUI("combat_speed"))->value());
            settings->setBrightness(((UI::Slider*)getUI("brightness"))->value());
            settings->setMouseSensitivity(((UI::Slider*)getUI("mouse_sensitivity"))->value());

            settings->setPlayerSpeedup(((UI::ImageButton*)getUI("player_speedup"))->checked());

            settings->save();
            Game::getInstance()->popState();
        }
Exemple #8
0
JNIEXPORT void JNICALL Java_com_nooskewl_monsterrpg2_MyBroadcastReceiver_pauseSound
  (JNIEnv *env, jobject obj)
{
	backup_music_volume = getMusicVolume();
	backup_ambience_volume = getAmbienceVolume();
	setMusicVolume(0.0);
	setAmbienceVolume(0.0);
}
Exemple #9
0
void __fastcall__ addToMusicVolume(char add)
{
  char musicVolume = getMusicVolume() + add;
  musicVolume &= 15;
	enterNumberInMenuItem(caMenus[menu][1] + 13, musicVolume);
	drawMenuItem(item);
  setMusicVolume(musicVolume);
}
Exemple #10
0
void testmusic(){
	while(1){		
		playMusic();
		for(int i=0;i<100000000;i++);	
		setMusicVolume(140);
		for(int i=0;i<100000000;i++);
		stopMusic();
		for(int i=0;i<100000000;i++);
	}
}
Exemple #11
0
void Sound::optionChanged(const std::string &value)
{
    if (value == "playBattleSound")
        mPlayBattle = config.getBoolValue("playBattleSound");
    else if (value == "playGuiSound")
        mPlayGui = config.getBoolValue("playGuiSound");
    else if (value == "playMusic")
        mPlayMusic = config.getBoolValue("playMusic");
    else if (value == "sfxVolume")
        setSfxVolume(config.getIntValue("sfxVolume"));
    else if (value == "musicVolume")
        setMusicVolume(config.getIntValue("musicVolume"));
}
Exemple #12
0
void SoundManager::optionChanged(const std::string &value)
{
    if (value == "playBattleSound")
        mPlayBattle = config.getBoolValue("playBattleSound");
    else if (value == "playGuiSound")
        mPlayGui = config.getBoolValue("playGuiSound");
    else if (value == "playMusic")
        mPlayMusic = config.getBoolValue("playMusic");
    else if (value == "sfxVolume")
        setSfxVolume(config.getIntValue("sfxVolume"));
    else if (value == "musicVolume")
        setMusicVolume(config.getIntValue("musicVolume"));
    else if (value == "fadeoutmusic")
        mFadeoutMusic = config.getIntValue("fadeoutmusic");
    else if (value == "uselonglivesounds")
        mCacheSounds = config.getIntValue("uselonglivesounds");
}
Exemple #13
0
Player_V2CMS::Player_V2CMS(ScummEngine *scumm, Audio::Mixer *mixer)
	: Player_V2Base(scumm, mixer, true), _cmsVoicesBase(), _cmsVoices(),
	  _cmsChips(), _midiDelay(0), _octaveMask(0), _looping(0), _tempo(0),
	  _tempoSum(0), _midiData(0), _midiSongBegin(0), _musicTimer(0),
	  _musicTimerTicks(0), _voiceTimer(0), _loadedMidiSong(0),
	  _outputTableReady(0), _midiChannel(), _midiChannelUse() {
	setMusicVolume(255);

	_cmsVoices[0].amplitudeOutput = &_cmsChips[0].ampl[0];
	_cmsVoices[0].freqOutput = &_cmsChips[0].freq[0];
	_cmsVoices[0].octaveOutput = &_cmsChips[0].octave[0];
	_cmsVoices[1].amplitudeOutput = &_cmsChips[0].ampl[1];
	_cmsVoices[1].freqOutput = &_cmsChips[0].freq[1];
	_cmsVoices[1].octaveOutput = &_cmsChips[0].octave[0];
	_cmsVoices[2].amplitudeOutput = &_cmsChips[0].ampl[2];
	_cmsVoices[2].freqOutput = &_cmsChips[0].freq[2];
	_cmsVoices[2].octaveOutput = &_cmsChips[0].octave[1];
	_cmsVoices[3].amplitudeOutput = &_cmsChips[0].ampl[3];
	_cmsVoices[3].freqOutput = &_cmsChips[0].freq[3];
	_cmsVoices[3].octaveOutput = &_cmsChips[0].octave[1];
	_cmsVoices[4].amplitudeOutput = &_cmsChips[1].ampl[0];
	_cmsVoices[4].freqOutput = &_cmsChips[1].freq[0];
	_cmsVoices[4].octaveOutput = &_cmsChips[1].octave[0];
	_cmsVoices[5].amplitudeOutput = &_cmsChips[1].ampl[1];
	_cmsVoices[5].freqOutput = &_cmsChips[1].freq[1];
	_cmsVoices[5].octaveOutput = &_cmsChips[1].octave[0];
	_cmsVoices[6].amplitudeOutput = &_cmsChips[1].ampl[2];
	_cmsVoices[6].freqOutput = &_cmsChips[1].freq[2];
	_cmsVoices[6].octaveOutput = &_cmsChips[1].octave[1];
	_cmsVoices[7].amplitudeOutput = &_cmsChips[1].ampl[3];
	_cmsVoices[7].freqOutput = &_cmsChips[1].freq[3];
	_cmsVoices[7].octaveOutput = &_cmsChips[1].octave[1];

	// inits the CMS Emulator like in the original
	_cmsEmu = new CMSEmulator(_sampleRate);
	for (int i = 0, cmsPort = 0x220; i < 2; cmsPort += 2, ++i) {
		for (int off = 0; off < 13; ++off) {
			_cmsEmu->portWrite(cmsPort+1, _cmsInitData[off*2]);
			_cmsEmu->portWrite(cmsPort, _cmsInitData[off*2+1]);
		}
	}

	_mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true);
}
GameSound::GameSound()
{
  // load sounds
  QString sndpath = GameWidget::getResourcePath() + "sounds/";

  loadSound(sndpath + "disappear.wav");
  loadSound(sndpath + "smallhammer.wav");
  loadSound(sndpath + "unblock.wav");
  loadSound(sndpath + "hammer.wav");
  loadSound(sndpath + "bighammer.wav");
  loadSound(sndpath + "bomb.wav");
  loadSound(sndpath + "row.wav");
  loadSound(sndpath + "randomkill.wav");
  loadSound(sndpath + "mixer.wav");
  loadSound(sndpath + "twin.wav");
  loadSound(sndpath + "clock.wav");
  loadSound(sndpath + "bonusend.wav");
  loadSound(sndpath + "newitem.wav");
  loadSound(sndpath + "target.wav");
  loadSound(sndpath + "levelstart.wav");
  loadSound(sndpath + "levelfail.wav");
  loadSound(sndpath + "levelwon.wav");
  loadSound(sndpath + "beep.wav");
  loadSound(sndpath + "bonus.wav");
  loadSound(sndpath + "newtool.wav");

  // music
  music = 0;
  musicEnabled = false;
  musicPlaying = false;

  myTimer = new QTimer(this);
  myTimer->setInterval(1000);
  connect(myTimer, SIGNAL(timeout()), this, SLOT(checkPlayMusic()));
  myTimer->stop();

  // setup volume
  setChannelVolume(MIX_MAX_VOLUME);
  setMusicVolume(MIX_MAX_VOLUME/4);
}
bool playMOD (int f, int a, int fromTrack) {
	if (! soundOK) return true;
	stopMOD (a);

	setResourceForFatal (f);
	uint32_t length = openFileFromNum (f);
	if (length == 0) {
		finishAccess();
		setResourceForFatal (-1);
		return false;
	}

	unsigned char * memImage;
	memImage = (unsigned char *) loadEntireFileToMemory (bigDataFile, length);
	if (! memImage) return fatal (ERROR_MUSIC_MEMORY_LOW);

	modCache[a].stream = alureCreateStreamFromMemory(memImage, length, 19200, 0, NULL);
	delete memImage;

	if (modCache[a].stream != NULL) {
		setMusicVolume (a, defVol);
		if (! alureSetStreamOrder (modCache[a].stream, fromTrack)) {
			debugOut( "Failed to set stream order: %s\n",
						alureGetErrorString());
		}

		playStream (a, true, true);

	} else {
		debugOut("Failed to create stream from MOD: %s\n",
						alureGetErrorString());
		warning (ERROR_MUSIC_ODDNESS);
		soundCache[a].stream = NULL;
		soundCache[a].playing = false;
		soundCache[a].playingOnSource = 0;
	}
	setResourceForFatal (-1);

	return true;
}
SoundManager::SoundManager()
{
	int audio_rate = 22050;
	Uint16 audio_format = MIX_DEFAULT_FORMAT;
	int audio_channels = 2;
	int audio_buffers = 4096;

    if(SDL_Init(SDL_INIT_AUDIO) == -1)
    {
        std::cout << "Unable to initialize audio in SoundManager" << std::endl;
        SDL_Quit();
    }

	if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers))
	{
		std::cout << "Unable to open audio" << std::endl;
		SDL_Quit();
	}
	soundVolume = 60;
	musicVolume = 60;
	setMusicVolume(musicVolume);
	setSoundVolume(soundVolume);
}
Exemple #17
0
void AudioManager::muteMusic(bool muted) {
	setMusicVolume(muted ? 0 : 255);
	_musicMuted = muted;
}
 void SoundsManager::init(Settings config)
 {
     setGlobalVolume(config.getGlobalVolume());
     setInGameVolume(config.getInGameVolume());
     setMusicVolume(config.getMusicVolume());
 }
Exemple #19
0
AudioManager *SDLAudioManager::setGlobalVolume(float volume) {
	REQUIRE(volume >= 0.0f && volume <= 1.0f, "Volume must be in the range 0.0f <= volume <= 1.0f.");
	return setMusicVolume(volume)->setSoundVolume(volume);
}
Exemple #20
0
/**
 * Initialises OpenJazz.
 *
 * Establishes the paths from which to read files, loads configuration, sets up
 * the game window and loads required data.
 *
 * @param argc Number of arguments, as passed to main function
 * @param argv Array of argument strings, as passed to main function
 */
void startUp (int argc, char *argv[]) {

	File* file;
	unsigned char* pixels = NULL;
	int count;
	int screenW = DEFAULT_SCREEN_WIDTH;
	int screenH = DEFAULT_SCREEN_HEIGHT;
	int scaleFactor = 1;
#ifdef FULLSCREEN_ONLY
	bool fullscreen = true;
#else
	bool fullscreen = false;
#endif


	// Determine paths

	// Use hard-coded paths, if available

#ifdef DATAPATH
	firstPath = new Path(NULL, createString(DATAPATH));
#else
	firstPath = NULL;
#endif

#ifdef __HAIKU__
	dev_t volume = dev_for_path("/boot");
	char buffer[10 + B_PATH_NAME_LENGTH + B_FILE_NAME_LENGTH];
	status_t result;

	result = find_directory(B_SYSTEM_DATA_DIRECTORY,
		volume, false, buffer, sizeof(buffer));
	strncat(buffer, "/openjazz/", sizeof(buffer));
	firstPath = new Path(firstPath, createString(buffer));

	result = find_directory(B_USER_NONPACKAGED_DATA_DIRECTORY,
		volume, false, buffer, sizeof(buffer));
	strncat(buffer, "/openjazz/", sizeof(buffer));
	firstPath = new Path(firstPath, createString(buffer));
#endif

#ifdef __SYMBIAN32__
	#ifdef UIQ3
	firstPath = new Path(firstPath, createString("c:\\shared\\openjazz\\"));
	#else
	firstPath = new Path(firstPath, createString("c:\\data\\openjazz\\"));
	#endif
	firstPath = new Path(firstPath, createString(KOpenJazzPath));
#endif


	// Use any provided paths, appending a directory separator as necessary

	for (count = 1; count < argc; count++) {

		// If it isn't an option, it should be a path
		if (argv[count][0] != '-') {

#ifdef _WIN32
			if (argv[count][strlen(argv[count]) - 1] != '\\') {

				firstPath = new Path(firstPath, createString(argv[count], "\\"));
#else
			if (argv[count][strlen(argv[count]) - 1] != '/') {

				firstPath = new Path(firstPath, createString(argv[count], "/"));
#endif

			} else {

				firstPath = new Path(firstPath, createString(argv[count]));

			}

		}

	}

	// Use the path of the program, but not on Wii as this does crash in
	// dolphin emulator. Also is not needed, because CWD is used there

#ifndef WII
	count = strlen(argv[0]) - 1;

	// Search for directory separator
#ifdef _WIN32
	while ((argv[0][count] != '\\') && (count >= 0)) count--;
#else
	while ((argv[0][count] != '/') && (count >= 0)) count--;
#endif

	// If a directory was found, copy it to the path
	if (count > 0) {

		firstPath = new Path(firstPath, new char[count + 2]);
		memcpy(firstPath->path, argv[0], count + 1);
		firstPath->path[count + 1] = 0;

	}
#endif


	// Use the user's home directory, if available

#ifdef HOMEDIR
	#ifdef _WIN32
	firstPath = new Path(firstPath, createString(getenv("HOME"), "\\"));
	#else
	firstPath = new Path(firstPath, createString(getenv("HOME"), "/."));
	#endif
#endif


	// Use the current working directory

	firstPath = new Path(firstPath, createString(""));



	// Default settings

	// Sound settings
#if defined(WIZ) || defined(GP2X)
	volume = 40;
#endif

	// Create the network address
	netAddress = createString(NET_ADDRESS);


	// Load settings from config file
	setup.load(&screenW, &screenH, &fullscreen, &scaleFactor);


	// Get command-line override
	for (count = 1; count < argc; count++) {

		// If there's a hyphen, it should be an option
		if (argv[count][0] == '-') {

#ifndef FULLSCREEN_ONLY
			if (argv[count][1] == 'f') fullscreen = true;
#endif
			if (argv[count][1] == 'm') {
				setMusicVolume(0);
				setSoundVolume(0);
			}

		}

	}


	// Create the game's window

	canvas = NULL;

	if (!video.init(screenW, screenH, fullscreen)) {

		delete firstPath;

		throw E_VIDEO;

	}

#ifdef SCALE
	video.setScaleFactor(scaleFactor);
#endif


	if (SDL_NumJoysticks() > 0) SDL_JoystickOpen(0);


	// Set up audio
	openAudio();



	// Load fonts

	// Open the panel, which contains two fonts

	try {

		file = new File("PANEL.000", false);

	} catch (int e) {

		closeAudio();

		delete firstPath;

		log("Unable to find game data files. When launching OpenJazz, pass the location");
		log("of the original game data, eg:");
		log("  OpenJazz ~/jazz1");

#ifdef __HAIKU__
		char alertBuffer[100+B_PATH_NAME_LENGTH+B_FILE_NAME_LENGTH];
		strcpy(alertBuffer, "Unable to find game data files!\n"
			"Put the data into the folder:\n");
		strncat(alertBuffer, buffer, sizeof(alertBuffer));
		BAlert* alert = new BAlert("OpenJazz", alertBuffer, "Exit", NULL, NULL,
			B_WIDTH_AS_USUAL, B_STOP_ALERT);
		alert->Go();
#endif

		throw e;

	}

	pixels = file->loadRLE(46272);

	delete file;

	panelBigFont = NULL;
	panelSmallFont = NULL;
	font2 = NULL;
	fontbig = NULL;
	fontiny = NULL;
	fontmn1 = NULL;

	try {

		panelBigFont = new Font(pixels + (40 * 320), true);
		panelSmallFont = new Font(pixels + (48 * 320), false);
		font2 = new Font("FONT2.0FN");
		fontbig = new Font("FONTBIG.0FN");
		fontiny = new Font("FONTINY.0FN");
		fontmn1 = new Font("FONTMN1.0FN");
		fontmn2 = new Font("FONTMN2.0FN");

	} catch (int e) {

		if (panelBigFont) delete panelBigFont;
		if (panelSmallFont) delete panelSmallFont;
		if (font2) delete font2;
		if (fontbig) delete fontbig;
		if (fontiny) delete fontiny;
		if (fontmn1) delete fontmn1;

		delete[] pixels;

		closeAudio();

		delete firstPath;

		throw e;

	}

	delete[] pixels;


	// Establish arbitrary timing
	globalTicks = SDL_GetTicks() - 20;


	// Fill trigonometric function look-up tables
	for (count = 0; count < 1024; count++)
		sinLut[count] = fixed(sinf(2 * PI * float(count) / 1024.0f) * 1024.0f);


	// Initiate networking
	net = new Network();


	level = NULL;
	jj2Level = NULL;

}


/**
 * De-initialises OpenJazz.
 *
 * Frees data, writes configuration, and shuts down SDL.
 */
void shutDown () {

	delete net;

	delete panelBigFont;
	delete panelSmallFont;
	delete font2;
	delete fontbig;
	delete fontiny;
	delete fontmn1;
	delete fontmn2;

#ifdef SCALE
	if (video.getScaleFactor() > 1) SDL_FreeSurface(canvas);
#endif

	closeAudio();


	// Save settings to config file
	setup.save();


	delete firstPath;

}
Exemple #21
0
int main( int argc, char *argv[] ) {
  char *path;
  list *l;
#ifdef SOUND
  int c;
#endif

#ifdef __FreeBSD__
  fpsetmask(0);
#endif

#ifdef macintosh
    setupHomeEnvironment ();
#endif

  SystemInit(&argc, argv);

#ifndef CURRENT_EQ_DATA_DIR
  goto_installpath(argv[0]);
#endif

  /* initialize artpack list before loading settigns! */
  initArtpacks();

  path = getFullPath("settings.txt");
  if(path != NULL)
    initMainGameSettings(path); /* reads defaults from ~/.gltronrc */
  else {
    printf("fatal: could not settings.txt, exiting...\n");
    exit(1);
  }

  parse_args(argc, argv);

  consoleInit();
  initGameStructures();
  resetScores();

  /* sound */
  path = getMusicPath(MUSIC_DIR);
  game->settings->soundList = 
    readDirectoryContents(path, SONG_PREFIX);
  
  game->settings->soundIndex = -1;

  l = game->settings->soundList;

#ifdef SOUND
  printf("initializing sound\n");
  initSound();
  setFxVolume(game->settings->fxVolume);

  if(l->next != NULL) {
    char *tmp;
    tmp = malloc(strlen(path) + 1 + /* seperator */
		 strlen((char*) l->data) + 1);
    sprintf(tmp, "%s%c%s", path, SEPERATOR, 
	    (char*) l->data);
    fprintf(stderr, "loading song %s\n", tmp);
    loadSound(tmp);
    free(tmp);
    game->settings->soundIndex = 0;
  }

  c = 0;
  while(l->next != NULL) {
    l = l->next;
    c++;
  }
  game->settings->soundSongCount = c;

  if(game->settings->playMusic)
    playSound();
  fprintf(stderr, "setting music volume to %.3f\n",
	  game->settings->musicVolume);
  setMusicVolume(game->settings->musicVolume);
  free(path);
#endif

  printf("loading menu\n");
  path = getFullPath("menu.txt");
  if(path != NULL)
    pMenuList = loadMenuFile(path);
  else {
    printf("fatal: could not load menu.txt, exiting...\n");
    exit(1);
  }
  printf("menu loaded\n");
  free(path);

  setupDisplay(game->screen);
  switchCallbacks(&guiCallbacks);
  switchCallbacks(&guiCallbacks);

  SystemMainLoop();

  return 0;
}
Exemple #22
0
  void FMODAudio::initialize()
  {
    FMOD_RESULT hr;

    mEngine->getConsole()->printf( Console::srcSound,
      L"Initializing FMOD Ex %x.%x.%x",
      HIWORD( FMOD_VERSION ), HIBYTE( LOWORD( FMOD_VERSION ) ),
      LOBYTE( LOWORD( FMOD_VERSION ) ) );

    refreshDrivers();
    refreshOutputTypes();
    refreshSpeakerModes();

    // Set output type
    setOutputType( stringToOutputType( g_CVar_fm_outputmode.getString() ) );

    // Set output device
    setDriver( g_CVar_fm_device.getInt() );

    // Get driver caps
    hr = mSystem->getDriverCaps( NULL, &mInfo.caps, &mInfo.rate, &mInfo.speakerMode );
    if ( FMOD_FAILED( hr ) )
      ENGINE_EXCEPT_FMOD( hr, "Failed to get driver caps" );

    // Print a warning and raise the DSP buffer if someone is poor enough to run on emulation
    if ( mInfo.caps & FMOD_CAPS_HARDWARE_EMULATED )
    {
      mEngine->getConsole()->printf( Console::srcSound,
        L"No hardware audio acceleration detected! Using software emulation!" );
      mSystem->setDSPBufferSize( 1024, 10 );
    }

    // Set speaker mode
    setSpeakerMode( stringToSpeakerMode( g_CVar_fm_speakermode.getString() ) );

    // Prepare flags
    FMOD_INITFLAGS fmodFlags = FMOD_INIT_NORMAL | FMOD_INIT_3D_RIGHTHANDED | FMOD_INIT_OCCLUSION_LOWPASS | FMOD_INIT_HRTF_LOWPASS | FMOD_INIT_GEOMETRY_USECLOSEST;
    FMOD_EVENT_INITFLAGS eventFlags = FMOD_EVENT_INIT_NORMAL;

    // Initialize the system
    int channels = g_CVar_fm_maxchannels.getInt();
    hr =  mEventSystem->init( channels, fmodFlags, nullptr, eventFlags );
    if ( FMOD_FAILED( hr ) )
      ENGINE_EXCEPT_FMOD( hr, "Failed to initialize FMOD EventSystem" );

    // Fetch realized values
    hr = mSystem->getSpeakerMode( &mInfo.speakerMode );
    if ( FMOD_FAILED( hr ) )
      ENGINE_EXCEPT_FMOD( hr, "getSpeakerMode failed" );
    mSystem->getOutput( &mInfo.outputType );
    if ( FMOD_FAILED( hr ) )
      ENGINE_EXCEPT_FMOD( hr, "getOutput failed" );
    mSystem->getDriver( &mInfo.driver );
    if ( FMOD_FAILED( hr ) )
      ENGINE_EXCEPT_FMOD( hr, "getDriver failed" );

    if ( mSettings.outputType != 0 )
      for ( size_t i = 0; i < mOutputTypes.size(); i++ )
        if ( ((FMODOutputType*)mOutputTypes[i])->fmodValue == mInfo.outputType )
        {
          mSettings.outputType = (int)i;
          break;
        }

    if ( mSettings.driver != 0 )
      for ( size_t i = 0; i < mDrivers.size(); i++ )
        if ( ((FMODDriver*)mDrivers[i])->fmodValue == mInfo.driver )
        {
          mSettings.driver = (int)i;
          break;
        }

    if ( mSettings.speakerMode != 0 )
      for ( size_t i = 0; i < mSpeakerModes.size(); i++ )
        if ( ((FMODSpeakerMode*)mSpeakerModes[i])->fmodValue == mInfo.speakerMode )
        {
          mSettings.speakerMode = (int)i;
          break;
        }

    // Log to console for good measure
    mEngine->getConsole()->printf( Console::srcSound,
      L"Speaker mode: %s", speakerModeToDisplayString( mInfo.speakerMode ).c_str() );
    mEngine->getConsole()->printf( Console::srcSound,
      L"Output type: %s", outputTypeToDisplayString( mInfo.outputType ).c_str() );

    // Setup channel groups
    hr = mSystem->getMasterChannelGroup( &mMasterGroup );
    if ( FMOD_FAILED( hr ) )
      ENGINE_EXCEPT_FMOD( hr, "Failed to get master channel group" );

    hr = mSystem->createChannelGroup( "music", &mMusicGroup );
    if ( FMOD_FAILED( hr ) )
      ENGINE_EXCEPT_FMOD( hr, "Failed to create music channel group" );
    hr = mMasterGroup->addGroup( mMusicGroup );
    if ( FMOD_FAILED( hr ) )
      ENGINE_EXCEPT_FMOD( hr, "Failed to assign music channel group" );

    hr = mSystem->createChannelGroup( "effect", &mEffectGroup );
    if ( FMOD_FAILED( hr ) )
      ENGINE_EXCEPT_FMOD( hr, "Failed to create effect channel group" );
    hr = mMasterGroup->addGroup( mEffectGroup );
    if ( FMOD_FAILED( hr ) )
      ENGINE_EXCEPT_FMOD( hr, "Failed to assign effect channel group" );

    // Set initial volumes
    setMasterVolume( g_CVar_fm_volume.getFloat() );
    setMusicVolume( g_CVar_fm_bgvolume.getFloat() );
    setEffectVolume( g_CVar_fm_fxvolume.getFloat() );

    mMusic = new FMODMusic( this );
    Locator::provideMusic( mMusic );

    mEngine->operationContinueAudio();
  }
Exemple #23
0
void Menu::UpdateVolume()
{
	setMusicVolume(sliders[0]->getValue());
}