Skip to content

Commit

Permalink
VDC autocropping fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sonninnos committed Feb 22, 2024
1 parent 45eeaf2 commit 7bef4a0
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions retrodep/video.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,10 @@ static void video_canvas_crop(struct video_canvas_s *canvas)
if (c128_vdc)
{
if (vice_raster.first_line < crop_top_border)
{
vice_raster.last_line -= crop_top_border - vice_raster.first_line;
crop_bottom_border -= crop_top_border - vice_raster.first_line;
}
}
#endif

Expand Down Expand Up @@ -245,6 +248,25 @@ static void video_canvas_crop(struct video_canvas_s *canvas)
break;
}

#if defined(__X128__)
if (c128_vdc)
{
/* Center vertically if the whole area is not used */
if (vice_raster.first_line < crop_top_border)
{
if (i == crop_bottom_border)
{
int center = (vice_raster.last_line - i + 1) / 2;
if (center > 1)
{
vice_raster.first_line -= center;
vice_raster.last_line -= center;
}
}
}
}
#endif

/* Align the resulting screen height to even number */
if ((vice_raster.last_line - vice_raster.first_line) % 2)
vice_raster.last_line++;
Expand Down Expand Up @@ -281,12 +303,14 @@ static void video_canvas_crop(struct video_canvas_s *canvas)

if (vice_raster.counter > crop_counter)
{
if ( (retroh_crop != vice_raster.last_line - vice_raster.first_line)
|| vice_raster.first_line != vice_raster.first_line_active
|| vice_raster.last_line != vice_raster.last_line_active)
crop_id_prev = -1;

vice_raster.counter = 0;
vice_raster.first_line_active = vice_raster.first_line;
vice_raster.last_line_active = vice_raster.last_line;

if (retroh_crop != vice_raster.last_line - vice_raster.first_line)
crop_id_prev = -1;
}

#if 0
Expand Down Expand Up @@ -327,12 +351,12 @@ static void video_canvas_crop(struct video_canvas_s *canvas)

if (vice_raster.counter > crop_counter)
{
if (retroh_crop != vice_raster.last_line - vice_raster.first_line)
crop_id_prev = -1;

vice_raster.counter = 0;
vice_raster.first_line_active = vice_raster.first_line;
vice_raster.last_line_active = vice_raster.last_line;

if (retroh_crop != vice_raster.last_line - vice_raster.first_line)
crop_id_prev = -1;
}
break;
#endif
Expand Down

0 comments on commit 7bef4a0

Please sign in to comment.