1 /*
2 	d_modech.c
3 
4 	called when mode has just changed
5 
6 	Copyright (C) 1996-1997  Id Software, Inc.
7 
8 	This program is free software; you can redistribute it and/or
9 	modify it under the terms of the GNU General Public License
10 	as published by the Free Software Foundation; either version 2
11 	of the License, or (at your option) any later version.
12 
13 	This program is distributed in the hope that it will be useful,
14 	but WITHOUT ANY WARRANTY; without even the implied warranty of
15 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 
17 	See the GNU General Public License for more details.
18 
19 	You should have received a copy of the GNU General Public License
20 	along with this program; if not, write to:
21 
22 		Free Software Foundation, Inc.
23 		59 Temple Place - Suite 330
24 		Boston, MA  02111-1307, USA
25 
26 */
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30 
31 #define NH_DEFINE
32 #include "namehack.h"
33 
34 #include "QF/render.h"
35 
36 #include "d_local.h"
37 #include "r_internal.h"
38 
39 int         sw32_d_vrectx, sw32_d_vrecty, sw32_d_vrectright_particle, sw32_d_vrectbottom_particle;
40 
41 int         sw32_d_y_aspect_shift, sw32_d_pix_min, sw32_d_pix_max, sw32_d_pix_shift;
42 
43 int         sw32_d_scantable[MAXHEIGHT];
44 short      *sw32_zspantable[MAXHEIGHT];
45 
46 
47 static void
D_Patch(void)48 D_Patch (void)
49 {
50 }
51 
52 void
sw32_D_ViewChanged(void)53 sw32_D_ViewChanged (void)
54 {
55 	int         rowpixels;
56 
57 	if (sw32_r_dowarp)
58 		rowpixels = WARP_WIDTH;
59 	else
60 		rowpixels = vid.rowbytes / sw32_r_pixbytes;
61 
62 	sw32_scale_for_mip = sw32_xscale;
63 	if (sw32_yscale > sw32_xscale)
64 		sw32_scale_for_mip = sw32_yscale;
65 
66 	sw32_d_zrowbytes = vid.width * 2;
67 	sw32_d_zwidth = vid.width;
68 
69 	sw32_d_pix_min = r_refdef.vrect.width / 320;
70 	if (sw32_d_pix_min < 1)
71 		sw32_d_pix_min = 1;
72 
73 	sw32_d_pix_max = (int) ((float) r_refdef.vrect.width / (320.0 / 4.0) + 0.5);
74 	sw32_d_pix_shift = 8 - (int) ((float) r_refdef.vrect.width / 320.0 + 0.5);
75 	if (sw32_d_pix_max < 1)
76 		sw32_d_pix_max = 1;
77 
78 	if (sw32_pixelAspect > 1.4)
79 		sw32_d_y_aspect_shift = 1;
80 	else
81 		sw32_d_y_aspect_shift = 0;
82 
83 	sw32_d_vrectx = r_refdef.vrect.x;
84 	sw32_d_vrecty = r_refdef.vrect.y;
85 	sw32_d_vrectright_particle = r_refdef.vrectright - sw32_d_pix_max;
86 	sw32_d_vrectbottom_particle =
87 		r_refdef.vrectbottom - (sw32_d_pix_max << sw32_d_y_aspect_shift);
88 
89 	{
90 		int i;
91 
92 		for (i = 0; i < vid.height; i++) {
93 			sw32_d_scantable[i] = i * rowpixels;
94 			sw32_zspantable[i] = sw32_d_pzbuffer + i * sw32_d_zwidth;
95 		}
96 	}
97 
98 	D_Patch ();
99 }
100