64-bit fixes.
[AROS-Contrib.git] / Games / Quake / d_part.c
blob176b76beab95440eca5f9bd141548705c936ae1b
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_part.c: software driver module for drawing particles
22 #include "quakedef.h"
23 #include "d_local.h"
27 ==============
28 D_EndParticles
29 ==============
31 void D_EndParticles (void)
33 // not used by software driver
38 ==============
39 D_StartParticles
40 ==============
42 void D_StartParticles (void)
44 // not used by software driver
48 #if !id386
51 ==============
52 D_DrawParticle
53 ==============
55 void D_DrawParticle (particle_t *pparticle)
57 vec3_t local, transformed;
58 float zi;
59 byte *pdest;
60 short *pz;
61 int i, izi, pix, count, u, v;
63 // transform point
64 VectorSubtract (pparticle->org, r_origin, local);
66 transformed[0] = DotProduct(local, r_pright);
67 transformed[1] = DotProduct(local, r_pup);
68 transformed[2] = DotProduct(local, r_ppn);
70 if (transformed[2] < PARTICLE_Z_CLIP)
71 return;
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);
79 if ((v > d_vrectbottom_particle) ||
80 (u > d_vrectright_particle) ||
81 (v < d_vrecty) ||
82 (u < d_vrectx))
84 return;
87 pz = d_pzbuffer + (d_zwidth * v) + u;
88 pdest = d_viewbuffer + d_scantable[v] + u;
89 izi = (int)(zi * 0x8000);
91 pix = izi >> d_pix_shift;
93 if (pix < d_pix_min)
94 pix = d_pix_min;
95 else if (pix > d_pix_max)
96 pix = d_pix_max;
98 switch (pix)
100 case 1:
101 count = 1 << d_y_aspect_shift;
103 for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth)
105 if (pz[0] <= izi)
107 pz[0] = izi;
108 pdest[0] = pparticle->color;
111 break;
113 case 2:
114 count = 2 << d_y_aspect_shift;
116 for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth)
118 if (pz[0] <= izi)
120 pz[0] = izi;
121 pdest[0] = pparticle->color;
124 if (pz[1] <= izi)
126 pz[1] = izi;
127 pdest[1] = pparticle->color;
130 break;
132 case 3:
133 count = 3 << d_y_aspect_shift;
135 for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth)
137 if (pz[0] <= izi)
139 pz[0] = izi;
140 pdest[0] = pparticle->color;
143 if (pz[1] <= izi)
145 pz[1] = izi;
146 pdest[1] = pparticle->color;
149 if (pz[2] <= izi)
151 pz[2] = izi;
152 pdest[2] = pparticle->color;
155 break;
157 case 4:
158 count = 4 << d_y_aspect_shift;
160 for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth)
162 if (pz[0] <= izi)
164 pz[0] = izi;
165 pdest[0] = pparticle->color;
168 if (pz[1] <= izi)
170 pz[1] = izi;
171 pdest[1] = pparticle->color;
174 if (pz[2] <= izi)
176 pz[2] = izi;
177 pdest[2] = pparticle->color;
180 if (pz[3] <= izi)
182 pz[3] = izi;
183 pdest[3] = pparticle->color;
186 break;
188 default:
189 count = pix << d_y_aspect_shift;
191 for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth)
193 for (i=0 ; i<pix ; i++)
195 if (pz[i] <= izi)
197 pz[i] = izi;
198 pdest[i] = pparticle->color;
202 break;
206 #endif // !id386