--- uae/src/drawing.c 2018/04/24 16:43:30 1.1.1.2 +++ uae/src/drawing.c 2018/04/24 16:50:06 1.1.1.7 @@ -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]; @@ -127,10 +127,10 @@ int framecnt = 0; static int frame_redraw_necessary; static int picasso_redraw_necessary; -static __inline__ void count_frame (void) +STATIC_INLINE void count_frame (void) { framecnt++; - if (framecnt >= currprefs.framerate) + if (framecnt >= currprefs.gfx_framerate) framecnt = 0; } @@ -459,7 +459,7 @@ static void fill_line_24 (char *buf, int } #endif -static __inline__ void fill_line_full (void) +STATIC_INLINE void fill_line_full (void) { switch (gfxvidinfo.pixbytes) { case 1: fill_line_8 (xlinebuffer, linetoscr_x_adjust, linetoscr_x_adjust + gfxvidinfo.width); break; @@ -483,7 +483,7 @@ static __inline__ void fill_line_full (v #if 1 #undef fill_line -static __inline__ void fill_line (void) +STATIC_INLINE void fill_line (void) { int shift; int nints, nrem; @@ -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,11 +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; @@ -732,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; @@ -1012,7 +1019,7 @@ static uae_u32 do_sprite_collisions (str return datab; } -static __inline__ void render_sprite (int spr, int sprxp, uae_u32 datab, int ham, int attch, int sprx_inc) +STATIC_INLINE void render_sprite (int spr, int sprxp, uae_u32 datab, int ham, int attch, int sprx_inc) { uae_u32 datcd; int basecol = 16; @@ -1164,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]; @@ -1243,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]; @@ -1324,7 +1331,7 @@ static void pfield_doline_unaligned_l (i #else /* not UNALIGNED_PROFITABLE */ -static __inline__ void pfield_orword_hires_h(int data, unsigned char *dp, int bit) +STATIC_INLINE void pfield_orword_hires_h(int data, unsigned char *dp, int bit) { uae_u32 *pixptr = (uae_u32 *)dp; @@ -1334,7 +1341,7 @@ static __inline__ void pfield_orword_hir *(pixptr+3) |= hirestab_h[data & 255][1] << bit; } -static __inline__ void pfield_orword_lores_h(int data, unsigned char *dp, int bit) +STATIC_INLINE void pfield_orword_lores_h(int data, unsigned char *dp, int bit) { uae_u32 *pixptr = (uae_u32 *)dp; @@ -1348,7 +1355,7 @@ static __inline__ void pfield_orword_lor *(pixptr+7) |= lorestab_h[data & 255][3] << bit; } -static __inline__ void pfield_setword_hires_h(int data, unsigned char *dp, int bit) +STATIC_INLINE void pfield_setword_hires_h(int data, unsigned char *dp, int bit) { uae_u32 *pixptr = (uae_u32 *)dp; @@ -1358,7 +1365,7 @@ static __inline__ void pfield_setword_hi *(pixptr+3) = hirestab_h[data & 255][1] << bit; } -static __inline__ void pfield_setword_lores_h(int data, unsigned char *dp, int bit) +STATIC_INLINE void pfield_setword_lores_h(int data, unsigned char *dp, int bit) { uae_u32 *pixptr = (uae_u32 *)dp; @@ -1372,7 +1379,7 @@ static __inline__ void pfield_setword_lo *(pixptr+7) = lorestab_h[data & 255][3] << bit; } -static __inline__ void pfield_orword_hires_l(int data, unsigned char *dp, int bit) +STATIC_INLINE void pfield_orword_hires_l(int data, unsigned char *dp, int bit) { uae_u32 *pixptr = (uae_u32 *)dp; @@ -1380,7 +1387,7 @@ static __inline__ void pfield_orword_hir *(pixptr+1) |= hirestab_l[data & 255][0] << bit; } -static __inline__ void pfield_orword_lores_l(int data, unsigned char *dp, int bit) +STATIC_INLINE void pfield_orword_lores_l(int data, unsigned char *dp, int bit) { uae_u32 *pixptr = (uae_u32 *)dp; @@ -1390,7 +1397,7 @@ static __inline__ void pfield_orword_lor *(pixptr+3) |= lorestab_l[data & 255][1] << bit; } -static __inline__ void pfield_setword_hires_l(int data, unsigned char *dp, int bit) +STATIC_INLINE void pfield_setword_hires_l(int data, unsigned char *dp, int bit) { uae_u32 *pixptr = (uae_u32 *)dp; @@ -1398,7 +1405,7 @@ static __inline__ void pfield_setword_hi *(pixptr+1) = hirestab_l[data & 255][0] << bit; } -static __inline__ void pfield_setword_lores_l(int data, unsigned char *dp, int bit) +STATIC_INLINE void pfield_setword_lores_l(int data, unsigned char *dp, int bit) { uae_u32 *pixptr = (uae_u32 *)dp; @@ -1436,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); @@ -1479,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) { @@ -1521,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)); } } } @@ -1530,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); @@ -1640,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) @@ -1674,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) @@ -1685,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++) { @@ -1700,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; @@ -1760,7 +1768,7 @@ static void do_flush_line_1 (int lineno) } } -static __inline__ void do_flush_line (int lineno) +STATIC_INLINE void do_flush_line (int lineno) { /* We don't want to call X libraries from the second thread right now. */ #ifndef SUPPORT_PENGUINS @@ -1776,7 +1784,7 @@ static __inline__ void do_flush_line (in * systems. */ -static __inline__ void do_flush_screen (int start, int stop) +STATIC_INLINE void do_flush_screen (int start, int stop) { #ifdef SUPPORT_PENGUINS int i; @@ -1785,6 +1793,11 @@ static __inline__ void do_flush_screen ( do_flush_line_1 (i); } #endif + + /* TODO: this flush operation is executed outside locked state! + Should be corrected. + (sjo 26.9.99) */ + if (gfxvidinfo.maxblocklines != 0 && first_block_line != -2) { flush_block (first_block_line, last_block_line); } @@ -1792,7 +1805,7 @@ static __inline__ void do_flush_screen ( flush_screen (start, stop); } -static __inline__ void finish_line_aga (void) +STATIC_INLINE void finish_line_aga (void) { #if AGA_CHIPSET != 0 aga_lbufptr = aga_linebuf; @@ -1831,7 +1844,7 @@ static void adjust_drawing_colors (int c #endif } -static __inline__ void adjust_color0_for_color_change (void) +STATIC_INLINE void adjust_color0_for_color_change (void) { drawing_color_matches = -1; if (dp_for_drawing->color0 != 0xFFFFFFFFul) { @@ -1842,12 +1855,9 @@ static __inline__ void adjust_color0_for } } -/* Fetched data spends 9 lores pixels somewhere in the chips before it appears - * on-screen. We don't emulate this. Instead, we cheat with the copper to - * compensate (much easier that way). */ -#define COPPER_MAGIC_FUDGE -9 +#define COPPER_MAGIC_FUDGE -1 -static __inline__ void do_color_changes (line_draw_func worker) +STATIC_INLINE void do_color_changes (line_draw_func worker) { int lastpos = 0, nextpos, i; struct color_change *cc = curr_color_changes + dip_for_drawing->first_color_change; @@ -1877,8 +1887,12 @@ static __inline__ void do_color_changes * form. */ static void pfield_expand_dp_bplcon (void) { - bplhires = (dp_for_drawing->bplcon0 & 0x8000) == 0x8000; - bplplanecnt = (dp_for_drawing->bplcon0 & 0x7000) >> 12; + 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 * stuff, and it's set by some demos (e.g. Andromeda Seven Seas) */ @@ -1900,7 +1914,7 @@ enum double_how { dh_emerg }; -static __inline__ void pfield_draw_line (int lineno, int gfx_ypos, int follow_ypos) +STATIC_INLINE void pfield_draw_line (int lineno, int gfx_ypos, int follow_ypos) { int border = 0; int do_double = 0; @@ -1971,7 +1985,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 @@ -2368,7 +2382,7 @@ void hardware_line_completed (int lineno #endif } -static __inline__ void check_picasso (void) +STATIC_INLINE void check_picasso (void) { #ifdef PICASSO96 if (picasso_on && picasso_redraw_necessary) @@ -2381,9 +2395,9 @@ static __inline__ void check_picasso (vo picasso_on = picasso_requested_on; if (!picasso_on) - clear_inhibit_frame (2); + clear_inhibit_frame (IHF_PICASSO); else - set_inhibit_frame (2); + set_inhibit_frame (IHF_PICASSO); gfx_set_picasso_state (picasso_on); picasso_enablescreen (picasso_requested_on); @@ -2411,7 +2425,7 @@ void vsync_handle_redraw (int long_frame if (quit_program < 0) { quit_program = -quit_program; - set_inhibit_frame (1); + set_inhibit_frame (IHF_QUIT_PROGRAM); regs.spcflags |= SPCFLAG_BRK; filesys_prepare_reset (); #ifdef SUPPORT_PENGUINS