189 (void)unused_batch_alias;
190 float signed_depth_bias = -9.99999975e-05f;
194 int32_t input_count_snapshot = has_fourth_vertex + 3;
195 int32_t input_vertex_count = input_count_snapshot;
199 signed_depth_bias = 9.99999975e-05f;
202 long double first_zero_test_depth = (
long double)batch->
view_vertices[0].
z;
203 long double first_zero_threshold = (
long double)0.0f;
205 if (!(first_zero_test_depth >= first_zero_threshold))
207 long double second_zero_test_depth = (
long double)batch->
view_vertices[1].
z;
208 long double second_zero_threshold = (
long double)0.0f;
210 if (!(second_zero_test_depth >= second_zero_threshold))
212 long double third_zero_test_depth = (
long double)batch->
view_vertices[2].
z;
213 long double third_zero_threshold = (
long double)0.0f;
215 if (!(third_zero_test_depth >= third_zero_threshold))
217 if (input_count_snapshot == 3)
220 long double fourth_zero_test_depth = (
long double)batch->
view_vertices[3].
z;
221 long double fourth_zero_threshold = (
long double)0.0f;
223 if (!(fourth_zero_test_depth >= fourth_zero_threshold))
230 long double first_clip_test_depth = (
long double)batch->
view_vertices[0].
z;
233 if (first_clip_test_depth >= first_clip_distance)
235 long double second_clip_test_depth = (
long double)batch->
view_vertices[1].
z;
238 if (second_clip_test_depth >= second_clip_distance)
240 long double third_clip_test_depth = (
long double)batch->
view_vertices[2].
z;
243 if (third_clip_test_depth >= third_clip_distance)
249 if (input_count_snapshot == 3)
254 long double left_test_depth = (
long double)batch->
view_vertices[3].
z;
257 if (left_test_depth >= left_clip_distance)
262 if (!(first_screen_axis <= 0x27f || batch->screen_vertices[1].screen.x <= 0x27f || batch->
screen_vertices[2].
screen.
x <= 0x27f))
264 if (input_count_snapshot == 3)
269 long double right_test_depth = (
long double)batch->
view_vertices[3].
z;
272 if (right_test_depth >= right_clip_distance)
281 if (input_count_snapshot == 3)
286 long double top_test_depth = (
long double)batch->
view_vertices[3].
z;
287 long double top_clip_distance =
290 if (top_test_depth >= top_clip_distance)
295 if (!(first_screen_axis <= 0x1df || batch->screen_vertices[1].screen.y <= 0x1df || batch->
screen_vertices[2].
screen.
y <= 0x1df))
297 if (input_count_snapshot == 3)
302 long double bottom_test_depth = (
long double)batch->
view_vertices[3].
z;
303 long double bottom_clip_distance =
306 if (bottom_test_depth >= bottom_clip_distance)
314 int32_t input_vertex_index = 0;
318 if (input_count_snapshot > 0)
328 vertex->
uv.
u = prepared_vertices[input_vertex_index].
uv.
u;
329 vertex->
uv.
v = prepared_vertices[input_vertex_index].
uv.
v;
333 long double output_blue;
336 if (!(uint8_t)brighten_or_clipped_count)
342 color_green_cursor[-1] = (float)(
long double)source_red;
343 *color_green_cursor = (float)(
long double)source_green;
344 output_blue = (
long double)source_blue;
348 uint32_t bright_red = source_red << 1;
350 if (bright_red >= 0xff)
355 color_green_cursor[-1] = (float)(
long double)bright_red;
357 if (bright_green >= 0xff)
362 *color_green_cursor = (float)(
long double)bright_green;
364 if (bright_blue >= 0xff)
367 output_blue = (
long double)bright_blue;
370 input_count_snapshot = input_vertex_count;
371 color_green_cursor[1] = (float)output_blue;
372 input_vertex_index += 1;
373 color_green_cursor = &color_green_cursor[3];
374 }
while (input_vertex_index < input_count_snapshot);
377 int32_t triangles_remaining = 1;
380 if (input_count_snapshot == 4)
388 triangles_remaining = 2;
430 brighten_or_clipped_count = 3;
434 if (input_vertex_count != 4)
455 else if (triangles_remaining != 2)
520 int32_t clipped_count_snapshot = brighten_or_clipped_count;
522 if (clipped_count_snapshot >= 3 && clipped_count_snapshot <= 0xf)
524 BOOL clipped_vertex_index = 0;
526 if (clipped_count_snapshot > 0)
533 long double clipped_zero_depth = (
long double)0.0f;
535 if (!(clipped_view_depth > clipped_zero_depth))
556 long double normalized_depth = ((
long double)depth_bias + (
long double)
g_clipOutputVertices[clipped_vertex_index].pos.z) * (
long double)1.52587891e-05f + (
long double)signed_depth_bias;
558 long double maximum_normalized_depth = (
long double)0.99000001f;
560 if (!(maximum_normalized_depth >= normalized_depth))
561 normalized_depth = (
long double)0.99000001f;
572 long double clipped_red =
573 (
long double)clipped_color_cursor->
components[0];
579 int32_t packed_alpha_red = (uint8_t)(
__ftol_msvc(clipped_red));
581 *(uint8_t *)((
char *)&packed_alpha_red + 1) = alpha_byte;
584 long double screen_x_before_lower_clamp =
586 long double minimum_screen_x = (
long double)0.0f;
588 if (!(screen_x_before_lower_clamp >= minimum_screen_x))
591 long double screen_x_before_upper_clamp =
593 long double maximum_screen_x = (
long double)639.0f;
595 if (screen_x_before_upper_clamp > maximum_screen_x)
598 long double screen_y_before_lower_clamp =
600 long double minimum_screen_y = (
long double)0.0f;
602 if (!(screen_y_before_lower_clamp >= minimum_screen_y))
605 long double screen_y_before_upper_clamp =
607 long double maximum_screen_y = (
long double)479.0f;
609 if (screen_y_before_upper_clamp > maximum_screen_y)
612 clipped_count_snapshot = brighten_or_clipped_count;
614 clipped_vertex_index += 1;
615 clipped_color_cursor++;
617 if (clipped_vertex_index >= clipped_count_snapshot)
622 if (clipped_vertex_index == clipped_count_snapshot)
625 int32_t draw_vertex_count;
627 IDirect3DDevice7 *device;
628 IDirect3DDevice7Vtbl *device_vtable;
633 if (clipped_count_snapshot > 0)
637 int32_t vertices_remaining = clipped_count_snapshot;
638 int32_t remaining_before_copy;
644 int32_t screen_x_bits = *(uint32_t *)&textured_vertex->
pos.
x;
647 untextured_y_cursor[-1] = screen_x_bits;
648 *(uint32_t *)untextured_y_cursor = *(uint32_t *)&textured_vertex[-1].
pos.
y;
649 untextured_y_cursor[1] = *(uint32_t *)&textured_vertex[-1].
pos.
z;
650 untextured_y_cursor[2] = *(uint32_t *)&textured_vertex[-1].
pos.
rhw;
651 untextured_y_cursor[3] = *(uint32_t *)&textured_vertex[-1].
color_or_data;
652 untextured_y_cursor = &untextured_y_cursor[5];
653 remaining_before_copy = vertices_remaining;
654 vertices_remaining -= 1;
655 }
while (remaining_before_copy != 1);
663 draw_vertex_count = clipped_count_snapshot;
665 device_vtable = device->lpVtbl;
667 device_vtable->DrawPrimitive(device, D3DPT_TRIANGLEFAN, vertex_format_flags, draw_vertices, draw_vertex_count, 0);
679 draw_vertex_count = clipped_count_snapshot;
681 device_vtable = device->lpVtbl;
684 device_vtable->DrawPrimitive(device, D3DPT_TRIANGLEFAN, vertex_format_flags, draw_vertices, draw_vertex_count, 0);
695 triangles_remaining -= 1;
697 if (!triangles_remaining)
714 int32_t position_x = (int32_t)(int16_t)(position->
x >> 8);
717 int32_t position_y = (int32_t)(int16_t)(position->
y >> 8);
719 int32_t position_z = (int32_t)(int16_t)(position->
z >> 8);
722 int32_t negative_radius_q10 = -((cull_radius << 0xa));
730 if (first_side_distance <= negative_radius_q10)
735 if (second_side_distance <= negative_radius_q10)
740 if (third_side_distance <= negative_radius_q10)
748 int32_t positive_radius_q10 = -(negative_radius_q10);
750 if (first_side_distance >= positive_radius_q10 && second_side_distance >= positive_radius_q10 && third_side_distance >= positive_radius_q10 && fourth_side_distance >= positive_radius_q10)
754 int32_t fully_inside_visibility = near_plane_distance;
758 return fully_inside_visibility;
763 int32_t partially_inside_visibility = near_plane_distance;
767 return partially_inside_visibility;