401 sceVu0FVECTOR shadow_point;
402 sceVu0FVECTOR shadow_normal;
403 sceVu0FMATRIX shadow_matrix;
404 sceVu0FMATRIX screen_matrix;
405 sceVu0FMATRIX normal_matrix;
407 sceVu0FMATRIX inverse;
408 sceVu0FMATRIX clip_matrix;
425 if (program == 6 || program == 4 || program == 0) {
426 MulMatrix(screen_matrix, info->
view_screen, matrix);
428 MulMatrix(screen_matrix, info->
view_scaled, matrix);
433 *packet++ = 0x10000000;
441 *packet++ = 0x50000004;
443 *packet++ = 0x10000000;
463 *packet++ = fog_color;
468 *packet++ = 0x0300003C;
469 *packet++ = 0x020000AA;
472 unpack_data = packet;
473 *packet++ = program * 2;
477 *(u_long128 *) packet = *(u_long128 *) screen_matrix[0];
479 *(u_long128 *) packet = *(u_long128 *) screen_matrix[1];
481 *(u_long128 *) packet = *(u_long128 *) screen_matrix[2];
483 *(u_long128 *) packet = *(u_long128 *) screen_matrix[3];
487 inv_len_x = InverseLength(matrix[0]);
488 inv_len_y = InverseLength(matrix[1]);
489 inv_len_z = InverseLength(matrix[2]);
492 sceVu0ScaleVector(normal_matrix[0], matrix[0], inv_len_x * inv_len_x);
493 sceVu0ScaleVector(normal_matrix[1], matrix[1], inv_len_y * inv_len_y);
494 sceVu0ScaleVector(normal_matrix[2], matrix[2], inv_len_z * inv_len_z);
496 sceVu0ScaleVector(normal_matrix[0], matrix[0], inv_len_x);
497 sceVu0ScaleVector(normal_matrix[1], matrix[1], inv_len_y);
498 sceVu0ScaleVector(normal_matrix[2], matrix[2], inv_len_z);
501 normal_matrix[0][3] = 0.0f;
502 normal_matrix[1][3] = 0.0f;
503 normal_matrix[2][3] = 0.0f;
504 *(u_long128 *) packet = *(u_long128 *) normal_matrix[0];
506 *(u_long128 *) packet = *(u_long128 *) normal_matrix[1];
508 *(u_long128 *) packet = *(u_long128 *) normal_matrix[2];
510 *(u_long128 *) packet = *(u_long128 *) normal_matrix[3];
522 *(u_long128 *) packet = *(u_long128 *) info->
light_color[0];
524 *(u_long128 *) packet = *(u_long128 *) info->
light_color[1];
526 *(u_long128 *) packet = *(u_long128 *) info->
light_color[2];
528 *(u_long128 *) packet = *(u_long128 *) info->
light_color[3];
530 *(u_long128 *) packet = *(u_long128 *) info->
ambient;
532 *(u_long128 *) packet = *(u_long128 *) info->
scale;
534 *(u_long128 *) packet = *(u_long128 *) info->
offset;
536 *(u_long128 *) packet = *(u_long128 *) info->
clip_max;
538 *(u_long128 *) packet = *(u_long128 *) info->
clip_min;
540 *packet++ = *(u_int *) &info->
fog_a;
541 *packet++ = *(u_int *) &info->
fog_near;
542 *packet++ = *(u_int *) &info->
fog_far;
543 *packet++ = *(u_int *) &info->
fog_b;
550 sceVu0CopyMatrix(inverse, matrix);
551 sceVu0InversMatrix(inverse, inverse);
552 sceVu0ApplyMatrix(eye, inverse, eye);
553 *(u_long128 *) packet = *(u_long128 *) eye;
560 MulMatrix(clip_matrix, clip_matrix, matrix);
561 *(u_long128 *) packet = *(u_long128 *) clip_matrix[0];
563 *(u_long128 *) packet = *(u_long128 *) clip_matrix[1];
565 *(u_long128 *) packet = *(u_long128 *) clip_matrix[2];
567 *(u_long128 *) packet = *(u_long128 *) clip_matrix[3];
569 *(u_long128 *) packet = *(u_long128 *) info->
viewport[0];
571 *(u_long128 *) packet = *(u_long128 *) info->
viewport[1];
573 *(u_long128 *) packet = *(u_long128 *) info->
viewport[2];
575 *(u_long128 *) packet = *(u_long128 *) info->
viewport[3];
579 MulMatrix(shadow_matrix, info->
shadow, matrix);
580 MulMatrix(shadow_matrix, info->
view_scaled, shadow_matrix);
581 MulMatrix(shadow_matrix, info->
perspective, shadow_matrix);
586 *packet++ = 0x302EC000;
591 *packet++ = 0x3022C000;
597 *packet++ = 0x102E8000;
606 *unpack = (((packet - unpack_data) >> 2) << 16) | 0x6C000000;
609 packet += SetShadowData(packet, shadow_matrix);
612 *tag |= (packet - header) >> 2;
613 *packet++ =
vu_size | 0x30000000;
617 *packet++ = 0x10000003;
624 *packet++ = 0x50000002;
626 *packet++ = 0x10000000;
633 return packet - start;
734 u_int end[4] = {0x13000000, 0, 0, 0};
737 mesh = (u_int *) ((u_char *) data + header->
mesh_ofs);
738 vertex = (u_long128 *) ((u_char *) data + header->
vertex_ofs);
739 normal = (u_long128 *) ((u_char *) data + header->
normal[1]);
740 uv = (u_long128 *) ((u_char *) data + header->
uv[1]);
742 if (header->
uv[1] <= 0) {
746 colour = (u_long128 *) ((u_char *) data + header->
colour_ofs);
759 for (strip = 0; strip < strips; strip++) {
760 remaining = index[1];
763 material_entry = &materials[material];
766 if (material != -1) {
767 handle = TexManager.GetTextureHandle(material_entry->
texture, -1);
768 word += SetTEX0(&block[word], TexManager.GetTexture(handle)->
tex0, TexManager.GetTexture(handle)->
tex1);
769 word += SetMaterial(&block[word], material_entry);
774 if (colour != NULL) {
780 while (remaining > 0) {
783 if (remaining < limit) {
789 block[(u_int) (word + 1)] = 0;
790 block[(u_int) (word + 2)] = 0;
792 block[unpack] = 0x6C008000;
794 size = SetVuData(count, (u_long128 *) &block[word], index, vertex, normal, uv, colour, prim);
797 if (prim == 4 && limit < remaining) {
802 index += count * stride;
805 block[(u_int) unpack] |= qwc << 16;
807 block[(u_int) (word + 1)] = 0;
808 block[(u_int) (word + 2)] = 0;
812 block[(u_int) (word + 3)] = 0x14000000;
816 block[(u_int) (word + 3)] = 0x14000001;
822 block[(u_int) (word + 3)] = 0x17000000;
829 *(u_long128 *) &block[word] = *(u_long128 *) end;
844 u_int *mesh = (u_int *) ((u_char *) data + header->
mesh_ofs);
846 u_long128 *vertex = (u_long128 *) ((u_char *) data + header->
vertex_ofs);
847 u_long128 *colour = (u_long128 *) ((u_char *) data + header->
colour_ofs);
857 u_int *index = mesh + 4;
858 int strips = mesh[2];
860 for (strip = 0; strip < strips; strip++) {
861 int remaining = index[1];
863 int material = index[2];
867 if (material != -1) {
869 word += SetMaterial(&block[word], material_entry);
875 if (colour != NULL) {
881 while (remaining > 0) {
884 if (remaining < limit) {
891 u_int *source = index;
892 index += count * stride;
893 out = (u_long128 *) &block[word] + 2;
894 u_long128 *colour_out = out + count * 3;
897 if (colour == NULL) {
898 for (i = count; i > 0; i--) {
899 *out++ = vertex[source[0]];
903 size = count * 3 + 2;
905 for (i = count; i > 0; i--) {
906 *out++ = vertex[source[0]];
907 *colour_out++ = colour[source[3]];
911 size = count * 4 + 2;
914 if (prim == 4 && limit < remaining) {