Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Iskhodnyy_kod_Doom

.pdf
Скачиваний:
7
Добавлен:
13.02.2015
Размер:
1.01 Mб
Скачать

//Main loop menu stuff.

//Random number LUT.

//Default Config File.

//PCX Screenshots.

//

//-----------------------------------------------------------------------------

static const char

rcsid[] = "$Id: m_bbox.c,v 1.1 1997/02/03 22:45:10 b1 Exp $";

#ifdef __GNUG__

#pragma implementation "m_bbox.h" #endif

#include "m_bbox.h"

void M_ClearBox (fixed_t *box)

{

box[BOXTOP] = box[BOXRIGHT] = MININT; box[BOXBOTTOM] = box[BOXLEFT] = MAXINT;

}

void M_AddToBox

(fixed_t* box, fixed_t x,

fixed_t

y )

{

if (x<box[BOXLEFT]) box[BOXLEFT] = x;

else if (x>box[BOXRIGHT]) box[BOXRIGHT] = x;

if (y<box[BOXBOTTOM]) box[BOXBOTTOM] = y;

else if (y>box[BOXTOP]) box[BOXTOP] = y;

}

8.4m bbox.h

// Emacs style mode select -*- C++ -*- //-----------------------------------------------------------------------------

//

//$Id:$

//Copyright (C) 1993-1996 by id Software, Inc.

//This program is free software; you can redistribute it and/or

//modify it under the terms of the GNU General Public License

//as published by the Free Software Foundation; either version 2

//of the License, or (at your option) any later version.

//

//This program is distributed in the hope that it will be useful,

//but WITHOUT ANY WARRANTY; without even the implied warranty of

//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

//GNU General Public License for more details.

//

221

//DESCRIPTION:

//Nil.

//

//-----------------------------------------------------------------------------

#ifndef __M_BBOX__ #define __M_BBOX__

#include <values.h>

#include "m_fixed.h"

// Bounding box coordinate storage.

enum

 

 

{

 

 

 

BOXTOP,

 

BOXBOTTOM,

 

BOXLEFT,

 

BOXRIGHT

 

};

 

// bbox coordinates

 

// Bounding box functions.

 

void M_ClearBox (fixed_t*

box);

void

 

 

M_AddToBox

 

 

( fixed_t*

box,

 

fixed_t

x,

 

fixed_t

y );

 

#endif

 

 

//-----------------------------------------------------------------------------

 

 

 

//

 

 

 

// $Log:$

 

 

//

 

 

 

//-----------------------------------------------------------------------------

 

 

 

8.5 m

 

cheat.c

 

// Emacs style mode select

-*- C++ -*-

//-----------------------------------------------------------------------------

 

 

 

//

 

 

 

//$Id:$

//Copyright (C) 1993-1996 by id Software, Inc.

//This program is free software; you can redistribute it and/or

//modify it under the terms of the GNU General Public License

//as published by the Free Software Foundation; either version 2

//of the License, or (at your option) any later version.

//

//This program is distributed in the hope that it will be useful,

//but WITHOUT ANY WARRANTY; without even the implied warranty of

//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

//GNU General Public License for more details.

//

//$Log:$

//DESCRIPTION:

//Cheat sequence checking.

//-----------------------------------------------------------------------------

222

static const char

rcsid[] = "$Id: m_cheat.c,v 1.1 1997/02/03 21:24:34 b1 Exp $";

#include "m_cheat.h"

//

// CHEAT SEQUENCE PACKAGE

//

static

int

firsttime = 1;

static

unsigned char

cheat_xlate_table[256];

//

//Called in st_stuff module, which handles the input.

//Returns a 1 if the cheat was successful, 0 if failed.

int cht_CheckCheat

( cheatseq_t*

cht,

 

char

key

)

{

 

 

int i;

 

 

int rc = 0;

 

 

if (firsttime)

{

firsttime = 0;

for (i=0;i<256;i++) cheat_xlate_table[i] = SCRAMBLE(i);

}

if (!cht->p)

cht->p = cht->sequence; // initialize if first time

if (*cht->p == 0) *(cht->p++) = key;

else if

(cheat_xlate_table[(unsigned char)key] == *cht->p) cht->p++;

else

cht->p = cht->sequence;

if (*cht->p == 1) cht->p++;

else if (*cht->p == 0xff) // end of sequence character

{

cht->p = cht->sequence; rc = 1;

}

return rc;

}

 

void

 

cht_GetParam

 

( cheatseq_t*

cht,

char*

buffer )

{

 

unsigned char *p, c;

p = cht->sequence; while (*(p++) != 1);

223

do

{

c = *p; *(buffer++) = c; *(p++) = 0;

}

while (c && *p!=0xff );

if (*p==0xff) *buffer = 0;

}

8.6m cheat.h

// Emacs style mode select -*- C++ -*- //-----------------------------------------------------------------------------

//

//$Id:$

//Copyright (C) 1993-1996 by id Software, Inc.

//This program is free software; you can redistribute it and/or

//modify it under the terms of the GNU General Public License

//as published by the Free Software Foundation; either version 2

//of the License, or (at your option) any later version.

//

