From 1d1fc389fb1251fab795e43fc1d292250ebe3615 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Fri, 13 Oct 2023 20:32:50 +0300 Subject: [PATCH] Non-lace fields/fields+ last line flicker fix. --- custom.cpp | 6 +++++- drawing.cpp | 22 ++++++++++++++++++++-- include/drawing.h | 3 ++- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/custom.cpp b/custom.cpp index d2feaa64..51ca5cd9 100644 --- a/custom.cpp +++ b/custom.cpp @@ -554,6 +554,7 @@ frame_time_t lastframetime; uae_u32 hsync_counter, vsync_counter; frame_time_t idletime; int bogusframe; +static int display_vsync_counter; /* Recording of custom chip register changes. */ static int current_change_set; @@ -11650,7 +11651,7 @@ static int calculate_lineno(int vp) lineno++; } else if (!interlace_seen && doublescan <= 0 && currprefs.gfx_vresolution && currprefs.gfx_pscanlines > 1) { lineno *= 2; - if (vsync_counter & 1) { + if (display_vsync_counter & 1) { lineno++; nextline_how = currprefs.gfx_pscanlines == 3 ? nln_lower_black_always : nln_lower_black; } else { @@ -14251,6 +14252,7 @@ static void hsync_handler(void) } if (vpos == maxvpos_display_vsync) { + hsync_record_line_state_last(next_lineno, nextline_how, 0); inputdevice_read_msg(true); vsync_display_render(); vsync_display_rendered = false; @@ -14258,6 +14260,7 @@ static void hsync_handler(void) hstrobe_conflict = false; minfirstline_linear = minfirstline; reset_autoscale(); + display_vsync_counter++; } vsync_line = vs; hsync_handler_post(vs); @@ -14397,6 +14400,7 @@ void custom_reset(bool hardreset, bool keyboardreset) extra_cycle = 0; hsync_counter = 0; vsync_counter = 0; + display_vsync_counter = 0; currprefs.chipset_mask = changed_prefs.chipset_mask; update_mirrors(); blitter_reset(); diff --git a/drawing.cpp b/drawing.cpp index 0211b8e3..cc25a59f 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -3566,7 +3566,11 @@ static void adjust_drawing_colors (int ctable, int need_full, bool blankcheck) color_reg_cpy (&colors_for_drawing, curr_color_tables + ctable); color_match_type = color_match_full; } else { - memcpy (colors_for_drawing.acolors, curr_color_tables[ctable].acolors, sizeof colors_for_drawing.acolors); + if (aga_mode) { + memcpy(colors_for_drawing.acolors, curr_color_tables[ctable].acolors, sizeof(xcolnr) * 256); + } else { + memcpy(colors_for_drawing.acolors, curr_color_tables[ctable].acolors, sizeof(xcolnr) * 32); + } colors_for_drawing.extra = curr_color_tables[ctable].extra; color_match_type = color_match_acolors; } @@ -5145,7 +5149,21 @@ void vsync_handle_redraw(int long_field, int lof_changed, uae_u16 bplcon0p, uae_ gui_flicker_led (-1, 0, 0); } -void hsync_record_line_state (int lineno, enum nln_how how, int changed) +void hsync_record_line_state_last(int lineno, enum nln_how how, int changed) +{ + uae_u8 *state = linestate + lineno; + + switch (how) { + case nln_upper_black: + case nln_upper_black_always: + case nln_lower_black: + case nln_lower_black_always: + hsync_record_line_state(lineno, how, 0); + break; + } +} + +void hsync_record_line_state(int lineno, enum nln_how how, int changed) { struct amigadisplay *ad = &adisplays[0]; uae_u8 *state; diff --git a/include/drawing.h b/include/drawing.h index 1b0db893..92141065 100644 --- a/include/drawing.h +++ b/include/drawing.h @@ -357,7 +357,8 @@ enum nln_how { nln_lower_black_always }; -extern void hsync_record_line_state (int lineno, enum nln_how, int changed); +extern void hsync_record_line_state(int lineno, enum nln_how, int changed); +extern void hsync_record_line_state_last(int lineno, enum nln_how, int changed); extern void vsync_handle_redraw (int long_field, int lof_changed, uae_u16, uae_u16, bool drawlines, bool initial); extern bool vsync_handle_check (void); extern void draw_lines(int end, int section); -- 2.47.3