49 int32_t view_plane_distance = view_normal_dot + face_plane_reload->
plane_dist;
56 uint16_t source_flags = polygon_ref->
flags;
60 int32_t outer_first_index = (uint16_t)(polygon_ref->
vertex_indices[0]);
68 int16_t *outer_first_position = (int16_t *)&runtime_vertices[outer_first_index];
72 int32_t outer_second_index = (uint16_t)(polygon_ref->
vertex_indices[1]);
73 int16_t *outer_second_position = (int16_t *)&runtime_vertices[outer_second_index];
77 int32_t outer_fourth_index = (uint16_t)(polygon_ref->
vertex_indices[3]);
83 int16_t *outer_fourth_position = (int16_t *)&runtime_vertices[outer_fourth_index];
88 int16_t outer_fourth_y = outer_fourth_position[1];
89 int16_t outer_fourth_x_or_edge_b_x = *outer_fourth_position;
90 int16_t outer_fourth_z = outer_fourth_position[2];
91 int16_t outer_edge_a_x_short = (int16_t)(outer_fourth_x_or_edge_b_x - *outer_first_position);
92 int16_t outer_edge_a_y_short = (int16_t)(outer_fourth_y - outer_first_position[1]);
95 outer_fourth_x_or_edge_b_x = (int16_t)(outer_fourth_x_or_edge_b_x - *outer_second_position_reload);
97 int32_t outer_edge_b_y = (int32_t)(int16_t)(outer_fourth_y - outer_second_position_reload[1]);
98 int32_t outer_edge_a_z = (int32_t)(int16_t)(outer_fourth_z - outer_first_position[2]);
99 int32_t outer_edge_b_z = (int32_t)(int16_t)(outer_fourth_z - outer_second_position_reload[2]);
100 int16_t outer_edge_b_x_short = outer_fourth_x_or_edge_b_x;
101 int32_t outer_cross_x = (int32_t)outer_edge_a_y_short * outer_edge_b_z - outer_edge_a_z * outer_edge_b_y;
102 int32_t outer_edge_a_x = (int32_t)outer_edge_a_x_short;
103 int32_t outer_normal_x = outer_cross_x;
104 int32_t outer_edge_b_x = (int32_t)outer_edge_b_x_short;
105 int32_t outer_cross_y = outer_edge_b_x * outer_edge_a_z - outer_edge_a_x * outer_edge_b_z;
106 int32_t outer_normal_y = outer_cross_y;
107 int32_t outer_cross_z = outer_edge_a_x * outer_edge_b_y - outer_edge_b_x * (int32_t)outer_edge_a_y_short;
108 int32_t outer_normal_z = outer_cross_z;
109 int64_t outer_square_x_product = (int64_t)outer_normal_x * outer_normal_x;
110 int64_t outer_square_y_product = (int64_t)outer_normal_y * outer_normal_y;
111 int64_t outer_square_z_product = (int64_t)outer_normal_z * outer_normal_z;
112 int32_t outer_length_squared = ((int32_t)((int64_t)((uint64_t)outer_square_z_product + (uint64_t)outer_square_x_product + (uint64_t)outer_square_y_product) >> 12));
114 if ((uint32_t)outer_length_squared < 0x1000u)
118 int32_t outer_scaled_cross_z;
120 if ((uint32_t)outer_length_squared >= 0x100u)
122 outer_normal_x = outer_cross_x << 6;
123 outer_normal_y = outer_cross_y << 6;
124 outer_scaled_cross_z = outer_cross_z << 6;
128 outer_normal_x = outer_cross_x << 8;
129 outer_normal_y = outer_cross_y << 8;
130 outer_scaled_cross_z = outer_cross_z << 8;
133 outer_normal_z = outer_scaled_cross_z;
136 int64_t outer_scaled_square_x_product = (int64_t)outer_normal_x * outer_normal_x;
137 int64_t outer_scaled_square_y_product = (int64_t)outer_normal_y * outer_normal_y;
138 int64_t outer_scaled_square_z_product = (int64_t)outer_normal_z * outer_normal_z;
139 int32_t outer_normal_length =
140 Math_SqrtFP12(((int32_t)((int64_t)((uint64_t)outer_scaled_square_z_product + (uint64_t)outer_scaled_square_x_product + (uint64_t)outer_scaled_square_y_product) >> 12)));
142 if (outer_normal_length)
144 int32_t outer_inverse_length = INT64_C(0x100000000) / outer_normal_length;
145 int64_t outer_normalize_x_product = (int64_t)outer_inverse_length * outer_normal_x;
148 (int16_t)(((int32_t)(uint32_t)((uint64_t)outer_normalize_x_product >> 12)) >> 8);
150 int64_t outer_normalize_y_product = (int64_t)outer_inverse_length * outer_normal_y;
153 (int16_t)(((int32_t)(uint32_t)((uint64_t)outer_normalize_y_product >> 12)) >> 8);
155 int64_t outer_normalize_z_product = (int64_t)outer_inverse_length * outer_normal_z;
158 (int16_t)(((int32_t)(uint32_t)((uint64_t)outer_normalize_z_product >> 12)) >> 8);
167 int32_t inner_second_index = (uint16_t)(polygon_refs->
vertex_indices[1]);
168 int16_t *inner_second_position = (int16_t *)&saved_runtime_vertices[inner_second_index];
172 int32_t inner_third_index = (uint16_t)(polygon_refs->
vertex_indices[2]);
173 int16_t *inner_third_position = (int16_t *)&saved_runtime_vertices[inner_third_index];
177 int32_t inner_fourth_index = (uint16_t)(polygon_refs->
vertex_indices[3]);
178 int16_t *inner_fourth_position = (int16_t *)&saved_runtime_vertices[inner_fourth_index];
183 int16_t inner_fourth_x_or_edge_b_x = *(uint16_t *)inner_fourth_position;
184 int16_t inner_edge_a_x_short = (int16_t)(*inner_third_position - inner_fourth_x_or_edge_b_x);
186 inner_fourth_x_or_edge_b_x -= *(uint16_t *)inner_second_position;
188 int16_t saved_inner_edge_a_x_short = inner_edge_a_x_short;
189 int16_t inner_fourth_y = inner_fourth_position[1];
190 int16_t inner_fourth_z = inner_fourth_position[2];
191 int32_t inner_edge_b_y = (int32_t)(int16_t)(inner_fourth_y - inner_second_position[1]);
192 int32_t inner_edge_a_z = (int32_t)(int16_t)(inner_third_position[2] - inner_fourth_z);
193 int32_t inner_edge_b_z = (int32_t)(int16_t)(inner_fourth_z - inner_second_position[2]);
194 int32_t inner_edge_a_y = (int32_t)(int16_t)(inner_third_position[1] - inner_fourth_y);
195 int32_t inner_cross_x = inner_edge_a_y * inner_edge_b_z - inner_edge_a_z * inner_edge_b_y;
196 int32_t inner_normal_x = inner_cross_x;
197 int32_t inner_edge_b_x = (int32_t)inner_fourth_x_or_edge_b_x;
198 int32_t inner_edge_a_x = (int32_t)saved_inner_edge_a_x_short;
199 int32_t inner_cross_y = inner_edge_b_x * inner_edge_a_z - inner_edge_a_x * inner_edge_b_z;
200 int32_t inner_cross_z = inner_edge_a_x * inner_edge_b_y - inner_edge_b_x * inner_edge_a_y;
201 int32_t inner_normal_y = inner_cross_y;
202 int32_t inner_normal_z = inner_cross_z;
203 int64_t inner_square_x_product = (int64_t)inner_normal_x * inner_normal_x;
204 int64_t inner_square_y_product = (int64_t)inner_normal_y * inner_normal_y;
205 int64_t inner_square_z_product = (int64_t)inner_normal_z * inner_normal_z;
206 int32_t inner_length_squared = ((int32_t)((int64_t)((uint64_t)inner_square_z_product + (uint64_t)inner_square_x_product + (uint64_t)inner_square_y_product) >> 12));
208 if ((uint32_t)inner_length_squared < 0x1000u)
210 int32_t inner_scaled_cross_z;
212 if ((uint32_t)inner_length_squared >= 0x100u)
214 inner_normal_x = inner_cross_x << 6;
215 inner_normal_y = inner_cross_y << 6;
216 inner_scaled_cross_z = inner_cross_z << 6;
220 inner_normal_x = inner_cross_x << 8;
221 inner_normal_y = inner_cross_y << 8;
222 inner_scaled_cross_z = inner_cross_z << 8;
225 inner_normal_z = inner_scaled_cross_z;
228 int64_t inner_scaled_square_x_product = (int64_t)inner_normal_x * inner_normal_x;
229 int64_t inner_scaled_square_y_product = (int64_t)inner_normal_y * inner_normal_y;
234 int64_t inner_scaled_square_z_product = (int64_t)inner_normal_z * inner_normal_z;
235 int32_t inner_normal_length_or_zero =
236 Math_SqrtFP12(((int32_t)((int64_t)((uint64_t)inner_scaled_square_z_product + (uint64_t)inner_scaled_square_x_product + (uint64_t)inner_scaled_square_y_product) >> 12)));
238 if (inner_normal_length_or_zero)
240 int32_t inner_inverse_length = INT64_C(0x100000000) / inner_normal_length_or_zero;
241 int64_t inner_normalize_x_product = (int64_t)inner_inverse_length * inner_normal_x;
247 g_polygonRenderFlags = (int16_t)(((int32_t)(uint32_t)((uint64_t)inner_normalize_x_product >> 12)) >> 8);
249 int64_t inner_normalize_y_product = (int64_t)inner_inverse_length * inner_normal_y;
251 data_49482a = (int16_t)(((int32_t)(uint32_t)((uint64_t)inner_normalize_y_product >> 12)) >> 8);
253 int64_t inner_normalize_z_product = (int64_t)inner_inverse_length * inner_normal_z;
256 (int16_t)(((int32_t)(uint32_t)((uint64_t)inner_normalize_z_product >> 12)) >> 8);
257 inner_normal_length_or_zero = 0;
262 data_49482a = (uint16_t)inner_normal_length_or_zero;
266 int32_t outer_normal_xy_bits =
268 int32_t outer_normal_z_padding_bits =
275 int32_t outer_unit_x =
280 int32_t outer_unit_z =
284 int32_t outer_anchor_y = (int32_t)outer_plane_anchor[1];
285 int32_t outer_unit_y =
287 int32_t outer_plane_offset;
291 outer_plane_offset = -(((outer_anchor_y * outer_unit_y + (int32_t)outer_plane_anchor[2] * outer_unit_z + (int32_t)*(int16_t *)outer_plane_anchor * outer_unit_x) >> 2));
296 outer_plane_offset >>= 4;
302 outer_plane_offset = -((outer_anchor_y * outer_unit_y + (int32_t)outer_plane_anchor[2] * outer_unit_z + (int32_t)*(int16_t *)outer_plane_anchor * outer_unit_x));
306 int32_t inner_plane_offset;
307 int32_t inner_unit_y;
308 int32_t inner_unit_z;
309 int32_t inner_unit_x;
313 int32_t inner_normal_z_padding_bits =
324 int32_t inner_anchor_y = (int32_t)inner_plane_anchor[1];
330 inner_plane_offset = -(((inner_anchor_y * inner_unit_y + (int32_t)inner_plane_anchor[2] * inner_unit_z + (int32_t)*(int16_t *)inner_plane_anchor * inner_unit_x) >> 2));
335 inner_plane_offset >>= 4;
341 inner_plane_offset = -((inner_anchor_y * inner_unit_y + (int32_t)inner_plane_anchor[2] * inner_unit_z + (int32_t)*(int16_t *)inner_plane_anchor * inner_unit_x));
349 runtime_vertices = saved_runtime_vertices;
350 polygon_ref = polygon_refs;
352 polygon_refs = &polygon_ref[1];
359 runtime_vertices = saved_runtime_vertices;
360 polygon_ref = polygon_refs;
366 int32_t projected_axis_or_polygon_flags;
367 int32_t fourth_screen_y_q12;
368 int32_t fourth_screen_x;
372 int32_t vertex0_index_shift4 = (uint16_t)(polygon_ref->
vertex_indices[0]);
373 int32_t vertex0_local_z_shift4 = (int32_t)runtime_vertices[vertex0_index_shift4].pos.z;
374 struct Math_Vec3I16 *vertex0_position_shift4 = &runtime_vertices[vertex0_index_shift4].
pos;
375 int32_t vertex0_local_y_shift4 = (int32_t)vertex0_position_shift4->
y;
376 int32_t vertex0_local_x_shift4 = (int32_t)vertex0_position_shift4->
x;
382 (float)((
long double)vertex0_view_x_shift4 * (
long double)0.015625f);
384 (float)((
long double)vertex0_view_y_precise_shift4 * (
long double)0.015625f);
386 (float)((
long double)vertex0_view_z_shift4 * (
long double)0.015625f);
394 int32_t vertex0_focal_distance_shift4 = vertex0_list_state_shift4->
focal_distance;
395 int32_t vertex0_perspective_scale_shift4 =
396 ((int64_t)vertex0_focal_distance_shift4 *
MATH_Q12_ONE) / vertex0_view_z_shift4;
397 int64_t vertex0_screen_x_product_shift4 = (int64_t)vertex0_perspective_scale_shift4 * vertex0_view_x_shift4;
398 int32_t vertex0_screen_x_shift4 = (((int32_t)(uint32_t)((uint64_t)vertex0_screen_x_product_shift4 >> 12)) >> 0xc) + (
Graphics_WindowWidth >> 1);
399 int64_t vertex0_screen_y_product_shift4 = (int64_t)vertex0_perspective_scale_shift4 * vertex0_view_y_precise_shift4;
400 int32_t vertex0_screen_y_shift4 = (((int32_t)(uint32_t)((uint64_t)vertex0_screen_y_product_shift4 >> 12)) >> 0xc) + (
Graphics_WindowHeight >> 1);
402 if (vertex0_screen_x_shift4 != (int32_t)(int16_t)vertex0_screen_x_shift4 || vertex0_screen_y_shift4 != (int32_t)(int16_t)vertex0_screen_y_shift4)
411 int32_t vertex1_index_shift4 = (uint16_t)(polygon_ref->
vertex_indices[1]);
412 struct Math_Vec3I16 *vertex1_position_shift4 = &runtime_vertices[vertex1_index_shift4].
pos;
413 int32_t vertex1_z_scale4 = (int32_t)runtime_vertices[vertex1_index_shift4].pos.z;
414 int32_t vertex1_local_y_shift4 = (int32_t)vertex1_position_shift4->
y;
415 int32_t vertex1_local_x_shift4 = (int32_t)vertex1_position_shift4->
x;
421 (float)((
long double)vertex1_view_x_shift4 * (
long double)0.015625f);
423 int32_t vertex1_view_y_scale4 = vertex1_view_y_precise_shift4;
426 (float)((
long double)vertex1_view_y_scale4 * (
long double)0.015625f);
428 (float)((
long double)vertex1_view_z_shift4 * (
long double)0.015625f);
436 int32_t vertex1_focal_distance_shift4 = vertex1_list_state_shift4->
focal_distance;
437 int32_t vertex1_perspective_scale_shift4 =
438 ((int64_t)vertex1_focal_distance_shift4 *
MATH_Q12_ONE) / vertex1_view_z_shift4;
439 int64_t vertex1_screen_x_product_shift4 = (int64_t)vertex1_perspective_scale_shift4 * vertex1_view_x_shift4;
440 int32_t vertex1_screen_x_shift4 = (((int32_t)(uint32_t)((uint64_t)vertex1_screen_x_product_shift4 >> 12)) >> 0xc) + (
Graphics_WindowWidth >> 1);
441 int64_t vertex1_screen_y_product_shift4 = (int64_t)vertex1_perspective_scale_shift4 * vertex1_view_y_scale4;
442 int32_t vertex1_screen_y_shift4 = (((int32_t)(uint32_t)((uint64_t)vertex1_screen_y_product_shift4 >> 12)) >> 0xc) + (
Graphics_WindowHeight >> 1);
444 if (vertex1_screen_x_shift4 != (int32_t)(int16_t)vertex1_screen_x_shift4 || vertex1_screen_y_shift4 != (int32_t)(int16_t)vertex1_screen_y_shift4)
453 int32_t vertex2_index_shift4 = (uint16_t)(polygon_ref->
vertex_indices[2]);
454 struct Math_Vec3I16 *vertex2_position_shift4 = &runtime_vertices[vertex2_index_shift4].
pos;
455 int32_t vertex2_z_scale4 = (int32_t)runtime_vertices[vertex2_index_shift4].pos.z;
456 int32_t vertex2_local_y_shift4 = (int32_t)vertex2_position_shift4->
y;
457 int32_t vertex2_local_x_shift4 = (int32_t)vertex2_position_shift4->
x;
462 projected_axis_or_polygon_flags = vertex2_view_z_shift4;
464 (float)((
long double)vertex2_view_x_shift4 * (
long double)0.015625f);
466 int32_t vertex2_view_y_scale4 = vertex2_view_y_precise_shift4;
469 (float)((
long double)vertex2_view_y_scale4 * (
long double)0.015625f);
471 (float)((
long double)vertex2_view_z_shift4 * (
long double)0.015625f);
479 int32_t vertex2_focal_distance_shift4 = vertex2_list_state_shift4->
focal_distance;
480 int32_t vertex2_perspective_scale_shift4 = ((int64_t)vertex2_focal_distance_shift4 *
MATH_Q12_ONE) / vertex2_view_z_shift4;
481 int64_t vertex2_screen_x_product_shift4 = (int64_t)vertex2_perspective_scale_shift4 * vertex2_view_x_shift4;
482 int32_t vertex2_screen_x_shift4 = (((int32_t)(uint32_t)((uint64_t)vertex2_screen_x_product_shift4 >> 12)) >> 0xc) + (
Graphics_WindowWidth >> 1);
483 int64_t vertex2_screen_y_product_shift4 = (int64_t)vertex2_perspective_scale_shift4 * vertex2_view_y_scale4;
485 projected_axis_or_polygon_flags = (((int32_t)(uint32_t)((uint64_t)vertex2_screen_y_product_shift4 >> 12)) >> 0xc) + (
Graphics_WindowHeight >> 1);
487 if (vertex2_screen_x_shift4 != (int32_t)(int16_t)vertex2_screen_x_shift4 || projected_axis_or_polygon_flags != (int32_t)(int16_t)projected_axis_or_polygon_flags)
502 int32_t vertex3_index_shift4 = (uint16_t)(polygon_ref->
vertex_indices[3]);
503 struct Math_Vec3I16 *vertex3_position_shift4 = &runtime_vertices[vertex3_index_shift4].
pos;
504 int32_t vertex3_z_scale4 = (int32_t)runtime_vertices[vertex3_index_shift4].pos.z;
505 int32_t vertex3_local_y_shift4 = (int32_t)vertex3_position_shift4->
y;
506 int32_t vertex3_local_x_shift4 = (int32_t)vertex3_position_shift4->
x;
507 int32_t vertex3_view_z_shift4 = ((
514 projected_axis_or_polygon_flags = vertex3_view_z_shift4;
516 (float)((
long double)vertex3_view_x_shift4 * (
long double)0.015625f);
518 int32_t vertex3_view_y_scale4 = vertex3_view_y_precise_shift4;
521 (float)((
long double)vertex3_view_y_scale4 * (
long double)0.015625f);
523 (float)((
long double)vertex3_view_z_shift4 * (
long double)0.015625f);
531 int32_t vertex3_focal_distance_shift4 = vertex3_list_state_shift4->
focal_distance;
532 int32_t vertex3_perspective_scale_shift4 =
533 ((int64_t)vertex3_focal_distance_shift4 *
MATH_Q12_ONE) / vertex3_view_z_shift4;
534 int64_t vertex3_screen_x_product_shift4 = (int64_t)vertex3_perspective_scale_shift4 * vertex3_view_x_shift4;
536 fourth_screen_x = (((int32_t)(uint32_t)((uint64_t)vertex3_screen_x_product_shift4 >> 12)) >> 0xc) + (
Graphics_WindowWidth >> 1);
538 int64_t vertex3_screen_y_product_shift4 = (int64_t)vertex3_perspective_scale_shift4 * vertex3_view_y_scale4;
540 fourth_screen_y_q12 = (int32_t)(uint32_t)((uint64_t)vertex3_screen_y_product_shift4 >> 12);
544 if (fourth_screen_x != (int32_t)(int16_t)fourth_screen_x || projected_axis_or_polygon_flags != (int32_t)(int16_t)projected_axis_or_polygon_flags)
556 memset(&fourth_projected_vertex, 0, 4);
560 int32_t vertex0_index_shift6 = (uint16_t)(polygon_ref->
vertex_indices[0]);
561 struct Math_Vec3I16 *vertex0_position_shift6 = &runtime_vertices[vertex0_index_shift6].
pos;
562 int32_t vertex0_z_scale6 = (int32_t)runtime_vertices[vertex0_index_shift6].pos.z;
563 int32_t vertex0_local_y_shift6 = (int32_t)vertex0_position_shift6->
y;
564 int32_t vertex0_local_x_shift6 = (int32_t)vertex0_position_shift6->
x;
570 (float)((
long double)vertex0_view_x_shift6 * (
long double)0.015625f);
572 int32_t vertex0_view_y_scale6 = vertex0_view_y_precise_shift6;
575 (float)((
long double)vertex0_view_y_scale6 * (
long double)0.015625f);
577 (float)((
long double)vertex0_view_z_shift6 * (
long double)0.015625f);
585 int32_t vertex0_focal_distance_shift6 = vertex0_list_state_shift6->
focal_distance;
586 int32_t vertex0_perspective_scale_shift6 =
587 ((int64_t)vertex0_focal_distance_shift6 *
MATH_Q12_ONE) / vertex0_view_z_shift6;
588 int64_t vertex0_screen_x_product_shift6 = (int64_t)vertex0_perspective_scale_shift6 * vertex0_view_x_shift6;
589 int32_t vertex0_screen_x_shift6 = (((int32_t)(uint32_t)((uint64_t)vertex0_screen_x_product_shift6 >> 12)) >> 0xc) + (
Graphics_WindowWidth >> 1);
590 int64_t vertex0_screen_y_product_shift6 = (int64_t)vertex0_perspective_scale_shift6 * vertex0_view_y_scale6;
591 int32_t vertex0_screen_y_shift6 = (((int32_t)(uint32_t)((uint64_t)vertex0_screen_y_product_shift6 >> 12)) >> 0xc) + (
Graphics_WindowHeight >> 1);
593 if (vertex0_screen_x_shift6 != (int32_t)(int16_t)vertex0_screen_x_shift6 || vertex0_screen_y_shift6 != (int32_t)(int16_t)vertex0_screen_y_shift6)
602 int32_t vertex1_index_shift6 = (uint16_t)(polygon_ref->
vertex_indices[1]);
603 struct Math_Vec3I16 *vertex1_position_shift6 = &runtime_vertices[vertex1_index_shift6].
pos;
604 int32_t vertex1_z_scale6 = (int32_t)runtime_vertices[vertex1_index_shift6].pos.z;
605 int32_t vertex1_local_y_shift6 = (int32_t)vertex1_position_shift6->
y;
606 int32_t vertex1_local_x_shift6 = (int32_t)vertex1_position_shift6->
x;
612 (float)((
long double)vertex1_view_x_shift6 * (
long double)0.015625f);
614 int32_t vertex1_view_y_scale6 = vertex1_view_y_precise_shift6;
617 (float)((
long double)vertex1_view_y_scale6 * (
long double)0.015625f);
619 (float)((
long double)vertex1_view_z_shift6 * (
long double)0.015625f);
627 int32_t vertex1_focal_distance_shift6 = vertex1_list_state_shift6->
focal_distance;
628 int32_t vertex1_perspective_scale_shift6 =
629 ((int64_t)vertex1_focal_distance_shift6 *
MATH_Q12_ONE) / vertex1_view_z_shift6;
630 int64_t vertex1_screen_x_product_shift6 = (int64_t)vertex1_perspective_scale_shift6 * vertex1_view_x_shift6;
631 int32_t vertex1_screen_x_shift6 = (((int32_t)(uint32_t)((uint64_t)vertex1_screen_x_product_shift6 >> 12)) >> 0xc) + (
Graphics_WindowWidth >> 1);
632 int64_t vertex1_screen_y_product_shift6 = (int64_t)vertex1_perspective_scale_shift6 * vertex1_view_y_scale6;
633 int32_t vertex1_screen_y_shift6 = (((int32_t)(uint32_t)((uint64_t)vertex1_screen_y_product_shift6 >> 12)) >> 0xc) + (
Graphics_WindowHeight >> 1);
635 if (vertex1_screen_x_shift6 != (int32_t)(int16_t)vertex1_screen_x_shift6 || vertex1_screen_y_shift6 != (int32_t)(int16_t)vertex1_screen_y_shift6)
644 int32_t vertex2_index_shift6 = (uint16_t)(polygon_ref->
vertex_indices[2]);
645 struct Math_Vec3I16 *vertex2_position_shift6 = &runtime_vertices[vertex2_index_shift6].
pos;
646 int32_t vertex2_z_scale6 = (int32_t)runtime_vertices[vertex2_index_shift6].pos.z;
647 int32_t vertex2_local_y_shift6 = (int32_t)vertex2_position_shift6->
y;
648 int32_t vertex2_local_x_shift6 = (int32_t)vertex2_position_shift6->
x;
654 (float)((
long double)vertex2_view_x_shift6 * (
long double)0.015625f);
656 int32_t vertex2_view_y_scale6 = vertex2_view_y_precise_shift6;
659 (float)((
long double)vertex2_view_y_scale6 * (
long double)0.015625f);
661 (float)((
long double)vertex2_view_z_shift6 * (
long double)0.015625f);
669 int32_t vertex2_focal_distance_shift6 = vertex2_list_state_shift6->
focal_distance;
670 int32_t vertex2_perspective_scale_shift6 =
671 ((int64_t)vertex2_focal_distance_shift6 *
MATH_Q12_ONE) / vertex2_view_z_shift6;
672 int64_t vertex2_screen_x_product_shift6 = (int64_t)vertex2_perspective_scale_shift6 * vertex2_view_x_shift6;
673 int32_t vertex2_screen_x_shift6 = (((int32_t)(uint32_t)((uint64_t)vertex2_screen_x_product_shift6 >> 12)) >> 0xc) + (
Graphics_WindowWidth >> 1);
674 int64_t vertex2_screen_y_product_shift6 = (int64_t)vertex2_perspective_scale_shift6 * vertex2_view_y_scale6;
675 int32_t vertex2_screen_y_shift6 = (((int32_t)(uint32_t)((uint64_t)vertex2_screen_y_product_shift6 >> 12)) >> 0xc) + (
Graphics_WindowHeight >> 1);
677 if (vertex2_screen_x_shift6 != (int32_t)(int16_t)vertex2_screen_x_shift6 || vertex2_screen_y_shift6 != (int32_t)(int16_t)vertex2_screen_y_shift6)
690 int32_t vertex3_index_shift6 = (uint16_t)(polygon_ref->
vertex_indices[3]);
691 struct Math_Vec3I16 *vertex3_position_shift6 = &runtime_vertices[vertex3_index_shift6].
pos;
692 int32_t vertex3_z_scale6 = (int32_t)runtime_vertices[vertex3_index_shift6].pos.z;
693 int32_t vertex3_local_y_shift6 = (int32_t)vertex3_position_shift6->
y;
694 int32_t vertex3_local_x_shift6 = (int32_t)vertex3_position_shift6->
x;
695 int32_t vertex3_view_z_shift6 = ((
702 projected_axis_or_polygon_flags = vertex3_view_z_shift6;
704 (float)((
long double)vertex3_view_x_shift6 * (
long double)0.015625f);
706 int32_t vertex3_view_y_scale6 = vertex3_view_y_precise_shift6;
709 (float)((
long double)vertex3_view_y_scale6 * (
long double)0.015625f);
711 (float)((
long double)vertex3_view_z_shift6 * (
long double)0.015625f);
719 int32_t vertex3_focal_distance_shift6 = vertex3_list_state_shift6->
focal_distance;
720 int32_t vertex3_perspective_scale_shift6 =
721 ((int64_t)vertex3_focal_distance_shift6 *
MATH_Q12_ONE) / vertex3_view_z_shift6;
722 int64_t vertex3_screen_x_product_shift6 = (int64_t)vertex3_perspective_scale_shift6 * vertex3_view_x_shift6;
723 int32_t vertex3_screen_x_shift6 = (((int32_t)(uint32_t)((uint64_t)vertex3_screen_x_product_shift6 >> 12)) >> 0xc) + (
Graphics_WindowWidth >> 1);
724 int64_t vertex3_screen_y_product_shift6 = (int64_t)vertex3_perspective_scale_shift6 * vertex3_view_y_scale6;
726 projected_axis_or_polygon_flags = (((int32_t)(uint32_t)((uint64_t)vertex3_screen_y_product_shift6 >> 12)) >> 0xc) + (
Graphics_WindowHeight >> 1);
728 if (vertex3_screen_x_shift6 != (int32_t)(int16_t)vertex3_screen_x_shift6 || projected_axis_or_polygon_flags != (int32_t)(int16_t)projected_axis_or_polygon_flags)
741 projected_axis_or_polygon_flags = 0;
742 memset(&fourth_projected_vertex, 0, 4);
750 int32_t vertex0_index_shift10 = (uint16_t)(polygon_ref->
vertex_indices[0]);
751 struct Math_Vec3I16 *vertex0_position_shift10 = &runtime_vertices[vertex0_index_shift10].
pos;
752 int32_t vertex0_z_scale10 = (int32_t)runtime_vertices[vertex0_index_shift10].pos.z;
753 int32_t vertex0_local_y_shift10 = (int32_t)vertex0_position_shift10->
y;
754 int32_t vertex0_local_x_shift10 = (int32_t)vertex0_position_shift10->
x;
760 (float)((
long double)vertex0_view_x_shift10 * (
long double)0.015625f);
762 int32_t vertex0_view_y_scale10 = vertex0_view_y_precise_shift10;
765 (float)((
long double)vertex0_view_y_scale10 * (
long double)0.015625f);
767 (float)((
long double)vertex0_view_z_shift10 * (
long double)0.015625f);
775 int32_t vertex0_focal_distance_shift10 = vertex0_list_state_shift10->
focal_distance;
776 int32_t vertex0_perspective_scale_shift10 =
777 ((int64_t)vertex0_focal_distance_shift10 *
MATH_Q12_ONE) / vertex0_view_z_shift10;
778 int64_t vertex0_screen_x_product_shift10 = (int64_t)vertex0_perspective_scale_shift10 * vertex0_view_x_shift10;
779 int32_t vertex0_screen_x_shift10 = (((int32_t)(uint32_t)((uint64_t)vertex0_screen_x_product_shift10 >> 12)) >> 0xc) + (
Graphics_WindowWidth >> 1);
780 int64_t vertex0_screen_y_product_shift10 = (int64_t)vertex0_perspective_scale_shift10 * vertex0_view_y_scale10;
781 int32_t vertex0_screen_y_shift10 = (((int32_t)(uint32_t)((uint64_t)vertex0_screen_y_product_shift10 >> 12)) >> 0xc) + (
Graphics_WindowHeight >> 1);
783 if (vertex0_screen_x_shift10 != (int32_t)(int16_t)vertex0_screen_x_shift10 || vertex0_screen_y_shift10 != (int32_t)(int16_t)vertex0_screen_y_shift10)
792 int32_t vertex1_index_shift10 = (uint16_t)(polygon_ref->
vertex_indices[1]);
793 struct Math_Vec3I16 *vertex1_position_shift10 = &runtime_vertices[vertex1_index_shift10].
pos;
794 int32_t vertex1_z_scale10 = (int32_t)runtime_vertices[vertex1_index_shift10].pos.z;
795 int32_t vertex1_local_y_shift10 = (int32_t)vertex1_position_shift10->
y;
796 int32_t vertex1_local_x_shift10 = (int32_t)vertex1_position_shift10->
x;
802 (float)((
long double)vertex1_view_x_shift10 * (
long double)0.015625f);
804 int32_t vertex1_view_y_scale10 = vertex1_view_y_precise_shift10;
807 (float)((
long double)vertex1_view_y_scale10 * (
long double)0.015625f);
809 (float)((
long double)vertex1_view_z_shift10 * (
long double)0.015625f);
817 int32_t vertex1_focal_distance_shift10 = vertex1_list_state_shift10->
focal_distance;
818 int32_t vertex1_perspective_scale_shift10 =
819 ((int64_t)vertex1_focal_distance_shift10 *
MATH_Q12_ONE) / vertex1_view_z_shift10;
820 int64_t vertex1_screen_x_product_shift10 = (int64_t)vertex1_perspective_scale_shift10 * vertex1_view_x_shift10;
821 int32_t vertex1_screen_x_shift10 = (((int32_t)(uint32_t)((uint64_t)vertex1_screen_x_product_shift10 >> 12)) >> 0xc) + (
Graphics_WindowWidth >> 1);
822 int64_t vertex1_screen_y_product_shift10 = (int64_t)vertex1_perspective_scale_shift10 * vertex1_view_y_scale10;
823 int32_t vertex1_screen_y_shift10 = (((int32_t)(uint32_t)((uint64_t)vertex1_screen_y_product_shift10 >> 12)) >> 0xc) + (
Graphics_WindowHeight >> 1);
825 if (vertex1_screen_x_shift10 != (int32_t)(int16_t)vertex1_screen_x_shift10 || vertex1_screen_y_shift10 != (int32_t)(int16_t)vertex1_screen_y_shift10)
834 int32_t vertex2_index_shift10 = (uint16_t)(polygon_ref->
vertex_indices[2]);
835 struct Math_Vec3I16 *vertex2_position_shift10 = &runtime_vertices[vertex2_index_shift10].
pos;
836 int32_t vertex2_z_scale10 = (int32_t)runtime_vertices[vertex2_index_shift10].pos.z;
837 int32_t vertex2_local_y_shift10 = (int32_t)vertex2_position_shift10->
y;
838 int32_t vertex2_local_x_shift10 = (int32_t)vertex2_position_shift10->
x;
844 (float)((
long double)vertex2_view_x_shift10 * (
long double)0.015625f);
846 int32_t vertex2_view_y_scale10 = vertex2_view_y_precise_shift10;
849 (float)((
long double)vertex2_view_y_scale10 * (
long double)0.015625f);
851 (float)((
long double)vertex2_view_z_shift10 * (
long double)0.015625f);
859 int32_t vertex2_focal_distance_shift10 = vertex2_list_state_shift10->
focal_distance;
860 int32_t vertex2_perspective_scale_shift10 =
861 ((int64_t)vertex2_focal_distance_shift10 *
MATH_Q12_ONE) / vertex2_view_z_shift10;
862 int64_t vertex2_screen_x_product_shift10 = (int64_t)vertex2_perspective_scale_shift10 * vertex2_view_x_shift10;
863 int32_t vertex2_screen_x_shift10 = (((int32_t)(uint32_t)((uint64_t)vertex2_screen_x_product_shift10 >> 12)) >> 0xc) + (
Graphics_WindowWidth >> 1);
864 int64_t vertex2_screen_y_product_shift10 = (int64_t)vertex2_perspective_scale_shift10 * vertex2_view_y_scale10;
865 int32_t vertex2_screen_y_shift10 = (((int32_t)(uint32_t)((uint64_t)vertex2_screen_y_product_shift10 >> 12)) >> 0xc) + (
Graphics_WindowHeight >> 1);
867 if (vertex2_screen_x_shift10 != (int32_t)(int16_t)vertex2_screen_x_shift10 || vertex2_screen_y_shift10 != (int32_t)(int16_t)vertex2_screen_y_shift10)
880 int32_t vertex3_index_shift10 = (uint16_t)(polygon_ref->
vertex_indices[3]);
881 struct Math_Vec3I16 *vertex3_position_shift10 = &runtime_vertices[vertex3_index_shift10].
pos;
882 int32_t vertex3_z_scale10 =
883 (int32_t)runtime_vertices[vertex3_index_shift10].pos.z;
884 int32_t vertex3_local_y_shift10 = (int32_t)vertex3_position_shift10->
y;
885 int32_t vertex3_local_x_shift10 = (int32_t)vertex3_position_shift10->
x;
886 int32_t vertex3_view_z_shift10 = ((
893 projected_axis_or_polygon_flags = vertex3_view_z_shift10;
895 (float)((
long double)vertex3_view_x_shift10 * (
long double)0.015625f);
897 int32_t vertex3_view_y_scale10 = vertex3_view_y_precise_shift10;
900 (float)((
long double)vertex3_view_y_scale10 * (
long double)0.015625f);
902 (float)((
long double)vertex3_view_z_shift10 * (
long double)0.015625f);
910 int32_t vertex3_focal_distance_shift10 = vertex3_list_state_shift10->
focal_distance;
911 int32_t vertex3_perspective_scale_shift10 =
912 ((int64_t)vertex3_focal_distance_shift10 *
MATH_Q12_ONE) / vertex3_view_z_shift10;
913 int64_t vertex3_screen_x_product_shift10 = (int64_t)vertex3_perspective_scale_shift10 * vertex3_view_x_shift10;
915 fourth_screen_x = (((int32_t)(uint32_t)((uint64_t)vertex3_screen_x_product_shift10 >> 12)) >> 0xc) + (
Graphics_WindowWidth >> 1);
917 int64_t vertex3_screen_y_product_shift10 = (int64_t)vertex3_perspective_scale_shift10 * vertex3_view_y_scale10;
919 fourth_screen_y_q12 = (int32_t)(uint32_t)((uint64_t)vertex3_screen_y_product_shift10 >> 12);
923 if (fourth_screen_x != (int32_t)(int16_t)fourth_screen_x || projected_axis_or_polygon_flags != (int32_t)(int16_t)projected_axis_or_polygon_flags)
936 projected_axis_or_polygon_flags = 0;
937 memset(&fourth_projected_vertex, 0, 4);
948 uint16_t polygon_flags = polygon_ref->
flags;
954 if (view_plane_distance >= 0)
962 polygon_ref->
flags = (uint16_t)polygon_flags;
966 int32_t initial_uv_first_index = (uint16_t)(polygon_ref->
vertex_indices[0]);
969 initial_uv_vertices[0] = &runtime_vertices[initial_uv_first_index];
971 int32_t initial_uv_second_index = (uint16_t)(polygon_ref->
vertex_indices[1]);
972 int32_t initial_uv_third_index = (uint16_t)(polygon_ref->
vertex_indices[2]);
973 void *initial_uv_second_vertex = &runtime_vertices[initial_uv_second_index];
975 initial_uv_vertices[1] = initial_uv_second_vertex;
979 initial_uv_vertices[2] = &runtime_vertices[initial_uv_third_index];
981 if (initial_uv_has_fourth_vertex)
983 int32_t initial_uv_fourth_index = (uint16_t)(polygon_ref->
vertex_indices[3]);
985 initial_uv_vertices[3] = &runtime_vertices[initial_uv_fourth_index];
988 initial_uv_vertices[3] = 0;
991 initial_uv_vertices);
1007 int32_t face_depth_bias_q15 = (int32_t)polygon_ref->
depth_bias_q12 << 3;
1011 else if (face_depth_bias_q15)
1017 long double scaled_depth_bias = (
long double)face_depth_bias_q15 * (
long double)0.015625f;
1019 out_batch->
depth_bias = (float)scaled_depth_bias;
1021 long double minimum_depth_bias = (
long double)256.0f;
1023 if (scaled_depth_bias < minimum_depth_bias)
1027 long double first_ignored_depth_bias = (
long double)320.0f;
1033 long double second_ignored_depth_bias = (
long double)640.0f;
1035 if (((uint8_t)((((scaled_depth_bias < second_ignored_depth_bias) ?
X87_STATUS_C0 : 0) | ((isunordered(scaled_depth_bias, second_ignored_depth_bias)) ?
X87_STATUS_C2 : 0) | ((scaled_depth_bias == second_ignored_depth_bias) ?
X87_STATUS_C3 : 0)) >> 8)) & (
X87_STATUS_C3 >> 8))
1048 pending_base_material = NULL;
1051 pending_base_material = base_material;
1055 int32_t linked_uv_first_index = (uint16_t)(polygon_ref->
vertex_indices[0]);
1058 linked_uv_vertices[0] = &runtime_vertices[linked_uv_first_index];
1060 int32_t linked_uv_second_index = (uint16_t)(polygon_ref->
vertex_indices[1]);
1062 linked_uv_vertices[1] = &runtime_vertices[linked_uv_second_index];
1064 int32_t linked_uv_third_index = (uint16_t)(polygon_ref->
vertex_indices[2]);
1065 void *linked_uv_later_vertex = &runtime_vertices[linked_uv_third_index];
1067 linked_uv_vertices[2] = linked_uv_later_vertex;
1069 uint8_t linked_face_flags = polygon_ref->
flags;
1073 int32_t linked_uv_fourth_index = (uint16_t)(polygon_ref->
vertex_indices[3]);
1075 linked_uv_later_vertex = &runtime_vertices[linked_uv_fourth_index];
1076 linked_uv_vertices[3] = linked_uv_later_vertex;
1079 linked_uv_vertices[3] = 0;
1082 linked_uv_vertices);
1085 uint32_t flags = out_batch->
flags;
1086 int32_t depth_bucket_index = 0;
1092 int32_t depth_comparison_flag = 1;
1093 long double three_vertex_depth_sum = (
long double)saved_third_view_z + (
long double)saved_second_view_z + (
long double)saved_first_view_z;
1094 long double first_sort_depth = (
long double)saved_first_view_z;
1095 long double second_sort_depth = (
long double)saved_second_view_z;
1098 depth_comparison_flag = 0;
1100 long double depth_equality_as_float = (
long double)depth_comparison_flag;
1101 long double third_sort_depth = (
long double)saved_third_view_z;
1103 long double scaled_sort_depth;
1107 else if (!fourth_projected_vertex)
1112 int32_t integer_sort_depth =
__ftol_msvc(scaled_sort_depth);
1114 if (integer_sort_depth > 0x3fff)
1115 integer_sort_depth = 0x3fff;
1117 depth_bucket_index = 0x3fff - integer_sort_depth;
1119 if (0x3fff - integer_sort_depth < 1)
1120 depth_bucket_index = 1;
1121 else if (0x3fff - integer_sort_depth > 0x3fff)
1122 depth_bucket_index = 0x3fff;
1138 int32_t first_green = (uint8_t)((uint8_t)((uint32_t)first_color >> 8));
1141 out_batch->
vertex_colors[0] = (((first_green * fade_scale_q12) & 0xff000) | ((uint32_t)(uint8_t)first_color * fade_scale_q12) >> 8) >> 4 | (((first_color >> 0xc & 0xff0) * fade_scale_q12) & 0xff0000);
1143 int32_t second_green = (uint8_t)((uint8_t)((uint32_t)second_color >> 8));
1146 out_batch->
vertex_colors[1] = (((second_green * fade_scale_q12) & 0xff000) | ((uint32_t)(uint8_t)second_color * fade_scale_q12) >> 8) >> 4 | (((second_color >> 0xc & 0xff0) * fade_scale_q12) & 0xff0000);
1150 int32_t third_green = (uint8_t)((uint8_t)((uint32_t)third_color >> 8));
1153 out_batch->
vertex_colors[2] = (((third_green * fade_scale_q12) & 0xff000) | ((uint32_t)(uint8_t)third_color * fade_scale_q12) >> 8) >> 4 | (((third_color >> 0xc & 0xff0) * fade_scale_q12) & 0xff0000);
1155 int32_t fourth_green = (uint8_t)((uint8_t)((uint32_t)fourth_color >> 8));
1157 runtime_vertices = saved_runtime_vertices;
1158 out_batch->
vertex_colors[3] = (((fourth_green * fade_scale_q12) & 0xff000) | ((uint32_t)(uint8_t)fourth_color * fade_scale_q12) >> 8) >> 4 | (((fourth_color >> 0xc & 0xff0) * fade_scale_q12) & 0xff0000);
1181 uint32_t insertion_flags = out_batch->
flags;
1187 int32_t insertion_bucket_index = depth_bucket_index;
1189 if (insertion_bucket_index < 1)
1191 insertion_bucket_index = 1;
1192 depth_bucket_index = 1;
1214 (uint16_t)((uint32_t)first_packed_screen >> 16);
1221 (uint16_t)((uint32_t)second_packed_screen >> 16);
1231 (uint16_t)((uint32_t)third_packed_screen >> 16);
1245 fourth_projected_vertex;
1250 if (fourth_screen_source)
1254 memcpy(&screen, &fourth_screen_source->
screen,
sizeof screen);
1259 .x = saved_fourth_view_x,
1260 .y = saved_fourth_view_y,
1261 .z = saved_fourth_view_z};
1275 if (!second_pass_material)
1280 int32_t second_pass_first_index = (uint16_t)(polygon_ref->
vertex_indices[0]);
1282 pending_base_material = NULL;
1287 second_pass_uv_vertices[0] = &runtime_vertices[second_pass_first_index];
1289 int32_t second_pass_second_index = (uint16_t)(polygon_ref->
vertex_indices[1]);
1291 second_pass_uv_vertices[1] = &runtime_vertices[second_pass_second_index];
1293 int32_t second_pass_third_index = (uint16_t)(polygon_ref->
vertex_indices[2]);
1294 void *second_pass_later_vertex = &runtime_vertices[second_pass_third_index];
1296 second_pass_uv_vertices[2] = second_pass_later_vertex;
1298 uint8_t second_pass_face_flags = polygon_ref->
flags;
1302 int32_t second_pass_fourth_index = (uint16_t)(polygon_ref->
vertex_indices[3]);
1304 second_pass_later_vertex = &runtime_vertices[second_pass_fourth_index];
1305 second_pass_uv_vertices[3] = second_pass_later_vertex;
1308 second_pass_uv_vertices[3] = 0;
1311 second_pass_uv_vertices);
1324 .
x = saved_fourth_view_x,
1325 .y = saved_fourth_view_y,
1326 .z = saved_fourth_view_z};
1331 polygon_refs = &polygon_ref[1];