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

Iskhodnyy_kod_Doom

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

//refresh everything if this is him coming back to life ST_updateFaceWidget();

//used by the w_armsbg widget

st_notdeathmatch = !deathmatch;

// used by w_arms[] widgets

st_armson = st_statusbaron && !deathmatch;

// used by w_frags widget

st_fragson = deathmatch && st_statusbaron; st_fragscount = 0;

for (i=0 ; i<MAXPLAYERS ; i++)

{

if (i != consoleplayer) st_fragscount += plyr->frags[i];

else

st_fragscount -= plyr->frags[i];

}

// get rid of chat window if up because of message if (!--st_msgcounter)

st_chat = st_oldchat;

}

void ST_Ticker (void)

{

st_clock++;

st_randomnumber = M_Random(); ST_updateWidgets(); st_oldhealth = plyr->health;

}

static int st_palette = 0;

void ST_doPaletteStuff(void)

{

int

palette;

byte*

pal;

int

cnt;

int

bzc;

cnt = plyr->damagecount;

if (plyr->powers[pw_strength])

{

// slowly fade the berzerk out

bzc = 12 - (plyr->powers[pw_strength]>>6);

if (bzc > cnt) cnt = bzc;

}

if (cnt)

{

palette = (cnt+7)>>3;

if (palette >= NUMREDPALS) palette = NUMREDPALS-1;

751

palette += STARTREDPALS;

}

else if (plyr->bonuscount)

{

palette = (plyr->bonuscount+7)>>3;

if (palette >= NUMBONUSPALS) palette = NUMBONUSPALS-1;

palette += STARTBONUSPALS;

}

else if ( plyr->powers[pw_ironfeet] > 4*32 || plyr->powers[pw_ironfeet]&8)

palette = RADIATIONPAL;

else

palette = 0;

if (palette != st_palette)

{

st_palette = palette;

pal = (byte *) W_CacheLumpNum (lu_palette, PU_CACHE)+palette*768; I_SetPalette (pal);

}

}

void ST_drawWidgets(boolean refresh)

{

int

i;

 

//

used by

w_arms[] widgets

 

st_armson = st_statusbaron

&& !deathmatch;

//

used by

w_frags widget

 

st_fragson

= deathmatch &&

st_statusbaron;

STlib_updateNum(&w_ready, refresh);

for (i=0;i<4;i++)

{

STlib_updateNum(&w_ammo[i], refresh);

STlib_updateNum(&w_maxammo[i], refresh);

}

STlib_updatePercent(&w_health, refresh);

STlib_updatePercent(&w_armor, refresh);

STlib_updateBinIcon(&w_armsbg, refresh);

for (i=0;i<6;i++) STlib_updateMultIcon(&w_arms[i], refresh);

STlib_updateMultIcon(&w_faces, refresh);

for (i=0;i<3;i++) STlib_updateMultIcon(&w_keyboxes[i], refresh);

STlib_updateNum(&w_frags, refresh);

}

void ST_doRefresh(void)

{

752

st_firsttime = false;

//draw status bar background to off-screen buff ST_refreshBackground();

//and refresh all widgets

ST_drawWidgets(true);

}

void ST_diffDraw(void)

{

// update all widgets ST_drawWidgets(false);

}

void ST_Drawer (boolean fullscreen, boolean refresh)

{

st_statusbaron = (!fullscreen) || automapactive; st_firsttime = st_firsttime || refresh;

//Do red-/gold-shifts from damage/items ST_doPaletteStuff();

//If just after ST_Start(), refresh all if (st_firsttime) ST_doRefresh();

//Otherwise, update as little as possible else ST_diffDraw();

}

void ST_loadGraphics(void)

{

int

i;

int

j;

int

facenum;

char

namebuf[9];

// Load the numbers, tall and short for (i=0;i<10;i++)

{

sprintf(namebuf, "STTNUM%d", i);

tallnum[i] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC);

sprintf(namebuf, "STYSNUM%d", i);

shortnum[i] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC);

}

// Load percent key.

//Note: why not load STMINUS here, too?

tallpercent = (patch_t *) W_CacheLumpName("STTPRCNT", PU_STATIC);

// key cards

for (i=0;i<NUMCARDS;i++)

{

sprintf(namebuf, "STKEYS%d", i);

keys[i] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC);

}

// arms background

armsbg = (patch_t *) W_CacheLumpName("STARMS", PU_STATIC);

753

// arms ownership widgets for (i=0;i<6;i++)

{

sprintf(namebuf, "STGNUM%d", i+2);

// gray #

arms[i][0] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC);

// yellow #

arms[i][1] = shortnum[i+2];

}

//face backgrounds for different color players sprintf(namebuf, "STFB%d", consoleplayer);

faceback = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC);

//status bar background bits

