--- uae/src/drawing.c 2018/04/24 17:12:34 1.1.1.17 +++ uae/src/drawing.c 2018/04/24 17:16:39 1.1.1.19 @@ -32,7 +32,6 @@ #include #include -#include "config.h" #include "options.h" #include "threaddep/thread.h" #include "uae.h" @@ -447,7 +446,7 @@ STATIC_INLINE void fill_line (void) start = (int *)(((char *)xlinebuffer) + (visible_left_border << shift)); val = colors_for_drawing.acolors[0]; if (gfxvidinfo.pixbytes == 2) - val |= val << 16; + val |= val << 16; for (; nints > 0; nints -= 8, start += 8) { *start = val; *(start+1) = val; @@ -500,10 +499,10 @@ static void pfield_do_linetoscr (int sta case 2: src_pixel = linetoscr_16_shrink1_aga (src_pixel, start, stop); break; case 4: src_pixel = linetoscr_32_shrink1_aga (src_pixel, start, stop); break; } - else + else abort (); } else { - if (res_shift == 0) + if (res_shift == 0) switch (gfxvidinfo.pixbytes) { case 1: src_pixel = linetoscr_8 (src_pixel, start, stop); break; case 2: src_pixel = linetoscr_16 (src_pixel, start, stop); break; @@ -584,7 +583,7 @@ static void init_ham_decoding (void) } } else if (bplplanecnt == 6) { /* AGA mode HAM6 */ while (unpainted_amiga-- > 0) { - int pv = pixdata.apixels[ham_decode_pixel++]; + int pv = pixdata.apixels[ham_decode_pixel++]; switch (pv & 0x30) { case 0x00: ham_lastcolor = colors_for_drawing.color_regs_aga[pv]; break; case 0x10: ham_lastcolor &= 0xFFFF00; ham_lastcolor |= (pv & 0xF) << 4; break; @@ -594,7 +593,7 @@ static void init_ham_decoding (void) } } } else { - if (bplplanecnt == 6) { /* OCS/ECS mode HAM6 */ + if (bplplanecnt == 6) { /* OCS/ECS mode HAM6 */ while (unpainted_amiga-- > 0) { int pv = pixdata.apixels[ham_decode_pixel++]; switch (pv & 0x30) { @@ -647,9 +646,9 @@ static void decode_ham (int pix, int sto } } } else { - if (bplplanecnt == 6) { /* OCS/ECS mode HAM6 */ + if (bplplanecnt == 6) { /* OCS/ECS mode HAM6 */ while (todraw_amiga-- > 0) { - int pv = pixdata.apixels[ham_decode_pixel]; + int pv = pixdata.apixels[ham_decode_pixel]; switch (pv & 0x30) { case 0x00: ham_lastcolor = colors_for_drawing.color_regs_ecs[pv]; break; case 0x10: ham_lastcolor &= 0xFF0; ham_lastcolor |= (pv & 0xF); break; @@ -749,7 +748,7 @@ STATIC_INLINE void draw_sprites_1 (struc /* Shift highest priority sprite pair down to bit zero. */ v >>= offs * 2; v &= 15; - + if (has_attach && (stbuf[pos] & (1 << offs))) { col = v; if (aga) @@ -810,7 +809,7 @@ STATIC_INLINE void draw_sprites_1 (struc window_pos += 1 << doubling; } } - + /* See comments above. Do not touch if you don't know what's going on. * (We do _not_ want the following to be inlined themselves). */ /* lores bitplane, lores sprites */ @@ -1009,16 +1008,16 @@ static void init_aspect_maps (void) 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) + if (curr_gfx->correct_aspect) native_lines_per_amiga_line = ((double)gfxvidinfo.height - * (currprefs.gfx_lores ? 320 : 640) - / (currprefs.gfx_linedbl ? 512 : 256) + * (curr_gfx->lores ? 320 : 640) + / (curr_gfx->linedbl ? 512 : 256) / gfxvidinfo.width); else native_lines_per_amiga_line = 1; - maxl = (MAXVPOS + 1) * (currprefs.gfx_linedbl ? 2 : 1); - min_ypos_for_screen = minfirstline << (currprefs.gfx_linedbl ? 1 : 0); + maxl = (MAXVPOS + 1) * (curr_gfx->linedbl ? 2 : 1); + min_ypos_for_screen = minfirstline << (curr_gfx->linedbl ? 1 : 0); max_drawn_amiga_line = -1; for (i = 0; i < maxl; i++) { int v = (int) ((i - min_ypos_for_screen) * native_lines_per_amiga_line); @@ -1028,12 +1027,12 @@ static void init_aspect_maps (void) v = -1; amiga2aspect_line_map[i] = v; } - if (currprefs.gfx_linedbl) + if (curr_gfx->linedbl) max_drawn_amiga_line >>= 1; - if (currprefs.gfx_ycenter && !(currprefs.gfx_correct_aspect)) { + if (curr_gfx->ycenter && !(curr_gfx->correct_aspect)) { /* @@@ verify maxvpos vs. MAXVPOS */ - extra_y_adjust = (gfxvidinfo.height - (maxvpos << (currprefs.gfx_linedbl ? 1 : 0))) >> 1; + extra_y_adjust = (gfxvidinfo.height - (maxvpos << (curr_gfx->linedbl ? 1 : 0))) >> 1; if (extra_y_adjust < 0) extra_y_adjust = 0; } @@ -1045,7 +1044,7 @@ static void init_aspect_maps (void) /* Must omit drawing some lines. */ for (i = maxl - 1; i > min_ypos_for_screen; i--) { if (amiga2aspect_line_map[i] == amiga2aspect_line_map[i-1]) { - if (currprefs.gfx_linedbl && (i & 1) == 0 && amiga2aspect_line_map[i+1] != -1) { + if (curr_gfx->linedbl && (i & 1) == 0 && amiga2aspect_line_map[i+1] != -1) { /* If only the first line of a line pair would be omitted, * omit the second one instead to avoid problems with line * doubling. */ @@ -1062,7 +1061,7 @@ static void init_aspect_maps (void) if (amiga2aspect_line_map[i] == -1) continue; for (j = amiga2aspect_line_map[i]; j < gfxvidinfo.height && native2amiga_line_map[j] == -1; j++) - native2amiga_line_map[j] = i >> (currprefs.gfx_linedbl ? 1 : 0); + native2amiga_line_map[j] = i >> (curr_gfx->linedbl ? 1 : 0); } } @@ -1131,7 +1130,7 @@ static void adjust_drawing_colors (int c color_match_type = color_match_full; } else { memcpy (colors_for_drawing.acolors, curr_color_tables[ctable].acolors, - sizeof colors_for_drawing.acolors); + sizeof colors_for_drawing.acolors); color_match_type = color_match_acolors; } drawing_color_matches = ctable; @@ -1288,8 +1287,8 @@ STATIC_INLINE void pfield_draw_line (int if (border == 0) { pfield_expand_dp_bplcon (); - if (bplres == RES_LORES && ! currprefs.gfx_lores) - currprefs.gfx_lores = 2; + if (bplres == RES_LORES && ! curr_gfx->lores) + curr_gfx->lores = 2; pfield_init_linetoscr (); pfield_doline (lineno); @@ -1333,8 +1332,8 @@ STATIC_INLINE void pfield_draw_line (int memcpy (row_map[follow_ypos], row_map[gfx_ypos], gfxvidinfo.pixbytes * gfxvidinfo.width); do_flush_line (follow_ypos); } - if (currprefs.gfx_lores == 2) - currprefs.gfx_lores = 0; + if (curr_gfx->lores == 2) + curr_gfx->lores = 0; } else if (border == 1) { adjust_drawing_colors (dp_for_drawing->ctable, 0); @@ -1389,8 +1388,8 @@ static void center_image (void) int prev_x_adjust = visible_left_border; int prev_y_adjust = thisframe_y_adjust; - if (currprefs.gfx_xcenter) { - if (max_diwstop - min_diwstart < gfxvidinfo.width && currprefs.gfx_xcenter == 2) + if (curr_gfx->xcenter) { + if (max_diwstop - min_diwstart < gfxvidinfo.width && curr_gfx->xcenter == 2) /* Try to center. */ visible_left_border = ((max_diwstop - min_diwstart - gfxvidinfo.width) / 2 + min_diwstart) & ~1; else @@ -1398,7 +1397,7 @@ static void center_image (void) /* Would the old value be good enough? If so, leave it as it is if we want to * be clever. */ - if (currprefs.gfx_xcenter == 2) { + if (curr_gfx->xcenter == 2) { if (visible_left_border < prev_x_adjust && prev_x_adjust < min_diwstart) visible_left_border = prev_x_adjust; } @@ -1414,14 +1413,14 @@ static void center_image (void) visible_right_border = max_diwlastword; thisframe_y_adjust = minfirstline; - if (currprefs.gfx_ycenter && thisframe_first_drawn_line != -1) { - if (thisframe_last_drawn_line - thisframe_first_drawn_line < max_drawn_amiga_line && currprefs.gfx_ycenter == 2) + if (curr_gfx->ycenter && thisframe_first_drawn_line != -1) { + if (thisframe_last_drawn_line - thisframe_first_drawn_line < max_drawn_amiga_line && curr_gfx->ycenter == 2) thisframe_y_adjust = (thisframe_last_drawn_line - thisframe_first_drawn_line - max_drawn_amiga_line) / 2 + thisframe_first_drawn_line; else thisframe_y_adjust = thisframe_first_drawn_line; /* Would the old value be good enough? If so, leave it as it is if we want to * be clever. */ - if (currprefs.gfx_ycenter == 2) { + if (curr_gfx->ycenter == 2) { if (thisframe_y_adjust != prev_y_adjust && prev_y_adjust <= thisframe_first_drawn_line && prev_y_adjust + max_drawn_amiga_line > thisframe_last_drawn_line) @@ -1433,13 +1432,13 @@ static void center_image (void) if (thisframe_y_adjust < minfirstline) thisframe_y_adjust = minfirstline; } - thisframe_y_adjust_real = thisframe_y_adjust << (currprefs.gfx_linedbl ? 1 : 0); - max_ypos_thisframe = (maxvpos - thisframe_y_adjust) << (currprefs.gfx_linedbl ? 1 : 0); + thisframe_y_adjust_real = thisframe_y_adjust << (curr_gfx->linedbl ? 1 : 0); + max_ypos_thisframe = (maxvpos - thisframe_y_adjust) << (curr_gfx->linedbl ? 1 : 0); /* @@@ interlace_seen used to be (bplcon0 & 4), but this is probably * better. */ if (prev_x_adjust != visible_left_border || prev_y_adjust != thisframe_y_adjust) - frame_redraw_necessary |= interlace_seen && currprefs.gfx_linedbl ? 2 : 1; + frame_redraw_necessary |= interlace_seen && curr_gfx->linedbl ? 2 : 1; max_diwstop = 0; min_diwstart = 10000; @@ -1456,7 +1455,10 @@ static void init_drawing_frame (void) if (thisframe_first_drawn_line > thisframe_last_drawn_line) thisframe_last_drawn_line = thisframe_first_drawn_line; - maxline = currprefs.gfx_linedbl ? (maxvpos+1) * 2 + 1 : (maxvpos+1) + 1; + if (!curr_gfx) + return; + + maxline = curr_gfx->linedbl ? (maxvpos+1) * 2 + 1 : (maxvpos+1) + 1; #ifdef SMART_UPDATE for (i = 0; i < maxline; i++) { switch (linestate[i]) { @@ -1551,7 +1553,7 @@ static void write_tdnumber (int x, int y { int j; uae_u8 *numptr; - + numptr = numbers + num * TD_NUM_WIDTH + NUMBERS_NUM * TD_NUM_WIDTH * y; for (j = 0; j < TD_NUM_WIDTH; j++) { if (*numptr == 'x') @@ -1567,9 +1569,9 @@ static void draw_status_line (int line) int x_start, y, j, led; if (td_pos & TD_RIGHT) - x_start = gfxvidinfo.width - TD_PADX - 5 * TD_WIDTH; + x_start = gfxvidinfo.width - TD_PADX - 5 * TD_WIDTH; else - x_start = TD_PADX; + x_start = TD_PADX; y = line - (gfxvidinfo.height - TD_TOTAL_HEIGHT); xlinebuffer = gfxvidinfo.linemem; @@ -1590,8 +1592,8 @@ static void draw_status_line (int line) num1 = -1; num2 = track / 10; num3 = track % 10; - on = gui_data.drive_motor[pled]; - if (gui_data.drive_writing[pled]) + on = gui_data.drive_motor[pled]; + if (gui_data.drive_writing[pled]) on_rgb = 0xc00; } /*side = gui_data.drive_side;*/ @@ -1604,7 +1606,7 @@ static void draw_status_line (int line) c = xcolors[on ? on_rgb : off_rgb]; x = x_start + pos * TD_WIDTH; - for (j = 0; j < TD_LED_WIDTH; j++) + for (j = 0; j < TD_LED_WIDTH; j++) putpixel (x + j, c); if (y >= TD_PADY && y - TD_PADY < TD_NUM_HEIGHT) { @@ -1615,7 +1617,7 @@ static void draw_status_line (int line) write_tdnumber (x + offs, y - TD_PADY, num1); offs += TD_NUM_WIDTH; } - write_tdnumber (x + offs, y - TD_PADY, num2); + write_tdnumber (x + offs, y - TD_PADY, num2); write_tdnumber (x + offs + TD_NUM_WIDTH, y - TD_PADY, num3); if (num4 > 0) write_tdnumber (x + offs + 2 * TD_NUM_WIDTH, y - TD_PADY, num4); @@ -1664,7 +1666,6 @@ void finish_drawing_frame (void) do_flush_line (line); } } - do_flush_screen (first_drawn_line, last_drawn_line); } @@ -1732,7 +1733,7 @@ void vsync_handle_redraw (int long_frame savestate_state = 0; } else if (savestate_state == STATE_DORESTORE) { savestate_state = STATE_RESTORE; - uae_reset (); + uae_reset (0); } if (quit_program < 0) { @@ -1750,8 +1751,10 @@ void vsync_handle_redraw (int long_frame check_prefs_changed_custom (); check_prefs_changed_cpu (); if (check_prefs_changed_gfx ()) { - init_row_map (); - init_aspect_maps (); + if (curr_gfx) { + init_row_map (); + init_aspect_maps (); + } notice_screen_contents_lost (); notice_new_xcolors (); } @@ -1814,16 +1817,12 @@ void reset_drawing (void) inhibit_frame = 0; uae_sem_init (&gui_sem, 0, 1); -#ifdef PICASSO96 - InitPicasso96 (); - picasso_on = 0; - picasso_requested_on = 0; - gfx_set_picasso_state (0); -#endif max_diwstop = 0; - lores_factor = currprefs.gfx_lores ? 1 : 2; - lores_shift = currprefs.gfx_lores ? 0 : 1; + if (!curr_gfx) + return; + lores_factor = curr_gfx->lores ? 1 : 2; + lores_shift = curr_gfx->lores ? 0 : 1; /*memset(blitcount, 0, sizeof(blitcount)); blitter debug */ for (i = 0; i < sizeof linestate / sizeof *linestate; i++)