📄 r_draw.c
字号:
translationtables [i+7*256] = 0xc7 + (i&0xf); // dark blue else translationtables [i+7*256] = 0xf0-9 + (i&0xf); if ((i&0xf) <8) translationtables [i+8*256] = 0xe0 + (i&0xf); // yellow else translationtables [i+8*256] = 0xa0-8 + (i&0xf); translationtables [i+9*256] = 0x80 + (i&0xf); // beige } } else { // Keep all other colors as is. for (j=0;j<(MAXSKINCOLORS-1)*256;j+=256) translationtables [i+j] = i; } }}// ==========================================================================// COMMON DRAWER FOR 8 AND 16 BIT COLOR MODES// ==========================================================================// in a perfect world, all routines would be compatible for either mode,// and optimised enough//// in reality, the few routines that can work for either mode, are// put here// R_InitViewBuffer// Creates lookup tables for getting the framebuffer address// of a pixel to draw.//void R_InitViewBuffer ( int width, int height ){ int i; int bytesperpixel = vid.bpp; if (bytesperpixel<1 || bytesperpixel>4) I_Error ("R_InitViewBuffer : wrong bytesperpixel value %d\n", bytesperpixel); // Handle resize, // e.g. smaller view windows // with border and/or status bar. viewwindowx = (vid.width-width) >> 1; // Column offset for those columns of the view window, but // relative to the entire screen for (i=0 ; i<width ; i++) columnofs[i] = (viewwindowx + i) * bytesperpixel; // Same with base row offset. if (width == vid.width) viewwindowy = 0; else viewwindowy = (vid.height-stbarheight-height) >> 1; // Precalculate all row offsets. for (i=0 ; i<height ; i++) { ylookup[i] = ylookup1[i] = vid.buffer + (i+viewwindowy)*vid.width*bytesperpixel; ylookup2[i] = vid.buffer + (i+(vid.height>>1))*vid.width*bytesperpixel; // for splitscreen } #ifdef HORIZONTALDRAW //Fab 17-06-98 // create similar lookup tables for horizontal column draw optimisation // (the first column is the bottom line) for (i=0; i<width; i++) yhlookup[i] = screens[2] + ((width-i-1) * bytesperpixel * height); for (i=0; i<height; i++) hcolumnofs[i] = i * bytesperpixel;#endif}//// Store the lumpnumber of the viewborder patches.//int viewborderlump[8];void R_InitViewBorder (void){ if( raven ) { viewborderlump[BRDR_T] = W_GetNumForName ("bordt"); viewborderlump[BRDR_B] = W_GetNumForName ("bordb"); viewborderlump[BRDR_L] = W_GetNumForName ("bordl"); viewborderlump[BRDR_R] = W_GetNumForName ("bordr"); viewborderlump[BRDR_TL] = W_GetNumForName ("bordtl"); viewborderlump[BRDR_BL] = W_GetNumForName ("bordbl"); viewborderlump[BRDR_TR] = W_GetNumForName ("bordtr"); viewborderlump[BRDR_BR] = W_GetNumForName ("bordbr"); } else { viewborderlump[BRDR_T] = W_GetNumForName ("brdr_t"); viewborderlump[BRDR_B] = W_GetNumForName ("brdr_b"); viewborderlump[BRDR_L] = W_GetNumForName ("brdr_l"); viewborderlump[BRDR_R] = W_GetNumForName ("brdr_r"); viewborderlump[BRDR_TL] = W_GetNumForName ("brdr_tl"); viewborderlump[BRDR_BL] = W_GetNumForName ("brdr_bl"); viewborderlump[BRDR_TR] = W_GetNumForName ("brdr_tr"); viewborderlump[BRDR_BR] = W_GetNumForName ("brdr_br"); }}//// R_FillBackScreen// Fills the back screen with a pattern for variable screen sizes// Also draws a beveled edge.//void R_FillBackScreen (void){ byte* src; byte* dest; int x; int y; patch_t* patch; int step,boff; //faB: quickfix, don't cache lumps in both modes if (rendermode!=render_soft) return; //added:08-01-98:draw pattern around the status bar too (when hires), // so return only when in full-screen without status bar. if ((scaledviewwidth == vid.width)&&(viewheight==vid.height)) return; src = scr_borderpatch; dest = screens[1]; for (y=0 ; y<vid.height ; y++) { for (x=0 ; x<vid.width/64 ; x++) { memcpy (dest, src+((y&63)<<6), 64); dest += 64; } if (vid.width&63) { memcpy (dest, src+((y&63)<<6), vid.width&63); dest += (vid.width&63); } } //added:08-01-98:dont draw the borders when viewwidth is full vid.width. if (scaledviewwidth == vid.width) return; if( gamemode == heretic ) { step = 16; boff = 4; // borderoffset } else { step = 8; boff = 8; } patch = W_CacheLumpNum (viewborderlump[BRDR_T],PU_CACHE); for (x=0 ; x<scaledviewwidth ; x+=step) V_DrawPatch (viewwindowx+x,viewwindowy-boff,1,patch); patch = W_CacheLumpNum (viewborderlump[BRDR_B],PU_CACHE); for (x=0 ; x<scaledviewwidth ; x+=step) V_DrawPatch (viewwindowx+x,viewwindowy+viewheight,1,patch); patch = W_CacheLumpNum (viewborderlump[BRDR_L],PU_CACHE); for (y=0 ; y<viewheight ; y+=step) V_DrawPatch (viewwindowx-boff,viewwindowy+y,1,patch); patch = W_CacheLumpNum (viewborderlump[BRDR_R],PU_CACHE); for (y=0 ; y<viewheight ; y+=step) V_DrawPatch (viewwindowx+scaledviewwidth,viewwindowy+y,1,patch); // Draw beveled corners. V_DrawPatch (viewwindowx-boff, viewwindowy-boff, 1, W_CacheLumpNum (viewborderlump[BRDR_TL],PU_CACHE)); V_DrawPatch (viewwindowx+scaledviewwidth, viewwindowy-boff, 1, W_CacheLumpNum (viewborderlump[BRDR_TR],PU_CACHE)); V_DrawPatch (viewwindowx-boff, viewwindowy+viewheight, 1, W_CacheLumpNum (viewborderlump[BRDR_BL],PU_CACHE)); V_DrawPatch (viewwindowx+scaledviewwidth, viewwindowy+viewheight, 1, W_CacheLumpNum (viewborderlump[BRDR_BR],PU_CACHE));}//// Copy a screen buffer.//void R_VideoErase (unsigned ofs, int count){ // LFB copy. // This might not be a good idea if memcpy // is not optiomal, e.g. byte by byte on // a 32bit CPU, as GNU GCC/Linux libc did // at one point. memcpy (screens[0]+ofs, screens[1]+ofs, count);}//// R_DrawViewBorder// Draws the border around the view// for different size windows?//void R_DrawViewBorder (void){ int top; int side; int ofs;#ifdef HWRENDER // not win32 only 19990829 by Kin if (rendermode != render_soft) { HWR_DrawViewBorder (0); return; }#endif#ifdef DEBUG fprintf(stderr,"RDVB: vidwidth %d vidheight %d scaledviewwidth %d viewheight %d\n", vid.width,vid.height,scaledviewwidth,viewheight);#endif //added:08-01-98: draw the backtile pattern around the status bar too // (when statusbar width is shorter than vid.width) /* if( (vid.width>ST_WIDTH) && (vid.height!=viewheight) ) { ofs = (vid.height-stbarheight)*vid.width; side = (vid.width-ST_WIDTH)>>1; R_VideoErase(ofs,side); ofs += (vid.width-side); for (i=1;i<stbarheight;i++) { R_VideoErase(ofs,side<<1); //wraparound right to left border ofs += vid.width; } R_VideoErase(ofs,side); }*/ if (scaledviewwidth == vid.width) return; top = (vid.height-stbarheight-viewheight) >>1; side = (vid.width-scaledviewwidth) >>1; // copy top and one line of left side R_VideoErase (0, top*vid.width+side); // copy one line of right side and bottom ofs = (viewheight+top)*vid.width-side; R_VideoErase (ofs, top*vid.width+side); // copy sides using wraparound ofs = top*vid.width + vid.width-side; side <<= 1; //added:05-02-98:simpler using our new VID_Blit routine VID_BlitLinearScreen(screens[1]+ofs, screens[0]+ofs, side, viewheight-1, vid.width, vid.width); // useless, old dirty rectangle stuff //V_MarkRect (0,0,vid.width, vid.height-stbarheight);}// ==========================================================================// INCLUDE 8bpp DRAWING CODE HERE// ==========================================================================#include "r_draw8.c"// ==========================================================================// INCLUDE 16bpp DRAWING CODE HERE// ==========================================================================#include "r_draw16.c"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -