]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
ECS blanking, copper, sprite collision updates/fixes.
authorToni Wilen <twilen@winuae.net>
Sat, 29 Jan 2022 18:48:01 +0000 (20:48 +0200)
committerToni Wilen <twilen@winuae.net>
Sat, 29 Jan 2022 18:48:01 +0000 (20:48 +0200)
custom.cpp

index dc85dc4bd15f3669c3eb97dac679f2c098afb623..9a776a6075144cc90c988f37f8cab882f85fd912 100644 (file)
@@ -938,7 +938,7 @@ static void record_color_change2(int hpos, int regno, uae_u32 value)
        }
 
        // HCENTER blanking (ECS Denise only)
-       if (hcenter_v2 && vs_state_on && vpos < maxvpos_display_vsync) {
+       if (hcenter_v2 && vs_state_on && lof_display) {
                int chpos = pos;
                if (!hcenterblank_state && hcenter_v2 < chpos && hcenter_v2 >= last_recorded_diw_hpos) {
                        hcenterblank_state = true;
@@ -953,6 +953,7 @@ static void record_color_change2(int hpos, int regno, uae_u32 value)
                                if (debug_dma) {
                                        record_dma_event(DMA_EVENT_HBS, diw_to_hpos(cc->linepos), vpos);
                                }
+                               thisline_changed = 1;
                        }
                }
                if (hcenterblank_state && hcenter_v2_end < chpos && hcenter_v2_end >= last_recorded_diw_hpos) {
@@ -968,6 +969,7 @@ static void record_color_change2(int hpos, int regno, uae_u32 value)
                                if (debug_dma) {
                                        record_dma_event(DMA_EVENT_HBE, diw_to_hpos(cc->linepos), vpos);
                                }
+                               thisline_changed = 1;
                        }
                }
        }
@@ -3981,7 +3983,7 @@ static void do_playfield_collisions(void)
        if (minpos < hw_diwfirst) {
                minpos = hw_diwfirst;
        }
-       maxpos = thisline_decision.plfright * 2- DDF_OFFSET;
+       maxpos = thisline_decision.plfright - DDF_OFFSET;
        if (maxpos > hw_diwlast) {
                maxpos = hw_diwlast;
        }
@@ -4050,12 +4052,14 @@ static void do_sprite_collisions(void)
                hwres_t maxp1 = maxpos >> sprite_buffer_res;
 
                if (maxp1 > hw_diwlast) {
+                       maxp1 = hw_diwlast;
                        maxpos = hw_diwlast << sprite_buffer_res;
                }
