コード例 #1
0
static void AQBufferCallback(
    void *in,
    AudioQueueRef inQ,
    AudioQueueBufferRef outQB)
{
    AQCallbackStruct * inData;
    short *coreAudioBuffer;
    inData = (AQCallbackStruct *)in;
    coreAudioBuffer = (short*) outQB->mAudioData;

    if (inData->frameCount > 0) {
		AudioQueueSetParameter(inQ, kAudioQueueParam_Volume, __audioVolume);
		sound_callback(NULL, (byte*)coreAudioBuffer, inData->frameCount * 4);
        outQB->mAudioDataByteSize = 4*inData->frameCount;
        AudioQueueEnqueueBuffer(inQ, outQB, 0, NULL);
    }
}
コード例 #2
0
void CBaseMonster::feel_sound_new(CObject* who, int eType, CSound_UserDataPtr user_data, const Fvector &Position, float power)
{
	if (!g_Alive())		return;

	// ignore my sounds
	if (this == who)	return;

	if (user_data)
		user_data->accept	(sound_user_data_visitor());

	// ignore unknown sounds
	if (eType == 0xffffffff) return;

	// ignore distant sounds
	Fvector center;
	Center	(center);
	float dist	= center.distance_to(Position);
	if (dist > db().m_max_hear_dist)	return;

	// ignore sounds if not from enemies and not help sounds
	CEntityAlive* entity = smart_cast<CEntityAlive*> (who);

	// ignore sound if enemy drop a weapon on death
	if (!entity && ((eType & SOUND_TYPE_ITEM_HIDING) == SOUND_TYPE_ITEM_HIDING)) return;

	if (entity && (!EnemyMan.is_enemy(entity))) {
		SoundMemory.check_help_sound(eType, entity->ai_location().level_vertex_id());
		return;
	}
	
	if ((eType & SOUND_TYPE_WEAPON_SHOOTING) == SOUND_TYPE_WEAPON_SHOOTING) power = 1.f;

	if (((eType & SOUND_TYPE_WEAPON_BULLET_HIT) == SOUND_TYPE_WEAPON_BULLET_HIT) && (dist < 2.f)) 
		HitMemory.add_hit(who,eSideFront);

	// execute callback
	sound_callback	(who,eType,Position,power);
	
	// register in sound memory
	if (power >= db().m_fSoundThreshold) {
		SoundMemory.HearSound(who,eType,Position,power,Device.dwTimeGlobal);
 	}
}
コード例 #3
0
bool OSystem_PalmOS5::setSoundCallback(SoundProc proc, void *param) {
	Err e;
	Boolean success = false;

	if (!_sound.active) {
		if (gVars->fmQuality != FM_QUALITY_INI) {
			ConfMan.setBool("FM_medium_quality", (gVars->fmQuality == FM_QUALITY_MED));
			ConfMan.setBool("FM_high_quality", (gVars->fmQuality == FM_QUALITY_HI));
		}

#if defined (COMPILE_OS5)
		CALLBACK_INIT(_soundEx);
#endif
		_sound.proc = proc;
		_sound.param = param;
		_sound.active = true;	// always true when we call this function, false when sound is off

		_soundEx.handle = 0;
		_soundEx.size = 0;		// set by the callback
		_soundEx.set = false;
		_soundEx.dataP = NULL;	// set by the handler

		if (ConfMan.hasKey("output_rate"))
			_samplesPerSec = ConfMan.getInt("output_rate");
		else
			_samplesPerSec = SAMPLES_PER_SEC;

		// try to create sound stream
		if (OPTIONS_TST(kOptPalmSoundAPI)) {
			e = SndStreamCreateExtended(
						&_soundEx.handle,
						sndOutput,
						sndFormatPCM,
						_samplesPerSec,
#ifdef PALMOS_68K
						sndInt16Big,
#else
						sndInt16Little,
#endif
						sndStereo,
						sound_callback(),
						&_soundEx,
						8192
#ifdef PALMOS_68K
						,false
#elif defined (COMPILE_OS5)
						,true
#endif
						);

			e = e ? e : SndStreamStart(_soundEx.handle);
			e = e ? e :	SndStreamSetVolume(_soundEx.handle, 1024L * gVars->palmVolume / 100);
			success = (e == errNone);

		// no Sound API
		} else {
			_soundEx.size = 512;
			_soundEx.dataP = MemPtrNew(_soundEx.size);
		}
	}
	// if not true some scenes (indy3 256,...) may freeze (ESC to skip)
	return true;
}
コード例 #4
0
ファイル: d_main.c プロジェクト: rodrigobmg/64doom
//
// D_DoomMain
//
void D_DoomMain(void)
{
    int  p;
    char file[256];

    IdentifyVersion ();

    modifiedgame = false;

    nomonsters = M_CheckParm("-nomonsters");
    respawnparm = M_CheckParm("-respawn");
    fastparm = M_CheckParm("-fast");
    devparm = M_CheckParm("-devparm");
    if (M_CheckParm("-altdeath"))
    {
        deathmatch = 2;
    }
    else if (M_CheckParm ("-deathmatch"))
    {
        deathmatch = 1;
    }

    switch (gamemode)
    {
    case retail:
        sprintf (title,
//		 "                         "
                 "The Ultimate DOOM Startup v%i.%i",
//		 "                           ",
                 VERSION/100,VERSION%100);
        break;
    case shareware:
        sprintf (title,
//		 "                            "
                 "DOOM Shareware Startup v%i.%i",
//		 "                           ",
                 VERSION/100,VERSION%100);
        break;
    case registered:
        sprintf (title,
//		 "                            "
                 "DOOM Registered Startup v%i.%i",
//		 "                           ",
                 VERSION/100,VERSION%100);
        break;
    case commercial:
        sprintf (title,
//		 "                         "
                 "DOOM 2: Hell on Earth v%i.%i",
//		 "                           ",
                 VERSION/100,VERSION%100);
        break;
    /*FIXME
           case pack_plut:
    	sprintf (title,
    		 "                   "
    		 "DOOM 2: Plutonia Experiment v%i.%i"
    		 "                           ",
    		 VERSION/100,VERSION%100);
    	break;
          case pack_tnt:
    	sprintf (title,
    		 "                     "
    		 "DOOM 2: TNT - Evilution v%i.%i"
    		 "                           ",
    		 VERSION/100,VERSION%100);
    	break;
    */
    default:
        sprintf (title,
//		 "                     "
                 "Public DOOM - v%i.%i",
//		 "                           ",
                 VERSION/100,VERSION%100);
        break;
    }

    printf ("%s\n",title);

    // turbo option
    if ( (p=M_CheckParm ("-turbo")) )
    {
        int     scale = 200;
        extern int forwardmove[2];
        extern int sidemove[2];

        if (p<myargc-1)
            scale = atoi (myargv[p+1]);
        if (scale < 10)
            scale = 10;
        if (scale > 400)
            scale = 400;
//	printf ("turbo scale: %i%%\n",scale);
        forwardmove[0] = forwardmove[0]*scale/100;
        forwardmove[1] = forwardmove[1]*scale/100;
        sidemove[0] = sidemove[0]*scale/100;
        sidemove[1] = sidemove[1]*scale/100;
    }

    // add any files specified on the command line with -file wadfile
    // to the wad list
    //
    // convenience hack to allow -wart e m to add a wad file
    // prepend a tilde to the filename so wadfile will be reloadable
    p = M_CheckParm ("-wart");
    if (p)
    {
        myargv[p][4] = 'p';     // big hack, change to -warp

        // Map name handling.
        switch (gamemode )
        {
        case shareware:
        case retail:
        case registered:
            sprintf (file,"~"DEVMAPS"E%cM%c.wad",
                     myargv[p+1][0], myargv[p+2][0]);
            printf("Warping to Episode %s, Map %s.\n",
                   myargv[p+1],myargv[p+2]);
            break;

        case commercial:
        default:
            p = atoi (myargv[p+1]);
            if (p<10)
                sprintf (file,"~"DEVMAPS"cdata/map0%i.wad", p);
            else
                sprintf (file,"~"DEVMAPS"cdata/map%i.wad", p);
            break;
        }
        D_AddFile (file);
    }

    p = M_CheckParm ("-file");
    if (p)
    {
        // the parms after p are wadfile/lump names,
        // until end of parms or another - preceded parm
        modifiedgame = true;            // homebrew levels
        while (++p != myargc && myargv[p][0] != '-')
            D_AddFile (myargv[p]);
    }

    p = M_CheckParm ("-playdemo");

    if (!p)
        p = M_CheckParm ("-timedemo");

    if (p && p < myargc-1)
    {
        sprintf (file,"%s.lmp", myargv[p+1]);
        D_AddFile (file);
        printf("Playing demo %s.lmp.\n",myargv[p+1]);
    }

    // get skill / episode / map from parms
    startskill = sk_medium;
    startepisode = 1;
    startmap = 3;
    autostart = false;

    p = M_CheckParm ("-skill");
    if (p && p < myargc-1)
    {
        startskill = myargv[p+1][0]-'1';
        autostart = true;
    }

    p = M_CheckParm ("-episode");
    if (p && p < myargc-1)
    {
        startepisode = myargv[p+1][0]-'0';
        startmap = 1;
        autostart = true;
    }

    p = M_CheckParm ("-timer");
    if (p && p < myargc-1 && deathmatch)
    {
        int     time;
        time = atoi(myargv[p+1]);
        printf("Levels will end after %d minute",time);
        if (time>1)
            printf("s");
        printf(".\n");
    }

    p = M_CheckParm ("-avg");
    if (p && p < myargc-1 && deathmatch)
        printf("Austin Virtual Gaming: Levels will end after 20 minutes\n");

    p = M_CheckParm ("-warp");
    if (p && p < myargc-1)
    {
        if (gamemode == commercial)
            startmap = atoi (myargv[p+1]);
        else
        {
            startepisode = myargv[p+1][0]-'0';
            startmap = myargv[p+2][0]-'0';
        }
        autostart = true;
    }

    // init subsystems
    printf ("V_Init: allocate screens.\n");
    V_Init ();

    printf ("M_LoadDefaults: Load system defaults.\n");
    M_LoadDefaults ();              // load before initing other systems

    printf ("Z_Init: Init zone memory allocation daemon. \n");
    Z_Init ();

    printf ("W_Init: Init WADfiles.\n");
    W_InitMultipleFiles (wadfiles);

    // Check for -file in shareware
    /*    if (modifiedgame)
        {
    	// These are the lumps that will be checked in IWAD,
    	// if any one is not present, execution will be aborted.
    	char name[23][8]=
    	{
    	    "e2m1","e2m2","e2m3","e2m4","e2m5","e2m6","e2m7","e2m8","e2m9",
    	    "e3m1","e3m3","e3m3","e3m4","e3m5","e3m6","e3m7","e3m8","e3m9",
    	    "dphoof","bfgga0","heada1","cybra1","spida1d1"
    	};
    	int i;

    	if ( gamemode == shareware)
    	    I_Error("\nYou cannot -file with the shareware "
    		    "version. Register!");

    	// Check for fake IWAD with right name,
    	// but w/o all the lumps of the registered version.
    	if (gamemode == registered)
    	    for (i = 0;i < 23; i++)
    		if (W_CheckNumForName(name[i])<0)
    		    I_Error("\nThis is not the registered version.");
        }

        // Iff additonal PWAD files are used, print modified banner
        if (modifiedgame)
        {
    	printf (
    	    "===========================================================================\n"
    	    "ATTENTION:  This version of DOOM has been modified.  If you would like to\n"
    	    "get a copy of the original game, call 1-800-IDGAMES or see the readme file.\n"
    	    "        You will not receive technical support for modified games.\n"
    	    "                      press enter to continue\n"
    	    "===========================================================================\n"
    	    );
    	getchar ();
        }
    */

    // Check and print which version is executed.
    switch ( gamemode )
    {
    case shareware:
    case indetermined:
        printf ( "%s", shareware_banner
                 /*	    "===========================================================================\n"
                 	    "                                Shareware!\n",
                 	    "===========================================================================\n"*/
               );
        break;
    case registered:
    case retail:
    case commercial:
        printf ( "%s", commercial_banner
                 /*	    "===========================================================================\n"
                 	    "                 Commercial product - do not distribute!\n"
                 	    "         Please report software piracy to the SPA: 1-800-388-PIR8\n"
                 	    "===========================================================================\n"*/
               );
        break;

    default:
        // Ouch.
        break;
    }

    printf ("M_Init: Init miscellaneous info.\n");
    M_Init ();

    printf ("R_Init: Init DOOM refresh daemon - ");
    R_Init ();

    printf ("\nP_Init: Init Playloop state.\n");
    P_Init ();

    printf ("I_Init: Setting up machine state.\n");
    I_Init ();

    printf ("D_CheckNetGame: Checking network game status.\n");
    D_CheckNetGame ();

    printf ("S_Init: Setting up sound.\n");
    S_Init (snd_SfxVolume /* *8 */, snd_MusicVolume /* *8*/ );

    printf ("HU_Init: Setting up heads up display.\n");
    HU_Init ();

    printf ("ST_Init: Init status bar.\n");
    ST_Init ();

    /*    // check for a driver that wants intermission stats
        p = M_CheckParm ("-statcopy");
        if (p && p<myargc-1)
        {
    	// for statistics driver
    	extern  void*	statcopy;

    	statcopy = (void*)atoi(myargv[p+1]);
    	printf ("External statistics registered.\n");
        }*/

    /*    // start the apropriate game based on parms
        p = M_CheckParm ("-record");

        if (p && p < myargc-1)
        {
    	G_RecordDemo (myargv[p+1]);
    	autostart = true;
        }*/

    /*    p = M_CheckParm ("-playdemo");
        if (p && p < myargc-1)
        {
    	singledemo = true;              // quit after one demo
    	G_DeferedPlayDemo (myargv[p+1]);
    	D_DoomLoop ();  // never returns
        }*/

    /*    p = M_CheckParm ("-timedemo");
        if (p && p < myargc-1)
        {
    	G_TimeDemo (myargv[p+1]);
    	D_DoomLoop ();  // never returns
        }*/

    /*    p = M_CheckParm ("-loadgame");
        if (p && p < myargc-1)
        {
    	if (M_CheckParm("-cdrom"))
    	    sprintf(file, "c:\\doomdata\\"SAVEGAMENAME"%c.dsg",myargv[p+1][0]);
    	else
    	    sprintf(file, SAVEGAMENAME"%c.dsg",myargv[p+1][0]);
    	G_LoadGame (file);
        }*/

    if (!should_sound)
    {
        // install sound callback
        register_AI_handler(sound_callback);
        set_AI_interrupt(1);
        should_sound = 1;
        sound_callback();
        printf("D_DoomMain: AI interrupt handler installed.\n");
    }


    if (gameaction != ga_loadgame)
    {
        if (autostart || netgame)
        {
            G_InitNew(startskill, startepisode, startmap);
        }
        else
        {
            D_StartTitle(); // start up intro loop
        }
    }

    console_clear();
    console_close();

    D_DoomLoop();  // never returns
}