summaryrefslogtreecommitdiff
path: root/apps/plugins/sdl/progs/quake/d_modech.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/sdl/progs/quake/d_modech.c')
-rw-r--r--apps/plugins/sdl/progs/quake/d_modech.c107
1 files changed, 107 insertions, 0 deletions
diff --git a/apps/plugins/sdl/progs/quake/d_modech.c b/apps/plugins/sdl/progs/quake/d_modech.c
new file mode 100644
index 0000000000..75c188e362
--- /dev/null
+++ b/apps/plugins/sdl/progs/quake/d_modech.c
@@ -0,0 +1,107 @@
1/*
2Copyright (C) 1996-1997 Id Software, Inc.
3
4This program is free software; you can redistribute it and/or
5modify it under the terms of the GNU General Public License
6as published by the Free Software Foundation; either version 2
7of the License, or (at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13See the GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19*/
20// d_modech.c: called when mode has just changed
21
22#include "quakedef.h"
23#include "d_local.h"
24
25int d_vrectx, d_vrecty, d_vrectright_particle, d_vrectbottom_particle;
26
27int d_y_aspect_shift, d_pix_min, d_pix_max, d_pix_shift;
28
29int d_scantable[MAXHEIGHT];
30short *zspantable[MAXHEIGHT];
31
32/*
33================
34D_Patch
35================
36*/
37void D_Patch (void)
38{
39#if id386
40
41 static qboolean protectset8 = false;
42
43 if (!protectset8)
44 {
45 Sys_MakeCodeWriteable ((int)D_PolysetAff8Start,
46 (int)D_PolysetAff8End - (int)D_PolysetAff8Start);
47 protectset8 = true;
48 }
49
50#endif // id386
51}
52
53
54/*
55================
56D_ViewChanged
57================
58*/
59void D_ViewChanged (void)
60{
61 int rowbytes;
62
63 if (r_dowarp)
64 rowbytes = WARP_WIDTH;
65 else
66 rowbytes = vid.rowbytes;
67
68 scale_for_mip = xscale;
69 if (yscale > xscale)
70 scale_for_mip = yscale;
71
72 d_zrowbytes = vid.width * 2;
73 d_zwidth = vid.width;
74
75 d_pix_min = r_refdef.vrect.width / 320;
76 if (d_pix_min < 1)
77 d_pix_min = 1;
78
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;
83
84 if (pixelAspect > 1.4)
85 d_y_aspect_shift = 1;
86 else
87 d_y_aspect_shift = 0;
88
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);
94
95 {
96 int i;
97
98 for (i=0 ; i<vid.height; i++)
99 {
100 d_scantable[i] = i*rowbytes;
101 zspantable[i] = d_pzbuffer + i*d_zwidth;
102 }
103 }
104
105 D_Patch ();
106}
107