From 2ffff44957ae0393f895f5ad30d4888b2682e791 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sun, 6 Nov 2022 18:50:30 +0200 Subject: [PATCH] AGA EHB instant on/off --- custom.cpp | 24 ++++++++++++++++++------ drawing.cpp | 7 ++++++- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/custom.cpp b/custom.cpp index 05e47b76..69e5f429 100644 --- a/custom.cpp +++ b/custom.cpp @@ -948,10 +948,14 @@ static void record_color_change2(int hpos, int regno, uae_u32 value) int pos = hpos < 0 ? -hpos : hpos_to_diwx(hpos); // AGA has extra hires pixel delay in color changes - if ((regno < RECORDED_REGISTER_CHANGE_OFFSET || regno == RECORDED_REGISTER_CHANGE_OFFSET + 0x10c) && aga_mode) { + if ((regno < RECORDED_REGISTER_CHANGE_OFFSET || regno == RECORDED_REGISTER_CHANGE_OFFSET + 0x10c || regno == RECORDED_REGISTER_CHANGE_OFFSET + 0x201) && aga_mode) { if (currprefs.chipset_hr) { pos += 2; } + if (regno == RECORDED_REGISTER_CHANGE_OFFSET + 0x201) { + // EHB delay + pos += 2; + } if (regno == RECORDED_REGISTER_CHANGE_OFFSET + 0x10c) { // BPLCON4: // Bitplane XOR change: 2 hires pixel delay @@ -4645,11 +4649,11 @@ static void record_register_change(int hpos, int regno, uae_u16 value) if (regno == 0x0100 || regno == 0x0101) { // BPLCON0 if (value & 0x800) thisline_decision.ham_seen = 1; - thisline_decision.ehb_seen = isehb(value, bplcon2); + thisline_decision.ehb_seen |= isehb(value, bplcon2); isbrdblank(hpos, value, bplcon3); issprbrd(hpos, value, bplcon3); } else if (regno == 0x104) { // BPLCON2 - thisline_decision.ehb_seen = isehb(bplcon0, value); + thisline_decision.ehb_seen |= isehb(bplcon0, value); } else if (regno == 0x106) { // BPLCON3 isbrdblank(hpos, bplcon0, value); issprbrd(hpos, bplcon0, value); @@ -5616,9 +5620,9 @@ static void reset_decisions_hsync_start(void) thisline_decision.plfleft = -1; thisline_decision.plflinelen = -1; thisline_decision.plfright = -1; - thisline_decision.ham_seen = !!(bplcon0 & 0x800); - thisline_decision.ehb_seen = !!isehb(bplcon0, bplcon2); - thisline_decision.ham_at_start = !!(bplcon0 & 0x800); + thisline_decision.ham_seen = (bplcon0 & 0x800) != 0; + thisline_decision.ehb_seen = isehb(bplcon0, bplcon2); + thisline_decision.ham_at_start = (bplcon0 & 0x800) != 0; thisline_decision.bordersprite_seen = issprbrd(-1, bplcon0, bplcon3); thisline_decision.xor_seen = (bplcon4 & 0xff00) != 0; thisline_decision.nr_planes = toscr_nr_planes_agnus; @@ -8059,6 +8063,14 @@ static void bplcon0_denise_change_early(int hpos, uae_u16 con0) decide_line(hpos); decide_fetch_safe(hpos); + if (aga_mode) { + int e1 = isehb(dcon0, bplcon2); + int e2 = isehb(dcon0o, bplcon2); + if (e1 ^ e2) { + record_register_change(hpos, 0x201, dcon0); + } + } + toscr_nr_planes_shifter_new = np; if (ecs_denise || aga_mode) { toscr_nr_changed = np != toscr_nr_planes3 && res == toscr_res; diff --git a/drawing.cpp b/drawing.cpp index 3e23a02f..702fc3c5 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -256,6 +256,7 @@ static int vblank_top_start, vblank_bottom_stop; static int hblank_left_start, hblank_right_stop; static int hblank_left_start_hard, hblank_right_stop_hard; static bool exthblank, extborder, exthblanken, exthblankon; +static bool ehb_enable; static int linetoscr_x_adjust_pixbytes, linetoscr_x_adjust_pixels; static int thisframe_y_adjust; @@ -3257,7 +3258,7 @@ static void pfield_expand_dp_bplcon(void) bplres = dp_for_drawing->bplres; bplplanecnt = dp_for_drawing->nr_planes; bplham = dp_for_drawing->ham_seen; - bplehb = dp_for_drawing->ehb_seen; + bplehb = dp_for_drawing->ehb_seen && ehb_enable; if (ecs_denise) { // Check for KillEHB bit in ECS/AGA if (dp_for_drawing->bplcon2 & 0x0200) { @@ -3379,6 +3380,9 @@ static void pfield_expand_dp_bplconx (int regno, int v, int hp, int vp) dp_for_drawing->ham_seen = isham(v); extblankcheck(); break; + case 0x201: // AGA EHB immediate change + ehb_enable = (v & 0x7010) == 0x6000; + break; case 0x104: // BPLCON2 dp_for_drawing->bplcon2 = v; break; @@ -5160,6 +5164,7 @@ void reset_drawing(void) exthblankon = false; extborder = false; display_reset = 1; + ehb_enable = true; lores_reset (); -- 2.47.3