From: Toni Wilen Date: Wed, 15 May 2024 18:14:03 +0000 (+0300) Subject: Fix AGA genlock transparency bit being misdetected as special blanking bits X-Git-Tag: 5300~5 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=3caaf8e0f8306db34e5a899914da12aaec3318ae;p=francis%2Fwinuae.git Fix AGA genlock transparency bit being misdetected as special blanking bits --- diff --git a/custom.cpp b/custom.cpp index 7ad1db01..413de225 100644 --- a/custom.cpp +++ b/custom.cpp @@ -933,16 +933,12 @@ static void docols(struct color_entry *colentry) if (aga_mode) { for (int i = 0; i < 256; i++) { int v = color_reg_get(colentry, i); - if (v < 0 || v > 16777215) - continue; colentry->acolors[i] = getxcolor(v); } } else { #endif for (int i = 0; i < 32; i++) { int v = color_reg_get(colentry, i); - if (v < 0 || v > 4095) - continue; colentry->acolors[i] = getxcolor(v); } #ifdef AGA @@ -10286,7 +10282,6 @@ bool get_custom_color_reg(int colreg, uae_u8 *r, uae_u8 *g, uae_u8 *b) static void COLOR_WRITE(int hpos, uae_u16 v, int num) { - bool colzero = false; bool samecycle = false; // skip color register write color change state update if COLOR0 register was already written in same cycle @@ -10331,14 +10326,11 @@ static void COLOR_WRITE(int hpos, uae_u16 v, int num) cb = b + (b << 4); color_regs_genlock[colreg] = v >> 15; } - cval = (cr << 16) | (cg << 8) | cb | (color_regs_genlock[colreg] ? 0x80000000 : 0); - if (cval && colreg == 0) - colzero = true; - - if (cval == current_colors.color_regs_aga[colreg]) + cval = (cr << 16) | (cg << 8) | cb | (color_regs_genlock[colreg] ? COLOR_CHANGE_GENLOCK : 0); + if (cval == current_colors.color_regs_aga[colreg]) { return; - - if (colreg == 0) { + } + if ((cval & 0xffffff) && colreg == 0) { checkautoscalecol0(); } @@ -10352,17 +10344,14 @@ static void COLOR_WRITE(int hpos, uae_u16 v, int num) } else { #endif - if (ecs_denise) { - color_regs_genlock[num] = v >> 15; - } - v &= 0xfff; - if (num && v == 0) { - colzero = true; + if (!ecs_denise) { + v &= 0xfff; } + color_regs_genlock[num] = v >> 15; if (current_colors.color_regs_ecs[num] == v) { return; } - if (num == 0) { + if ((v & 0xfff) && num == 0) { checkautoscalecol0(); } @@ -11525,13 +11514,13 @@ static void cursorsprite(void) } if (aga_mode) { int sbasecol = ((bplcon4 >> 4) & 15) << 4; - sprite_0_colors[1] = current_colors.color_regs_aga[sbasecol + 1]; - sprite_0_colors[2] = current_colors.color_regs_aga[sbasecol + 2]; - sprite_0_colors[3] = current_colors.color_regs_aga[sbasecol + 3]; + sprite_0_colors[1] = current_colors.color_regs_aga[sbasecol + 1] & 0xffffff; + sprite_0_colors[2] = current_colors.color_regs_aga[sbasecol + 2] & 0xffffff; + sprite_0_colors[3] = current_colors.color_regs_aga[sbasecol + 3] & 0xffffff; } else { - sprite_0_colors[1] = xcolors[current_colors.color_regs_ecs[17]]; - sprite_0_colors[2] = xcolors[current_colors.color_regs_ecs[18]]; - sprite_0_colors[3] = xcolors[current_colors.color_regs_ecs[19]]; + sprite_0_colors[1] = xcolors[current_colors.color_regs_ecs[17] & 0xfff]; + sprite_0_colors[2] = xcolors[current_colors.color_regs_ecs[18] & 0xfff]; + sprite_0_colors[3] = xcolors[current_colors.color_regs_ecs[19] & 0xfff]; } sprite_0_width = sprite_width; if (currprefs.input_tablet && (currprefs.input_mouse_untrap & MOUSEUNTRAP_MAGIC)) { @@ -16066,10 +16055,11 @@ uae_u8 *restore_custom_agacolors(uae_u8 *src) #ifdef AGA uae_u32 v = RL; color_regs_genlock[i] = 0; - if (v & 0x80000000) + if (v & 0x80000000) { color_regs_genlock[i] = 1; - v &= 0x80ffffff; - current_colors.color_regs_aga[i] = v; + } + v &= 0xffffff; + current_colors.color_regs_aga[i] = v | (color_regs_genlock[i] ? COLOR_CHANGE_GENLOCK : 0); #else RL; #endif @@ -16097,7 +16087,7 @@ uae_u8 *save_custom_agacolors(size_t *len, uae_u8 *dstptr) dstbak = dst = xmalloc (uae_u8, 256 * 4); for (int i = 0; i < 256; i++) #ifdef AGA - SL (current_colors.color_regs_aga[i] | (color_regs_genlock[i] ? 0x80000000 : 0)); + SL ((current_colors.color_regs_aga[i] & 0xffffff) | (color_regs_genlock[i] ? 0x80000000 : 0)); #else SL (0); #endif diff --git a/drawing.cpp b/drawing.cpp index 3413f939..7c24c4fd 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -1500,7 +1500,7 @@ static bool get_genlock_very_rare_and_complex_case(uae_u8 v) } else { // color key match? if (aga_mode) { - if (colors_for_drawing.color_regs_aga[v] & 0x80000000) + if (colors_for_drawing.color_regs_aga[v] & COLOR_CHANGE_GENLOCK) return false; } else { if (colors_for_drawing.color_regs_ecs[v] & 0x8000) diff --git a/include/drawing.h b/include/drawing.h index b0e9823c..b9a209d4 100644 --- a/include/drawing.h +++ b/include/drawing.h @@ -183,7 +183,7 @@ STATIC_INLINE xcolnr getxcolor(int c) return CONVERT_RGB(c); else #endif - return xcolors[c]; + return xcolors[c & 0xfff]; } /* functions for reading, writing, copying and comparing struct color_entry */ @@ -246,6 +246,7 @@ STATIC_INLINE void color_reg_cpy (struct color_entry *dst, struct color_entry *s #define COLOR_CHANGE_BLANK 0x20000000 #define COLOR_CHANGE_ACTBORDER (COLOR_CHANGE_BLANK | COLOR_CHANGE_BRDBLANK) #define COLOR_CHANGE_MASK 0xf0000000 +#define COLOR_CHANGE_GENLOCK 0x01000000 struct color_change { int linepos; int regno;