--- uae/src/drawing.c 2018/04/24 16:46:14 1.1.1.4 +++ uae/src/drawing.c 2018/04/24 16:47:27 1.1.1.5 @@ -95,9 +95,9 @@ typedef void (*line_draw_func)(int, int) #define LINE_REMEMBERED_AS_PREVIOUS 9 static char *line_drawn; -static char linestate[(maxvpos + 1)*2 + 1]; +static char linestate[(MAXVPOS + 1)*2 + 1]; -uae_u8 line_data[(maxvpos+1) * 2][MAX_PLANES * MAX_WORDS_PER_LINE * 2]; +uae_u8 line_data[(MAXVPOS + 1) * 2][MAX_PLANES * MAX_WORDS_PER_LINE * 2]; static int min_diwstart, max_diwstop, prev_x_adjust, linetoscr_x_adjust, linetoscr_right_x; static int linetoscr_x_adjust_bytes; @@ -113,7 +113,7 @@ static int first_block_line, last_block_ /* These are generated by the drawing code from the line_decisions array for * each line that needs to be drawn. */ -static int bplehb, bplham, bpldualpf, bpldualpfpri, bplplanecnt, bplhires; +static int bplehb, bplham, bpldualpf, bpldualpfpri, bplplanecnt, bplres; static int bpldelay1, bpldelay2; static int plfpri[3]; @@ -130,7 +130,7 @@ static int picasso_redraw_necessary; static __inline__ void count_frame (void) { framecnt++; - if (framecnt >= currprefs.framerate) + if (framecnt >= currprefs.gfx_framerate) framecnt = 0; } @@ -693,7 +693,6 @@ static int linetoscr_diw_end, linetoscr_ * it must possibly be cleared here. */ static void pfield_init_linetoscr (void) { - int ddf_left, ddf_right; int mindelay = bpldelay1, maxdelay = bpldelay2; if (bpldelay1 > bpldelay2) maxdelay = bpldelay1, mindelay = bpldelay2; @@ -704,13 +703,15 @@ static void pfield_init_linetoscr (void) /* We should really look at DDF also when calculating max_diwstop/min_diwstrt, * so that centering works better, but I'm afraid that might cost too many * cycles. Plus it's dangerous, see the code below that handles the case - * with sprites. */ - if (dip_for_drawing->nr_sprites == 0) { - int hiresadjust = bplhires ? 4 : 8; - ddf_left = (((dp_for_drawing->plfstrt + hiresadjust)*2 - + mindelay - DISPLAY_LEFT_SHIFT) << lores_shift); - ddf_right = (((dp_for_drawing->plfstrt + dp_for_drawing->plflinelen + hiresadjust)*2 - + maxdelay - DISPLAY_LEFT_SHIFT) << lores_shift); + * with sprites. + * The fuzzy_memset_le32 code won't work for AGA, so skip this part here. + */ + if (dip_for_drawing->nr_sprites == 0 || (currprefs.chipset_mask & CSMASK_AGA)) { + int hiresadjust = RES_ADJUST (bplres); + int ddf_left = (((dp_for_drawing->plfstrt + hiresadjust)*2 + + mindelay - DISPLAY_LEFT_SHIFT) << lores_shift); + int ddf_right = (((dp_for_drawing->plfstrt + dp_for_drawing->plflinelen + hiresadjust)*2 + + maxdelay - DISPLAY_LEFT_SHIFT) << lores_shift); if (linetoscr_diw_start < ddf_left) linetoscr_diw_start = ddf_left; @@ -734,12 +735,16 @@ static void pfield_init_linetoscr (void) } } } else { - int hiresadjust = bplhires ? 4 : 8; + /* Conservative case. */ + int hiresadjust = RES_ADJUST (bplres); /* We swap mindelay and maxdelay here to get rid of the mindelay != maxdelay check. * Since we have to do a memset anyway (because there may be sprites), * we might as well clear all at once. */ - ddf_left = ((dp_for_drawing->plfstrt + hiresadjust)*2 + maxdelay - DISPLAY_LEFT_SHIFT) << lores_shift; - ddf_right = ((dp_for_drawing->plfstrt + dp_for_drawing->plflinelen + hiresadjust)*2 + mindelay - DISPLAY_LEFT_SHIFT) << lores_shift; + int ddf_left = ((dp_for_drawing->plfstrt + hiresadjust)*2 + + maxdelay - DISPLAY_LEFT_SHIFT) << lores_shift; + int ddf_right = ((dp_for_drawing->plfstrt + dp_for_drawing->plflinelen + hiresadjust)*2 + + mindelay - DISPLAY_LEFT_SHIFT) << lores_shift; + if (linetoscr_diw_start < ddf_left) { int strt = linetoscr_diw_start; int stop = ddf_left; @@ -1166,7 +1171,7 @@ static void pfield_doline_unaligned_h (i { int xpos = dp_for_drawing->plfstrt * 4 - DISPLAY_LEFT_SHIFT * 2; - if (bplhires) { + if (bplres == RES_HIRES) { int xpos1 = xpos + 16 + bpldelay1*2; int xpos2; uae_u8 *dataptr = line_data[lineno]; @@ -1245,7 +1250,7 @@ static void pfield_doline_unaligned_l (i { int xpos = dp_for_drawing->plfstrt * 2 - DISPLAY_LEFT_SHIFT; - if (bplhires) { + if (bplres == RES_HIRES) { int xpos1 = xpos + 8 + bpldelay1; int xpos2; uae_u8 *dataptr = line_data[lineno]; @@ -1438,7 +1443,7 @@ static void pfield_doline_aligned_h (int { int xpos = dp_for_drawing->plfstrt * 4 - DISPLAY_LEFT_SHIFT * 2; - if (bplhires) { + if (bplres == RES_HIRES) { if (bplplanecnt > 0) { int xpos1 = xpos + 16 + (bpldelay1 >= 8 ? 16 : 0); int xpos2 = xpos + 16 + (bpldelay2 >= 8 ? 16 : 0); @@ -1481,7 +1486,7 @@ static void pfield_doline_aligned_h (int } #endif } else { - memset(pixdata.apixels, 0, sizeof(pixdata.apixels)); + memset (pixdata.apixels, 0, sizeof(pixdata.apixels)); } } else { if (bplplanecnt > 0) { @@ -1523,7 +1528,7 @@ static void pfield_doline_aligned_h (int } #endif } else { - memset(pixdata.apixels, 0, sizeof(pixdata.apixels)); + memset (pixdata.apixels, 0, sizeof(pixdata.apixels)); } } } @@ -1532,7 +1537,7 @@ static void pfield_doline_aligned_l (int { int xpos = dp_for_drawing->plfstrt * 2 - DISPLAY_LEFT_SHIFT; - if (bplhires) { + if (bplres == RES_HIRES) { if (bplplanecnt > 0) { int xpos1 = xpos + 8 + (bpldelay1 >= 8 ? 8 : 0); int xpos2 = xpos + 8 + (bpldelay2 >= 8 ? 8 : 0); @@ -1642,8 +1647,8 @@ static void pfield_adjust_delay (void) int startpos = i == dip_for_drawing->last_delay_change - 1 ? ddf_right + 8 : delay_changes[i+1].linepos; int stoppos = i < dip_for_drawing->first_delay_change ? ddf_left : delay_changes[i].linepos; int j; - startpos = PIXEL_XPOS (startpos + (bplhires ? 4 : 8)); - stoppos = PIXEL_XPOS (stoppos + (bplhires ? 4 : 8)); + startpos = PIXEL_XPOS (startpos + RES_ADJUST (bplres)); + stoppos = PIXEL_XPOS (stoppos + RES_ADJUST (bplres)); if (currprefs.gfx_lores == 0) delay1 <<= 1, delay2 <<= 1; else if (currprefs.gfx_lores == 2) @@ -1676,7 +1681,7 @@ static void init_aspect_maps (void) free (amiga2aspect_line_map); /* At least for this array the +1 is necessary. */ - amiga2aspect_line_map = (int *)malloc (sizeof (int) * (maxvpos+1)*2 + 1); + amiga2aspect_line_map = (int *)malloc (sizeof (int) * (MAXVPOS + 1)*2 + 1); native2amiga_line_map = (int *)malloc (sizeof (int) * gfxvidinfo.height); if (currprefs.gfx_correct_aspect) @@ -1687,7 +1692,7 @@ static void init_aspect_maps (void) else native_lines_per_amiga_line = 1; - maxl = (maxvpos+1) * (currprefs.gfx_linedbl ? 2 : 1); + maxl = (MAXVPOS + 1) * (currprefs.gfx_linedbl ? 2 : 1); min_ypos_for_screen = minfirstline << (currprefs.gfx_linedbl ? 1 : 0); max_drawn_amiga_line = -1; for (i = 0; i < maxl; i++) { @@ -1702,6 +1707,7 @@ static void init_aspect_maps (void) max_drawn_amiga_line >>= 1; if (currprefs.gfx_ycenter && !(currprefs.gfx_correct_aspect)) { + /* @@@ verify maxvpos vs. MAXVPOS */ extra_y_adjust = (gfxvidinfo.height - (maxvpos << (currprefs.gfx_linedbl ? 1 : 0))) >> 1; if (extra_y_adjust < 0) extra_y_adjust = 0; @@ -1879,7 +1885,11 @@ static __inline__ void do_color_changes * form. */ static void pfield_expand_dp_bplcon (void) { - bplhires = (dp_for_drawing->bplcon0 & 0x8000) == 0x8000; + bplres = RES_LORES; + if (dp_for_drawing->bplcon0 & 0x8000) + bplres = RES_HIRES; + if (dp_for_drawing->bplcon0 & 0x40) + bplres = RES_SUPERHIRES; bplplanecnt = GET_PLANES (dp_for_drawing->bplcon0); bplham = (dp_for_drawing->bplcon0 & 0x800) == 0x800; #if AGA_CHIPSET == 1 /* The KILLEHB bit exists in ECS, but is apparently meant for Genlock @@ -1973,7 +1983,7 @@ static __inline__ void pfield_draw_line pfield_expand_dp_bplcon (); #ifdef LORES_HACK - if (gfxvidinfo.can_double && !bplhires && !currprefs.gfx_lores + if (gfxvidinfo.can_double && bplres == RES_LORES && !currprefs.gfx_lores && dip_for_drawing->nr_color_changes == 0 && !bplham) currprefs.gfx_lores = 2; #endif