]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Genlock adjustable blanking support, fix scaling.
authorToni Wilen <twilen@winuae.net>
Mon, 12 Feb 2024 19:10:10 +0000 (21:10 +0200)
committerToni Wilen <twilen@winuae.net>
Mon, 12 Feb 2024 19:10:10 +0000 (21:10 +0200)
drawing.cpp
include/drawing.h
specialmonitors.cpp

index 1c0240088d4d4d0d670bb5c15612b3856d4d13c3..4b56e7ac7c4fb4086e27108f1607c7d9bb27863b 100644 (file)
@@ -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;
index 75116633024f86c22b67ee19026cf4a1ebe582e9..b0e9823cbd412f0395d7ec83d20a8ca3114db950 100644 (file)
@@ -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.  */
 
index b20347bf93d768a170fe6889aec863fdfe92606a..b53e069868d83766cfa96fb4720b4b036bdbd3f3 100755 (executable)
@@ -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) {