given clip 0,0 639, 479 and a triangle start at 479 y_count 480 this clipped off-by-one? - René Rebe --- ./src/vid_s3_virge.c.vanilla 2018-11-02 21:34:23.001923446 +0100 +++ ./src/vid_s3_virge.c 2018-11-02 21:36:33.253917430 +0100 @@ -2975,8 +2975,8 @@ z_offset -= s3d_tri->z_str; y_count -= diff_y; } - if ((state->y - y_count) < s3d_tri->clip_t) - y_count = state->y - s3d_tri->clip_t; + if ((state->y + 1 - y_count) < s3d_tri->clip_t) + y_count = state->y - s3d_tri->clip_t + 1; } for (; y_count > 0; y_count--) @@ -2990,7 +2990,7 @@ xe--; } - if (x != xe && ((x_dir > 0 && x < xe) || (x_dir < 0 && x > xe))) + if ((x_dir > 0 && x <= xe) || (x_dir < 0 && x >= xe)) { uint32_t dest_addr, z_addr; int dx = (x_dir > 0) ? ((31 - ((state->x1-1) >> 15)) & 0x1f) : (((state->x1-1) >> 15) & 0x1f); @@ -3069,7 +3069,7 @@ dest_addr = dest_offset + (x * (bpp + 1)); z_addr = z_offset + (x << 1); - for (; x != xe; x = (x + x_dir) & 0xfff) + for (; (x_dir > 0 && x <= xe) || (x_dir < 0 && x >= xe); x = (x + x_dir) & 0xfff) { int update = 1; uint16_t src_z = 0;