-               if (maxp1 > thisline_decision.plfright * 2 - DDF_OFFSET) {
-                       maxpos = (thisline_decision.plfright * 2 - DDF_OFFSET) << sprite_buffer_res;
+               if (maxp1 > thisline_decision.plfright - DDF_OFFSET) {
+                       maxpos = (thisline_decision.plfright - DDF_OFFSET) << sprite_buffer_res;
                }
                if (minp1 < hw_diwfirst) {
+                       minp1 = hw_diwfirst;
                        minpos = hw_diwfirst << sprite_buffer_res;
                }
                if (minp1 < thisline_decision.plfleft - DDF_OFFSET) {
@@ -4782,19 +4786,12 @@ static void reset_decisions_hsync_start(void)
        thisline_decision.bplcon4sp = bplcon4;
        thisline_decision.fmode = fmode;
 
-       // 0 = vb, 1 = vb off, 3 = vb off, previous line was bitplane + vb on
-       //bool t = thisline_decision.plfleft >= 0 && (thisline_decision.vb & 1) == 0 && !vb_state && !vb_end_line;
        if (!aga_mode && ecs_denise && exthblank) {
-               // ECS Denise + EXTHBLANK: VBLANK blanking is different
-               if (new_beamcon0 & BEAMCON0_VARCSYEN) {
-                       // programmed vsync
-                       thisline_decision.vb = vs_state_on ? 0 : VB_NOVB;
-               } else if (new_beamcon0 & BEAMCON0_BLANKEN) {
+               // ECS Denise + EXTBLANK: VBLANK blanking is different
+               thisline_decision.vb = VB_NOVB;
+               if (new_beamcon0 & BEAMCON0_BLANKEN) {
                        // blanking working same as AGA
                        thisline_decision.vb = vb_start_line > 1 + vblank_extraline || vb_end_next_line ? 0 : VB_NOVB;
-               } else {
-                       // hardwired vsync
-                       thisline_decision.vb = vs_state_hw ? 0 : VB_NOVB;
                }
        } else {
                // Visible vblank end is delayed by 1 line
@@ -4833,7 +4830,6 @@ static void reset_decisions_hsync_start(void)
        thisline_decision.bordersprite_seen = issprbrd(-1, bplcon0, bplcon3);
        thisline_decision.xor_seen = (bplcon4 & 0xff00) != 0;
        thisline_decision.nr_planes = toscr_nr_planes_agnus;
-       thisline_decision.max_planes = toscr_nr_planes_agnus;
 
        toscr_nr_planes2 = GET_PLANES(bplcon0d);
        if (isocs7planes()) {
@@ -4844,6 +4840,8 @@ static void reset_decisions_hsync_start(void)
        toscr_nr_planes3 = toscr_nr_planes2;
        toscr_nr_changed = false;
 
+       thisline_decision.max_planes = toscr_nr_planes2 > toscr_nr_planes_agnus ? toscr_nr_planes2 : toscr_nr_planes_agnus;
+
        hpos_hsync_extra = 0;
        int hpos = current_hpos();
        bool normalstart = true;
@@ -5651,6 +5649,9 @@ static void init_hz(bool checkvposw)
                        }
                }
                maxhpos_display *= 2;
+               if (hsstop_detect2 > hsstop_detect + 5) {
+                       hsstop_detect = hsstop_detect2;
+               }
 
        } else {
 
@@ -8701,12 +8702,8 @@ static int coppercomp(int hpos, bool blitwait)
        int hpos_cmp = hpos;
        int vpos_cmp = vpos;
 
-       // Copper comparison can match both odd and even cycles
-       // Important when crossing scanlines.
-       hpos_cmp += 1;
-       if (hpos_cmp >= maxhpos) {
-               hpos_cmp -= maxhpos;
-               vpos_cmp++;
+       if (hpos_cmp == maxhposm1 && maxhposeven == COPPER_CYCLE_POLARITY) {
+               hpos_cmp = 0;
        }
 
        int vp = vpos_cmp & (((cop_state.ir[1] >> 8) & 0x7F) | 0x80);
@@ -8728,10 +8725,14 @@ static int coppercomp(int hpos, bool blitwait)
                }
        }
 
-       if (vp == cop_state.vcmp && hp < cop_state.hcmp) {
-               return 1;
+       if (vp > cop_state.vcmp) {
+               return 0;
        }
-       return 0;
+       if (vp == cop_state.vcmp && hp >= cop_state.hcmp) {
+               return 0;
+       }
+
+       return 1;
 }
 
 static void update_copper(int until_hpos)
@@ -8908,13 +8909,23 @@ static void update_copper(int until_hpos)
                        cop_state.state = COP_skip1;
                        break;
 
-                       // SKIP: Second idle cycle. Check comparison.
+                       // SKIP: Second idle cycle. Do nothing.
                        // Free cycle needed, cycle not allocated.
                case COP_skip1:
+
                        if (copper_cant_read(hpos, 0)) {
                                goto next;
                        }
 
+                       cop_state.state = COP_skip;
+                       break;
+
+                       // Check comparison. SKIP finished. Request IR1.
+               case COP_skip:
+                       if (copper_cant_read(hpos, CYCLE_PIPE_COPPER | 0x005)) {
+                               goto next;
+                       }
+
                        if (!coppercomp(hpos, false)) {
                                cop_state.ignore_next = 1;
 
@@ -8929,14 +8940,6 @@ static void update_copper(int until_hpos)
                                cop_state.ignore_next = -1;
                        }
 
-                       cop_state.state = COP_skip;
-                       break;
-
-                       // SKIP finished. Request IR1.
-               case COP_skip:
-                       if (copper_cant_read(hpos, CYCLE_PIPE_COPPER | 0x005)) {
-                               goto next;
-                       }
                        cop_state.state = COP_read1;
                        break;