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

📄 r_draw.c

📁 The source code of Doom legacy for windows
💻 C
📖 第 1 页 / 共 2 页
字号:
// Emacs style mode select   -*- C++ -*- //-----------------------------------------------------------------------------//// $Id: r_draw.c,v 1.12 2001/04/01 17:35:06 bpereira Exp $//// Copyright (C) 1993-1996 by id Software, Inc.// 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: r_draw.c,v $// Revision 1.12  2001/04/01 17:35:06  bpereira// no message//// Revision 1.11  2001/03/13 22:14:20  stroggonmeth// Long time no commit. 3D floors, FraggleScript, portals, ect.//// Revision 1.10  2001/02/24 13:35:21  bpereira// no message//// Revision 1.9  2001/01/25 22:15:44  bpereira// added heretic support//// Revision 1.8  2000/11/09 17:56:20  stroggonmeth// Hopefully fixed a few bugs and did a few optimizations.//// Revision 1.7  2000/11/03 03:48:54  stroggonmeth// Fix a few warnings when compiling.//// Revision 1.6  2000/11/02 17:50:09  stroggonmeth// Big 3Dfloors & FraggleScript commit!!//// Revision 1.5  2000/07/01 09:23:49  bpereira// no message//// Revision 1.4  2000/04/07 18:47:09  hurdler// There is still a problem with the asm code and boom colormap// At least, with this little modif, it compiles on my Linux box//// Revision 1.3  2000/04/06 21:06:19  stroggonmeth// Optimized extra_colormap code...// Added #ifdefs for older water code.//// Revision 1.2  2000/02/27 00:42:10  hurdler// fix CR+LF problem//// Revision 1.1.1.1  2000/02/22 20:32:32  hurdler// Initial import into CVS (v1.29 pr3)////// DESCRIPTION://      span / column drawer functions, for 8bpp and 16bpp////      All drawing to the view buffer is accomplished in this file.//      The other refresh files only know about ccordinates,//      not the architecture of the frame buffer.//      The frame buffer is a linear one, and we need only the base address.////-----------------------------------------------------------------------------#include "doomdef.h"#include "doomstat.h"#include "r_local.h"#include "st_stuff.h"   //added:24-01-98:need ST_HEIGHT#include "i_video.h"#include "v_video.h"#include "w_wad.h"#include "z_zone.h"#include "console.h" //Som: Until I get buffering finished#ifdef HWRENDER#include "hardware/hw_main.h"#endif// ==========================================================================//                     COMMON DATA FOR 8bpp AND 16bpp// ==========================================================================byte*           viewimage;int             viewwidth;int             scaledviewwidth;int             viewheight;int             viewwindowx;int             viewwindowy;                // pointer to the start of each line of the screen,byte*           ylookup[MAXVIDHEIGHT];byte*           ylookup1[MAXVIDHEIGHT]; // for view1 (splitscreen)byte*           ylookup2[MAXVIDHEIGHT]; // for view2 (splitscreen)                 // x byte offset for columns inside the viewwindow                // so the first column starts at (SCRWIDTH-VIEWWIDTH)/2int             columnofs[MAXVIDWIDTH];#ifdef HORIZONTALDRAW//Fab 17-06-98: horizontal column drawer optimisationbyte*           yhlookup[MAXVIDWIDTH];int             hcolumnofs[MAXVIDHEIGHT];#endif// =========================================================================//                      COLUMN DRAWING CODE STUFF// =========================================================================lighttable_t*           dc_colormap;int                     dc_x;int                     dc_yl;int                     dc_yh;//Hurdler: 04/06/2000: asm code still use it//#ifdef OLDWATERint                     dc_yw;          //added:24-02-98: WATER!lighttable_t*           dc_wcolormap;   //added:24-02-98:WATER!//#endiffixed_t                 dc_iscale;fixed_t                 dc_texturemid;byte*                   dc_source;// -----------------------// translucency stuff here// -----------------------#define NUMTRANSTABLES  5     // how many translucency tables are usedbyte*                   transtables;    // translucency tables// R_DrawTransColumn uses thisbyte*                   dc_transmap;    // one of the translucency tables// ----------------------// translation stuff here// ----------------------byte*                   translationtables;// R_DrawTranslatedColumn uses thisbyte*                   dc_translation;struct r_lightlist_s*   dc_lightlist = NULL;int                     dc_numlights = 0;int                     dc_maxlights;struct wallportal_s*    dc_wallportals = NULL;int     dc_texheight;// =========================================================================//                      SPAN DRAWING CODE STUFF// =========================================================================int                     ds_y;int                     ds_x1;int                     ds_x2;lighttable_t*           ds_colormap;fixed_t                 ds_xfrac;fixed_t                 ds_yfrac;fixed_t                 ds_xstep;fixed_t                 ds_ystep;byte*                   ds_source;      // start of a 64*64 tile imagebyte*                   ds_transmap;    // one of the translucency tables// ==========================================================================//                        OLD DOOM FUZZY EFFECT// ==========================================================================//// Spectre/Invisibility.//#define FUZZTABLE     50#define FUZZOFF       (1)static  int fuzzoffset[FUZZTABLE] ={    FUZZOFF,-FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,    FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,    FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF,    FUZZOFF,-FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,    FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,-FUZZOFF,FUZZOFF,    FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,    FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF};static  int fuzzpos = 0;     // move through the fuzz table//  fuzzoffsets are dependend of vid width, for optimising purpose//  this is called by SCR_Recalc() whenever the screen size changes//void R_RecalcFuzzOffsets (void){    int i;    for (i=0;i<FUZZTABLE;i++)    {        fuzzoffset[i] = (fuzzoffset[i] < 0) ? -vid.width : vid.width;    }}// =========================================================================//                   TRANSLATION COLORMAP CODE// =========================================================================char *Color_Names[MAXSKINCOLORS]={   "Green",   "Gray" ,   "Brown",   "Red"  ,   "light gray" ,   "light brown",   "light red"  ,   "light blue" ,   "Blue"       ,   "Yellow"     ,   "Beige"};CV_PossibleValue_t Color_cons_t[]={{0,NULL},{1,NULL},{2,NULL},{3,NULL},                                   {4,NULL},{5,NULL},{6,NULL},{7,NULL},                                   {8,NULL},{9,NULL},{10,NULL},{0,NULL}};//  Creates the translation tables to map the green color ramp to//  another ramp (gray, brown, red, ...)////  This is precalculated for drawing the player sprites in the player's//  chosen color//void R_InitTranslationTables (void){    int         i,j;    //added:11-01-98: load here the transparency lookup tables 'TINTTAB'    // NOTE: the TINTTAB resource MUST BE aligned on 64k for the asm optimised    //       (in other words, transtables pointer low word is 0)    transtables = Z_MallocAlign (NUMTRANSTABLES*0x10000, PU_STATIC, 0, 16);    // load in translucency tables    if( gamemode == heretic )    {        W_ReadLump( W_GetNumForName("TINTTAB"), transtables );        W_ReadLump( W_GetNumForName("TINTTAB"), transtables+0x10000 );        W_ReadLump( W_GetNumForName("TINTTAB"), transtables+0x20000 );        W_ReadLump( W_GetNumForName("TINTTAB"), transtables+0x30000 );        W_ReadLump( W_GetNumForName("TINTTAB"), transtables+0x40000 );    }    else    {        W_ReadLump( W_GetNumForName("TRANSMED"), transtables );        W_ReadLump( W_GetNumForName("TRANSMOR"), transtables+0x10000 );        W_ReadLump( W_GetNumForName("TRANSHI"),  transtables+0x20000 );        W_ReadLump( W_GetNumForName("TRANSFIR"), transtables+0x30000 );        W_ReadLump( W_GetNumForName("TRANSFX1"), transtables+0x40000 );    }    translationtables = Z_MallocAlign (256*(MAXSKINCOLORS-1), PU_STATIC, 0, 8);    // translate just the 16 green colors    for (i=0 ; i<256 ; i++)    {        if ((i >= 0x70 && i <= 0x7f && gamemode != heretic) ||             (i >=  225 && i <=  240 && gamemode == heretic))        {            if( gamemode == heretic )            {                translationtables[i+ 0*256] =   0+(i-225); // dark gray                translationtables[i+ 1*256] =  67+(i-225); // brown                translationtables[i+ 2*256] = 145+(i-225); // red                translationtables[i+ 3*256] =   9+(i-225); // light gray                translationtables[i+ 4*256] =  74+(i-225); // light brown                translationtables[i+ 5*256] = 150+(i-225); // light red                translationtables[i+ 6*256] = 192+(i-225); // light blue                translationtables[i+ 7*256] = 185+(i-225); // dark blue                translationtables[i+ 8*256] = 114+(i-225); // yellow                translationtables[i+ 9*256] =  95+(i-225); // beige            }            else            {                // map green ramp to gray, brown, red                translationtables [i      ] = 0x60 + (i&0xf);                translationtables [i+  256] = 0x40 + (i&0xf);                translationtables [i+2*256] = 0x20 + (i&0xf);                                // added 9-2-98                translationtables [i+3*256] = 0x58 + (i&0xf); // light gray                translationtables [i+4*256] = 0x38 + (i&0xf); // light brown                translationtables [i+5*256] = 0xb0 + (i&0xf); // light red                translationtables [i+6*256] = 0xc0 + (i&0xf); // light blue                                if ((i&0xf) <9)

⌨️ 快捷键说明

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