23 "lqc2 $vf1, 0x00(%2) \n"
24 "lqc2 $vf2, 0x10(%2) \n"
25 "lqc2 $vf3, 0x20(%2) \n"
26 "lqc2 $vf4, 0x30(%2) \n"
27 "lqc2 $vf5, 0x00(%1) \n"
28 "vmulaw $ACC, $vf4, $vf0\n"
29 "vmaddax $ACC, $vf1, $vf5\n"
30 "vmadday $ACC, $vf2, $vf5\n"
31 "vmaddz $vf6, $vf3, $vf5\n"
32 "sqc2 $vf6, 0x00(%0) \n"
34 "lqc2 vf1, 0x00(%2) \n"
35 "lqc2 vf2, 0x10(%2) \n"
36 "lqc2 vf3, 0x20(%2) \n"
37 "lqc2 vf4, 0x30(%2) \n"
38 "lqc2 vf5, 0x00(%1) \n"
39 "vmulaw ACC, vf4, vf0 \n"
40 "vmaddax ACC, vf1, vf5 \n"
41 "vmadday ACC, vf2, vf5 \n"
42 "vmaddz vf6, vf3, vf5 \n"
43 "sqc2 vf6, 0x00(%0) \n"
45 : :
"r" (output),
"r" (input0),
"r" (input1)
57 if (work[0] <
min) { work[0] =
min; }
58 if (work[1] <
min) { work[1] =
min; }
59 if (work[2] <
min) { work[2] =
min; }
60 if (work[3] <
min) { work[3] =
min; }
63 if (work[0] >
max) { work[0] =
max; }
64 if (work[1] >
max) { work[1] =
max; }
65 if (work[2] >
max) { work[2] =
max; }
66 if (work[3] >
max) { work[3] =
max; }
76 "lqc2 $vf1, 0x00(%1) \n"
77 "sqc2 $vf1, 0x00(%0) \n"
79 "lqc2 vf1, 0x00(%1) \n"
80 "sqc2 vf1, 0x00(%0) \n"
82 : :
"r" (output),
"r" (input0)
91 work0[0] = (input0[0] / input0[3]);
92 work0[1] = (input0[1] / input0[3]);
93 work0[2] = (input0[2] / input0[3]);
97 work1[0] = (input1[0] / input1[3]);
98 work1[1] = (input1[1] / input1[3]);
99 work1[2] = (input1[2] / input1[3]);
103 return (work0[0] * work1[0]) + (work0[1] * work1[1]) + (work0[2] * work1[2]);
111 work[0] = input0[0] * input1[0];
112 work[1] = input0[1] * input1[1];
113 work[2] = input0[2] * input1[2];
114 work[3] = input0[3] * input1[3];
124 "lqc2 $vf1, 0x00(%1) \n"
125 "vmul.xyz $vf2, $vf1, $vf1\n"
126 "vmulax.w $ACC, $vf0, $vf2\n"
127 "vmadday.w $ACC, $vf0, $vf2\n"
128 "vmaddz.w $vf2, $vf0, $vf2\n"
129 "vrsqrt $Q, $vf0w, $vf2w\n"
130 "vsub.w $vf1, $vf0, $vf0\n"
132 "vmulq.xyz $vf1, $vf1, $Q \n"
133 "sqc2 $vf1, 0x00(%0) \n"
135 "lqc2 vf1, 0x00(%1) \n"
136 "vmul.xyz vf2, vf1, vf1 \n"
137 "vmulax.w ACC, vf0, vf2 \n"
138 "vmadday.w ACC, vf0, vf2 \n"
139 "vmaddz.w vf2, vf0, vf2 \n"
140 "vrsqrt Q, vf0w, vf2w \n"
141 "vsub.w vf1, vf0, vf0 \n"
143 "vmulq.xyz vf1, vf1, Q \n"
144 "sqc2 vf1, 0x00(%0) \n"
146 : :
"r" (output),
"r" (input0)
154 "lqc2 $vf1, 0x00(%1) \n"
155 "lqc2 $vf2, 0x00(%2) \n"
156 "vopmula.xyz $ACC, $vf1, $vf2\n"
157 "vopmsub.xyz $vf2, $vf2, $vf1\n"
158 "vsub.w $vf2, $vf0, $vf0\n"
159 "sqc2 $vf2, 0x00(%0) \n"
161 "lqc2 vf1, 0x00(%1) \n"
162 "lqc2 vf2, 0x00(%2) \n"
163 "vopmula.xyz ACC, vf1, vf2 \n"
164 "vopmsub.xyz vf2, vf2, vf1 \n"
165 "vsub.w vf2, vf0, vf0 \n"
166 "sqc2 vf2, 0x00(%0) \n"
168 : :
"r" (output),
"r" (input0),
"r" (input1)
178 "lqc2 $vf1, 0x00(%1) \n"
179 "lqc2 $vf2, 0x10(%1) \n"
180 "lqc2 $vf3, 0x20(%1) \n"
181 "lqc2 $vf4, 0x30(%1) \n"
182 "sqc2 $vf1, 0x00(%0) \n"
183 "sqc2 $vf2, 0x10(%0) \n"
184 "sqc2 $vf3, 0x20(%0) \n"
185 "sqc2 $vf4, 0x30(%0) \n"
187 "lqc2 vf1, 0x00(%1) \n"
188 "lqc2 vf2, 0x10(%1) \n"
189 "lqc2 vf3, 0x20(%1) \n"
190 "lqc2 vf4, 0x30(%1) \n"
191 "sqc2 vf1, 0x00(%0) \n"
192 "sqc2 vf2, 0x10(%0) \n"
193 "sqc2 vf3, 0x20(%0) \n"
194 "sqc2 vf4, 0x30(%0) \n"
196 : :
"r" (output),
"r" (input0)
209 work[0x0C] = -(input0[0x0C] * work[0x00] + input0[0x0D] * work[0x04] + input0[0x0E] * work[0x08]);
210 work[0x0D] = -(input0[0x0C] * work[0x01] + input0[0x0D] * work[0x05] + input0[0x0E] * work[0x09]);
211 work[0x0E] = -(input0[0x0C] * work[0x02] + input0[0x0D] * work[0x06] + input0[0x0E] * work[0x0A]);
222 "lqc2 $vf1, 0x00(%1) \n"
223 "lqc2 $vf2, 0x10(%1) \n"
224 "lqc2 $vf3, 0x20(%1) \n"
225 "lqc2 $vf4, 0x30(%1) \n"
226 "lqc2 $vf5, 0x00(%2) \n"
227 "lqc2 $vf6, 0x10(%2) \n"
228 "lqc2 $vf7, 0x20(%2) \n"
229 "lqc2 $vf8, 0x30(%2) \n"
230 "vmulax.xyzw $ACC, $vf5, $vf1\n"
231 "vmadday.xyzw $ACC, $vf6, $vf1\n"
232 "vmaddaz.xyzw $ACC, $vf7, $vf1\n"
233 "vmaddw.xyzw $vf1, $vf8, $vf1\n"
234 "vmulax.xyzw $ACC, $vf5, $vf2\n"
235 "vmadday.xyzw $ACC, $vf6, $vf2\n"
236 "vmaddaz.xyzw $ACC, $vf7, $vf2\n"
237 "vmaddw.xyzw $vf2, $vf8, $vf2\n"
238 "vmulax.xyzw $ACC, $vf5, $vf3\n"
239 "vmadday.xyzw $ACC, $vf6, $vf3\n"
240 "vmaddaz.xyzw $ACC, $vf7, $vf3\n"
241 "vmaddw.xyzw $vf3, $vf8, $vf3\n"
242 "vmulax.xyzw $ACC, $vf5, $vf4\n"
243 "vmadday.xyzw $ACC, $vf6, $vf4\n"
244 "vmaddaz.xyzw $ACC, $vf7, $vf4\n"
245 "vmaddw.xyzw $vf4, $vf8, $vf4\n"
246 "sqc2 $vf1, 0x00(%0) \n"
247 "sqc2 $vf2, 0x10(%0) \n"
248 "sqc2 $vf3, 0x20(%0) \n"
249 "sqc2 $vf4, 0x30(%0) \n"
251 "lqc2 vf1, 0x00(%1) \n"
252 "lqc2 vf2, 0x10(%1) \n"
253 "lqc2 vf3, 0x20(%1) \n"
254 "lqc2 vf4, 0x30(%1) \n"
255 "lqc2 vf5, 0x00(%2) \n"
256 "lqc2 vf6, 0x10(%2) \n"
257 "lqc2 vf7, 0x20(%2) \n"
258 "lqc2 vf8, 0x30(%2) \n"
259 "vmulax.xyzw ACC, vf5, vf1 \n"
260 "vmadday.xyzw ACC, vf6, vf1 \n"
261 "vmaddaz.xyzw ACC, vf7, vf1 \n"
262 "vmaddw.xyzw vf1, vf8, vf1 \n"
263 "vmulax.xyzw ACC, vf5, vf2 \n"
264 "vmadday.xyzw ACC, vf6, vf2 \n"
265 "vmaddaz.xyzw ACC, vf7, vf2 \n"
266 "vmaddw.xyzw vf2, vf8, vf2 \n"
267 "vmulax.xyzw ACC, vf5, vf3 \n"
268 "vmadday.xyzw ACC, vf6, vf3 \n"
269 "vmaddaz.xyzw ACC, vf7, vf3 \n"
270 "vmaddw.xyzw vf3, vf8, vf3 \n"
271 "vmulax.xyzw ACC, vf5, vf4 \n"
272 "vmadday.xyzw ACC, vf6, vf4 \n"
273 "vmaddaz.xyzw ACC, vf7, vf4 \n"
274 "vmaddw.xyzw vf4, vf8, vf4 \n"
275 "sqc2 vf1, 0x00(%0) \n"
276 "sqc2 vf2, 0x10(%0) \n"
277 "sqc2 vf3, 0x20(%0) \n"
278 "sqc2 vf4, 0x30(%0) \n"
280 : :
"r" (output),
"r" (input0),
"r" (input1)
290 work[0x00] = cosf(input1[2]);
291 work[0x01] = sinf(input1[2]);
292 work[0x04] = -sinf(input1[2]);
293 work[0x05] = cosf(input1[2]);
298 work[0x00] = cosf(input1[1]);
299 work[0x02] = -sinf(input1[1]);
300 work[0x08] = sinf(input1[1]);
301 work[0x0A] = cosf(input1[1]);
306 work[0x05] = cosf(input1[0]);
307 work[0x06] = sinf(input1[0]);
308 work[0x09] = -sinf(input1[0]);
309 work[0x0A] = cosf(input1[0]);
319 work[0x00] = input1[0];
320 work[0x05] = input1[1];
321 work[0x0A] = input1[2];
331 work[0x0C] = input1[0];
332 work[0x0D] = input1[1];
333 work[0x0E] = input1[2];
342 work[0x00] = input0[0x00];
343 work[0x01] = input0[0x04];
344 work[0x02] = input0[0x08];
345 work[0x03] = input0[0x0C];
346 work[0x04] = input0[0x01];
347 work[0x05] = input0[0x05];
348 work[0x06] = input0[0x09];
349 work[0x07] = input0[0x0D];
350 work[0x08] = input0[0x02];
351 work[0x09] = input0[0x06];
352 work[0x0A] = input0[0x0A];
353 work[0x0B] = input0[0x0E];
354 work[0x0C] = input0[0x03];
355 work[0x0D] = input0[0x07];
356 work[0x0E] = input0[0x0B];
357 work[0x0F] = input0[0x0F];
367 memset(output, 0,
sizeof(
MATRIX));
368 output[0x00] = 1.00f;
369 output[0x05] = 1.00f;
370 output[0x0A] = 1.00f;
371 output[0x0F] = 1.00f;
398 work0[0] = -translation[0];
399 work0[1] = -translation[1];
400 work0[2] = -translation[2];
401 work0[3] = translation[3];
404 work1[0] = -rotation[0];
405 work1[1] = -rotation[1];
406 work1[2] = -rotation[2];
407 work1[3] = rotation[3];
419 left = (left * aspect); right = (right * aspect);
425 view_screen[0x08] = (right + left) / (right - left);
426 view_screen[0x09] = (top + bottom) / (top - bottom);
429 view_screen[0x0E] = (2 * far * near) / (far - near);
449 "lqc2 $vf1, 0x00(%3) \n"
450 "lqc2 $vf2, 0x10(%3) \n"
451 "lqc2 $vf3, 0x20(%3) \n"
452 "lqc2 $vf4, 0x30(%3) \n"
454 "lqc2 $vf6, 0x00(%2) \n"
455 "vmulaw $ACC, $vf4, $vf0\n"
456 "vmaddax $ACC, $vf1, $vf6\n"
457 "vmadday $ACC, $vf2, $vf6\n"
458 "vmaddz $vf7, $vf3, $vf6\n"
459 "vdiv $Q, $vf0w, $vf7w\n"
461 "vmulq.xyzw $vf7, $vf7, $Q \n"
462 "sqc2 $vf7, 0x00(%0) \n"
468 "lqc2 vf1, 0x00(%3) \n"
469 "lqc2 vf2, 0x10(%3) \n"
470 "lqc2 vf3, 0x20(%3) \n"
471 "lqc2 vf4, 0x30(%3) \n"
473 "lqc2 vf6, 0x00(%2) \n"
474 "vmulaw ACC, vf4, vf0 \n"
475 "vmaddax ACC, vf1, vf6 \n"
476 "vmadday ACC, vf2, vf6 \n"
477 "vmaddz vf7, vf3, vf6 \n"
478 "vdiv Q, vf0w, vf7w \n"
480 "vmulq.xyzw vf7, vf7, Q \n"
481 "sqc2 vf7, 0x00(%0) \n"
487 : :
"r" (output),
"r" (count),
"r" (
normals),
"r" (local_light)
493 int loop0, loop1;
float intensity = 0.00f;
496 memset(output, 0,
sizeof(
VECTOR) * count);
499 for (loop0=0;loop0<count;loop0++) {
517 if (intensity < 0.00f) { intensity = 0.00f; }
520 }
else { intensity = 0.00f; }
523 if (intensity > 0.00f) {
526 output[loop0][0] += (
light_colour[loop1][0] * intensity);
527 output[loop0][1] += (
light_colour[loop1][1] * intensity);
528 output[loop0][2] += (
light_colour[loop1][2] * intensity);
529 output[loop0][3] = 1.00f;
543 for (loop0=0;loop0<count;loop0++) {
546 output[loop0][0] = (
colours[loop0][0] * lights[loop0][0]);
547 output[loop0][1] = (
colours[loop0][1] * lights[loop0][1]);
548 output[loop0][2] = (
colours[loop0][2] * lights[loop0][2]);
551 vector_clamp(output[loop0], output[loop0], 0.00f, 1.99f);
560 "lqc2 $vf1, 0x00(%3) \n"
561 "lqc2 $vf2, 0x10(%3) \n"
562 "lqc2 $vf3, 0x20(%3) \n"
563 "lqc2 $vf4, 0x30(%3) \n"
565 "lqc2 $vf6, 0x00(%2) \n"
566 "vmulaw $ACC, $vf4, $vf0\n"
567 "vmaddax $ACC, $vf1, $vf6\n"
568 "vmadday $ACC, $vf2, $vf6\n"
569 "vmaddz $vf7, $vf3, $vf6\n"
570 "vclipw.xyz $vf7, $vf7 \n"
574 "sqc2 $0, 0x00(%0) \n"
577 "vdiv $Q, $vf0w, $vf7w\n"
579 "vmulq.xyz $vf7, $vf7, $Q \n"
580 "sqc2 $vf7, 0x00(%0) \n"
582 "lqc2 vf1, 0x00(%3) \n"
583 "lqc2 vf2, 0x10(%3) \n"
584 "lqc2 vf3, 0x20(%3) \n"
585 "lqc2 vf4, 0x30(%3) \n"
587 "lqc2 vf6, 0x00(%2) \n"
588 "vmulaw ACC, vf4, vf0 \n"
589 "vmaddax ACC, vf1, vf6 \n"
590 "vmadday ACC, vf2, vf6 \n"
591 "vmaddz vf7, vf3, vf6 \n"
592 "vclipw.xyz vf7, vf7 \n"
596 "sqc2 vi00, 0x00(%0) \n"
599 "vdiv Q, vf0w, vf7w \n"
601 "vmulq.xyz vf7, vf7, Q \n"
602 "sqc2 vf7, 0x00(%0) \n"
void vector_normalize(VECTOR output, VECTOR input0)
void create_local_screen(MATRIX local_screen, MATRIX local_world, MATRIX world_view, MATRIX view_screen)
void matrix_multiply(MATRIX output, MATRIX input0, MATRIX input1)
void vector_copy(VECTOR output, VECTOR input0)
void vector_multiply(VECTOR output, VECTOR input0, VECTOR input1)
void vector_clamp(VECTOR output, VECTOR input0, float min, float max)
void create_local_world(MATRIX local_world, VECTOR translation, VECTOR rotation)
void matrix_copy(MATRIX output, MATRIX input0)
float vector_innerproduct(VECTOR input0, VECTOR input1)
void matrix_inverse(MATRIX output, MATRIX input0)
void calculate_vertices(VECTOR *output, int count, VECTOR *vertices, MATRIX local_screen)
void matrix_scale(MATRIX output, MATRIX input0, VECTOR input1)
void matrix_rotate(MATRIX output, MATRIX input0, VECTOR input1)
void matrix_unit(MATRIX output)
void create_world_view(MATRIX world_view, VECTOR translation, VECTOR rotation)
void vector_outerproduct(VECTOR output, VECTOR input0, VECTOR input1)
void calculate_lights(VECTOR *output, int count, VECTOR *normals, VECTOR *light_direction, VECTOR *light_colour, int *light_type, int light_count)
void create_view_screen(MATRIX view_screen, float aspect, float left, float right, float bottom, float top, float near, float far)
void calculate_normals(VECTOR *output, int count, VECTOR *normals, MATRIX local_light)
void vector_apply(VECTOR output, VECTOR input0, MATRIX input1)
void matrix_translate(MATRIX output, MATRIX input0, VECTOR input1)
void calculate_colours(VECTOR *output, int count, VECTOR *colours, VECTOR *lights)
void create_local_light(MATRIX local_light, VECTOR rotation)
void matrix_transpose(MATRIX output, MATRIX input0)
#define LIGHT_DIRECTIONAL
VECTOR light_direction[4]