git-svn-id: http://bladebattles.com/kurok/SVN@11 20cd92bb-ff49-0410-b73e-96a06e42c3b9
[kurok.git] / d_modech.c
blobf1162b4b10da62f1119b6c3c956674819ef14b86
1 /*
2 Copyright (C) 1996-1997 Id Software, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 // d_modech.c: called when mode has just changed
22 #include "quakedef.h"
23 #include "d_local.h"
25 int d_vrectx, d_vrecty, d_vrectright_particle, d_vrectbottom_particle;
27 int d_y_aspect_shift, d_pix_min, d_pix_max, d_pix_shift;
29 int d_scantable[MAXHEIGHT];
30 short *zspantable[MAXHEIGHT];
33 ================
34 D_Patch
35 ================
37 void D_Patch (void)
39 #if id386
41 static qboolean protectset8 = false;
43 if (!protectset8)
45 Sys_MakeCodeWriteable ((int)D_PolysetAff8Start,
46 (int)D_PolysetAff8End - (int)D_PolysetAff8Start);
47 protectset8 = true;
50 #endif // id386
55 ================
56 D_ViewChanged
57 ================
59 void D_ViewChanged (void)
61 int rowbytes;
63 if (r_dowarp)
64 rowbytes = WARP_WIDTH;
65 else
66 rowbytes = vid.rowbytes;
68 scale_for_mip = xscale;
69 if (yscale > xscale)
70 scale_for_mip = yscale;
72 d_zrowbytes = vid.width * 2;
73 d_zwidth = vid.width;
75 d_pix_min = r_refdef.vrect.width / 320;
76 if (d_pix_min < 1)
77 d_pix_min = 1;
79 d_pix_max = (int)((float)r_refdef.vrect.width / (320.0 / 4.0) + 0.5);
80 d_pix_shift = 8 - (int)((float)r_refdef.vrect.width / 320.0 + 0.5);
81 if (d_pix_max < 1)
82 d_pix_max = 1;
84 if (pixelAspect > 1.4)
85 d_y_aspect_shift = 1;
86 else
87 d_y_aspect_shift = 0;
89 d_vrectx = r_refdef.vrect.x;
90 d_vrecty = r_refdef.vrect.y;
91 d_vrectright_particle = r_refdef.vrectright - d_pix_max;
92 d_vrectbottom_particle =
93 r_refdef.vrectbottom - (d_pix_max << d_y_aspect_shift);
96 int i;
98 for (i=0 ; i<vid.height; i++)
100 d_scantable[i] = i*rowbytes;
101 zspantable[i] = d_pzbuffer + i*d_zwidth;
105 D_Patch ();