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

📄 sb_bar.c

📁 The source code of Doom legacy for windows
💻 C
📖 第 1 页 / 共 2 页
字号:
// Emacs style mode select   -*- C++ -*- //-----------------------------------------------------------------------------//// $Id: sb_bar.c,v 1.4 2001/02/24 13:35:21 bpereira Exp $//// Copyright (C) 1993-1996 by Raven Software, Corp.// Portions Copyright (C) 1998-2000 by DooM Legacy Team.//// 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: sb_bar.c,v $// Revision 1.4  2001/02/24 13:35:21  bpereira// no message//// Revision 1.3  2001/02/10 13:20:55  hurdler// update license//////// DESCRIPTION:////-----------------------------------------------------------------------------#include "doomdef.h"#include "p_local.h"#include "s_sound.h"#include "v_video.h"#include "w_wad.h"#include "z_zone.h"#include "dstrings.h"#include "am_map.h"#include "g_game.h"#include "m_cheat.h"#include "screen.h"#include "r_local.h"#include "p_local.h"#include "p_inter.h"#include "m_random.h"#include "i_video.h"#include "keys.h"#include "hu_stuff.h"#include "st_stuff.h"#include "st_lib.h"// Macros#define STARTREDPALS    1#define NUMREDPALS      8#define STARTBONUSPALS  9#define NUMBONUSPALS    4#define I_NOUPDATE      0#define I_FULLVIEW      1#define I_STATBAR       2#define I_MESSAGES      4#define I_FULLSCRN      8// Types// Private Functionsstatic void ShadeLine(int x, int y, int height, int shade);static void ShadeChain(void);static void DrINumber(signed int val, int x, int y);static void DrBNumber(signed int val, int x, int y);static void DrawCommonBar(void);static void DrawMainBar(void);static void DrawInventoryBar(void);static void DrawFullScreenStuff(void);void SB_PaletteFlash(void);// Public Dataint ArtifactFlash;// Private Datastatic int HealthMarker;static int ChainWiggle;static player_t *CPlayer;int playpalette;int UpdateState;patch_t *PatchLTFACE;patch_t *PatchRTFACE;patch_t *PatchBARBACK;patch_t *PatchCHAIN;patch_t *PatchSTATBAR;patch_t *PatchLIFEGEM;//patch_t *PatchEMPWEAP;//patch_t *PatchLIL4BOX;patch_t *PatchLTFCTOP;patch_t *PatchRTFCTOP;//patch_t *PatchARMORBOX;//patch_t *PatchARTIBOX;patch_t *PatchSELECTBOX;//patch_t *PatchKILLSPIC;//patch_t *PatchMANAPIC;//patch_t *PatchPOWERICN;patch_t *PatchINVLFGEM1;patch_t *PatchINVLFGEM2;patch_t *PatchINVRTGEM1;patch_t *PatchINVRTGEM2;patch_t *PatchINumbers[10];patch_t *PatchNEGATIVE;patch_t *PatchSmNumbers[10];patch_t *PatchBLACKSQ;patch_t *PatchINVBAR;patch_t *PatchARMCLEAR;patch_t *PatchCHAINBACK;//byte *ShadeTables;//extern byte *screen;int FontBNumBase;int spinbooklump;int spinflylump;//---------------------------------------------------------------------------//// PROC SB_Init////---------------------------------------------------------------------------void SB_Init(void){	int i;	int startLump;	PatchLTFACE = W_CachePatchName("LTFACE", PU_STATIC);	PatchRTFACE = W_CachePatchName("RTFACE", PU_STATIC);	PatchBARBACK = W_CachePatchName("BARBACK", PU_STATIC);	PatchINVBAR = W_CachePatchName("INVBAR", PU_STATIC);	PatchCHAIN = W_CachePatchName("CHAIN", PU_STATIC);	if(cv_deathmatch.value)	{		PatchSTATBAR = W_CachePatchName("STATBAR", PU_STATIC);	}	else	{		PatchSTATBAR = W_CachePatchName("LIFEBAR", PU_STATIC);	}	if(!multiplayer)	{ // single player game uses red life gem		PatchLIFEGEM = W_CachePatchName("LIFEGEM2", PU_STATIC);	}	else	{		PatchLIFEGEM = W_CachePatchNum(W_GetNumForName("LIFEGEM0")			+ consoleplayer, PU_STATIC);	}	PatchLTFCTOP = W_CachePatchName("LTFCTOP", PU_STATIC);	PatchRTFCTOP = W_CachePatchName("RTFCTOP", PU_STATIC);	PatchSELECTBOX = W_CachePatchName("SELECTBOX", PU_STATIC);	PatchINVLFGEM1 = W_CachePatchName("INVGEML1", PU_STATIC);	PatchINVLFGEM2 = W_CachePatchName("INVGEML2", PU_STATIC);	PatchINVRTGEM1 = W_CachePatchName("INVGEMR1", PU_STATIC);	PatchINVRTGEM2 = W_CachePatchName("INVGEMR2", PU_STATIC);	PatchBLACKSQ	=   W_CachePatchName("BLACKSQ", PU_STATIC);	PatchARMCLEAR = W_CachePatchName("ARMCLEAR", PU_STATIC);	PatchCHAINBACK = W_CachePatchName("CHAINBACK", PU_STATIC);	startLump = W_GetNumForName("IN0");	for(i = 0; i < 10; i++)	{		PatchINumbers[i] = W_CachePatchNum(startLump+i, PU_STATIC);	}	PatchNEGATIVE = W_CachePatchName("NEGNUM", PU_STATIC);	FontBNumBase = W_GetNumForName("FONTB16");	startLump = W_GetNumForName("SMALLIN0");	for(i = 0; i < 10; i++)	{		PatchSmNumbers[i] = W_CachePatchNum(startLump+i, PU_STATIC);	}	playpalette = W_GetNumForName("PLAYPAL");	spinbooklump = W_GetNumForName("SPINBK0");	spinflylump = W_GetNumForName("SPFLY0");}//---------------------------------------------------------------------------//// PROC SB_Ticker////---------------------------------------------------------------------------void SB_Ticker(void){	int delta;	int curHealth;	if(leveltime&1)	{		ChainWiggle = P_Random()&1;	}	curHealth = players[consoleplayer].mo->health;	if(curHealth < 0)	{		curHealth = 0;	}	if(curHealth < HealthMarker)	{		delta = (HealthMarker-curHealth)>>2;		if(delta < 1)		{			delta = 1;		}		else if(delta > 8)		{			delta = 8;		}		HealthMarker -= delta;	}	else if(curHealth > HealthMarker)	{		delta = (curHealth-HealthMarker)>>2;		if(delta < 1)		{			delta = 1;		}		else if(delta > 8)		{			delta = 8;		}		HealthMarker += delta;	}}//---------------------------------------------------------------------------//// PROC DrINumber//// Draws a three digit number.////---------------------------------------------------------------------------static void DrINumber(signed int val, int x, int y){	patch_t *patch;	int oldval;	oldval = val;	if(val < 0)	{		if(val < -9)		{			V_DrawScaledPatch(x+1, y+1, fgbuffer, W_CachePatchName("LAME", PU_CACHE));		}		else		{			val = -val;			V_DrawScaledPatch(x+18, y, fgbuffer, PatchINumbers[val]);			V_DrawScaledPatch(x+9, y, fgbuffer, PatchNEGATIVE);		}		return;	}	if(val > 99)	{		patch = PatchINumbers[val/100];		V_DrawScaledPatch(x, y, fgbuffer, patch);	}	val = val%100;	if(val > 9 || oldval > 99)	{		patch = PatchINumbers[val/10];		V_DrawScaledPatch(x+9, y, fgbuffer, patch);	}	val = val%10;	patch = PatchINumbers[val];	V_DrawScaledPatch(x+18, y, fgbuffer, patch);}//---------------------------------------------------------------------------//// PROC DrBNumber//// Draws a three digit number using FontB////---------------------------------------------------------------------------#define V_DrawShadowedPatch(x,y,p) V_DrawTranslucentPatch(x,y,V_SCALESTART|0,p)#define V_DrawFuzzPatch(x,y,p)     V_DrawTranslucentPatch(x,y,V_SCALESTART|0,p)static void DrBNumber(signed int val, int x, int y){	patch_t *patch;	int xpos;	int oldval;	oldval = val;	xpos = x;	if(val < 0)	{		val = 0;	}	if(val > 99)	{		patch = W_CachePatchNum(FontBNumBase+val/100, PU_CACHE);		V_DrawShadowedPatch(xpos+6-patch->width/2, y, patch);	}	val = val%100;	xpos += 12;	if(val > 9 || oldval > 99)	{		patch = W_CachePatchNum(FontBNumBase+val/10, PU_CACHE);		V_DrawShadowedPatch(xpos+6-patch->width/2, y, patch);	}	val = val%10;	xpos += 12;	patch = W_CachePatchNum(FontBNumBase+val, PU_CACHE);	V_DrawShadowedPatch(xpos+6-patch->width/2, y, patch);}//---------------------------------------------------------------------------//// PROC DrSmallNumber//// Draws a small two digit number.////---------------------------------------------------------------------------static void DrSmallNumber(int val, int x, int y){	patch_t *patch;	if(val == 1)	{		return;	}	if(val > 9)	{		patch = PatchSmNumbers[val/10];		V_DrawScaledPatch(x, y, fgbuffer, patch);	}	val = val%10;	patch = PatchSmNumbers[val];	V_DrawScaledPatch(x+4, y, fgbuffer, patch);}//---------------------------------------------------------------------------//// PROC ShadeLine////---------------------------------------------------------------------------static void ShadeLine(int x, int y, int height, int shade){    byte *dest;    byte *shades;        shades = colormaps+9*256+shade*2*256;    dest = screens[0]+y*vid.width+x;    while(height--)    {        *(dest) = *(shades+*dest);        dest += vid.width;    }}//---------------------------------------------------------------------------//// PROC ShadeChain////---------------------------------------------------------------------------static void ShadeChain(void){    int i;    if( rendermode != render_soft )        return;        for(i = 0; i < 16*st_scalex; i++)    {        ShadeLine((st_x+277)*st_scalex+i, (ST_Y+32)*st_scaley, 10*st_scaley, i/4);        ShadeLine((st_x+19)*st_scalex+i, (ST_Y+32)*st_scaley, 10*st_scaley, 7-(i/4));    }}//---------------------------------------------------------------------------//// PROC SB_Drawer////---------------------------------------------------------------------------char patcharti[][10] ={	{"ARTIBOX"},	// none	{"ARTIINVU"},	// invulnerability	{"ARTIINVS"},	// invisibility	{"ARTIPTN2"},	// health	{"ARTISPHL"},	// superhealth	{"ARTIPWBK"},	// tomeofpower	{"ARTITRCH"},	// torch	{"ARTIFBMB"},	// firebomb	{"ARTIEGGC"},	// egg	{"ARTISOAR"},	// fly	{"ARTIATLP"}	// teleport};char ammopic[][10] ={	{"INAMGLD"},	{"INAMBOW"},	{"INAMBST"},	{"INAMRAM"},	{"INAMPNX"},	{"INAMLOB"}};int SB_state = -1;static int oldarti = -1;static int oldartiCount = 0;static int oldfrags = -9999;static int oldammo = -1;static int oldarmor = -1;static int oldweapon = -1;static int oldhealth = -1;static int oldlife = -1;static int oldkeys = -1;

⌨️ 快捷键说明

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