X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=plugins%2Fgpu_neon%2Fpsx_gpu%2Fpsx_gpu_parse.c;h=053661339b2a04a817338e32043529d0ff6e7620;hp=f920c73e259a9dae13be24c8a606438beb78076a;hb=f0931e56b2428fe5e0f6b4d7d6d0f41462cfc551;hpb=06bc35c833797ce9f6f3287abf954f037bb12319 diff --git a/plugins/gpu_neon/psx_gpu/psx_gpu_parse.c b/plugins/gpu_neon/psx_gpu/psx_gpu_parse.c index f920c73e..05366133 100644 --- a/plugins/gpu_neon/psx_gpu/psx_gpu_parse.c +++ b/plugins/gpu_neon/psx_gpu/psx_gpu_parse.c @@ -760,17 +760,28 @@ breakloop: return list - list_start; } -static void *select_enhancement_buf_ptr(psx_gpu_struct *psx_gpu, u32 x) +#ifdef PCSX + +static void update_enhancement_buf_table(psx_gpu_struct *psx_gpu) { - u32 b; - for (b = 0; x >= psx_gpu->enhancement_x_threshold; b++) - x -= psx_gpu->enhancement_x_threshold; - return psx_gpu->enhancement_buf_ptr + b * 1024 * 1024; + u32 b, x, s; + + b = 0; + s = psx_gpu->enhancement_x_threshold; + for (x = 0; x < sizeof(psx_gpu->enhancement_buf_by_x16); x++) + { + if (x * 16 >= s - 15) + { + s += psx_gpu->enhancement_x_threshold; + b++; + } + psx_gpu->enhancement_buf_by_x16[x] = b; + } } #define select_enhancement_buf(psx_gpu) \ psx_gpu->enhancement_current_buf_ptr = \ - select_enhancement_buf_ptr(psx_gpu, psx_gpu->saved_viewport_start_x + 8) + select_enhancement_buf_ptr(psx_gpu, psx_gpu->saved_viewport_start_x) #define enhancement_disable() { \ psx_gpu->vram_out_ptr = psx_gpu->vram_ptr; \ @@ -864,6 +875,8 @@ static void do_quad_enhanced(psx_gpu_struct *psx_gpu, vertex_struct *vertexes, } } +#if 0 + #define fill_vertex(i, x_, y_, u_, v_, rgb_) \ vertexes[i].x = x_; \ vertexes[i].y = y_; \ @@ -873,7 +886,7 @@ static void do_quad_enhanced(psx_gpu_struct *psx_gpu, vertex_struct *vertexes, vertexes[i].g = (rgb_) >> 8; \ vertexes[i].b = (rgb_) >> 16 -static void do_esprite_in_triangles(psx_gpu_struct *psx_gpu, int x, int y, +static void do_sprite_enhanced(psx_gpu_struct *psx_gpu, int x, int y, u32 u, u32 v, u32 w, u32 h, u32 cmd_rgb) { vertex_struct *vertex_ptrs[3]; @@ -928,8 +941,19 @@ static void do_esprite_in_triangles(psx_gpu_struct *psx_gpu, int x, int y, psx_gpu->render_state_base = render_state_base_saved; } +#else +static void do_sprite_enhanced(psx_gpu_struct *psx_gpu, int x, int y, + u32 u, u32 v, u32 w, u32 h, u32 cmd_rgb) +{ + u32 flags = (cmd_rgb >> 24); + u32 color = cmd_rgb & 0xffffff; + + render_sprite_4x(psx_gpu, x, y, u, v, w, h, flags, color); +} +#endif -u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, u32 *last_command) +u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, + u32 *last_command) { u32 current_command = 0, command_length; @@ -972,7 +996,7 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, u32 *last_c do_fill(psx_gpu, x, y, width, height, color); - psx_gpu->vram_out_ptr = psx_gpu->enhancement_current_buf_ptr; + psx_gpu->vram_out_ptr = select_enhancement_buf_ptr(psx_gpu, x); x *= 2; y *= 2; width *= 2; @@ -1216,7 +1240,7 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, u32 *last_c u32 height = list_s16[5] & 0x1FF; render_sprite(psx_gpu, x, y, 0, 0, width, height, current_command, list[0]); - do_esprite_in_triangles(psx_gpu, x, y, 0, 0, width, height, list[0]); + do_sprite_enhanced(psx_gpu, x, y, 0, 0, width, height, list[0]); break; } @@ -1233,7 +1257,7 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, u32 *last_c render_sprite(psx_gpu, x, y, u, v, width, height, current_command, list[0]); - do_esprite_in_triangles(psx_gpu, x, y, u, v, width, height, list[0]); + do_sprite_enhanced(psx_gpu, x, y, u, v, width, height, list[0]); break; } @@ -1246,7 +1270,7 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, u32 *last_c s32 y = sign_extend_11bit(list_s16[3] + psx_gpu->offset_y); render_sprite(psx_gpu, x, y, 0, 0, 1, 1, current_command, list[0]); - do_esprite_in_triangles(psx_gpu, x, y, 0, 0, 1, 1, list[0]); + do_sprite_enhanced(psx_gpu, x, y, 0, 0, 1, 1, list[0]); break; } @@ -1259,7 +1283,7 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, u32 *last_c s32 y = sign_extend_11bit(list_s16[3] + psx_gpu->offset_y); render_sprite(psx_gpu, x, y, 0, 0, 8, 8, current_command, list[0]); - do_esprite_in_triangles(psx_gpu, x, y, 0, 0, 8, 8, list[0]); + do_sprite_enhanced(psx_gpu, x, y, 0, 0, 8, 8, list[0]); break; } @@ -1277,7 +1301,7 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, u32 *last_c render_sprite(psx_gpu, x, y, u, v, 8, 8, current_command, list[0]); - do_esprite_in_triangles(psx_gpu, x, y, u, v, 8, 8, list[0]); + do_sprite_enhanced(psx_gpu, x, y, u, v, 8, 8, list[0]); break; } @@ -1290,7 +1314,7 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, u32 *last_c s32 y = sign_extend_11bit(list_s16[3] + psx_gpu->offset_y); render_sprite(psx_gpu, x, y, 0, 0, 16, 16, current_command, list[0]); - do_esprite_in_triangles(psx_gpu, x, y, 0, 0, 16, 16, list[0]); + do_sprite_enhanced(psx_gpu, x, y, 0, 0, 16, 16, list[0]); break; } @@ -1307,7 +1331,7 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, u32 *last_c set_clut(psx_gpu, list_s16[5]); render_sprite(psx_gpu, x, y, u, v, 16, 16, current_command, list[0]); - do_esprite_in_triangles(psx_gpu, x, y, u, v, 16, 16, list[0]); + do_sprite_enhanced(psx_gpu, x, y, u, v, 16, 16, list[0]); break; } @@ -1388,10 +1412,20 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, u32 *last_c } case 0xE3: + { + u32 d; psx_gpu->viewport_start_x = list[0] & 0x3FF; psx_gpu->viewport_start_y = (list[0] >> 10) & 0x1FF; psx_gpu->saved_viewport_start_x = psx_gpu->viewport_start_x; psx_gpu->saved_viewport_start_y = psx_gpu->viewport_start_y; + + d = psx_gpu->enhancement_x_threshold - psx_gpu->viewport_start_x; + if(unlikely(0 < d && d <= 8)) + { + // Grandia hack.. + psx_gpu->enhancement_x_threshold = psx_gpu->viewport_start_x; + update_enhancement_buf_table(psx_gpu); + } select_enhancement_buf(psx_gpu); #ifdef TEXTURE_CACHE_4BPP @@ -1402,7 +1436,8 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, u32 *last_c #endif SET_Ex(3, list[0]); break; - + } + case 0xE4: psx_gpu->viewport_end_x = list[0] & 0x3FF; psx_gpu->viewport_end_y = (list[0] >> 10) & 0x1FF; @@ -1454,13 +1489,14 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, u32 *last_c } } -#ifdef PCSX + enhancement_disable(); + breakloop: -#endif -enhancement_disable(); if (last_command != NULL) *last_command = current_command; return list - list_start; } +#endif /* PCSX */ + // vim:shiftwidth=2:expandtab