]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Sprite buffer checks
authorToni Wilen <twilen@winuae.net>
Fri, 26 May 2023 18:30:41 +0000 (21:30 +0300)
committerToni Wilen <twilen@winuae.net>
Fri, 26 May 2023 18:30:41 +0000 (21:30 +0300)
custom.cpp

index fa8a8fb7bbabdec21b29bf8dae6cc29a90b2ad35..0731d44fb0ec29967e3a3d71c3f04d470a6aed11 100644 (file)
@@ -551,7 +551,8 @@ int bogusframe;
 
 /* Recording of custom chip register changes.  */
 static int current_change_set;
-static struct sprite_entry sprite_entries[2][MAX_SPR_PIXELS / 32];
+#define MAX_SPRITE_ENTRIES ((MAXVPOS + MAXVPOS_WRAPLINES) * 16)
+static struct sprite_entry sprite_entries[2][MAX_SPRITE_ENTRIES];
 static struct color_change color_changes[2][MAX_REG_CHANGE];
 
 struct decision line_decisions[2 * (MAXVPOS + MAXVPOS_WRAPLINES) + 1];
@@ -559,7 +560,7 @@ static struct draw_info line_drawinfo[2][2 * (MAXVPOS + MAXVPOS_WRAPLINES) + 1];
 #define COLOR_TABLE_SIZE (MAXVPOS + MAXVPOS_WRAPLINES) * 2
 static struct color_entry color_tables[2][COLOR_TABLE_SIZE];
 
-static int next_sprite_entry = 0, last_sprite_entry = 0, end_sprite_entry;
+static int next_sprite_entry = 0, end_sprite_entry;
 static int prev_next_sprite_entry;
 static int next_sprite_forced = 1;
 static int spixels_max;
@@ -5588,7 +5589,7 @@ static void record_sprite(int num, int sprxp, uae_u16 *data, uae_u16 *datb, unsi
 
        /* Try to coalesce entries if they aren't too far apart  */
        /* Don't coelesce 64-bit wide sprites, needed to support FMODE change tricks */
-       if (!next_sprite_forced && e[-1].max + spr_width >= sprxp) {
+       if (next_sprite_entry > 0 && !next_sprite_forced && e[-1].max + spr_width >= sprxp) {
                e--;
        } else {
                next_sprite_entry++;
@@ -11510,17 +11511,17 @@ void init_hardware_for_drawing_frame(void)
                int first_pixel = prev_sprite_entries[0].first_pixel;
                int npixels = prev_sprite_entries[prev_next_sprite_entry].first_pixel - first_pixel;
                if (npixels > 0) {
-                       memset(spixels + first_pixel, 0, npixels * sizeof * spixels);
-                       memset(spixstate.stb + first_pixel, 0, npixels * sizeof * spixstate.stb);
+                       memset(spixels + first_pixel, 0, npixels * sizeof *spixels);
+                       memset(spixstate.stb + first_pixel, 0, npixels * sizeof *spixstate.stb);
                        if (aga_mode) {
-                               memset(spixstate.stbfm + first_pixel, 0, npixels * sizeof * spixstate.stbfm);
+                               memset(spixstate.stbfm + first_pixel, 0, npixels * sizeof *spixstate.stbfm);
                        }
                }
        }
+
        prev_next_sprite_entry = next_sprite_entry;
        next_sprite_entry = 0;
-       last_sprite_entry = MAX_SPR_PIXELS - 1;
-       end_sprite_entry = MAX_SPR_PIXELS - 2;
+       end_sprite_entry = MAX_SPRITE_ENTRIES - 2;
        spixels_max = sizeof(spixels) / sizeof(*spixels) - MAX_PIXELS_PER_LINE;
 
        next_lineno = calculate_lineno(vpos);