Skip to content

Commit

Permalink
enhancement: Fix AGA genlock transparency bit being detected as speci…
Browse files Browse the repository at this point in the history
…al blanking bits

(merged from WinUAE)
  • Loading branch information
midwan committed May 16, 2024
1 parent 4cbb92d commit d42fec3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 31 deletions.
48 changes: 19 additions & 29 deletions src/custom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -936,16 +936,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
Expand Down Expand Up @@ -10296,7 +10292,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
Expand Down Expand Up @@ -10341,14 +10336,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();
}

Expand All @@ -10362,17 +10354,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();
}

Expand Down Expand Up @@ -11535,13 +11524,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)) {
Expand Down Expand Up @@ -16080,10 +16069,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
Expand Down Expand Up @@ -16111,7 +16101,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
Expand Down
2 changes: 1 addition & 1 deletion src/drawing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1524,7 +1524,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)
Expand Down
3 changes: 2 additions & 1 deletion src/include/drawing.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit d42fec3

Please sign in to comment.