sbar = (patch_t *) W_CacheLumpName("STBAR", PU_STATIC);

// face states facenum = 0;

for (i=0;i<ST_NUMPAINFACES;i++)

{

for (j=0;j<ST_NUMSTRAIGHTFACES;j++)

{

sprintf(namebuf, "STFST%d%d", i, j);

faces[facenum++] = W_CacheLumpName(namebuf, PU_STATIC);

}

 

 

sprintf(namebuf, "STFTR%d0", i);

// turn right

faces[facenum++] = W_CacheLumpName(namebuf,

PU_STATIC);

sprintf(namebuf, "STFTL%d0", i);

// turn left

faces[facenum++] = W_CacheLumpName(namebuf,

PU_STATIC);

sprintf(namebuf, "STFOUCH%d", i);

//

ouch!

faces[facenum++] = W_CacheLumpName(namebuf,

PU_STATIC);

sprintf(namebuf, "STFEVL%d", i);

// evil grin ;)

faces[facenum++] = W_CacheLumpName(namebuf,

PU_STATIC);

sprintf(namebuf, "STFKILL%d", i);

//

pissed off

faces[facenum++] = W_CacheLumpName(namebuf,

PU_STATIC);

}

faces[facenum++] = W_CacheLumpName("STFGOD0", PU_STATIC); faces[facenum++] = W_CacheLumpName("STFDEAD0", PU_STATIC);

}

void ST_loadData(void)

{

lu_palette = W_GetNumForName ("PLAYPAL"); ST_loadGraphics();

}

void ST_unloadGraphics(void)

{

int i;

//unload the numbers, tall and short for (i=0;i<10;i++)

{

Z_ChangeTag(tallnum[i], PU_CACHE); Z_ChangeTag(shortnum[i], PU_CACHE);

}

//unload tall percent

Z_ChangeTag(tallpercent, PU_CACHE);

754

// unload arms background Z_ChangeTag(armsbg, PU_CACHE);

//unload gray #’s for (i=0;i<6;i++)

Z_ChangeTag(arms[i][0], PU_CACHE);

//unload the key cards

for (i=0;i<NUMCARDS;i++) Z_ChangeTag(keys[i], PU_CACHE);

Z_ChangeTag(sbar, PU_CACHE);

Z_ChangeTag(faceback, PU_CACHE);

for (i=0;i<ST_NUMFACES;i++) Z_ChangeTag(faces[i], PU_CACHE);

//Note: nobody ain’t seen no unloading

//of stminus yet. Dude.

}

void ST_unloadData(void)

{

ST_unloadGraphics();

}

void ST_initData(void)

{

int i;

st_firsttime = true;

plyr = &players[consoleplayer];

st_clock = 0;

st_chatstate = StartChatState; st_gamestate = FirstPersonState;

st_statusbaron = true; st_oldchat = st_chat = false; st_cursoron = false;

st_faceindex = 0; st_palette = -1;

st_oldhealth = -1;

for (i=0;i<NUMWEAPONS;i++)

oldweaponsowned[i] = plyr->weaponowned[i];

for (i=0;i<3;i++) keyboxes[i] = -1;

STlib_init();

}

void ST_createWidgets(void)

{

int i;

755

// ready weapon ammo STlib_initNum(&w_ready,

ST_AMMOX,

ST_AMMOY, tallnum,

&plyr->ammo[weaponinfo[plyr->readyweapon].ammo], &st_statusbaron,

ST_AMMOWIDTH );

// the last weapon type w_ready.data = plyr->readyweapon;

// health percentage STlib_initPercent(&w_health,

ST_HEALTHX,

ST_HEALTHY, tallnum, &plyr->health, &st_statusbaron, tallpercent);

// arms background STlib_initBinIcon(&w_armsbg,

ST_ARMSBGX,

ST_ARMSBGY, armsbg, &st_notdeathmatch, &st_statusbaron);

// weapons owned for(i=0;i<6;i++)

{

STlib_initMultIcon(&w_arms[i],

ST_ARMSX+(i%3)*ST_ARMSXSPACE,

ST_ARMSY+(i/3)*ST_ARMSYSPACE,

arms[i], (int *) &plyr->weaponowned[i+1], &st_armson);

}

// frags sum STlib_initNum(&w_frags,

ST_FRAGSX,

ST_FRAGSY, tallnum, &st_fragscount, &st_fragson, ST_FRAGSWIDTH);

// faces STlib_initMultIcon(&w_faces,

ST_FACESX,

ST_FACESY, faces, &st_faceindex,

&st_statusbaron);

// armor percentage - should be colored later STlib_initPercent(&w_armor,

ST_ARMORX,

ST_ARMORY, tallnum,

&plyr->armorpoints, &st_statusbaron, tallpercent);

