⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 d_main.c

📁 PIXIL is a small footprint operating environment, complete with PDA PIM applications, a browser and
💻 C
📖 第 1 页 / 共 2 页
字号:
// Emacs style mode select   -*- C++ -*- //-----------------------------------------------------------------------------//// $Id: d_main.c,v 1.2 2003/09/08 22:34:27 jasonk Exp $//// Copyright (C) 1993-1996 by id Software, Inc.//// This source is available for distribution and/or modification// only under the terms of the DOOM Source Code License as// published by id Software. All rights reserved.//// The source is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License// for more details.//// $Log: d_main.c,v $// Revision 1.2  2003/09/08 22:34:27  jasonk// Updated files because this fucker won't build for no fucking good reason.//// Revision 1.1.1.1  2003/09/04 21:08:12  jasonk// Initial import//// Revision 1.1  2000/12/08 21:07:51  jeffw// nxdoom initial entry -- No nxdoom/Makefile so it won't build automatically////// DESCRIPTION://	DOOM main program (D_DoomMain) and game loop (D_DoomLoop),//	plus functions to determine game mode (shareware, registered),//	parse command line parameters, configure game parameters (turbo),//	and call the startup functions.////-----------------------------------------------------------------------------static const char rcsid[] = "$Id: d_main.c,v 1.2 2003/09/08 22:34:27 jasonk Exp $";#define	BGCOLOR		7#define	FGCOLOR		8#include <stdio.h>#include <stdlib.h>extern int access(char *file, int mode);#define R_OK	4#if 0static int access(char *file, int mode){	FILE *test_fp;	test_fp = fopen(file, "r");	if ( test_fp != NULL ) {		fclose(test_fp);		return(0);	}	return(-1);}#endif#include "doomdef.h"#include "doomstat.h"#include "dstrings.h"#include "sounds.h"#include "z_zone.h"#include "w_wad.h"#include "s_sound.h"#include "v_video.h"#include "f_finale.h"#include "f_wipe.h"#include "m_argv.h"#include "m_misc.h"#include "m_menu.h"#include "i_system.h"#include "i_sound.h"#include "i_video.h"#include "g_game.h"#include "hu_stuff.h"#include "wi_stuff.h"#include "st_stuff.h"#include "am_map.h"#include "p_setup.h"#include "r_local.h"#include "d_main.h"//// D-DoomLoop()// Not a globally visible function,//  just included for source reference,//  called by D_DoomMain, never exits.// Manages timing and IO,//  calls all ?_Responder, ?_Ticker, and ?_Drawer,//  calls I_GetTime, I_StartFrame, and I_StartTic//void D_DoomLoop (void);char*		wadfiles[MAXWADFILES];boolean		devparm;	// started game with -devparmboolean         nomonsters;	// checkparm of -nomonstersboolean         respawnparm;	// checkparm of -respawnboolean         fastparm;	// checkparm of -fastboolean         drone;boolean		singletics = false; // debug flag to cancel adaptiveness//extern int soundVolume;//extern  int	sfxVolume;//extern  int	musicVolume;extern  boolean	inhelpscreens;skill_t		startskill;int             startepisode;int		startmap;boolean		autostart;FILE*		debugfile;boolean		advancedemo;char		wadfile[1024];		// primary wad filechar		mapdir[1024];           // directory of development mapschar		basedefault[1024];      // default filevoid D_CheckNetGame (void);void D_ProcessEvents (void);void G_BuildTiccmd (ticcmd_t* cmd);void D_DoAdvanceDemo (void);//// EVENT HANDLING//// Events are asynchronous inputs generally generated by the game user.// Events can be discarded if no responder claims them//event_t         events[MAXEVENTS];int             eventhead;int 		eventtail;//// D_PostEvent// Called by the I/O functions when input is detected//void D_PostEvent (event_t* ev){    events[eventhead] = *ev;    eventhead = (++eventhead)&(MAXEVENTS-1);}//// D_ProcessEvents// Send all the events of the given timestamp down the responder chain//void D_ProcessEvents (void){    event_t*	ev;	    // IF STORE DEMO, DO NOT ACCEPT INPUT    if ( ( gamemode == commercial )	 && (W_CheckNumForName("map01")<0) )      return;	    for ( ; eventtail != eventhead ; eventtail = (++eventtail)&(MAXEVENTS-1) )    {	ev = &events[eventtail];	if (M_Responder (ev))	    continue;               // menu ate the event	G_Responder (ev);    }}//// D_Display//  draw current display, possibly wiping it from the previous//// wipegamestate can be set to -1 to force a wipe on the next drawgamestate_t     wipegamestate = GS_DEMOSCREEN;extern  boolean setsizeneeded;extern  int             showMessages;void R_ExecuteSetViewSize (void);void D_Display (void){    static  boolean		viewactivestate = false;    static  boolean		menuactivestate = false;    static  boolean		inhelpscreensstate = false;    static  boolean		fullscreen = false;    static  gamestate_t		oldgamestate = -1;    static  int			borderdrawcount;    int				nowtime;    int				tics;    int				wipestart;    int				y;    boolean			done;    boolean			wipe;    boolean			redrawsbar;    if (nodrawers)	return;                    // for comparative timing / profiling		    redrawsbar = false;        // change the view size if needed    if (setsizeneeded)    {	R_ExecuteSetViewSize ();	oldgamestate = -1;                      // force background redraw	borderdrawcount = 3;    }    // save the current screen if about to wipe    if (gamestate != wipegamestate)    {	wipe = true;	wipe_StartScreen(0, 0, SCREENWIDTH, SCREENHEIGHT);    }    else	wipe = false;    if (gamestate == GS_LEVEL && gametic)	HU_Erase();        // do buffered drawing    switch (gamestate)    {      case GS_LEVEL:	if (!gametic)	    break;	if (automapactive)	    AM_Drawer ();	if (wipe || (viewheight != 200 && fullscreen) )	    redrawsbar = true;	if (inhelpscreensstate && !inhelpscreens)	    redrawsbar = true;              // just put away the help screen	ST_Drawer (viewheight == 200, redrawsbar );	fullscreen = viewheight == 200;	break;      case GS_INTERMISSION:	WI_Drawer ();	break;      case GS_FINALE:	F_Drawer ();	break;      case GS_DEMOSCREEN:	D_PageDrawer ();	break;    }        // draw buffered stuff to screen    I_UpdateNoBlit ();        // draw the view directly    if (gamestate == GS_LEVEL && !automapactive && gametic)	R_RenderPlayerView (&players[displayplayer]);    if (gamestate == GS_LEVEL && gametic)	HU_Drawer ();        // clean up border stuff    if (gamestate != oldgamestate && gamestate != GS_LEVEL)	I_SetPalette (W_CacheLumpName ("PLAYPAL",PU_CACHE));    // see if the border needs to be initially drawn    if (gamestate == GS_LEVEL && oldgamestate != GS_LEVEL)    {	viewactivestate = false;        // view was not active	R_FillBackScreen ();    // draw the pattern into the back screen    }    // see if the border needs to be updated to the screen    if (gamestate == GS_LEVEL && !automapactive && scaledviewwidth != 320)    {	if (menuactive || menuactivestate || !viewactivestate)	    borderdrawcount = 3;	if (borderdrawcount)	{	    R_DrawViewBorder ();    // erase old menu stuff	    borderdrawcount--;	}    }    menuactivestate = menuactive;    viewactivestate = viewactive;    inhelpscreensstate = inhelpscreens;    oldgamestate = wipegamestate = gamestate;        // draw pause pic    if (paused)    {	if (automapactive)	    y = 4;	else	    y = viewwindowy+4;	V_DrawPatchDirect(viewwindowx+(scaledviewwidth-68)/2,			  y,0,W_CacheLumpName ("M_PAUSE", PU_CACHE));    }    // menus go directly to the screen    M_Drawer ();          // menu is drawn even on top of everything    NetUpdate ();         // send out any new accumulation    // normal update    if (!wipe)    {	I_FinishUpdate ();              // page flip or blit buffer	return;    }        // wipe update    wipe_EndScreen(0, 0, SCREENWIDTH, SCREENHEIGHT);    wipestart = I_GetTime () - 1;    do    {	do	{	    nowtime = I_GetTime ();	    tics = nowtime - wipestart;	} while (!tics);	wipestart = nowtime;	done = wipe_ScreenWipe(wipe_Melt			       , 0, 0, SCREENWIDTH, SCREENHEIGHT, tics);	I_UpdateNoBlit ();	M_Drawer ();                            // menu is drawn even on top of wipes	I_FinishUpdate ();                      // page flip or blit buffer    } while (!done);}////  D_DoomLoop//extern  boolean         demorecording;void D_DoomLoop (void){    if (demorecording)	G_BeginRecording ();		    if (M_CheckParm ("-debugfile"))    {	char    filename[20];	sprintf (filename,"debug%i.txt",consoleplayer);	printf ("debug output to: %s\n",filename);	debugfile = fopen (filename,"w");    }	    I_InitGraphics ();    while (1)    {	// frame syncronous IO operations	I_StartFrame ();                		// process one or more tics	if (singletics)	{	    I_StartTic ();	    D_ProcessEvents ();	    G_BuildTiccmd (&netcmds[consoleplayer][maketic%BACKUPTICS]);	    if (advancedemo)		D_DoAdvanceDemo ();	    M_Ticker ();	    G_Ticker ();	    gametic++;	    maketic++;	}	else	{	    TryRunTics (); // will run at least one tic	}	S_UpdateSounds (players[consoleplayer].mo);// move positional sounds	// Update display, next frame, with current state.	D_Display ();    }}////  DEMO LOOP//int             demosequence;int             pagetic;char                    *pagename;//// D_PageTicker// Handles timing for warped projection//void D_PageTicker (void){    if (--pagetic < 0)	D_AdvanceDemo ();}//// D_PageDrawer//void D_PageDrawer (void){    V_DrawPatch (0,0, 0, W_CacheLumpName(pagename, PU_CACHE));}//// D_AdvanceDemo// Called after each demo or intro demosequence finishes//void D_AdvanceDemo (void){    advancedemo = true;}//// This cycles through the demo sequences.// FIXME - version dependend demo numbers?// void D_DoAdvanceDemo (void){    players[consoleplayer].playerstate = PST_LIVE;  // not reborn    advancedemo = false;    usergame = false;               // no save / end game here    paused = false;    gameaction = ga_nothing;    if ( gamemode == retail )      demosequence = (demosequence+1)%7;    else      demosequence = (demosequence+1)%6;        switch (demosequence)    {      case 0:	if ( gamemode == commercial )	    pagetic = 35 * 11;	else	    pagetic = 170;	gamestate = GS_DEMOSCREEN;	pagename = "TITLEPIC";	if ( gamemode == commercial )	  S_StartMusic(mus_dm2ttl);	else	  S_StartMusic (mus_intro);	break;      case 1:	G_DeferedPlayDemo ("demo1");	break;      case 2:	pagetic = 200;	gamestate = GS_DEMOSCREEN;	pagename = "CREDIT";	break;      case 3:	G_DeferedPlayDemo ("demo2");	break;      case 4:	gamestate = GS_DEMOSCREEN;	if ( gamemode == commercial)	{	    pagetic = 35 * 11;	    pagename = "TITLEPIC";	    S_StartMusic(mus_dm2ttl);	}	else	{	    pagetic = 200;	    if ( gamemode == retail )	      pagename = "CREDIT";	    else	      pagename = "HELP2";	}	break;      case 5:	G_DeferedPlayDemo ("demo3");	break;        // THE DEFINITIVE DOOM Special Edition demo      case 6:	G_DeferedPlayDemo ("demo4");	break;    }}//// D_StartTitle//void D_StartTitle (void){    gameaction = ga_nothing;    demosequence = -1;    D_AdvanceDemo ();}//      print title for every printed linechar            title[128];//// D_AddFile//void D_AddFile (char *file){    int     numwadfiles;    char    *newfile;	    for (numwadfiles = 0 ; wadfiles[numwadfiles] ; numwadfiles++)	;    newfile = malloc (strlen(file)+1);    strcpy (newfile, file);	    wadfiles[numwadfiles] = newfile;}//// IdentifyVersion// Checks availability of IWAD files by name,// to determine whether registered/commercial features// should be executed (notably loading PWAD's).//void IdentifyVersion (void){    char*	doom1wad;    char*	doomwad;    char*	doomuwad;    char*	doom2wad;    char*	doom2fwad;    char*	plutoniawad;    char*	tntwad;    char *home;    char *doomwaddir;    doomwaddir = getenv("DOOMWADDIR");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -