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

📄 v_video.c

📁 游戏类程序源代码---WinDoom 3D源程序.zip
💻 C
📖 第 1 页 / 共 2 页
字号:
//
// V_DrawPatchFlipped 
// Masks a column based masked pic to the screen.
// Flips horizontally, e.g. to mirror face.
//
void
V_DrawPatchFlipped
( int		x,
  int		y,
  // DQ start addition
  PBUFFER scrn,
  // DQ end addition
  //int		scrn,
  patch_t*	patch ) 
{ 

    int		count;
    int		col; 
    column_t*	column; 
    byte*	desttop;
    byte*	dest;
    byte*	source; 
    int		w; 
	 // DQ start addition
	 int		postY;
	 BYTE * Buffer;
	 long * YLookup;
	 // DQ end addition
	 
    y -= SHORT(patch->topoffset); 
    x -= SHORT(patch->leftoffset); 
#ifdef RANGECHECK 
    if (x<0
	||x+SHORT(patch->width) >SCREENWIDTH
	|| y<0
	|| y+SHORT(patch->height)>SCREENHEIGHT 
	/*DQ|| (unsigned)scrn>4*/ || scrn == NULL)
    {
      fprintf( stderr, "Patch origin %d,%d exceeds LFB\n", x,y );
      I_Error ("Bad V_DrawPatch in V_DrawPatchFlipped");
    }
#endif 
 
	 // DQ removed this,as we always update the entire image
    //if (scrn == RenderBuffer)  // DQ
    ////if (!scrn)
	//V_MarkRect (x, y, SHORT(patch->width), SHORT(patch->height)); 

    col = 0; 
    //desttop = scrn+y*BufferPitch+x; // DQ
    //desttop = screens[scrn]+y*SCREENWIDTH+x; 
	 
    w = SHORT(patch->width); 

	 Buffer = scrn->Buffer;
	 YLookup = scrn->YLookup;
    for ( ; col<w ; x++, col++, desttop++) 
    { 
	column = (column_t *)((byte *)patch + LONG(patch->columnofs[w-1-col])); 
 
	// step through the posts in a column 
	while (column->topdelta != 0xff ) 
	{ 
	    source = (byte *)column + 3; 
		 // DQ removed
	    // dest = desttop + column->topdelta*BufferPitch/*DQ*//*SCREENWIDTH*/; 
	    count = column->length; 
			 
      //while (count--) 
		for (postY = 0; postY < count; postY++)
         {
			 // DQ start addition
			 dest = Buffer + YLookup[y + column->topdelta + postY] + x;
			 // DQ end addition
          *dest = *source++; 
			 // removed by DQ
          // dest += SCREENWIDTH; 
         } 
	    column = (column_t *)(  (byte *)column + column->length 
				    + 4 ); 
	} 
    }			 
} 
 


//
// V_DrawPatchDirect
// Draws directly to the screen on the pc. 
//
void
V_DrawPatchDirect
( int		x,
  int		y,
  PBUFFER scrn, //DQ
  //int		scrn,
  patch_t*	patch ) 
{
    V_DrawPatch (x,y,scrn, patch); 

    /*
    int		count;
    int		col; 
    column_t*	column; 
    byte*	desttop;
    byte*	dest;
    byte*	source; 
    int		w; 
	 
    y -= SHORT(patch->topoffset); 
    x -= SHORT(patch->leftoffset); 

#ifdef RANGECHECK 
    if (x<0
	||x+SHORT(patch->width) >SCREENWIDTH
	|| y<0
	|| y+SHORT(patch->height)>SCREENHEIGHT 
	|| (unsigned)scrn>4)
    {
	I_Error ("Bad V_DrawPatchDirect");
    }
#endif 
 
    //	V_MarkRect (x, y, SHORT(patch->width), SHORT(patch->height)); 
    desttop = destscreen + y*SCREENWIDTH/4 + (x>>2); 
	 
    w = SHORT(patch->width); 
    for ( col = 0 ; col<w ; col++) 
    { 
	outp (SC_INDEX+1,1<<(x&3)); 
	column = (column_t *)((byte *)patch + LONG(patch->columnofs[col])); 
 
	// step through the posts in a column 
	 
	while (column->topdelta != 0xff ) 
	{ 
	    source = (byte *)column + 3; 
	    dest = desttop + column->topdelta*SCREENWIDTH/4; 
	    count = column->length; 
 
	    while (count--) 
	    { 
		*dest = *source++; 
		dest += SCREENWIDTH/4; 
	    } 
	    column = (column_t *)(  (byte *)column + column->length 
				    + 4 ); 
	} 
	if ( ((++x)&3) == 0 ) 
	    desttop++;	// go to next byte, not next plane 
    }*/ 
} 
 


