@@ -1935,7 +1935,7 @@ setup_blocks_uv_adj_hack(psx_gpu_struct *psx_gpu, block_struct *block,
19351935
19361936#define setup_blocks_add_blocks_direct () \
19371937 stats_add(texel_blocks_untextured, span_num_blocks); \
1938- span_pixel_blocks += span_num_blocks \
1938+ stats_add( span_pixel_blocks, span_num_blocks); \
19391939
19401940
19411941#define setup_blocks_builder (shading , texturing , dithering , sw , target ) \
@@ -2918,9 +2918,9 @@ char *render_block_flag_strings[] =
29182918 (triangle_winding_##winding << 6)) \
29192919
29202920static int prepare_triangle (psx_gpu_struct * psx_gpu , vertex_struct * vertexes ,
2921- vertex_struct * vertexes_out [ 3 ] )
2921+ prepared_triangle * triangle_out )
29222922{
2923- s32 y_top , y_bottom ;
2923+ s32 y_top , y_bottom , offset_x , offset_y , i ;
29242924 s32 triangle_area ;
29252925 u32 triangle_winding = 0 ;
29262926
@@ -2955,6 +2955,7 @@ static int prepare_triangle(psx_gpu_struct *psx_gpu, vertex_struct *vertexes,
29552955
29562956 y_bottom = c -> y ;
29572957 y_top = a -> y ;
2958+ offset_y = sign_extend_11bit (y_top + psx_gpu -> offset_y ) - y_top ;
29582959
29592960 if ((y_bottom - y_top ) >= 512 )
29602961 {
@@ -2982,29 +2983,39 @@ static int prepare_triangle(psx_gpu_struct *psx_gpu, vertex_struct *vertexes,
29822983 vertex_swap (a , b );
29832984 }
29842985
2985- if (( c -> x - psx_gpu -> offset_x ) >= 1024 || ( c -> x - a -> x ) >= 1024 )
2986+ if (c -> x - a -> x >= 1024 )
29862987 {
29872988#ifdef PROFILE
29882989 trivial_rejects ++ ;
29892990#endif
29902991 return 0 ;
29912992 }
29922993
2993- if (invalidate_texture_cache_region_viewport (psx_gpu , a -> x , y_top , c -> x ,
2994- y_bottom ) == 0 )
2994+ offset_x = sign_extend_11bit (a -> x + psx_gpu -> offset_x ) - a -> x ;
2995+ if (invalidate_texture_cache_region_viewport (psx_gpu ,
2996+ a -> x + offset_x , y_top + offset_y ,
2997+ c -> x + offset_x , y_bottom + offset_y ) == 0 )
29952998 {
29962999#ifdef PROFILE
29973000 trivial_rejects ++ ;
29983001#endif
29993002 return 0 ;
30003003 }
30013004
3005+ for (i = 0 ; i < 3 ; i ++ )
3006+ {
3007+ vertexes [i ].x += offset_x ;
3008+ vertexes [i ].y += offset_y ;
3009+ }
3010+
30023011 psx_gpu -> triangle_area = triangle_area ;
30033012 psx_gpu -> triangle_winding = triangle_winding ;
30043013
3005- vertexes_out [0 ] = a ;
3006- vertexes_out [1 ] = b ;
3007- vertexes_out [2 ] = c ;
3014+ triangle_out -> vertexes [0 ] = a ;
3015+ triangle_out -> vertexes [1 ] = b ;
3016+ triangle_out -> vertexes [2 ] = c ;
3017+ triangle_out -> offset_x = offset_x ;
3018+ triangle_out -> offset_y = offset_y ;
30083019
30093020 return 1 ;
30103021}
@@ -3157,9 +3168,9 @@ static void render_triangle_p(psx_gpu_struct *psx_gpu,
31573168void render_triangle (psx_gpu_struct * psx_gpu , vertex_struct * vertexes ,
31583169 u32 flags )
31593170{
3160- vertex_struct * vertex_ptrs [ 3 ] ;
3161- if (prepare_triangle (psx_gpu , vertexes , vertex_ptrs ))
3162- render_triangle_p (psx_gpu , vertex_ptrs , flags );
3171+ prepared_triangle triangle ;
3172+ if (prepare_triangle (psx_gpu , vertexes , & triangle ))
3173+ render_triangle_p (psx_gpu , triangle . vertexes , flags );
31633174}
31643175
31653176#if !defined(NEON_BUILD ) || defined(SIMD_BUILD )
@@ -5067,6 +5078,7 @@ void initialize_psx_gpu(psx_gpu_struct *psx_gpu, u16 *vram)
50675078 psx_gpu -> dither_table [1 ] = dither_table_row (2 , -2 , 3 , -1 );
50685079 psx_gpu -> dither_table [2 ] = dither_table_row (-3 , 1 , -4 , 0 );
50695080 psx_gpu -> dither_table [3 ] = dither_table_row (3 , -1 , 2 , -2 );
5081+ psx_gpu -> allow_dithering = 1 ;
50705082
50715083 psx_gpu -> primitive_type = PRIMITIVE_TYPE_UNKNOWN ;
50725084
0 commit comments