From 2cdbb3522a3e4ef2d1bb7acaef5bf12ed1f81fca Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Mon, 12 Feb 2024 21:10:10 +0200 Subject: [PATCH] Genlock adjustable blanking support, fix scaling. --- drawing.cpp | 12 ++++++++++++ include/drawing.h | 3 ++- specialmonitors.cpp | 33 +++++++++++++++++++++++++-------- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/drawing.cpp b/drawing.cpp index 1c024008..4b56e7ac 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -481,6 +481,18 @@ void get_custom_topedge (int *xp, int *yp, bool max) } } +void get_screen_blanking_limits(int *hbstop, int *hbstrt, int *vbstop, int *vbstrt) +{ + *vbstop = vblank_bottom_stop; + *vbstrt = vblank_top_start; + + int hblank_left = exthblank ? hblank_left_start : hblank_left_start_hard; + int hblank_right = exthblank ? hblank_right_stop : hblank_right_stop_hard; + + *hbstop = hblank_left - visible_left_border; + *hbstrt = hblank_right - visible_left_border; +} + static void reset_custom_limits(void) { gclow = gcloh = gclox = gcloy = 0; diff --git a/include/drawing.h b/include/drawing.h index 75116633..b0e9823c 100644 --- a/include/drawing.h +++ b/include/drawing.h @@ -29,7 +29,7 @@ extern int hsync_end_left_border, denisehtotal; #define AMIGA_WIDTH_MAX (754 / 2) #define AMIGA_HEIGHT_MAX_PAL (576 / 2) -#define AMIGA_HEIGHT_MAX_NTSC (484 / 2) +#define AMIGA_HEIGHT_MAX_NTSC (486 / 2) #define AMIGA_HEIGHT_MAX (AMIGA_HEIGHT_MAX_PAL) // Cycles * 2 from start of scanline to first refresh slot (hsync strobe slot) @@ -385,6 +385,7 @@ extern void allocvidbuffer(int monid, struct vidbuffer *buf, int width, int heig extern void freevidbuffer(int monid, struct vidbuffer *buf); extern void check_prefs_picasso(void); extern int get_vertical_visible_height(bool); +extern void get_screen_blanking_limits(int*, int*, int*, int*); /* Finally, stuff that shouldn't really be shared. */ diff --git a/specialmonitors.cpp b/specialmonitors.cpp index b20347bf..b53e0698 100755 --- a/specialmonitors.cpp +++ b/specialmonitors.cpp @@ -2547,8 +2547,17 @@ skip: uae_u8 amix1 = 255 - (currprefs.genlock_mix > 255 ? 255 : 0); uae_u8 amix2 = 255 - amix1; - int ah = (((yend - ystart) * 2) >> 0); int aw = ((xend - xstart) >> 1); + if (avidinfo->xchange == 1) { + aw *= 2; + } else if (avidinfo->xchange == 4) { + aw /= 2; + } + + int ah = (((yend - ystart) * 2) >> 0); + if (avidinfo->ychange == 2) { + ah /= 2; + } if (ah < 16 || aw < 16) { return false; @@ -2563,9 +2572,6 @@ skip: if (abs(genlock_image_height - ah) > 8) { deltay = genlock_image_height * 65536 / ah; } - deltay <<= vdbl; - deltax <<= hdbl; - deltax >>= 1; deltax -= currprefs.genlock_scale * 256; deltay -= currprefs.genlock_scale * 256; @@ -2574,15 +2580,15 @@ skip: int offsety = 0; if (deltax && deltay) { - offsetx = ((aw - genlock_image_width) * 65536 / deltax) / 2; - offsety = ((ah - genlock_image_height) * 65536 / deltay) / 2; + offsetx = (aw - (genlock_image_width * 65536 / deltax)) / 2; + offsety = (ah - (genlock_image_height * 65536 / deltay)) / 2; if (currprefs.genlock_aspect) { if (deltax < deltay) { - offsetx = ((aw - genlock_image_width) * 65536 / deltay) / 2; + offsetx = (aw - (genlock_image_width * 65536 / deltay)) / 2; deltax = deltay; } else { - offsety = ((ah - genlock_image_height) * 65536 / deltax) / 2; + offsety = (ah - (genlock_image_height * 65536 / deltax)) / 2; deltay = deltax; } } @@ -2599,6 +2605,13 @@ skip: gen_xoffset += currprefs.genlock_offset_x; gen_yoffset += currprefs.genlock_offset_y; + int vblank_top_start, vblank_bottom_stop; + int hblank_left_start, hblank_right_stop; + + get_screen_blanking_limits(&hblank_left_start, &hblank_right_stop, &vblank_bottom_stop, &vblank_top_start); + vblank_bottom_stop <<= vdbl; + vblank_top_start <<= vdbl; + uae_u8 r = 0, g = 0, b = 0, a = 0; for (y = ystart; y < yend; y++) { int yoff = (y * 2 + oddlines) - src->yoffset; @@ -2606,6 +2619,8 @@ skip: continue; if (yoff >= src->inheight) continue; + if (y * 2 < vblank_top_start || y * 2 >= vblank_bottom_stop) + continue; bool ztoggle = false; uae_u8 *line = src->bufmem + yoff * src->rowbytes; @@ -2626,6 +2641,8 @@ skip: for (x = 0; x < src->inwidth; x++) { uae_u8 *s2 = s + src->rowbytes; uae_u8 *d2 = d + dst->rowbytes; + if (x < hblank_left_start || x >= hblank_right_stop) + continue; if ((!zclken && is_transparent(*s_genlock)) || (zclken && ztoggle)) { a = amix2; if (genlock_error) { -- 2.47.3