//
// V_DrawBlock
// Draw a linear block of pixels into the view buffer.
//
void
V_DrawBlock
( int		x,
  int		y,
  PBUFFER scrn, // DQ
  //int		scrn,
  int		width,
  int		height,
  PBUFFER src	// DQ
  ) 
{ 
    //byte*	dest; // DQ removed
	BYTE * srcBuffer, * scrnBuffer;		// DQ
	long * srcYLookup, * scrnYLookup;	// DQ
	 
#ifdef RANGECHECK 
    if (x < 0 || x+width > SCREENWIDTH || y < 0 || y+height > SCREENHEIGHT /*DQ|| (unsigned)scrn > 4 */ || scrn==NULL)
       {
        I_Error ("Bad V_DrawBlock");
       }
#endif 
 
    V_MarkRect (x, y, width, height); 
 
    //dest = screens[scrn] + y*SCREENWIDTH+x; 

	 srcBuffer = src->Buffer; // DQ
	 srcYLookup = src->YLookup; // DQ
	 scrnBuffer = scrn->Buffer; // DQ
	 scrnYLookup = scrn->YLookup; // DQ
    while (height--) 
    { 
		// DQ start addition
		memcpy(scrnBuffer + scrnYLookup[y] + x, srcBuffer + srcYLookup[y] + x, width); 
		y++;
		// DQ end addition
		// DQ start removal
		//memcpy (dest, src, width); 
		//dest += BufferPitch/*DQ*//*SCREENWIDTH*/; 
		//src += width; 
		// DQ end removal
    } 
} 
 


//
// V_GetBlock
// Gets a linear block of pixels from the view buffer.
//
void
V_GetBlock
( int		x,
  int		y,
  PBUFFER scrn,	//DQ
  //int		scrn,
  int		width,
  int		height,
  PBUFFER dest//DQ
  )
{ 
    //byte*	src; // DQ removed
	BYTE * scrnBuffer;		// DQ
	long * scrnYLookup;	// DQ
	 
#ifdef RANGECHECK 
    if (x<0
	||x+width >SCREENWIDTH
	|| y<0
	|| y+height>SCREENHEIGHT 
	/*DQ|| (unsigned)scrn>4 */ || scrn == NULL)
    {
	I_Error ("Bad V_DrawBlock");
    }
#endif 

	 // DQ removed
    //src = screens[scrn] + y*SCREENWIDTH+x; 

	 scrnBuffer = scrn->Buffer; // DQ
	 scrnYLookup = scrn->YLookup; // DQ
    while (height--) 
    { 
		// DQ start addition
		 memcpy(dest, scrnBuffer + scrnYLookup[y] + x, width);
		 y++;
		// DQ end addition
		// DQ start removal
		//memcpy (dest, src, width); 
		//src += SCREENWIDTH; 
		// DQ end removal
		dest += width; 
    } 
} 

//
// V_Init
// 
void V_Init (void) 
   { 
    int		i, j, x;
    //byte*	base;
    DWORD  *buff;
		
    // stick these in low dos memory on PCs

    //base = I_AllocLow (SCREENWIDTH*SCREENHEIGHT*4);

    for (i = 0; i < 5; i++)
       {
        x = SCREENWIDTH * SCREENHEIGHT;
        screens[i] = (byte *)malloc(x);
        buff = (DWORD *)screens[i];
        x /= 4;
        for (j = 0; j < x; j++)
           buff[j] = 0x00000000;
       }
	 // DQ addition start
	 gRenderBuffer.Buffer = screens[0];  // to give gRenderBuffer a default value
	 gRenderBuffer.YLookup = ScreensYLookup;
	 // DQ addition end
//  screens[i] = base + i*SCREENWIDTH*SCREENHEIGHT;
   }

⌨️ 快捷键说明

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