//This program is distributed in the hope that it will be useful,

//but WITHOUT ANY WARRANTY; without even the implied warranty of

//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

//GNU General Public License for more details.

//

//DESCRIPTION:

//Cheat code checking.

//-----------------------------------------------------------------------------

#ifndef __M_CHEAT__ #define __M_CHEAT__

//

// CHEAT SEQUENCE PACKAGE

//

#define SCRAMBLE(a) \

((((a)&1)<<7) + (((a)&2)<<5) + ((a)&4) + (((a)&8)<<1) \

+ (((a)&16)>>1) + ((a)&32) + (((a)&64)>>5) + (((a)&128)>>7))

typedef struct

 

{

 

unsigned char*

sequence;

unsigned char*

p;

} cheatseq_t;

 

int

 

cht_CheckCheat

 

( cheatseq_t*

cht,

char

key );

void

 

224

cht_GetParam

 

( cheatseq_t*

cht,

char*

buffer );

#endif

 

//-----------------------------------------------------------------------------

 

 

 

//

 

 

 

// $Log:$

 

//

 

 

 

//-----------------------------------------------------------------------------

 

 

 

8.7 m

 

fixed.c

 

// Emacs style mode select

-*- C++ -*-

//-----------------------------------------------------------------------------

 

 

 

//

 

 

 

//$Id:$

//Copyright (C) 1993-1996 by id Software, Inc.

//This program is free software; you can redistribute it and/or

//modify it under the terms of the GNU General Public License

//as published by the Free Software Foundation; either version 2

//of the License, or (at your option) any later version.

//

//This program is distributed in the hope that it will be useful,

//but WITHOUT ANY WARRANTY; without even the implied warranty of

//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

//GNU General Public License for more details.

//

//$Log:$

//DESCRIPTION:

//Fixed point implementation.

//-----------------------------------------------------------------------------

static const char

rcsid[] = "$Id: m_bbox.c,v 1.1 1997/02/03 22:45:10 b1 Exp $";

#include "stdlib.h"

#include "doomtype.h" #include "i_system.h"

#ifdef __GNUG__

#pragma implementation "m_fixed.h" #endif

#include "m_fixed.h"

// Fixme. __USE_C_FIXED__ or something.

fixed_t

 

FixedMul

 

( fixed_t

a,

fixed_t

b )

{

 

return ((long long) a * (long long) b) >> FRACBITS;

}

225

//

// FixedDiv, C version.

//

fixed_t

 

FixedDiv

 

( fixed_t

a,

fixed_t

b )

{

 

if ( (abs(a)>>14) >= abs(b))

return (a^b)<0 ? MININT : MAXINT;

return FixedDiv2 (a,b);

}

 

fixed_t

 

FixedDiv2

 

( fixed_t

a,

fixed_t

b )

{

 

#if 0

 

long long c;

 

c = ((long long)a<<16) / ((long long)b); return (fixed_t) c;

#endif

double c;

c = ((double)a) / ((double)b) * FRACUNIT;

if (c >= 2147483648.0 || c < -2147483648.0) I_Error("FixedDiv: divide by zero");

return (fixed_t) c;

}

8.8m fixed.h

// Emacs style mode select -*- C++ -*- //-----------------------------------------------------------------------------

//

//$Id:$

//Copyright (C) 1993-1996 by id Software, Inc.

//This program is free software; you can redistribute it and/or

//modify it under the terms of the GNU General Public License

//as published by the Free Software Foundation; either version 2

//of the License, or (at your option) any later version.

//

//This program is distributed in the hope that it will be useful,

//but WITHOUT ANY WARRANTY; without even the implied warranty of

//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

//GNU General Public License for more details.

//

//DESCRIPTION:

//Fixed point arithemtics, implementation.

//-----------------------------------------------------------------------------

#ifndef __M_FIXED__

#define __M_FIXED__

226

#ifdef __GNUG__ #pragma interface #endif

//

// Fixed point, 32bit as 16.16.

//

 

#define FRACBITS

16

#define FRACUNIT

(1<<FRACBITS)

typedef int fixed_t;

 

fixed_t FixedMul

(fixed_t a, fixed_t b);

fixed_t FixedDiv

(fixed_t a, fixed_t b);

fixed_t FixedDiv2

(fixed_t a, fixed_t b);

#endif //-----------------------------------------------------------------------------

//

// $Log:$

//

//-----------------------------------------------------------------------------

8.9 m menu.c

// Emacs style mode select -*- C++ -*- //-----------------------------------------------------------------------------

//

//$Id:$

//Copyright (C) 1993-1996 by id Software, Inc.

//This program is free software; you can redistribute it and/or

//modify it under the terms of the GNU General Public License

//as published by the Free Software Foundation; either version 2

//of the License, or (at your option) any later version.

//

//This program is distributed in the hope that it will be useful,

//but WITHOUT ANY WARRANTY; without even the implied warranty of

//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

//GNU General Public License for more details.

//

//$Log:$

//DESCRIPTION:

//DOOM selection menu, options, episode etc.

//Sliders and icons. Kinda widget stuff.

//

//-----------------------------------------------------------------------------

static const char

