#endif
u32 gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size,
- s32 *cpu_cycles_out, u32 *last_command)
+ s32 *cpu_cycles_sum_out, s32 *cpu_cycles_last, u32 *last_command)
{
vertex_struct vertexes[4] __attribute__((aligned(16))) = {};
- u32 current_command = 0, command_length, cpu_cycles = 0;
+ u32 current_command = 0, command_length;
+ u32 cpu_cycles_sum = 0, cpu_cycles = *cpu_cycles_last;
u32 *list_start = list;
u32 *list_end = list + (size / 4);
u32 color = list[0] & 0xFFFFFF;
do_fill(psx_gpu, x, y, width, height, color);
- cpu_cycles += gput_fill(width, height);
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_fill(width, height));
break;
}
get_vertex_data_xy(2, 6);
render_triangle(psx_gpu, vertexes, current_command);
- cpu_cycles += gput_poly_base();
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_poly_base());
break;
}
get_vertex_data_xy_uv(2, 10);
render_triangle(psx_gpu, vertexes, current_command);
- cpu_cycles += gput_poly_base_t();
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_poly_base_t());
break;
}
render_triangle(psx_gpu, vertexes, current_command);
render_triangle(psx_gpu, &(vertexes[1]), current_command);
- cpu_cycles += gput_quad_base();
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_quad_base());
break;
}
render_triangle(psx_gpu, vertexes, current_command);
render_triangle(psx_gpu, &(vertexes[1]), current_command);
- cpu_cycles += gput_quad_base_t();
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_quad_base_t());
break;
}
get_vertex_data_xy_rgb(2, 8);
render_triangle(psx_gpu, vertexes, current_command);
- cpu_cycles += gput_poly_base_g();
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_poly_base_g());
break;
}
get_vertex_data_xy_uv_rgb(2, 12);
render_triangle(psx_gpu, vertexes, current_command);
- cpu_cycles += gput_poly_base_gt();
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_poly_base_gt());
break;
}
render_triangle(psx_gpu, vertexes, current_command);
render_triangle(psx_gpu, &(vertexes[1]), current_command);
- cpu_cycles += gput_quad_base_g();
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_quad_base_g());
break;
}
render_triangle(psx_gpu, vertexes, current_command);
render_triangle(psx_gpu, &(vertexes[1]), current_command);
- cpu_cycles += gput_quad_base_gt();
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_quad_base_gt());
break;
}
vertexes[1].y = list_s16[5] + psx_gpu->offset_y;
render_line(psx_gpu, vertexes, current_command, list[0], 0);
- cpu_cycles += gput_line(0);
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_line(0));
break;
}
vertexes[1].y = (xy >> 16) + psx_gpu->offset_y;
render_line(psx_gpu, vertexes, current_command, list[0], 0);
- cpu_cycles += gput_line(0);
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_line(0));
list_position++;
num_vertexes++;
vertexes[1].y = list_s16[7] + psx_gpu->offset_y;
render_line(psx_gpu, vertexes, current_command, 0, 0);
- cpu_cycles += gput_line(0);
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_line(0));
break;
}
vertexes[1].y = (xy >> 16) + psx_gpu->offset_y;
render_line(psx_gpu, vertexes, current_command, 0, 0);
- cpu_cycles += gput_line(0);
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_line(0));
list_position += 2;
num_vertexes++;
render_sprite(psx_gpu, x, y, 0, 0, &width, &height,
current_command, list[0]);
- cpu_cycles += gput_sprite(width, height);
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_sprite(width, height));
break;
}
render_sprite(psx_gpu, x, y, uv & 0xFF, (uv >> 8) & 0xFF,
&width, &height, current_command, list[0]);
- cpu_cycles += gput_sprite(width, height);
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_sprite(width, height));
break;
}
render_sprite(psx_gpu, x, y, 0, 0, &width, &height,
current_command, list[0]);
- cpu_cycles += gput_sprite(1, 1);
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_sprite(1, 1));
break;
}
render_sprite(psx_gpu, x, y, 0, 0, &width, &height,
current_command, list[0]);
- cpu_cycles += gput_sprite(width, height);
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_sprite(width, height));
break;
}
render_sprite(psx_gpu, x, y, uv & 0xFF, (uv >> 8) & 0xFF,
&width, &height, current_command, list[0]);
- cpu_cycles += gput_sprite(width, height);
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_sprite(width, height));
break;
}
render_sprite(psx_gpu, x, y, 0, 0, &width, &height,
current_command, list[0]);
- cpu_cycles += gput_sprite(width, height);
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_sprite(width, height));
break;
}
render_sprite(psx_gpu, x, y, uv & 0xFF, (uv >> 8) & 0xFF,
&width, &height, current_command, list[0]);
- cpu_cycles += gput_sprite(width, height);
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_sprite(width, height));
break;
}
}
breakloop:
- *cpu_cycles_out += cpu_cycles;
+ *cpu_cycles_sum_out += cpu_cycles_sum;
+ *cpu_cycles_last = cpu_cycles;
*last_command = current_command;
return list - list_start;
}
}
#endif
-static int disable_main_render;
-
// simple check for a case where no clipping is used
// - now handled by adjusting the viewport
static int check_enhanced_range(psx_gpu_struct *psx_gpu, int x, int y)
vertex_ptrs[i].v = new;
}
+// this sometimes does more harm than good, like in PE2
static void uv_hack(vertex_struct *vertex_ptrs, int vertex_count)
{
int i, u[4], v[4];
if (!prepare_triangle(psx_gpu, vertexes, vertex_ptrs))
return;
- if (!disable_main_render)
+ if (!psx_gpu->hack_disable_main)
render_triangle_p(psx_gpu, vertex_ptrs, current_command);
if (!check_enhanced_range(psx_gpu, vertex_ptrs[0]->x, vertex_ptrs[2]->x))
#endif
u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size,
- s32 *cpu_cycles_out, u32 *last_command)
+ s32 *cpu_cycles_sum_out, s32 *cpu_cycles_last, u32 *last_command)
{
vertex_struct vertexes[4] __attribute__((aligned(16))) = {};
- u32 current_command = 0, command_length, cpu_cycles = 0;
+ u32 current_command = 0, command_length;
+ u32 cpu_cycles_sum = 0, cpu_cycles = *cpu_cycles_last;
u32 *list_start = list;
u32 *list_end = list + (size / 4);
x &= ~0xF;
width = ((width + 0xF) & ~0xF);
- cpu_cycles += gput_fill(width, height);
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_fill(width, height));
if (width == 0 || height == 0)
break;
get_vertex_data_xy(2, 6);
do_triangle_enhanced(psx_gpu, vertexes, current_command);
- cpu_cycles += gput_poly_base();
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_poly_base());
break;
}
get_vertex_data_xy_uv(2, 10);
do_triangle_enhanced(psx_gpu, vertexes, current_command);
- cpu_cycles += gput_poly_base_t();
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_poly_base_t());
break;
}
get_vertex_data_xy(3, 8);
do_quad_enhanced(psx_gpu, vertexes, current_command);
- cpu_cycles += gput_quad_base();
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_quad_base());
break;
}
get_vertex_data_xy_uv(2, 10);
get_vertex_data_xy_uv(3, 14);
- uv_hack(vertexes, 4);
+ if (psx_gpu->hack_texture_adj)
+ uv_hack(vertexes, 4);
do_quad_enhanced(psx_gpu, vertexes, current_command);
- cpu_cycles += gput_quad_base_t();
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_quad_base_t());
break;
}
get_vertex_data_xy_rgb(2, 8);
do_triangle_enhanced(psx_gpu, vertexes, current_command);
- cpu_cycles += gput_poly_base_g();
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_poly_base_g());
break;
}
get_vertex_data_xy_uv_rgb(2, 12);
do_triangle_enhanced(psx_gpu, vertexes, current_command);
- cpu_cycles += gput_poly_base_gt();
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_poly_base_gt());
break;
}
get_vertex_data_xy_rgb(3, 12);
do_quad_enhanced(psx_gpu, vertexes, current_command);
- cpu_cycles += gput_quad_base_g();
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_quad_base_g());
break;
}
get_vertex_data_xy_uv_rgb(2, 12);
get_vertex_data_xy_uv_rgb(3, 18);
- uv_hack(vertexes, 4);
+ if (psx_gpu->hack_texture_adj)
+ uv_hack(vertexes, 4);
do_quad_enhanced(psx_gpu, vertexes, current_command);
- cpu_cycles += gput_quad_base_gt();
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_quad_base_gt());
break;
}
render_line(psx_gpu, vertexes, current_command, list[0], 0);
if (enhancement_enable(psx_gpu))
render_line(psx_gpu, vertexes, current_command, list[0], 1);
- cpu_cycles += gput_line(0);
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_line(0));
break;
}
render_line(psx_gpu, vertexes, current_command, list[0], 0);
if (enhancement_enable(psx_gpu))
render_line(psx_gpu, vertexes, current_command, list[0], 1);
- cpu_cycles += gput_line(0);
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_line(0));
list_position++;
num_vertexes++;
render_line(psx_gpu, vertexes, current_command, 0, 0);
if (enhancement_enable(psx_gpu))
render_line(psx_gpu, vertexes, current_command, 0, 1);
- cpu_cycles += gput_line(0);
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_line(0));
break;
}
render_line(psx_gpu, vertexes, current_command, 0, 0);
if (enhancement_enable(psx_gpu))
render_line(psx_gpu, vertexes, current_command, 0, 1);
- cpu_cycles += gput_line(0);
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_line(0));
list_position += 2;
num_vertexes++;
render_sprite(psx_gpu, x, y, 0, 0, &width, &height,
current_command, list[0]);
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_sprite(width, height));
- if (check_enhanced_range(psx_gpu, x, x + width))
+ if (check_enhanced_range(psx_gpu, x, x + width)) {
+ width = list_s16[4] & 0x3FF;
+ height = list_s16[5] & 0x1FF;
do_sprite_enhanced(psx_gpu, x, y, 0, 0, width, height, list[0]);
- cpu_cycles += gput_sprite(width, height);
+ }
break;
}
render_sprite(psx_gpu, x, y, u, v,
&width, &height, current_command, list[0]);
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_sprite(width, height));
- if (check_enhanced_range(psx_gpu, x, x + width))
+ if (check_enhanced_range(psx_gpu, x, x + width)) {
+ width = list_s16[6] & 0x3FF;
+ height = list_s16[7] & 0x1FF;
do_sprite_enhanced(psx_gpu, x, y, u, v, width, height, list[0]);
- cpu_cycles += gput_sprite(width, height);
+ }
break;
}
render_sprite(psx_gpu, x, y, 0, 0, &width, &height,
current_command, list[0]);
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_sprite(1, 1));
if (check_enhanced_range(psx_gpu, x, x + 1))
- do_sprite_enhanced(psx_gpu, x, y, 0, 0, width, height, list[0]);
- cpu_cycles += gput_sprite(1, 1);
+ do_sprite_enhanced(psx_gpu, x, y, 0, 0, 1, 1, list[0]);
break;
}
render_sprite(psx_gpu, x, y, 0, 0, &width, &height,
current_command, list[0]);
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_sprite(width, height));
if (check_enhanced_range(psx_gpu, x, x + 8))
- do_sprite_enhanced(psx_gpu, x, y, 0, 0, width, height, list[0]);
- cpu_cycles += gput_sprite(width, height);
+ do_sprite_enhanced(psx_gpu, x, y, 0, 0, 8, 8, list[0]);
break;
}
render_sprite(psx_gpu, x, y, u, v,
&width, &height, current_command, list[0]);
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_sprite(width, height));
if (check_enhanced_range(psx_gpu, x, x + 8))
- do_sprite_enhanced(psx_gpu, x, y, u, v, width, height, list[0]);
- cpu_cycles += gput_sprite(width, height);
+ do_sprite_enhanced(psx_gpu, x, y, u, v, 8, 8, list[0]);
break;
}
render_sprite(psx_gpu, x, y, 0, 0, &width, &height,
current_command, list[0]);
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_sprite(width, height));
if (check_enhanced_range(psx_gpu, x, x + 16))
- do_sprite_enhanced(psx_gpu, x, y, 0, 0, width, height, list[0]);
- cpu_cycles += gput_sprite(width, height);
+ do_sprite_enhanced(psx_gpu, x, y, 0, 0, 16, 16, list[0]);
break;
}
render_sprite(psx_gpu, x, y, u, v,
&width, &height, current_command, list[0]);
+ gput_sum(cpu_cycles_sum, cpu_cycles, gput_sprite(width, height));
if (check_enhanced_range(psx_gpu, x, x + 16))
- do_sprite_enhanced(psx_gpu, x, y, u, v, width, height, list[0]);
- cpu_cycles += gput_sprite(width, height);
+ do_sprite_enhanced(psx_gpu, x, y, u, v, 16, 16, list[0]);
break;
}
enhancement_disable();
breakloop:
- *cpu_cycles_out += cpu_cycles;
+ *cpu_cycles_sum_out += cpu_cycles_sum;
+ *cpu_cycles_last = cpu_cycles;
*last_command = current_command;
return list - list_start;
}