--- uae/src/drawing.c 2018/04/24 17:16:39 1.1.1.19 +++ uae/src/drawing.c 2018/04/24 17:18:28 1.1.1.20 @@ -148,17 +148,19 @@ static int last_redraw_point; static int first_drawn_line, last_drawn_line; static int first_block_line, last_block_line; +#define NO_BLOCK -3 + /* These are generated by the drawing code from the line_decisions array for each line that needs to be drawn. These are basically extracted out of bit fields in the hardware registers. */ -static int bplehb, bplham, bpldualpf, bpldualpfpri, bpldualpf2of, bplplanecnt, bplres; +static int bplehb, bplham, bpldualpf, bpldualpfpri, bpldualpf2of, bplplanecnt; +static int bplres, adjusted_bplres; static uae_u32 plf_sprite_mask; static int sbasecol[2]; int picasso_requested_on; int picasso_on; -uae_sem_t gui_sem; int inhibit_frame; int framecnt = 0; @@ -487,13 +489,13 @@ static void pfield_do_linetoscr (int sta case 2: src_pixel = linetoscr_16_aga (src_pixel, start, stop); break; case 4: src_pixel = linetoscr_32_aga (src_pixel, start, stop); break; } - else if (res_shift == 1) + else if (res_shift > 0) switch (gfxvidinfo.pixbytes) { case 1: src_pixel = linetoscr_8_stretch1_aga (src_pixel, start, stop); break; case 2: src_pixel = linetoscr_16_stretch1_aga (src_pixel, start, stop); break; case 4: src_pixel = linetoscr_32_stretch1_aga (src_pixel, start, stop); break; } - else if (res_shift == -1) + else if (res_shift < 0) switch (gfxvidinfo.pixbytes) { case 1: src_pixel = linetoscr_8_shrink1_aga (src_pixel, start, stop); break; case 2: src_pixel = linetoscr_16_shrink1_aga (src_pixel, start, stop); break; @@ -955,7 +957,7 @@ static void NOINLINE pfield_doline_n8 (u static void pfield_doline (int lineno) { int wordcount = dp_for_drawing->plflinelen; - uae_u32 *data = pixdata.apixels_l + MAX_PIXELS_PER_LINE/4; + uae_u32 *data = pixdata.apixels_l + MAX_PIXELS_PER_LINE / 4; #ifdef SMART_UPDATE #define DATA_POINTER(n) (line_data[lineno] + (n)*MAX_WORDS_PER_LINE*2) @@ -1080,14 +1082,14 @@ static void do_flush_line_1 (int lineno) flush_line (lineno); else { if ((last_block_line+1) != lineno) { - if (first_block_line != -2) + if (first_block_line != NO_BLOCK) flush_block (first_block_line, last_block_line); first_block_line = lineno; } last_block_line = lineno; if (last_block_line - first_block_line >= gfxvidinfo.maxblocklines) { flush_block (first_block_line, last_block_line); - first_block_line = last_block_line = -2; + first_block_line = last_block_line = NO_BLOCK; } } } @@ -1109,7 +1111,7 @@ STATIC_INLINE void do_flush_screen (int Should be corrected. (sjo 26.9.99) */ - if (gfxvidinfo.maxblocklines != 0 && first_block_line != -2) { + if (gfxvidinfo.maxblocklines != 0 && first_block_line != NO_BLOCK) { flush_block (first_block_line, last_block_line); } unlockscr (); @@ -1117,6 +1119,34 @@ STATIC_INLINE void do_flush_screen (int flush_screen (start, stop); } +/* We only save hardware registers during the hardware frame. Now, when + * drawing the frame, we expand the data into a slightly more useful + * form. */ +static void pfield_expand_dp_bplcon (void) +{ + int plf1pri, plf2pri; + bplres = dp_for_drawing->bplres; + bplplanecnt = dp_for_drawing->nr_planes; + bplham = dp_for_drawing->ham_at_start; + + if (currprefs.chipset_mask & CSMASK_AGA) { + /* 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) */ + bplehb = ((dp_for_drawing->bplcon0 & 0xFCC0) == 0x6000 && !(dp_for_drawing->bplcon2 & 0x200)); + } else { + bplehb = (dp_for_drawing->bplcon0 & 0xFC00) == 0x6000; + } + plf1pri = dp_for_drawing->bplcon2 & 7; + plf2pri = (dp_for_drawing->bplcon2 >> 3) & 7; + plf_sprite_mask = 0xFFFF0000 << (4 * plf2pri); + plf_sprite_mask |= (0xFFFF << (4 * plf1pri)) & 0xFFFF; + bpldualpf = (dp_for_drawing->bplcon0 & 0x400) == 0x400; + bpldualpfpri = (dp_for_drawing->bplcon2 & 0x40) == 0x40; + bpldualpf2of = (dp_for_drawing->bplcon3 >> 10) & 7; + sbasecol[0] = ((dp_for_drawing->bplcon4 >> 4) & 15) << 4; + sbasecol[1] = ((dp_for_drawing->bplcon4 >> 0) & 15) << 4; +} + static int drawing_color_matches; static enum { color_match_acolors, color_match_full } color_match_type; @@ -1190,34 +1220,6 @@ STATIC_INLINE void do_color_changes (lin } } -/* We only save hardware registers during the hardware frame. Now, when - * drawing the frame, we expand the data into a slightly more useful - * form. */ -static void pfield_expand_dp_bplcon (void) -{ - int plf1pri, plf2pri; - bplres = dp_for_drawing->bplres; - bplplanecnt = dp_for_drawing->nr_planes; - bplham = dp_for_drawing->ham_at_start; - - if (currprefs.chipset_mask & CSMASK_AGA) { - /* 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) */ - bplehb = ((dp_for_drawing->bplcon0 & 0xFCC0) == 0x6000 && !(dp_for_drawing->bplcon2 & 0x200)); - } else { - bplehb = (dp_for_drawing->bplcon0 & 0xFC00) == 0x6000; - } - plf1pri = dp_for_drawing->bplcon2 & 7; - plf2pri = (dp_for_drawing->bplcon2 >> 3) & 7; - plf_sprite_mask = 0xFFFF0000 << (4 * plf2pri); - plf_sprite_mask |= (0xFFFF << (4 * plf1pri)) & 0xFFFF; - bpldualpf = (dp_for_drawing->bplcon0 & 0x400) == 0x400; - bpldualpfpri = (dp_for_drawing->bplcon2 & 0x40) == 0x40; - bpldualpf2of = (dp_for_drawing->bplcon3 >> 10) & 7; - sbasecol[0] = ((dp_for_drawing->bplcon4 >> 4) & 15) << 4; - sbasecol[1] = ((dp_for_drawing->bplcon4 >> 0) & 15) << 4; -} - enum double_how { dh_buf, dh_line, @@ -1478,7 +1480,7 @@ static void init_drawing_frame (void) last_drawn_line = 0; first_drawn_line = 32767; - first_block_line = last_block_line = -2; + first_block_line = last_block_line = NO_BLOCK; if (currprefs.test_drawing_speed) frame_redraw_necessary = 1; else if (frame_redraw_necessary) @@ -1512,22 +1514,23 @@ static int td_pos = (TD_RIGHT|TD_BOTTOM) #define TD_TOTAL_HEIGHT (TD_PADY * 2 + TD_NUM_HEIGHT) -#define NUMBERS_NUM 14 +#define NUMBERS_NUM 16 + +#define TD_BORDER 0x333 -static char *numbers = { /* ugly */ -"+++++++--++++-+++++++++++++++++-++++++++++++++++++++++++++++++++++++++++++++-++++++-++++----++---+" -"+xxxxx+--+xx+-+xxxxx++xxxxx++x+-+x++xxxxx++xxxxx++xxxxx++xxxxx++xxxxx++xxxx+-+x++x+-+xxx++-+xx+-+x" -"+x+++x+--++x+-+++++x++++++x++x+++x++x++++++x++++++++++x++x+++x++x+++x++x++++-+x++x+-+x++x+--+x++x+" -"+x+-+x+---+x+-+xxxxx++xxxxx++xxxxx++xxxxx++xxxxx+--++x+-+xxxxx++xxxxx++x+----+xxxx+-+x++x+----+x+-" -"+x+++x+---+x+-+x++++++++++x++++++x++++++x++x+++x+--+x+--+x+++x++++++x++x++++-+x++x+-+x++x+---+x+x+" -"+xxxxx+---+x+-+xxxxx++xxxxx+----+x++xxxxx++xxxxx+--+x+--+xxxxx++xxxxx++xxxx+-+x++x+-+xxx+---+x++xx" -"+++++++---+++-++++++++++++++----+++++++++++++++++--+++--++++++++++++++++++++-++++++-++++----------" +static const char *numbers = { /* ugly 0123456789CHD%+- */ +"+++++++--++++-+++++++++++++++++-++++++++++++++++++++++++++++++++++++++++++++-++++++-++++----++---+--------------" +"+xxxxx+--+xx+-+xxxxx++xxxxx++x+-+x++xxxxx++xxxxx++xxxxx++xxxxx++xxxxx++xxxx+-+x++x+-+xxx++-+xx+-+x---+----------" +"+x+++x+--++x+-+++++x++++++x++x+++x++x++++++x++++++++++x++x+++x++x+++x++x++++-+x++x+-+x++x+--+x++x+--+x+----+++--" +"+x+-+x+---+x+-+xxxxx++xxxxx++xxxxx++xxxxx++xxxxx+--++x+-+xxxxx++xxxxx++x+----+xxxx+-+x++x+----+x+--+xxx+--+xxx+-" +"+x+++x+---+x+-+x++++++++++x++++++x++++++x++x+++x+--+x+--+x+++x++++++x++x++++-+x++x+-+x++x+---+x+x+--+x+----+++--" +"+xxxxx+---+x+-+xxxxx++xxxxx+----+x++xxxxx++xxxxx+--+x+--+xxxxx++xxxxx++xxxx+-+x++x+-+xxx+---+x++xx--------------" +"+++++++---+++-++++++++++++++----+++++++++++++++++--+++--++++++++++++++++++++-++++++-++++------------------------" }; STATIC_INLINE void putpixel (int x, xcolnr c8) { - switch(gfxvidinfo.pixbytes) - { + switch (gfxvidinfo.pixbytes) { case 1: xlinebuffer[x] = (uae_u8)c8; break; @@ -1581,7 +1584,8 @@ static void draw_status_line (int line) memset (xlinebuffer, 0, gfxvidinfo.width * gfxvidinfo.pixbytes); for (led = 0; led < 5; led++) { - int side, pos, num1 = -1, num2 = -1, num3 = -1, num4 = -1, x, off_rgb, on_rgb, c, on = 0; + int side, pos, num1 = -1, num2 = -1, num3 = -1, num4 = -1; + int x, off_rgb, on_rgb, c, on = 0; if (led > 0) { int pled = led - 1; int track = gui_data.drive_track[pled]; @@ -1604,23 +1608,29 @@ static void draw_status_line (int line) off_rgb = 0x300; } c = xcolors[on ? on_rgb : off_rgb]; + if (y == 0 || y == TD_TOTAL_HEIGHT - 1) + c = xcolors[TD_BORDER]; x = x_start + pos * TD_WIDTH; + putpixel (x - 1, xcolors[TD_BORDER]); for (j = 0; j < TD_LED_WIDTH; j++) putpixel (x + j, c); + putpixel (x + j, xcolors[TD_BORDER]); if (y >= TD_PADY && y - TD_PADY < TD_NUM_HEIGHT) { if (num3 >= 0) { int tn = num1 > 0 ? 3 : 2; - int offs = (TD_LED_WIDTH - tn * TD_NUM_WIDTH) / 2; + x += (TD_LED_WIDTH - tn * TD_NUM_WIDTH) / 2; if (num1 > 0) { - write_tdnumber (x + offs, y - TD_PADY, num1); - offs += TD_NUM_WIDTH; + write_tdnumber (x, y - TD_PADY, num1); + x += TD_NUM_WIDTH; } - write_tdnumber (x + offs, y - TD_PADY, num2); - write_tdnumber (x + offs + TD_NUM_WIDTH, y - TD_PADY, num3); + write_tdnumber (x, y - TD_PADY, num2); + x += TD_NUM_WIDTH; + write_tdnumber (x, y - TD_PADY, num3); + x += TD_NUM_WIDTH; if (num4 > 0) - write_tdnumber (x + offs + 2 * TD_NUM_WIDTH, y - TD_PADY, num4); + write_tdnumber (x, y - TD_PADY, num4); } } } @@ -1652,14 +1662,14 @@ void finish_drawing_frame (void) break; where = amiga2aspect_line_map[i1]; - if (where >= gfxvidinfo.height - (currprefs.leds_on_screen ? TD_TOTAL_HEIGHT : 0)) + if (where >= gfxvidinfo.height - (curr_gfx->leds_on_screen ? TD_TOTAL_HEIGHT : 0)) break; if (where == -1) continue; pfield_draw_line (line, where, amiga2aspect_line_map[i1 + 1]); } - if (currprefs.leds_on_screen) { + if (curr_gfx->leds_on_screen) { for (i = 0; i < TD_TOTAL_HEIGHT; i++) { int line = gfxvidinfo.height - TD_TOTAL_HEIGHT + i; draw_status_line (line); @@ -1710,6 +1720,56 @@ STATIC_INLINE void check_picasso (void) #endif } +int check_prefs_changed_gfx (void) +{ + int params_changed = 0, screen_changed = 0; + int old_x, old_y; + + if (!screen_is_picasso) { + if (curr_gfx == &currprefs.gfx_w + && memcmp (&changed_prefs.gfx_w, &currprefs.gfx_w, sizeof (struct gfx_params)) != 0) + { + old_x = currprefs.gfx_w.width; + old_y = currprefs.gfx_w.height; + fixup_prefs_dimensions (&changed_prefs.gfx_w, gfx_windowed_modes, n_windowed_modes); + currprefs.gfx_w = changed_prefs.gfx_w; + params_changed = 1; + screen_changed = (old_x != currprefs.gfx_w.width + || old_y != currprefs.gfx_w.height); + } else if (curr_gfx == &currprefs.gfx_f + && memcmp (&changed_prefs.gfx_f, &currprefs.gfx_f, sizeof (struct gfx_params)) != 0) + { + old_x = currprefs.gfx_f.width; + old_y = currprefs.gfx_f.height; + fixup_prefs_dimensions (&changed_prefs.gfx_f, gfx_fullscreen_modes, n_fullscreen_modes); + currprefs.gfx_f = changed_prefs.gfx_f; + params_changed = 1; + screen_changed = (old_x != currprefs.gfx_f.width + || old_y != currprefs.gfx_f.height); + } + if (changed_prefs.gfx_afullscreen != currprefs.gfx_afullscreen) { + screen_changed = 1; + } + } else if (changed_prefs.gfx_pfullscreen != currprefs.gfx_pfullscreen) { + screen_changed = 1; + } + + currprefs.gfx_afullscreen = changed_prefs.gfx_afullscreen; + currprefs.gfx_pfullscreen = changed_prefs.gfx_pfullscreen; + + if (screen_changed) { + graphics_subshutdown (0); + + gui_update_gfx (); + + graphics_subinit (); + + reset_drawing (); + } + + return params_changed || screen_changed; +} + void vsync_handle_redraw (int long_frame, int lof_changed) { last_redraw_point++; @@ -1747,6 +1807,7 @@ void vsync_handle_redraw (int long_frame count_frame (); check_picasso (); + currprefs.keyboard_lang = changed_prefs.keyboard_lang; check_prefs_changed_audio (); check_prefs_changed_custom (); check_prefs_changed_cpu (); @@ -1757,6 +1818,9 @@ void vsync_handle_redraw (int long_frame } notice_screen_contents_lost (); notice_new_xcolors (); + + if (screen_is_picasso) + picasso_enablescreen (1); } if (inhibit_frame != 0) @@ -1814,9 +1878,6 @@ void reset_drawing (void) { int i; - inhibit_frame = 0; - uae_sem_init (&gui_sem, 0, 1); - max_diwstop = 0; if (!curr_gfx) @@ -1845,12 +1906,24 @@ void reset_drawing (void) init_drawing_frame (); } +void init_drawing_at_reset (void) +{ + InitPicasso96 (); + picasso_requested_on = 0; + picasso_on = 0; + gfx_set_picasso_state (0); + + inhibit_frame = 0; +} + void drawing_init () { + inhibit_frame = 0; + native2amiga_line_map = 0; amiga2aspect_line_map = 0; line_drawn = 0; - gen_pfield_tables(); + gen_pfield_tables (); }