Exemplo n.º 1
0
void I_PlaySong(int handle, boolean looping)
{
    int rc;
    rc = MUS_ChainSong(handle, looping ? handle : -1);
#ifdef SNDDEBUG
    if (rc < 0)
        ST_Message("    MUS_ChainSong() returned %d\n", rc);
#endif
    rc = MUS_PlaySong(handle, snd_MusicVolume);
#ifdef SNDDEBUG
    if (rc < 0)
        ST_Message("    MUS_PlaySong() returned %d\n", rc);
#endif

}
Exemplo n.º 2
0
static void WarpCheck(void)
{
    int p;
    int map;

    p = M_CheckParm("-warp");
    if (p && p < myargc - 1)
    {
        WarpMap = atoi(myargv[p + 1]);
        map = P_TranslateMap(WarpMap);
        if (map == -1)
        {                       // Couldn't find real map number
            startmap = 1;
            ST_Message("-WARP: Invalid map number.\n");
        }
        else
        {                       // Found a valid startmap
            startmap = map;
            autostart = true;
        }
    }
    else
    {
        WarpMap = 1;
        startmap = P_TranslateMap(1);
        if (startmap == -1)
        {
            startmap = 1;
        }
    }
}
Exemplo n.º 3
0
void I_UnRegisterSong(int handle)
{
    int rc = MUS_UnregisterSong(handle);
#ifdef SNDDEBUG
    if (rc < 0)
        ST_Message("    MUS_Unreg() returned %d\n", rc);
#endif
}
Exemplo n.º 4
0
void I_StartupSound(void)
{
    int rc, i;

    if (debugmode)
        ST_Message("I_StartupSound: Hope you hear a pop.\n");

    // initialize dmxCodes[]
    dmxCodes[0] = 0;
    dmxCodes[snd_PC] = AHW_PC_SPEAKER;
    dmxCodes[snd_Adlib] = AHW_ADLIB;
    dmxCodes[snd_SB] = AHW_SOUND_BLASTER;
    dmxCodes[snd_PAS] = AHW_MEDIA_VISION;
    dmxCodes[snd_GUS] = AHW_ULTRA_SOUND;
    dmxCodes[snd_MPU] = AHW_MPU_401;
    dmxCodes[snd_MPU2] = AHW_MPU_401;
    dmxCodes[snd_MPU3] = AHW_MPU_401;
    dmxCodes[snd_AWE] = AHW_AWE32;
    dmxCodes[snd_CDMUSIC] = 0;

    // inits sound library timer stuff
    I_StartupTimer();

    // pick the sound cards i'm going to use
    //
    I_sndArbitrateCards();

    if (debugmode)
    {
        ST_Message("    Music device #%d & dmxCode=%d,", snd_MusicDevice,
                   dmxCodes[snd_MusicDevice]);
        ST_Message(" Sfx device #%d & dmxCode=%d\n", snd_SfxDevice,
                   dmxCodes[snd_SfxDevice]);
    }

    // inits DMX sound library
    ST_Message("    Calling DMX_Init...");
    rc = DMX_Init(SND_TICRATE, SND_MAXSONGS, dmxCodes[snd_MusicDevice],
                  dmxCodes[snd_SfxDevice]);

    if (debugmode)
    {
        ST_Message(" DMX_Init() returned %d\n", rc);
    }

}
Exemplo n.º 5
0
int I_QrySongPlaying(int handle)
{
    int rc = MUS_QrySongPlaying(handle);
#ifdef SNDDEBUG
    if (rc < 0)
        ST_Message("    MUS_QrySP() returned %d\n", rc);
#endif
    return rc;
}
Exemplo n.º 6
0
int I_RegisterSong(void *data)
{
    int rc = MUS_RegisterSong(data);
#ifdef SNDDEBUG
    if (rc < 0)
        ST_Message("    MUS_Reg() returned %d\n", rc);
#endif
    return rc;
}
Exemplo n.º 7
0
void I_StartupTimer(void)
{
#ifndef NOTIMER
    extern int I_TimerISR(void);

    ST_Message("  I_StartupTimer()\n");
    // installs master timer.  Must be done before StartupTimer()!
    TSM_Install(SND_TICRATE);
    tsm_ID = TSM_NewService(I_TimerISR, 35, 255, 0);    // max priority
    if (tsm_ID == -1)
    {
        I_Error("Can't register 35 Hz timer w/ DMX library");
    }
#endif
}
Exemplo n.º 8
0
void I_StopSong(int handle)
{
    int rc;
    rc = MUS_StopSong(handle);
#ifdef SNDDEBUG
    if (rc < 0)
        ST_Message("    MUS_StopSong() returned %d\n", rc);
#endif
    /*
      // F*****g kluge pause
      {
    	int s;
    	extern volatile int ticcount;
    	for (s=ticcount ; ticcount - s < 10 ; );
      }
    */
}
Exemplo n.º 9
0
static void WarpCheck(void)
{
    int p;
    int map;

    //!
    // @category game
    // @arg x
    // @vanilla
    //
    // Start a game immediately, warping to MAPx.
    //

    p = M_CheckParm("-warp");
    if (p && p < myargc - 1)
    {
        WarpMap = atoi(myargv[p + 1]);
        map = P_TranslateMap(WarpMap);
        if (map == -1)
        {                       // Couldn't find real map number
            startmap = 1;
            ST_Message("-WARP: Invalid map number.\n");
        }
        else
        {                       // Found a valid startmap
            startmap = map;
            autostart = true;
        }
    }
    else
    {
        WarpMap = 1;
        startmap = P_TranslateMap(1);
        if (startmap == -1)
        {
            startmap = 1;
        }
    }
}
Exemplo n.º 10
0
void M_LoadDefaults(char *fileName)
{
	int i;
	int len;
	FILE *f;
	char def[80];
	char strparm[100];
	char *newstring;
	int parm;
	boolean isstring;

	// Set everything to base values
	numdefaults = sizeof(defaults)/sizeof(defaults[0]);
	for(i = 0; i < numdefaults; i++)
	{
		*defaults[i].location = defaults[i].defaultvalue;
	}

	// Check for a custom config file
	i = M_CheckParm("-config");
	if(i && i < myargc-1)
	{
		strcpy(defaultfile, myargv[i+1]);
		ST_Message("config file: %s\n", defaultfile);
	}
	else if(cdrom)
	{
		sprintf(defaultfile, "c:\\hexndata\\%s", fileName);
	}
	else
	{
		strcpy(defaultfile, fileName);
	}

#ifndef _HEXENDS //rww begin FIXME - use sram
	// Scan the config file
	f = fopen(defaultfile, "r");
	if(f)
	{
		while(!feof(f))
		{
			isstring = false;
			if(fscanf(f, "%79s %[^\n]\n", def, strparm) == 2)
			{
				if(strparm[0] == '"')
				{
					 // Get a string default
					 isstring = true;
					 len = strlen(strparm);
					 newstring = (char *)ds_malloc(len); //rww malloc->ds_malloc
					 if (newstring == NULL) I_Error("can't malloc newstring");
					 strparm[len-1] = 0;
					 strcpy(newstring, strparm+1);
				}
				else if(strparm[0] == '0' && strparm[1] == 'x')
				{
					sscanf(strparm+2, "%x", &parm);
				}
				else
				{
					sscanf(strparm, "%i", &parm);
				}
				for(i = 0; i < numdefaults; i++)
				{
					if(!strcmp(def, defaults[i].name))
					{
						if(!isstring)
						{
							*defaults[i].location = parm;
						}
						else
						{
							*defaults[i].location = (int)newstring;
						}
						break;
					}
				}
			}
		}

		fclose (f);
	}

#ifdef __WATCOMC__
	// Translate the key scancodes
	for(i = 0; i < numdefaults; i++)
	{
		if(defaults[i].scantranslate)
		{
			parm = *defaults[i].location;
			defaults[i].untranslated = parm;
			*defaults[i].location = scantokey[parm];
		}
	}
#endif

#endif //rww end
}
Exemplo n.º 11
0
void M_FindResponseFile(void)
{
	int i;

	for(i = 1; i < myargc; i++)
	{
#ifndef _HEXENDS //rww begin
		if(myargv[i][0] == '@')
		{
			FILE *handle;
			int size;
			int k;
			int index;
			int indexinfile;
			char *infile;
			char *file;
			char *moreargs[20];
			char *firstargv;

			// READ THE RESPONSE FILE INTO MEMORY
			handle = fopen(&myargv[i][1], "rb");
			if(!handle)
			{

				HEXENPRINTF("\nNo such response file!");
				exit(1);
			}
			ST_Message("Found response file %s!\n",&myargv[i][1]);
			fseek (handle,0,SEEK_END);
			size = ftell(handle);
			fseek (handle,0,SEEK_SET);
			file = ds_malloc (size); //rww malloc->ds_malloc
			fread (file,size,1,handle);
			fclose (handle);

			// KEEP ALL CMDLINE ARGS FOLLOWING @RESPONSEFILE ARG
			for (index = 0,k = i+1; k < myargc; k++)
				moreargs[index++] = myargv[k];
			
			firstargv = myargv[0];
			myargv = ds_malloc(sizeof(char *)*MAXARGVS); //rww malloc->ds_malloc
			memset(myargv,0,sizeof(char *)*MAXARGVS);
			myargv[0] = firstargv;
			
			infile = file;
			indexinfile = k = 0;
			indexinfile++;  // SKIP PAST ARGV[0] (KEEP IT)
			do
			{
				myargv[indexinfile++] = infile+k;
				while(k < size &&  

					((*(infile+k)>= ' '+1) && (*(infile+k)<='z')))
					k++;
				*(infile+k) = 0;
				while(k < size &&
					((*(infile+k)<= ' ') || (*(infile+k)>'z')))
					k++;
			} while(k < size);
			
			for (k = 0;k < index;k++)
				myargv[indexinfile++] = moreargs[k];
			myargc = indexinfile;
			// DISPLAY ARGS
			if(M_CheckParm("-debug"))
			{
				ST_Message("%d command-line args:\n", myargc);
				for(k = 1; k < myargc; k++)
				{
					ST_Message("%s\n", myargv[k]);
				}
			}
			break;
		}
#endif //rww end
	}
}
Exemplo n.º 12
0
void D_ArbitrateNetStart (void)
{
	int             i;
	boolean gotinfo[MAXNETNODES];
	boolean gotClass[MAXNETNODES];
#ifdef __WATCOMC__
	int nextTic;
	extern volatile int ticcount;

	nextTic = ticcount+8;
#endif

	autostart = true;

	memset (gotClass,0,sizeof(gotClass));
	memset (gotinfo,0,sizeof(gotinfo));
	gotClass[doomcom->consoleplayer] = true;
	do
	{
		i = 0;

		CheckAbort();
		while(HGetPacket())
		{ // Check for any incoming packets
			if(netbuffer->checksum&NCMD_SETUP && netbuffer->starttic >= 64)
			{
				
				PlayerClass[netbuffer->player] = netbuffer->starttic&0x3f;
				if(!gotClass[netbuffer->player])
				{
					gotClass[netbuffer->player] = true;
					ST_NetProgress();
					ST_Message("\n");
				}
				if(netbuffer->retransmitfrom)
				{ // that node has received info from all other nodes
					gotinfo[netbuffer->player] = true;
				}
			}
		}
#ifdef __WATCOMC__
		if(ticcount <= nextTic)
		{ // only send packets every half second
			continue;
		}
		nextTic = ticcount+8;
#endif
		// Keep sending out packets containing the console class
		for(i = 0; i < doomcom->numnodes; i++)
		{
			netbuffer->player = doomcom->consoleplayer;
			netbuffer->starttic = PlayerClass[doomcom->consoleplayer]+64;
			netbuffer->retransmitfrom = gotinfo[doomcom->consoleplayer];
			netbuffer->numtics = 0;
			HSendPacket(i, NCMD_SETUP);
		}
		for(i = 0; i < doomcom->numnodes; i++)
		{ // Make sure that all nodes have sent class info
			if (!gotClass[i])
			{
				ST_Message(".");
				break;
			}
		}
		if(i < doomcom->numnodes)
		{
			continue;
		}
		else
		{ // consoleplayer has received all player classes
			if(gotinfo[doomcom->consoleplayer])
			{
				CheckAbort();
			}
			else
			{
				gotinfo[doomcom->consoleplayer] = true;
				ST_Message("All player classes received, ready to proceed\n");
				ST_NetDone();
			}
		}
		for (i = 0; i < doomcom->numnodes; i++)
		{ // Make sure that all nodes are ready to proceed
			if (!gotinfo[i])
			{
				break;
			}
		}
	} while(i < doomcom->numnodes);

	memset (gotinfo,0,sizeof(gotinfo));

	if (doomcom->consoleplayer)
	{       // listen for setup info from key player
//              ST_Message ("listening for network start info...\n");
		while (1)
		{
			CheckAbort ();
			if (!HGetPacket ())
				continue;
			if(netbuffer->checksum & NCMD_SETUP && netbuffer->starttic < 64)
			{
				if (netbuffer->player != VERSION)
					I_Error ("Different HEXEN versions cannot play a net game!");
				startskill = netbuffer->retransmitfrom & 15;
				deathmatch = (netbuffer->retransmitfrom & 0xc0) >> 6;
				nomonsters = (netbuffer->retransmitfrom & 0x20) > 0;
				respawnparm = (netbuffer->retransmitfrom & 0x10) > 0;
				startmap = netbuffer->starttic & 0x3f;
				startepisode = 1;
				return;
			}
		}
	}
	else
	{       // key player, send the setup info
//              ST_Message ("sending network start info...\n");
		do
		{
Exemplo n.º 13
0
static void HandleArgs(void)
{
    int p;

    //!
    // @vanilla
    //
    // Disable monsters.
    //

    nomonsters = M_ParmExists("-nomonsters");

    //!
    // @vanilla
    //
    // Monsters respawn after being killed.
    //

    respawnparm = M_ParmExists("-respawn");

    //!
    // @vanilla
    // @category net
    //
    // In deathmatch mode, change a player's class each time the
    // player respawns.
    //

    randomclass = M_ParmExists("-randclass");

    //!
    // @vanilla
    //
    // Take screenshots when F1 is pressed.
    //

    ravpic = M_ParmExists("-ravpic");

    //!
    // @vanilla
    //
    // Don't allow artifacts to be used when the run key is held down.
    //

    artiskip = M_ParmExists("-artiskip");

    debugmode = M_ParmExists("-debug");

    //!
    // @vanilla
    // @category net
    //
    // Start a deathmatch game.
    //

    deathmatch = M_ParmExists("-deathmatch");

    // currently broken or unused:
    cmdfrag = M_ParmExists("-cmdfrag");

    // Check WAD file command line options
    W_ParseCommandLine();

    //!
    // @vanilla
    // @arg <path>
    //
    // Development option to specify path to level scripts.
    //

    p = M_CheckParmWithArgs("-scripts", 1);

    if (p)
    {
        sc_FileScripts = true;
        sc_ScriptsDir = myargv[p+1];
    }

    //!
    // @arg <skill>
    // @vanilla
    //
    // Set the game skill, 1-5 (1: easiest, 5: hardest).  A skill of
    // 0 disables all monsters.
    //

    p = M_CheckParmWithArgs("-skill", 1);

    if (p)
    {
        startskill = myargv[p+1][0] - '1';
        autostart = true;
    }

    //!
    // @arg <demo>
    // @category demo
    // @vanilla
    //
    // Play back the demo named demo.lmp.
    //

    p = M_CheckParmWithArgs("-playdemo", 1);

    if (!p)
    {
        //!
        // @arg <demo>
        // @category demo
        // @vanilla
        //
        // Play back the demo named demo.lmp, determining the framerate
        // of the screen.
        //

        p = M_CheckParmWithArgs("-timedemo", 1);
    }

    if (p)
    {
        char *uc_filename;
        char file[256];

        M_StringCopy(file, myargv[p+1], sizeof(file));

        // With Vanilla Hexen you have to specify the file without
        // extension, but make that optional.
        uc_filename = strdup(myargv[p + 1]);
        M_ForceUppercase(uc_filename);

        if (!M_StringEndsWith(uc_filename, ".LMP"))
        {
            M_StringConcat(file, ".lmp", sizeof(file));
        }

        free(uc_filename);

        if (W_AddFile(file) != NULL)
        {
            M_StringCopy(demolumpname, lumpinfo[numlumps - 1].name,
                         sizeof(demolumpname));
        }
        else
        {
            // The file failed to load, but copy the original arg as a
            // demo name to make tricks like -playdemo demo1 possible.
            M_StringCopy(demolumpname, myargv[p+1], sizeof(demolumpname));
        }

        ST_Message("Playing demo %s.\n", myargv[p+1]);
    }

    if (M_ParmExists("-testcontrols"))
    {
        autostart = true;
        testcontrols = true;
    }
}
Exemplo n.º 14
0
void D_DoomMain(void)
{
    GameMission_t gamemission;
    int p;

    I_AtExit(D_HexenQuitMessage, false);
    startepisode = 1;
    autostart = false;
    startskill = sk_medium;
    startmap = 1;
    gamemode = commercial;

    I_PrintBanner(PACKAGE_STRING);

    // Initialize subsystems

    ST_Message("V_Init: allocate screens.\n");
    V_Init();

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

#ifdef _WIN32

    //!
    // @platform windows
    // @vanilla
    //
    // Save configuration data and savegames in c:\hexndata,
    // allowing play from CD.
    //

    cdrom = M_ParmExists("-cdrom");
#endif

    if (cdrom)
    {
        M_SetConfigDir("c:\\hexndata\\");
    }
    else
    {
        M_SetConfigDir(NULL);
    }

    D_SetDefaultSavePath();
    M_SetConfigFilenames("hexen.cfg", PROGRAM_PREFIX "hexen.cfg");
    M_LoadDefaults();

    I_AtExit(M_SaveDefaults, false);


    // Now that the savedir is loaded from .CFG, make sure it exists
    CreateSavePath();

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

    // haleyjd: removed WATCOMC

    ST_Message("W_Init: Init WADfiles.\n");

    iwadfile = D_FindIWAD(IWAD_MASK_HEXEN, &gamemission);

    if (iwadfile == NULL)
    {
        I_Error("Game mode indeterminate. No IWAD was found. Try specifying\n"
                "one with the '-iwad' command line parameter.");
    }

    D_AddFile(iwadfile);
    W_CheckCorrectIWAD(hexen);
    D_IdentifyVersion();
    D_SetGameDescription();
    AdjustForMacIWAD();

    HandleArgs();

    I_PrintStartupBanner(gamedescription);

    ST_Message("MN_Init: Init menu system.\n");
    MN_Init();

    ST_Message("CT_Init: Init chat mode data.\n");
    CT_Init();

    InitMapMusicInfo();         // Init music fields in mapinfo

    ST_Message("S_InitScript\n");
    S_InitScript();

    ST_Message("SN_InitSequenceScript: Registering sound sequences.\n");
    SN_InitSequenceScript();
    ST_Message("I_Init: Setting up machine state.\n");
    I_CheckIsScreensaver();
    I_InitTimer();
    I_InitJoystick();
    I_InitSound(false);
    I_InitMusic();

#ifdef FEATURE_MULTIPLAYER
    ST_Message("NET_Init: Init networking subsystem.\n");
    NET_Init();
#endif
    D_ConnectNetGame();

    S_Init();
    S_Start();

    ST_Message("ST_Init: Init startup screen.\n");
    ST_Init();

    // Show version message now, so it's visible during R_Init()
    ST_Message("R_Init: Init Hexen refresh daemon");
    R_Init();
    ST_Message("\n");

    //if (M_CheckParm("-net"))
    //    ST_NetProgress();       // Console player found

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

    // Check for command line warping. Follows P_Init() because the
    // MAPINFO.TXT script must be already processed.
    WarpCheck();

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

    ST_Message("SB_Init: Loading patches.\n");
    SB_Init();

    ST_Done();

    if (autostart)
    {
        ST_Message("Warp to Map %d (\"%s\":%d), Skill %d\n",
                   WarpMap, P_GetMapName(startmap), startmap, startskill + 1);
    }

    CheckRecordFrom();

    p = M_CheckParm("-record");
    if (p && p < myargc - 1)
    {
        G_RecordDemo(startskill, 1, startepisode, startmap, myargv[p + 1]);
        H2_GameLoop();          // Never returns
    }

    p = M_CheckParmWithArgs("-playdemo", 1);
    if (p)
    {
        singledemo = true;      // Quit after one demo
        G_DeferedPlayDemo(demolumpname);
        H2_GameLoop();          // Never returns
    }

    p = M_CheckParmWithArgs("-timedemo", 1);
    if (p)
    {
        G_TimeDemo(demolumpname);
        H2_GameLoop();          // Never returns
    }

    //!
    // @arg <s>
    // @vanilla
    //
    // Load the game in savegame slot s.
    //

    p = M_CheckParmWithArgs("-loadgame", 1);
    if (p)
    {
        G_LoadGame(atoi(myargv[p + 1]));
    }

    if (gameaction != ga_loadgame)
    {
        UpdateState |= I_FULLSCRN;
        BorderNeedRefresh = true;
        if (autostart || netgame)
        {
            G_StartNewInit();
            G_InitNew(startskill, startepisode, startmap);
        }
        else
        {
            H2_StartTitle();
        }
    }
    H2_GameLoop();              // Never returns
}
Exemplo n.º 15
0
/*
==================
=
= R_InitTextures
=
= Initializes the texture list with the textures from the world map
=
==================
*/

void R_InitTextures (void)
{
	maptexture_t	*mtexture;
	texture_t		*texture;
	mappatch_t	*mpatch;
	texpatch_t	*patch;
	int			i,j;
	int			*maptex, *maptex2, *maptex1;
	char		name[9], *names, *name_p;
	int			*patchlookup;
	int			totalwidth;
	int			nummappatches;
	int			offset, maxoff, maxoff2;
	int			numtextures1, numtextures2;
	int			*directory;

//
// load the patch names from pnames.lmp
//
	name[8] = 0;
	names = W_CacheLumpName ("PNAMES", PU_STATIC);
	nummappatches = LONG ( *((int *)names) );
	name_p = names+4;
	//rww begin
	patchlookup = alloca (nummappatches*sizeof(*patchlookup));
	//patchlookup = Z_Malloc(nummappatches*sizeof(*patchlookup), PU_STATIC, 0);
	//rww end
	for (i=0 ; i<nummappatches ; i++)
	{
		strncpy (name,name_p+i*8, 8);
		patchlookup[i] = W_CheckNumForName (name);
	}
	Z_Free (names);

//
// load the map texture definitions from textures.lmp
//
	maptex = maptex1 = W_CacheLumpName ("TEXTURE1", PU_STATIC);
	numtextures1 = LONG(*maptex);
	maxoff = W_LumpLength (W_GetNumForName ("TEXTURE1"));
	directory = maptex+1;

	if (W_CheckNumForName ("TEXTURE2") != -1)
	{
		maptex2 = W_CacheLumpName ("TEXTURE2", PU_STATIC);
		numtextures2 = LONG(*maptex2);
		maxoff2 = W_LumpLength (W_GetNumForName ("TEXTURE2"));
	}
	else
	{
		maptex2 = NULL;
		numtextures2 = 0;
		maxoff2 = 0;
	}
	numtextures = numtextures1 + numtextures2;

	//rww begin
	ST_Message("R_InitTextures: %i\n", numtextures);
	//rww end

	textures = Z_Malloc (numtextures*4, PU_STATIC, 0);
	texturecolumnlump = Z_Malloc (numtextures*4, PU_STATIC, 0);
	texturecolumnofs = Z_Malloc (numtextures*4, PU_STATIC, 0);
	texturecomposite = Z_Malloc (numtextures*4, PU_STATIC, 0);
	texturecompositesize = Z_Malloc (numtextures*4, PU_STATIC, 0);
	texturewidthmask = Z_Malloc (numtextures*4, PU_STATIC, 0);
	textureheight = Z_Malloc (numtextures*4, PU_STATIC, 0);

	totalwidth = 0;

	for (i=0 ; i<numtextures ; i++, directory++)
	{
		if (i == numtextures1)
		{	// start looking in second texture file
			maptex = maptex2;
			maxoff = maxoff2;
			directory = maptex+1;
		}

		offset = LONG(*directory);
		if (offset > maxoff)
			I_Error ("R_InitTextures: bad texture directory");
		mtexture = (maptexture_t *) ( (byte *)maptex + offset);

#ifdef _TEXTURE_PATCH_DEBUG
		ST_Message("%s: %i, %i, %i, %i, %i     \n", mtexture->name,
			mtexture->patches[0].patch, mtexture->patches[0].colormap,
			mtexture->patches[0].originx, mtexture->patches[0].originy,
			mtexture->patches[0].stepdir);
	#ifdef _HEXENDS
		{
			int j = 0;
			while (j < 60) {
				swiWaitForVBlank();
				j++;
			}
		}
	#endif
#endif

		texture = textures[i] = Z_Malloc (sizeof(texture_t) 
			+ sizeof(texpatch_t)*(SHORT(mtexture->patchcount)-1), PU_STATIC,
			0);
		texture->width = SHORT(mtexture->width);
		texture->height = SHORT(mtexture->height);
		texture->patchcount = SHORT(mtexture->patchcount);
		memcpy (texture->name, mtexture->name, sizeof(texture->name));
		mpatch = &mtexture->patches[0];
		patch = &texture->patches[0];
//		ST_Message("tex (%s: %i %i %i %i %i %i)\n", texture->name, texture->width, texture->height,
//			texture->patchcount, mtexture->patchcount, mtexture->patches[0].patch, patchlookup[SHORT(mpatch->patch)]);

		for (j=0 ; j<texture->patchcount ; j++, mpatch++, patch++)
		{
			patch->originx = SHORT(mpatch->originx);
			patch->originy = SHORT(mpatch->originy);
			patch->patch = patchlookup[SHORT(mpatch->patch)];
			if (patch->patch == -1)
				I_Error (
				"R_InitTextures: Missing patch in texture %s",texture->name);
		}		

//		ST_Message("tex (%s: %i %i %i %i %i %i)\n", texture->name, texture->width, texture->height,
//			texture->patchcount, texture->patches[0].originx, texture->patches[0].originy, texture->patches[0].patch);

		texturecolumnlump[i] = Z_Malloc (texture->width*2, PU_STATIC,0);
		texturecolumnofs[i] = Z_Malloc (texture->width*2, PU_STATIC,0);
		j = 1;
		while (j*2 <= texture->width)
			j<<=1;
		texturewidthmask[i] = j-1;
		textureheight[i] = texture->height<<FRACBITS;
		
		totalwidth += texture->width;
	}

	Z_Free (maptex1);
	if (maptex2)
		Z_Free (maptex2);

//
// precalculate whatever possible
//		
	for (i=0 ; i<numtextures ; i++)
	{
		R_GenerateLookup (i);
		if(!(i&31)) ST_Progress();
	}

//
// translation table for global animation
//
	texturetranslation = Z_Malloc ((numtextures+1)*4, PU_STATIC, 0);
	for (i=0 ; i<numtextures ; i++)
		texturetranslation[i] = i;

	//rww begin
	//Z_Free(patchlookup);
	//rww end
Exemplo n.º 16
0
int I2_Init()
{
    DSBUFFERDESC        desc;
    LPDIRECTSOUNDBUFFER bufTemp;

    if(initOk) return true; // Don't init a second time.
    if(FAILED(hr = EAXDirectSoundCreate(NULL, &dsound, NULL)))
    {
        // EAX can't be initialized. Use normal DS, then.
        ST_Message("I2_Init: EAX 2 couldn't be initialized (result: %i).\n", hr & 0xffff);
        if(FAILED(hr = DirectSoundCreate(NULL, &dsound, NULL)))
        {
            ST_Message("I2_Init: Couldn't create dsound (result: %i).\n", hr & 0xffff);
            return false;
        }
    }
    // Set the cooperative level.
    if(FAILED(hr = IDirectSound_SetCooperativeLevel(dsound, hWndMain, DSSCL_PRIORITY)))
    {
        ST_Message("I2_Init: Couldn't set dSound cooperative level (result: %i).\n", hr & 0xffff);
        return false;
    }
    // Get the listener.
    memset(&desc, 0, sizeof(desc));
    desc.dwSize = sizeof(desc);
    desc.dwFlags = DSBCAPS_CTRL3D | DSBCAPS_PRIMARYBUFFER;
    if(SUCCEEDED(IDirectSound_CreateSoundBuffer(dsound, &desc, &bufTemp, NULL)))
    {
        // Query the listener interface.
        IDirectSoundBuffer_QueryInterface(bufTemp, &IID_IDirectSound3DListener, &dsListener);
    }
    // Release the primary buffer interface, we won't need it.
    IDirectSoundBuffer_Release(bufTemp);

    // Try to get the EAX listener property set. Create a temporary secondary buffer for it.
    if(SUCCEEDED( createDSBuffer(DSBCAPS_STATIC | DSBCAPS_CTRL3D, DSBSIZE_MIN, 22050, 8, 1, &bufTemp) ))
    {
        // Now try to get the property set.
        if(SUCCEEDED(hr = IDirectSoundBuffer_QueryInterface(bufTemp,
            &IID_IKsPropertySet, &eaxListener)))
        {
            DWORD support = 0, revsize = 0;
            // Check for support.
            if(FAILED(hr = IKsPropertySet_QuerySupport(eaxListener,
                &DSPROPSETID_EAX_ListenerProperties,
                DSPROPERTY_EAXLISTENER_ENVIRONMENT,
                &support))
                || ((support & NEEDED_SUPPORT) != NEEDED_SUPPORT))
            {
                ST_Message("I2_Init: Property set acquired, but EAX 2 not supported.\n  Result:%i, support:%x\n", hr&0xffff, support);
                IKsPropertySet_Release(eaxListener);
                eaxListener = NULL;
            }
            else
            {
                // EAX is supported!
                ST_Message("I2_Init: EAX 2 available.\n");
            }
        }
        // Release the temporary buffer interface.
        IDirectSoundBuffer_Release(bufTemp);
    }

    // Get the caps.
    dsCaps.dwSize = sizeof(dsCaps);
    IDirectSound_GetCaps(dsound, &dsCaps);
    ST_Message("I2_Init: Number of hardware 3D buffers: %i\n", dsCaps.dwMaxHw3DAllBuffers);

    // Configure the DS3D listener.
    if(dsListener)
    {
        IDirectSound3DListener_SetDistanceFactor(dsListener, 1/36.0f, DS3D_DEFERRED);
        IDirectSound3DListener_SetDopplerFactor(dsListener, 2, DS3D_DEFERRED);
    }

    // Success!
    initOk = true;
    return true;
}
Exemplo n.º 17
0
void I_sndArbitrateCards(void)
{
    char tmp[160];
    boolean gus, adlib, pc, sb, midi;
    int i, rc, mputype, p, opltype, wait, dmxlump;

    snd_MusicDevice = snd_DesiredMusicDevice;
    snd_SfxDevice = snd_DesiredSfxDevice;

    // check command-line parameters- overrides config file
    //
    if (M_CheckParm("-nosound"))
        snd_MusicDevice = snd_SfxDevice = snd_none;
    if (M_CheckParm("-nosfx"))
        snd_SfxDevice = snd_none;
    if (M_CheckParm("-nomusic"))
        snd_MusicDevice = snd_none;

    if (snd_MusicDevice > snd_MPU && snd_MusicDevice <= snd_MPU3)
        snd_MusicDevice = snd_MPU;
    if (snd_MusicDevice == snd_SB)
        snd_MusicDevice = snd_Adlib;
    if (snd_MusicDevice == snd_PAS)
        snd_MusicDevice = snd_Adlib;

    // figure out what i've got to initialize
    //
    gus = snd_MusicDevice == snd_GUS || snd_SfxDevice == snd_GUS;
    sb = snd_SfxDevice == snd_SB || snd_MusicDevice == snd_SB;
    adlib = snd_MusicDevice == snd_Adlib;
    pc = snd_SfxDevice == snd_PC;
    midi = snd_MusicDevice == snd_MPU;

    // initialize whatever i've got
    //
    if (gus)
    {
        if (GF1_Detect())
            ST_Message("    Dude.  The GUS ain't responding.\n");
        else
        {
            dmxlump = W_GetNumForName("dmxgus");
            GF1_SetMap(W_CacheLumpNum(dmxlump, PU_CACHE),
                       lumpinfo[dmxlump].size);
        }

    }
    if (sb)
    {
        if (debugmode)
        {
            ST_Message("  Sound cfg p=0x%x, i=%d, d=%d\n",
                       snd_SBport, snd_SBirq, snd_SBdma);
        }
        if (SB_Detect(&snd_SBport, &snd_SBirq, &snd_SBdma, 0))
        {
            ST_Message("    SB isn't responding at p=0x%x, i=%d, d=%d\n",
                       snd_SBport, snd_SBirq, snd_SBdma);
        }
        else
            SB_SetCard(snd_SBport, snd_SBirq, snd_SBdma);

        if (debugmode)
        {
            ST_Message("    SB_Detect returned p=0x%x, i=%d, d=%d\n",
                       snd_SBport, snd_SBirq, snd_SBdma);
        }
    }

    if (adlib)
    {
        if (AL_Detect(&wait, 0))
        {
            ST_Message("    Dude.  The Adlib isn't responding.\n");
        }
        else
        {
            AL_SetCard(wait, W_CacheLumpName("genmidi", PU_STATIC));
        }
    }

    if (midi)
    {
        if (debugmode)
        {
            ST_Message("    cfg p=0x%x\n", snd_Mport);
        }

        if (MPU_Detect(&snd_Mport, &i))
        {
            ST_Message("    The MPU-401 isn't reponding @ p=0x%x.\n",
                       snd_Mport);
        }
        else
            MPU_SetCard(snd_Mport);
    }

}
Exemplo n.º 18
0
int I2_PlaySound(void *data, boolean play3d, sound3d_t *desc, int pan)
{
    sampleheader_t  *header = data;
    byte            *sample = (byte*) data + sizeof(sampleheader_t);
    sndsource_t     *sndbuf;
    void            *writePtr1=NULL, *writePtr2=NULL;
    DWORD           writeBytes1, writeBytes2;
    int             samplelen = header->length, freq = header->frequency, bits = 8;

    // Can we play sounds?
    if(!initOk || data == NULL) return 0;   // Sorry...

    if(snd_Resample != 1 && snd_Resample != 2 && snd_Resample != 4)
    {
        ST_Message("I2_PlaySound: invalid resample factor.\n");
        snd_Resample = 1;
    }

    // Get a buffer that's doing nothing.
    sndbuf = I2_GetFreeSource(play3d);
    sndbuf->startTime = I_GetTime();
    // Prepare the audio data.
    if(snd_Resample == 1 && !snd_16bits) // Play sounds as normal?
    {
        // No resampling necessary.
        sndbuf->freq = header->frequency;
    }
    else
    {
        // Resample the sound.
        sample = I_Resample8bitSound(sample, header->length, freq,
            snd_Resample, snd_16bits, &samplelen);
        if(snd_16bits) bits = 16;
        freq *= snd_Resample;
        sndbuf->freq = freq;
    }
    if(sndbuf->source)
    {
        // Release the old source.
        I2_KillSource(sndbuf);
    }
    // Create a new source.
    if(FAILED(hr = createDSBuffer(play3d? DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLFREQUENCY
        | DSBCAPS_CTRL3D | DSBCAPS_MUTE3DATMAXDISTANCE | DSBCAPS_STATIC
        : DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLFREQUENCY
        | DSBCAPS_STATIC,
        header->length * snd_Resample, freq, bits, 1, &sndbuf->source)))
    {
        ST_Message("I2_PlaySound: couldn't create a new buffer (result = %d).\n", hr & 0xffff);
        memset(sndbuf, 0, sizeof(*sndbuf));
        return 0;
    }
    if(play3d)
    {
        // Query the 3D interface.
        if(FAILED(hr = IDirectSoundBuffer_QueryInterface(sndbuf->source, &IID_IDirectSound3DBuffer,
            &sndbuf->source3D)))
        {
            ST_Message("I2_PlaySound: couldn't get 3D buffer interface (result = %d).\n", hr & 0xffff);
            IDirectSoundBuffer_Release(sndbuf->source);
            memset(sndbuf, 0, sizeof(*sndbuf));
            return 0;
        }
    }

    // Lock the buffer.
    if(FAILED(hr = IDirectSoundBuffer_Lock(sndbuf->source, 0, samplelen,
        &writePtr1, &writeBytes1, &writePtr2, &writeBytes2, 0)))
    {
        I_error("I2_PlaySound: couldn't lock source (result = %d).\n", hr & 0xffff);
    }

    // Copy the data over.
    memcpy(writePtr1, sample, writeBytes1);
    if(writePtr2) memcpy(writePtr2, (char*) sample + writeBytes1, writeBytes2);

    // Unlock the buffer.
    if(FAILED(hr = IDirectSoundBuffer_Unlock(sndbuf->source, writePtr1, writeBytes1,
        writePtr2, writeBytes2)))
    {
        I_error("I2_PlaySound: couldn't unlock source (result = %d).\n", hr & 0xffff);
        return 0;
    }

    if(play3d)
    {
        // Set the 3D parameters of the source.
        if(desc->flags & DDSOUNDF_VERY_LOUD)
        {
            // You can hear this from very far away (e.g. thunderclap).
            IDirectSound3DBuffer_SetMinDistance(sndbuf->source3D, 10000, DS3D_DEFERRED);
            IDirectSound3DBuffer_SetMaxDistance(sndbuf->source3D, 20000, DS3D_DEFERRED);
        }
        else
        {
            IDirectSound3DBuffer_SetMinDistance(sndbuf->source3D, 100, DS3D_DEFERRED);
            IDirectSound3DBuffer_SetMaxDistance(sndbuf->source3D, MAX_SND_DIST, DS3D_DEFERRED);
        }
        if(desc->flags & DDSOUNDF_LOCAL)
            IDirectSound3DBuffer_SetMode(sndbuf->source3D, DS3DMODE_DISABLE, DS3D_DEFERRED);
    }
    else
    {
        // If playing in 2D mode, set the pan.
        I2_SetPan(sndbuf, pan/1000.0f);
    }
    I2_UpdateSource(sndbuf, desc);
    // Start playing the buffer.
    if(FAILED(hr = IDirectSoundBuffer_Play(sndbuf->source, 0, 0, 0)))
    {
        I_error("I2_PlaySound: couldn't start source (result = %d).\n", hr & 0xffff);
        return 0;
    }
    // Return the handle to the sound source.
    return (sndbuf->id = idGen++);
}
Exemplo n.º 19
0
/*
===================
=
= R_GenerateLookup
=
===================
*/

void R_GenerateLookup (int texnum)
{
	texture_t	*texture;
	byte		*patchcount;		// [texture->width]
	texpatch_t	*patch;	
	patch_t		*realpatch;
	int			x, x1, x2;
	int			i;
	short		*collump;
	unsigned short	*colofs;
	
	texture = textures[texnum];

	//ST_Message("lookup (%s: %i %i %i %i %i %i)\n", texture->name, texture->width, texture->height,
	//	texture->patchcount, texture->patches[0].originx, texture->patches[0].originy, texture->patches[0].patch);

	texturecomposite[texnum] = 0;	// composited not created yet
	texturecompositesize[texnum] = 0;
	collump = texturecolumnlump[texnum];
	colofs = texturecolumnofs[texnum];
	
//
// count the number of columns that are covered by more than one patch
// fill in the lump / offset, so columns with only a single patch are
// all done
//
	//rww begin
	patchcount = (byte *)alloca (texture->width);
	//patchcount = (byte *)Z_Malloc(texture->width, PU_STATIC, 0);
	//rww end
	memset (patchcount, 0, texture->width);
	patch = texture->patches;

	for (i=0 , patch = texture->patches; i<texture->patchcount ; i++, patch++)
	{
		realpatch = W_CacheLumpNumTexture (texture, patch->patch, PU_CACHE, -1);
		x1 = patch->originx;
		x2 = x1 + SHORT(realpatch->width);
		if (x1 < 0)
			x = 0;
		else
			x = x1;
		if (x2 > texture->width)
			x2 = texture->width;
		for ( ; x<x2 ; x++)
		{
			patchcount[x]++;
			collump[x] = patch->patch;
			colofs[x] = LONG(realpatch->columnofs[x-x1])+3;
		}
	}
	
	for (x=0 ; x<texture->width ; x++)
	{
		if (!patchcount[x])
		{
			//rww begin
			ST_Message ("R_GenerateLookup: column without a patch (%s)\n", texture->name);
			//I_Error("col without patch (%s (%i): %i %i %i %i %i %i)\n", texture->name, texnum, texture->width, texture->height,
			//	texture->patchcount, texture->patches[0].originx, texture->patches[0].originy, texture->patches[0].patch);
			//rww end
			return;
		}
//			I_Error ("R_GenerateLookup: column without a patch");
		if (patchcount[x] > 1)
		{
			collump[x] = -1;	// use the cached block
			colofs[x] = texturecompositesize[texnum];
			if (texturecompositesize[texnum] > 0x10000-texture->height)
				I_Error ("R_GenerateLookup: texture %i is >64k",texnum);
			texturecompositesize[texnum] += texture->height;
		}
	}	

	//rww begin
	//Z_Free(patchcount);
	//rww end