/* Copyright (C) 1997-2001 Id Software, Inc. 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. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // r_misc.c #include "r_local.h" #define NUM_MIPS 4 surfcache_t *d_initial_rover; qboolean d_roverwrapped; int d_minmip; float d_scalemip[NUM_MIPS-1]; static float basemip[NUM_MIPS-1] = {1.0, 0.5*0.8, 0.25*0.8}; //int d_vrectx, d_vrecty, d_vrectright_particle, d_vrectbottom_particle; //int d_pix_min, d_pix_max, d_pix_shift; int d_scantable[MAXHEIGHT]; short *zspantable[MAXHEIGHT]; struct qfrustum_s qfrustum; /* ================ D_Patch ================ */ void D_Patch (void) { #if id386 extern void D_Aff8Patch( void ); static qboolean protectset8 = false; extern void D_PolysetAff8Start( void ); if (!protectset8) { Sys_MakeCodeWriteable ((int)D_PolysetAff8Start, (int)D_Aff8Patch - (int)D_PolysetAff8Start); Sys_MakeCodeWriteable ((long)R_Surf8Start, (long)R_Surf8End - (long)R_Surf8Start); protectset8 = true; } colormap = vid.colormap; R_Surf8Patch (); D_Aff8Patch(); #endif } /* ================ D_ViewChanged ================ */ void D_ViewChanged (void) { int i; scale_for_mip = xscale; if (yscale > xscale) scale_for_mip = yscale; d_zrowbytes = vid.width * 2; d_zwidth = vid.width; /*d_pix_min = gpGlobals->width / 320; if (d_pix_min < 1) d_pix_min = 1; d_pix_max = (int)((float)gpGlobals->height / (320.0 / 4.0) + 0.5); d_pix_shift = 8 - (int)((float)gpGlobals->height / 320.0 + 0.5); if (d_pix_max < 1) d_pix_max = 1;*/ //d_vrectx = RI.vrect.x; //d_vrecty = RI.vrect.y; //d_vrectright_particle = gpGlobals->width - d_pix_max; //d_vrectbottom_particle = // gpGlobals->height - d_pix_max; for (i=0 ; iflags & FCVAR_CHANGED) { r_fullbright->flags &= ~FCVAR_CHANGED; D_FlushCaches( ); // so all lighting changes } //tr.framecount++; // build the transformation matrix for the given view angles VectorCopy (RI.vieworg, tr.modelorg); //AngleVectors (RI.viewangles, RI.vforward, RI.vright, RI.vup); // current viewleaf if ( RI.drawWorld ) { RI.viewleaf = gEngfuncs.Mod_PointInLeaf (RI.vieworg, WORLDMODEL->nodes); r_viewcluster = RI.viewleaf->cluster; } // if (sw_waterwarp->value && (r_newrefdef.rdflags & RDF_UNDERWATER) ) // r_dowarp = true; // else /*vrect.x = 0;//r_newrefdef.x; vrect.y = 0;//r_newrefdef.y; vrect.width = gpGlobals->width; vrect.height = gpGlobals->height;*/ vrect.x = RI.viewport[0]; vrect.y = RI.viewport[1]; vrect.width = RI.viewport[2]; vrect.height = RI.viewport[3]; d_viewbuffer = (void *)vid.buffer; r_screenwidth = vid.rowbytes; R_ViewChanged (&vrect); // start off with just the four screen edge clip planes R_TransformFrustum (); R_SetUpFrustumIndexes (); // save base values VectorCopy (RI.vforward, RI.base_vpn); VectorCopy (RI.vright, RI.base_vright); VectorCopy (RI.vup, RI.base_vup); // clear frame counts /* c_faceclip = 0; d_spanpixcount = 0; r_polycount = 0; r_drawnpolycount = 0; r_wholepolycount = 0; r_amodels_drawn = 0; r_outofsurfaces = 0; r_outofedges = 0;*/ // d_setup d_roverwrapped = false; d_initial_rover = sc_rover; d_minmip = sw_mipcap.value; if (d_minmip > 3) d_minmip = 3; else if (d_minmip < 0) d_minmip = 0; for (i=0 ; i<(NUM_MIPS-1) ; i++) d_scalemip[i] = basemip[i] * sw_mipscale.value; //d_aflatcolor = 0; } #if !id386 /* ================ R_SurfacePatch ================ */ /*void R_SurfacePatch (void) { // we only patch code on Intel } */ #endif // !id386