rcsid[] = "$Id: m_menu.c,v 1.7 1997/02/03 22:45:10 b1 Exp $";

#include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <stdlib.h> #include <ctype.h>

227

#include

"doomdef.h"

#include

"dstrings.h"

#include

"d_main.h"

#include

"i_system.h"

#include

"i_video.h"

#include

"z_zone.h"

#include

"v_video.h"

#include

"w_wad.h"

#include

"r_local.h"

#include

"hu_stuff.h"

#include

"g_game.h"

#include

"m_argv.h"

#include

"m_swap.h"

#include

"s_sound.h"

#include

"doomstat.h"

// Data.

 

#include

"sounds.h"

#include

"m_menu.h"

extern patch_t*

hu_font[HU_FONTSIZE];

extern boolean

message_dontfuckwithme;

extern boolean

chat_on;

// in heads-up code

//

 

 

// defaulted values

 

 

//

 

 

int

mouseSensitivity;

// has default

// Show messages has default, 0 = off, 1 = on

 

int

showMessages;

 

// Blocky mode, has default, 0 = high, 1 = normal

 

int

detailLevel;

 

int

screenblocks;

// has default

// temp for screenblocks (0-9)

 

int

screenSize;

 

// -1 = no quicksave slot picked!

 

int

quickSaveSlot;

 

// 1 = message to be printed

 

int

messageToPrint;

 

// ...and here is the message string!

 

char*

messageString;

 

// message x & y

 

 

int

messx;

 

int

messy;

 

228

int

 

messageLastMenuActive;

// timed message = no input from user

boolean

 

messageNeedsInput;

void

(*messageRoutine)(int response);

#define

SAVESTRINGSIZE

24

char gammamsg[5][26] =

{

GAMMALVL0,

GAMMALVL1,

GAMMALVL2,

GAMMALVL3,

GAMMALVL4

};

// we are going to be entering a savegame string

int

 

saveStringEnter;

int

 

saveSlot;

// which slot to save in

int

 

saveCharIndex;

// which char we’re editing

// old save description before edit

 

char

 

saveOldString[SAVESTRINGSIZE];

boolean

 

inhelpscreens;

boolean

 

menuactive;

#define SKULLXOFF

-32

 

#define LINEHEIGHT

16

 

extern boolean

sendpause;

 

char

 

savegamestrings[10][SAVESTRINGSIZE];

char

endstring[160];

 

//

// MENU TYPEDEFS

//

typedef struct

{

// 0 = no cursor here, 1 = ok, 2 = arrows ok short status;

char name[10];

//choice = menu item #.

//if status = 2,

//choice=0:leftarrow,1:rightarrow

void

(*routine)(int choice);

 

// hotkey in menu

 

 

char

alphaKey;

 

} menuitem_t;

 

 

 

typedef struct menu_s

 

 

{

 

 

 

short

 

numitems;

// # of menu items

struct menu_s*

prevMenu;

// previous menu

menuitem_t*

 

menuitems;

// menu items

void

 

(*routine)();

// draw routine

short

 

x;

 

229

short

y;

// x,y of menu

short

lastOn;

// last item user was on in menu

} menu_t;

 

 

short

itemOn;

// menu item skull is on

short

skullAnimCounter;

// skull animation counter

short

whichSkull;

// which skull to draw

//graphic name of skulls

//warning: initializer-string for array of chars is too long

char

skullName[2][/*8*/9] = {"M_SKULL1","M_SKULL2"};

// current menudef

menu_t*

currentMenu;

//

// PROTOTYPES

//

void M_NewGame(int choice); void M_Episode(int choice); void M_ChooseSkill(int choice); void M_LoadGame(int choice); void M_SaveGame(int choice); void M_Options(int choice); void M_EndGame(int choice); void M_ReadThis(int choice); void M_ReadThis2(int choice); void M_QuitDOOM(int choice);

void M_ChangeMessages(int choice); void M_ChangeSensitivity(int choice); void M_SfxVol(int choice);

void M_MusicVol(int choice); void M_ChangeDetail(int choice); void M_SizeDisplay(int choice); void M_StartGame(int choice); void M_Sound(int choice);

void M_FinishReadThis(int choice); void M_LoadSelect(int choice); void M_SaveSelect(int choice); void M_ReadSaveStrings(void);

void M_QuickSave(void); void M_QuickLoad(void);

void M_DrawMainMenu(void); void M_DrawReadThis1(void); void M_DrawReadThis2(void); void M_DrawNewGame(void); void M_DrawEpisode(void); void M_DrawOptions(void); void M_DrawSound(void); void M_DrawLoad(void);

void M_DrawSave(void);

void M_DrawSaveLoadBorder(int x,int y); void M_SetupNextMenu(menu_t *menudef);

void M_DrawThermo(int x,int y,int thermWidth,int thermDot); void M_DrawEmptyCell(menu_t *menu,int item);

void M_DrawSelCell(menu_t *menu,int item); void M_WriteText(int x, int y, char *string); int M_StringWidth(char *string);

int M_StringHeight(char *string); void M_StartControlPanel(void);

void M_StartMessage(char *string,void *routine,boolean input);

230

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]