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

📄 r_draw8.c

📁 The source code of Doom legacy for windows
💻 C
📖 第 1 页 / 共 2 页
字号:
  register fixed_t frac;  register fixed_t fracstep;       count = dc_yh - dc_yl + 1;   if (count <= 0)    // Zero length, column does not exceed a pixel.    return;                                  #ifdef RANGECHECK   if ((unsigned)dc_x >= vid.width      || dc_yl < 0      || dc_yh >= vid.height)     I_Error ("R_DrawColumn: %i to %i at %i", dc_yl, dc_yh, dc_x); #endif   // Framebuffer destination address.  // Use ylookup LUT to avoid multiply with ScreenWidth.  // Use columnofs LUT for subwindows?   dest = ylookup[dc_yl] + columnofs[dc_x];    // Determine scaling, which is the only mapping to be done.  fracstep = dc_iscale;   frac = dc_texturemid + (dc_yl-centery)*fracstep;   // Inner loop that does the actual texture mapping,  //  e.g. a DDA-lile scaling.  // This is as fast as it gets.  {      register const byte *source = dc_source;                  //register const lighttable_t *colormap = dc_colormap;      register int heightmask = dc_texheight-1;      if (dc_texheight & heightmask)      {          heightmask++;          heightmask <<= FRACBITS;                    if (frac < 0)              while ((frac += heightmask) <  0);              else                  while (frac >= heightmask)                      frac -= heightmask;                                    do                  {                      // Re-map color indices from wall texture column                      //  using a lighting/special effects LUT.                      // heightmask is the Tutti-Frutti fix -- killough                                            *dest = dc_colormap[*( dc_transmap + (source[frac>>FRACBITS] <<8) + (*dest) )];                      dest += vid.width;                      if ((frac += fracstep) >= heightmask)                          frac -= heightmask;                  }                   while (--count);      }      else      {          while ((count-=2)>=0)   // texture height is a power of 2 -- killough          {              *dest = dc_colormap[*( dc_transmap + (source[frac>>FRACBITS] <<8) + (*dest) )];              dest += vid.width;               frac += fracstep;              *dest = dc_colormap[*( dc_transmap + (source[frac>>FRACBITS] <<8) + (*dest) )];              dest += vid.width;               frac += fracstep;          }          if (count & 1)              *dest = dc_colormap[*( dc_transmap + (source[frac>>FRACBITS] <<8) + (*dest) )];      }  }}#endif // USEBOOMFUNC#endif////  Draw columns upto 128high but remap the green ramp to other colors////#ifndef USEASM        // STILL NOT IN ASM, TO DO..void R_DrawTranslatedColumn_8 (void){    register int     count;    register byte*   dest;    register fixed_t frac;    register fixed_t fracstep;    count = dc_yh - dc_yl;    if (count < 0)        return;#ifdef RANGECHECK    if ((unsigned)dc_x >= vid.width        || dc_yl < 0        || dc_yh >= vid.height)    {        I_Error ( "R_DrawColumn: %i to %i at %i",                  dc_yl, dc_yh, dc_x);    }#endif    // FIXME. As above.    dest = ylookup[dc_yl] + columnofs[dc_x];    // Looks familiar.    fracstep = dc_iscale;    frac = dc_texturemid + (dc_yl-centery)*fracstep;    // Here we do an additional index re-mapping.    do    {        // Translation tables are used        //  to map certain colorramps to other ones,        //  used with PLAY sprites.        // Thus the "green" ramp of the player 0 sprite        //  is mapped to gray, red, black/indigo.        *dest = dc_colormap[dc_translation[dc_source[frac>>FRACBITS]]];        dest += vid.width;        frac += fracstep;    } while (count--);}//#endif// ==========================================================================// SPANS// ==========================================================================//  Draws the actual span.//#ifndef USEASM#ifndef USEBOOMFUNCvoid R_DrawSpan_8 (void){    register ULONG     xfrac;    register ULONG     yfrac;    register byte*     dest;    register int       count;#ifdef RANGECHECK    if (ds_x2 < ds_x1        || ds_x1<0        || ds_x2>=vid.width        || (unsigned)ds_y>vid.height)    {        I_Error( "R_DrawSpan: %i to %i at %i",                 ds_x1,ds_x2,ds_y);    }#endif    xfrac = ds_xfrac&0x3fFFff;    yfrac = ds_yfrac;    dest = ylookup[ds_y] + columnofs[ds_x1];    // We do not check for zero spans here?    count = ds_x2 - ds_x1;    do    {        // Lookup pixel from flat texture tile,        //  re-index using light/colormap.        *dest++ = ds_colormap[ds_source[((yfrac>>(16-6))&(0x3f<<6)) | (xfrac>>16)]];        // Next step in u,v.        xfrac += ds_xstep;        yfrac += ds_ystep;        xfrac &= 0x3fFFff;    } while (count--);}#elsevoid R_DrawSpan_8 (void){   register unsigned position;  unsigned step;  byte *source;  byte *colormap;  byte *dest;      unsigned count;  unsigned spot;   unsigned xtemp;  unsigned ytemp;                  position = ((ds_xfrac<<10)&0xffff0000) | ((ds_yfrac>>6)&0xffff);  step = ((ds_xstep<<10)&0xffff0000) | ((ds_ystep>>6)&0xffff);                  source = ds_source;  colormap = ds_colormap;  dest = ylookup[ds_y] + columnofs[ds_x1];         count = ds_x2 - ds_x1 + 1;   while (count >= 4)    {      ytemp = position>>4;      ytemp = ytemp & 4032;      xtemp = position>>26;      spot = xtemp | ytemp;      position += step;      dest[0] = colormap[source[spot]];      ytemp = position>>4;      ytemp = ytemp & 4032;      xtemp = position>>26;      spot = xtemp | ytemp;      position += step;      dest[1] = colormap[source[spot]];      ytemp = position>>4;      ytemp = ytemp & 4032;      xtemp = position>>26;      spot = xtemp | ytemp;      position += step;      dest[2] = colormap[source[spot]];              ytemp = position>>4;      ytemp = ytemp & 4032;      xtemp = position>>26;      spot = xtemp | ytemp;      position += step;      dest[3] = colormap[source[spot]];      dest += 4;      count -= 4;    }  while (count)    {       ytemp = position>>4;      ytemp = ytemp & 4032;      xtemp = position>>26;      spot = xtemp | ytemp;      position += step;      *dest++ = colormap[source[spot]];      count--;    } }#endif // USEBOOMFUNC#endifvoid R_DrawTranslucentSpan_8 (void){   register unsigned position;  unsigned step;  byte *source;  byte *colormap;  byte *transmap;  byte *dest;      unsigned count;  unsigned spot;   unsigned xtemp;  unsigned ytemp;                  position = ((ds_xfrac<<10)&0xffff0000) | ((ds_yfrac>>6)&0xffff);  step = ((ds_xstep<<10)&0xffff0000) | ((ds_ystep>>6)&0xffff);                  source = ds_source;  colormap = ds_colormap;  transmap = ds_transmap;  dest = ylookup[ds_y] + columnofs[ds_x1];  count = ds_x2 - ds_x1 + 1;   while (count >= 4)    {      ytemp = position>>4;      ytemp = ytemp & 4032;      xtemp = position>>26;      spot = xtemp | ytemp;      position += step;      dest[0] = colormap[*(transmap + (source[spot] << 8) + (dest[0]))];      ytemp = position>>4;      ytemp = ytemp & 4032;      xtemp = position>>26;      spot = xtemp | ytemp;      position += step;      dest[1] = colormap[*(transmap + (source[spot] << 8) + (dest[1]))];              ytemp = position>>4;      ytemp = ytemp & 4032;      xtemp = position>>26;      spot = xtemp | ytemp;      position += step;      dest[2] = colormap[*(transmap + (source[spot] << 8) + (dest[2]))];              ytemp = position>>4;      ytemp = ytemp & 4032;      xtemp = position>>26;      spot = xtemp | ytemp;      position += step;      dest[3] = colormap[*(transmap + (source[spot] << 8) + (dest[3]))];      dest += 4;      count -= 4;    }  while (count--)    {       ytemp = position>>4;      ytemp = ytemp & 4032;      xtemp = position>>26;      spot = xtemp | ytemp;      position += step;      *dest++ = colormap[*(transmap + (source[spot] << 8) + (*dest))];      //count--;    } }void R_DrawFogSpan_8 (void){  byte *colormap;  byte *transmap;  byte *dest;      unsigned count;                  colormap = ds_colormap;  transmap = ds_transmap;  dest = ylookup[ds_y] + columnofs[ds_x1];         count = ds_x2 - ds_x1 + 1;           while (count >= 4)    {       dest[0] = colormap[dest[0]];      dest[1] = colormap[dest[1]];              dest[2] = colormap[dest[2]];              dest[3] = colormap[dest[3]];                      dest += 4;      count -= 4;    }   while (count--)      *dest++ = colormap[*dest];}//SoM: Fog wall.void R_DrawFogColumn_8 (void){    int                 count;    byte*               dest;    count = dc_yh - dc_yl;    // Zero length, column does not exceed a pixel.    if (count < 0)        return;#ifdef RANGECHECK    if ((unsigned)dc_x >= vid.width        || dc_yl < 0        || dc_yh >= vid.height)        I_Error ("R_DrawColumn: %i to %i at %i", dc_yl, dc_yh, dc_x);#endif    // Framebuffer destination address.    // Use ylookup LUT to avoid multiply with ScreenWidth.    // Use columnofs LUT for subwindows?    dest = ylookup[dc_yl] + columnofs[dc_x];    // Determine scaling,    //  which is the only mapping to be done.    do    {        //Simple. Apply the colormap to what's allready on the screen.        *dest = dc_colormap[*dest];        dest += vid.width;    } while (count--);}// SoM: This is for 3D floors that cast shadows on walls.// This function just cuts the column up into sections and calls// R_DrawColumn_8void R_DrawColumnShadowed_8 (void){    int                 count;    int                 realyh, realyl;    int                 i;    int                 height, bheight = 0;    int                 solid = 0;    realyh = dc_yh;    realyl = dc_yl;    count = dc_yh - dc_yl;    // Zero length, column does not exceed a pixel.    if (count < 0)        return;#ifdef RANGECHECK    if ((unsigned)dc_x >= vid.width        || dc_yl < 0        || dc_yh >= vid.height)        I_Error ("R_DrawColumn: %i to %i at %i", dc_yl, dc_yh, dc_x);#endif    // SoM: This runs through the lightlist from top to bottom and cuts up    // the column accordingly.    for(i = 0; i < dc_numlights; i++)    {      // If the height of the light is above the column, get the colormap      // anyway because the lighting of the top should be effected.      solid = dc_lightlist[i].flags & FF_CUTSOLIDS;      height = dc_lightlist[i].height >> 16;      if(solid)        bheight = dc_lightlist[i].botheight >> 16;      if(height <= dc_yl)      {        dc_colormap = dc_lightlist[i].rcolormap;        if(solid && dc_yl < bheight)          dc_yl = bheight;        continue;      }      // Found a break in the column!      dc_yh = height;      if(dc_yh > realyh)        dc_yh = realyh;      R_DrawColumn_8();      if(solid)        dc_yl = bheight;      else        dc_yl = dc_yh + 1;      dc_colormap = dc_lightlist[i].rcolormap;    }    dc_yh = realyh;    if(dc_yl <= realyh)      R_DrawColumn_8();}// SoM: This function works much like R_DrawColumnShadowed but it's purpose// is simply to cut into walls. When a wall portal sits on a column, the// column is split and the part (if any) that is left on the top and bottom// are sent to a regular column renderer and the "hole" is sent to be stored// in dc_portal.void R_DrawPortalColumn_8 (void){    int                 count;    int                 realyh, realyl;    int                 height = 0, bheight = 0;    wallportal_t*       wpr;    void                (*cfunc)(void);    realyh = dc_yh;    realyl = dc_yl;    count = dc_yh - dc_yl;    // Zero length, column does not exceed a pixel.    if (count < 0)        return;#ifdef RANGECHECK    if ((unsigned)dc_x >= vid.width        || dc_yl < 0        || dc_yh >= vid.height)        I_Error ("R_DrawColumn: %i to %i at %i", dc_yl, dc_yh, dc_x);#endif    if(dc_numlights)      cfunc = R_DrawColumnShadowed_8;    else      cfunc = R_DrawColumn_8;    // Run through the portal list and process them.    for(wpr = dc_wallportals; wpr; wpr = wpr->next)    {      height = wpr->top >> FRACBITS;      bheight = wpr->bottom >> FRACBITS;      // First, check to see if the portal's bottom is above the current top      if(bheight <= dc_yl)        continue;      // Draw the upper texture      if(height > dc_yl)      {        dc_yh = height - 1;        cfunc();        dc_yl = height;      }      dc_portal = wpr->portal;      dc_yh = bheight;      if(dc_yh > realyh)      {        dc_yh = realyh;        R_StorePortalRange();        return;      }      R_StorePortalRange();      dc_yl = dc_yh + 1;    }    dc_yh = realyh;    if(dc_yl <= realyh)      cfunc();}

⌨️ 快捷键说明

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