summaryrefslogtreecommitdiff
path: root/apps/plugins/sdl/progs/quake/d_part.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/sdl/progs/quake/d_part.c')
-rw-r--r--apps/plugins/sdl/progs/quake/d_part.c207
1 files changed, 207 insertions, 0 deletions
diff --git a/apps/plugins/sdl/progs/quake/d_part.c b/apps/plugins/sdl/progs/quake/d_part.c
new file mode 100644
index 0000000000..176b76beab
--- /dev/null
+++ b/apps/plugins/sdl/progs/quake/d_part.c
@@ -0,0 +1,207 @@
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_part.c: software driver module for drawing particles
21
22#include "quakedef.h"
23#include "d_local.h"
24
25
26/*
27==============
28D_EndParticles
29==============
30*/
31void D_EndParticles (void)
32{
33// not used by software driver
34}
35
36
37/*
38==============
39D_StartParticles
40==============
41*/
42void D_StartParticles (void)
43{
44// not used by software driver
45}
46
47
48#if !id386
49
50/*
51==============
52D_DrawParticle
53==============
54*/
55void D_DrawParticle (particle_t *pparticle)
56{
57 vec3_t local, transformed;
58 float zi;
59 byte *pdest;
60 short *pz;
61 int i, izi, pix, count, u, v;
62
63// transform point
64 VectorSubtract (pparticle->org, r_origin, local);
65
66 transformed[0] = DotProduct(local, r_pright);
67 transformed[1] = DotProduct(local, r_pup);
68 transformed[2] = DotProduct(local, r_ppn);
69
70 if (transformed[2] < PARTICLE_Z_CLIP)
71 return;
72
73// project the point
74// FIXME: preadjust xcenter and ycenter
75 zi = 1.0 / transformed[2];
76 u = (int)(xcenter + zi * transformed[0] + 0.5);
77 v = (int)(ycenter - zi * transformed[1] + 0.5);
78
79 if ((v > d_vrectbottom_particle) ||
80 (u > d_vrectright_particle) ||
81 (v < d_vrecty) ||
82 (u < d_vrectx))
83 {
84 return;
85 }
86
87 pz = d_pzbuffer + (d_zwidth * v) + u;
88 pdest = d_viewbuffer + d_scantable[v] + u;
89 izi = (int)(zi * 0x8000);
90
91 pix = izi >> d_pix_shift;
92
93 if (pix < d_pix_min)
94 pix = d_pix_min;
95 else if (pix > d_pix_max)
96 pix = d_pix_max;
97
98 switch (pix)
99 {
100 case 1:
101 count = 1 << d_y_aspect_shift;
102
103 for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth)
104 {
105 if (pz[0] <= izi)
106 {
107 pz[0] = izi;
108 pdest[0] = pparticle->color;
109 }
110 }
111 break;
112
113 case 2:
114 count = 2 << d_y_aspect_shift;
115
116 for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth)
117 {
118 if (pz[0] <= izi)
119 {
120 pz[0] = izi;
121 pdest[0] = pparticle->color;
122 }
123
124 if (pz[1] <= izi)
125 {
126 pz[1] = izi;
127 pdest[1] = pparticle->color;
128 }
129 }
130 break;
131
132 case 3:
133 count = 3 << d_y_aspect_shift;
134
135 for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth)
136 {
137 if (pz[0] <= izi)
138 {
139 pz[0] = izi;
140 pdest[0] = pparticle->color;
141 }
142
143 if (pz[1] <= izi)
144 {
145 pz[1] = izi;
146 pdest[1] = pparticle->color;
147 }
148
149 if (pz[2] <= izi)
150 {
151 pz[2] = izi;
152 pdest[2] = pparticle->color;
153 }
154 }
155 break;
156
157 case 4:
158 count = 4 << d_y_aspect_shift;
159
160 for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth)
161 {
162 if (pz[0] <= izi)
163 {
164 pz[0] = izi;
165 pdest[0] = pparticle->color;
166 }
167
168 if (pz[1] <= izi)
169 {
170 pz[1] = izi;
171 pdest[1] = pparticle->color;
172 }
173
174 if (pz[2] <= izi)
175 {
176 pz[2] = izi;
177 pdest[2] = pparticle->color;
178 }
179
180 if (pz[3] <= izi)
181 {
182 pz[3] = izi;
183 pdest[3] = pparticle->color;
184 }
185 }
186 break;
187
188 default:
189 count = pix << d_y_aspect_shift;
190
191 for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth)
192 {
193 for (i=0 ; i<pix ; i++)
194 {
195 if (pz[i] <= izi)
196 {
197 pz[i] = izi;
198 pdest[i] = pparticle->color;
199 }
200 }
201 }
202 break;
203 }
204}
205
206#endif // !id386
207