756

// keyboxes 0-2 STlib_initMultIcon(&w_keyboxes[0],

ST_KEY0X,

ST_KEY0Y, keys, &keyboxes[0],

&st_statusbaron);

STlib_initMultIcon(&w_keyboxes[1], ST_KEY1X, ST_KEY1Y,

keys,

&keyboxes[1], &st_statusbaron);

STlib_initMultIcon(&w_keyboxes[2], ST_KEY2X, ST_KEY2Y,

keys,

&keyboxes[2], &st_statusbaron);

// ammo count (all four kinds) STlib_initNum(&w_ammo[0],

ST_AMMO0X,

ST_AMMO0Y, shortnum, &plyr->ammo[0], &st_statusbaron, ST_AMMO0WIDTH);

STlib_initNum(&w_ammo[1], ST_AMMO1X, ST_AMMO1Y, shortnum, &plyr->ammo[1], &st_statusbaron, ST_AMMO1WIDTH);

STlib_initNum(&w_ammo[2], ST_AMMO2X, ST_AMMO2Y, shortnum, &plyr->ammo[2], &st_statusbaron, ST_AMMO2WIDTH);

STlib_initNum(&w_ammo[3], ST_AMMO3X, ST_AMMO3Y, shortnum, &plyr->ammo[3], &st_statusbaron, ST_AMMO3WIDTH);

// max ammo count (all four kinds) STlib_initNum(&w_maxammo[0],

ST_MAXAMMO0X,

ST_MAXAMMO0Y, shortnum, &plyr->maxammo[0], &st_statusbaron, ST_MAXAMMO0WIDTH);

STlib_initNum(&w_maxammo[1],

757

ST_MAXAMMO1X,

ST_MAXAMMO1Y, shortnum, &plyr->maxammo[1], &st_statusbaron, ST_MAXAMMO1WIDTH);

STlib_initNum(&w_maxammo[2], ST_MAXAMMO2X, ST_MAXAMMO2Y, shortnum, &plyr->maxammo[2], &st_statusbaron, ST_MAXAMMO2WIDTH);

STlib_initNum(&w_maxammo[3], ST_MAXAMMO3X, ST_MAXAMMO3Y, shortnum, &plyr->maxammo[3], &st_statusbaron, ST_MAXAMMO3WIDTH);

}

static boolean

st_stopped = true;

void ST_Start (void)

{

if (!st_stopped) ST_Stop();

ST_initData(); ST_createWidgets(); st_stopped = false;

}

void ST_Stop (void)

{

if (st_stopped) return;

I_SetPalette (W_CacheLumpNum (lu_palette, PU_CACHE));

st_stopped = true;

}

void ST_Init (void)

{

veryfirsttime = 0; ST_loadData();

screens[4] = (byte *) Z_Malloc(ST_WIDTH*ST_HEIGHT, PU_STATIC, 0);

}

12.4st stu .h

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

//

//$Id:$

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

758

//

//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:

//Status bar code.

//Does the face/direction indicator animatin.

//Does palette indicators as well (red pain/berserk, bright pickup)

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

#ifndef __STSTUFF_H__ #define __STSTUFF_H__

#include "doomtype.h" #include "d_event.h"

//Size of statusbar.

//Now sensitive for scaling.

#define ST_HEIGHT

32*SCREEN_MUL

#define

ST_WIDTH

SCREENWIDTH

#define

ST_Y

(SCREENHEIGHT - ST_HEIGHT)

//

//STATUS BAR

//Called by main loop.

boolean ST_Responder (event_t* ev);

//Called by main loop. void ST_Ticker (void);

//Called by main loop.

void ST_Drawer (boolean fullscreen, boolean refresh);

//Called when the console player is spawned on each level. void ST_Start (void);

//Called by startup code.

void ST_Init (void);

// States for status bar code. typedef enum

{

AutomapState,

FirstPersonState

} st_stateenum_t;

// States for the chat code. typedef enum

{

StartChatState,

759

WaitDestState,

GetChatState

} st_chatstateenum_t;

boolean ST_Responder(event_t* ev);

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

//

// $Log:$

//

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

13 General graphic drawing

13.1 v video.c

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

//

//$Id:$

//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:$

//DESCRIPTION:

//Gamma correction LUT stuff.

//Functions to draw patches (by post) directly to screen.

//Functions to blit a block to the screen.

//

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

static const char

rcsid[] = "$Id: v_video.c,v 1.5 1997/02/03 22:45:13 b1 Exp $";

#include "i_system.h" #include "r_local.h"

#include "doomdef.h" #include "doomdata.h"

#include "m_bbox.h" #include "m_swap.h"

#include "v_video.h"

// Each screen is [SCREENWIDTH*SCREENHEIGHT];

byte* screens[5];

760

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