From 4be044baf017d654481aee4301325320c4c1c31c Mon Sep 17 00:00:00 2001 From: Exophase Date: Sat, 24 Dec 2011 00:13:52 +0200 Subject: [PATCH] psx_gpu: fix sprite sign extend --- plugins/gpu_neon/psx_gpu/psx_gpu_main.c | 4 +-- plugins/gpu_neon/psx_gpu/psx_gpu_parse.c | 35 ++++++++++++++---------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/plugins/gpu_neon/psx_gpu/psx_gpu_main.c b/plugins/gpu_neon/psx_gpu/psx_gpu_main.c index 0f85604f..8624ff0b 100644 --- a/plugins/gpu_neon/psx_gpu/psx_gpu_main.c +++ b/plugins/gpu_neon/psx_gpu/psx_gpu_main.c @@ -211,7 +211,7 @@ int main(int argc, char *argv[]) printf("%d\n", cycles_elapsed); #endif -#if 1 +#if 0 u32 i; for(i = 0; i < 1024 * 512; i++) @@ -238,7 +238,7 @@ int main(int argc, char *argv[]) } #endif -#if 0 +#if 1 printf("\n"); printf(" %d pixels, %d pixel blocks, %d spans\n" " (%lf pixels per block, %lf pixels per span),\n" diff --git a/plugins/gpu_neon/psx_gpu/psx_gpu_parse.c b/plugins/gpu_neon/psx_gpu/psx_gpu_parse.c index 32895e15..2099edf3 100644 --- a/plugins/gpu_neon/psx_gpu/psx_gpu_parse.c +++ b/plugins/gpu_neon/psx_gpu/psx_gpu_parse.c @@ -153,6 +153,13 @@ void set_triangle_color(psx_gpu_struct *psx_gpu, u32 triangle_color) #define sign_extend_12bit(value) \ (((s32)((value) << 20)) >> 20) \ +#define sign_extend_11bit(value) \ + (((s32)((value) << 21)) >> 21) \ + +#define sign_extend_10bit(value) \ + (((s32)((value) << 22)) >> 22) \ + + #define get_vertex_data_xy(vertex_number, offset16) \ vertexes[vertex_number].x = \ sign_extend_12bit(list_s16[offset16]) + psx_gpu->offset_x; \ @@ -433,8 +440,8 @@ void gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size) case 0x60 ... 0x63: { - u32 x = sign_extend_12bit(list_s16[2]) + psx_gpu->offset_x; - u32 y = sign_extend_12bit(list_s16[3]) + psx_gpu->offset_y; + u32 x = sign_extend_11bit(list_s16[2] + psx_gpu->offset_x); + u32 y = sign_extend_11bit(list_s16[3] + psx_gpu->offset_y); u32 width = list_s16[4] & 0x3FF; u32 height = list_s16[5] & 0x1FF; @@ -444,8 +451,8 @@ void gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size) case 0x64 ... 0x67: { - u32 x = sign_extend_12bit(list_s16[2]) + psx_gpu->offset_x; - u32 y = sign_extend_12bit(list_s16[3]) + psx_gpu->offset_y; + u32 x = sign_extend_11bit(list_s16[2] + psx_gpu->offset_x); + u32 y = sign_extend_11bit(list_s16[3] + psx_gpu->offset_y); u32 uv = list_s16[4]; u32 width = list_s16[6] & 0x3FF; u32 height = list_s16[7] & 0x1FF; @@ -462,8 +469,8 @@ void gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size) case 0x6A: case 0x6B: { - s32 x = sign_extend_12bit(list_s16[2]) + psx_gpu->offset_x; - s32 y = sign_extend_12bit(list_s16[3]) + psx_gpu->offset_y; + s32 x = sign_extend_11bit(list_s16[2] + psx_gpu->offset_x); + 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]); break; @@ -474,8 +481,8 @@ void gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size) case 0x72: case 0x73: { - s32 x = sign_extend_12bit(list_s16[2]) + psx_gpu->offset_x; - s32 y = sign_extend_12bit(list_s16[3]) + psx_gpu->offset_y; + s32 x = sign_extend_11bit(list_s16[2] + psx_gpu->offset_x); + 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]); break; @@ -486,8 +493,8 @@ void gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size) case 0x76: case 0x77: { - s32 x = sign_extend_12bit(list_s16[2]) + psx_gpu->offset_x; - s32 y = sign_extend_12bit(list_s16[3]) + psx_gpu->offset_y; + s32 x = sign_extend_11bit(list_s16[2] + psx_gpu->offset_x); + s32 y = sign_extend_11bit(list_s16[3] + psx_gpu->offset_y); u32 uv = list_s16[4]; set_clut(psx_gpu, list_s16[5]); @@ -502,8 +509,8 @@ void gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size) case 0x7A: case 0x7B: { - s32 x = sign_extend_12bit(list_s16[2]) + psx_gpu->offset_x; - s32 y = sign_extend_12bit(list_s16[3]) + psx_gpu->offset_y; + s32 x = sign_extend_11bit(list_s16[2] + psx_gpu->offset_x); + 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]); break; @@ -514,8 +521,8 @@ void gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size) case 0x7E: case 0x7F: { - s32 x = sign_extend_12bit(list_s16[2]) + psx_gpu->offset_x; - s32 y = sign_extend_12bit(list_s16[3]) + psx_gpu->offset_y; + s32 x = sign_extend_11bit(list_s16[2] + psx_gpu->offset_x); + s32 y = sign_extend_11bit(list_s16[3] + psx_gpu->offset_y); u32 uv = list_s16[4]; set_clut(psx_gpu, list_s16[5]); -- 2.39.5