--- uae/src/drawing.c 2018/04/24 17:00:11 1.1.1.13 +++ uae/src/drawing.c 2018/04/24 17:12:34 1.1.1.17 @@ -34,7 +34,7 @@ #include "config.h" #include "options.h" -#include "threaddep/penguin.h" +#include "threaddep/thread.h" #include "uae.h" #include "memory.h" #include "custom.h" @@ -132,12 +132,12 @@ static char linestate[(MAXVPOS + 1)*2 + uae_u8 line_data[(MAXVPOS + 1) * 2][MAX_PLANES * MAX_WORDS_PER_LINE * 2]; /* Centering variables. */ -static int min_diwstart, max_diwstop, prev_x_adjust; +static int min_diwstart, max_diwstop; /* The visible window: VISIBLE_LEFT_BORDER contains the left border of the visible area, VISIBLE_RIGHT_BORDER the right border. These are in window coordinates. */ static int visible_left_border, visible_right_border; static int linetoscr_x_adjust_bytes; -static int thisframe_y_adjust, prev_y_adjust; +static int thisframe_y_adjust; static int thisframe_y_adjust_real, max_ypos_thisframe, min_ypos_for_screen; static int extra_y_adjust; int thisframe_first_drawn_line, thisframe_last_drawn_line; @@ -302,33 +302,33 @@ static void pfield_init_linetoscr (void) #define LNAME linetoscr_8 #define SRC_INC 1 #define HDOUBLE 0 -#define AGA 0 +#define AGAC 0 #include "linetoscr.c" #define LNAME linetoscr_8_stretch1 #define SRC_INC 1 #define HDOUBLE 1 -#define AGA 0 +#define AGAC 0 #include "linetoscr.c" #define LNAME linetoscr_8_shrink1 #define SRC_INC 2 #define HDOUBLE 0 -#define AGA 0 +#define AGAC 0 #include "linetoscr.c" #define LNAME linetoscr_8_aga #define SRC_INC 1 #define HDOUBLE 0 -#define AGA 1 +#define AGAC 1 #include "linetoscr.c" #define LNAME linetoscr_8_stretch1_aga #define SRC_INC 1 #define HDOUBLE 1 -#define AGA 1 +#define AGAC 1 #include "linetoscr.c" #define LNAME linetoscr_8_shrink1_aga #define SRC_INC 2 #define HDOUBLE 0 -#define AGA 1 +#define AGAC 1 #include "linetoscr.c" #undef TYPE @@ -337,33 +337,33 @@ static void pfield_init_linetoscr (void) #define LNAME linetoscr_16 #define SRC_INC 1 #define HDOUBLE 0 -#define AGA 0 +#define AGAC 0 #include "linetoscr.c" #define LNAME linetoscr_16_stretch1 #define SRC_INC 1 #define HDOUBLE 1 -#define AGA 0 +#define AGAC 0 #include "linetoscr.c" #define LNAME linetoscr_16_shrink1 #define SRC_INC 2 #define HDOUBLE 0 -#define AGA 0 +#define AGAC 0 #include "linetoscr.c" #define LNAME linetoscr_16_aga #define SRC_INC 1 #define HDOUBLE 0 -#define AGA 1 +#define AGAC 1 #include "linetoscr.c" #define LNAME linetoscr_16_stretch1_aga #define SRC_INC 1 #define HDOUBLE 1 -#define AGA 1 +#define AGAC 1 #include "linetoscr.c" #define LNAME linetoscr_16_shrink1_aga #define SRC_INC 2 #define HDOUBLE 0 -#define AGA 1 +#define AGAC 1 #include "linetoscr.c" #undef TYPE @@ -372,33 +372,33 @@ static void pfield_init_linetoscr (void) #define LNAME linetoscr_32 #define SRC_INC 1 #define HDOUBLE 0 -#define AGA 0 +#define AGAC 0 #include "linetoscr.c" #define LNAME linetoscr_32_stretch1 #define SRC_INC 1 #define HDOUBLE 1 -#define AGA 0 +#define AGAC 0 #include "linetoscr.c" #define LNAME linetoscr_32_shrink1 #define SRC_INC 2 #define HDOUBLE 0 -#define AGA 0 +#define AGAC 0 #include "linetoscr.c" #define LNAME linetoscr_32_aga #define SRC_INC 1 #define HDOUBLE 0 -#define AGA 1 +#define AGAC 1 #include "linetoscr.c" #define LNAME linetoscr_32_stretch1_aga #define SRC_INC 1 #define HDOUBLE 1 -#define AGA 1 +#define AGAC 1 #include "linetoscr.c" #define LNAME linetoscr_32_shrink1_aga #define SRC_INC 2 #define HDOUBLE 0 -#define AGA 1 +#define AGAC 1 #include "linetoscr.c" #undef TYPE @@ -563,7 +563,15 @@ static void init_ham_decoding (void) ham_decode_pixel = src_pixel; ham_lastcolor = color_reg_get (&colors_for_drawing, 0); - if (currprefs.chipset_mask & CSMASK_AGA) { + if (! bplham || (bplplanecnt != 6 && ((currprefs.chipset_mask & CSMASK_AGA) == 0 || bplplanecnt != 8))) { + if (unpainted_amiga > 0) { + int pv = pixdata.apixels[ham_decode_pixel + unpainted_amiga - 1]; + if (currprefs.chipset_mask & CSMASK_AGA) + ham_lastcolor = colors_for_drawing.color_regs_aga[pv]; + else + ham_lastcolor = colors_for_drawing.color_regs_ecs[pv]; + } + } else if (currprefs.chipset_mask & CSMASK_AGA) { if (bplplanecnt == 8) { /* AGA mode HAM8 */ while (unpainted_amiga-- > 0) { int pv = pixdata.apixels[ham_decode_pixel++]; @@ -574,7 +582,7 @@ static void init_ham_decoding (void) case 0x3: ham_lastcolor &= 0xFF03FF; ham_lastcolor |= (pv & 0xFC) << 8; break; } } - } else if(bplplanecnt == 6) { /* AGA mode HAM6 */ + } else if (bplplanecnt == 6) { /* AGA mode HAM6 */ while (unpainted_amiga-- > 0) { int pv = pixdata.apixels[ham_decode_pixel++]; switch (pv & 0x30) { @@ -603,10 +611,18 @@ static void init_ham_decoding (void) static void decode_ham (int pix, int stoppos) { int todraw_amiga = res_shift_from_window (stoppos - pix); - if (!bplham) - abort (); - if (currprefs.chipset_mask & CSMASK_AGA) { + if (! bplham || (bplplanecnt != 6 && ((currprefs.chipset_mask & CSMASK_AGA) == 0 || bplplanecnt != 8))) { + while (todraw_amiga-- > 0) { + int pv = pixdata.apixels[ham_decode_pixel]; + if (currprefs.chipset_mask & CSMASK_AGA) + ham_lastcolor = colors_for_drawing.color_regs_aga[pv]; + else + ham_lastcolor = colors_for_drawing.color_regs_ecs[pv]; + + ham_linebuf[ham_decode_pixel++] = ham_lastcolor; + } + } else if (currprefs.chipset_mask & CSMASK_AGA) { if (bplplanecnt == 8) { /* AGA mode HAM8 */ while (todraw_amiga-- > 0) { int pv = pixdata.apixels[ham_decode_pixel]; @@ -618,7 +634,7 @@ static void decode_ham (int pix, int sto } ham_linebuf[ham_decode_pixel++] = ham_lastcolor; } - } else if(bplplanecnt == 6) { /* AGA mode HAM6 */ + } else if (bplplanecnt == 6) { /* AGA mode HAM6 */ while (todraw_amiga-- > 0) { int pv = pixdata.apixels[ham_decode_pixel]; switch (pv & 0x30) { @@ -798,28 +814,28 @@ STATIC_INLINE void draw_sprites_1 (struc /* 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 */ -static void draw_sprites_normal_sp_lo_nat (struct sprite_entry *e) { draw_sprites_1 (e, 0, 0, 0, 0, 0, 0); } -static void draw_sprites_normal_dp_lo_nat (struct sprite_entry *e) { draw_sprites_1 (e, 0, 1, 0, 0, 0, 0); } -static void draw_sprites_ham_sp_lo_nat (struct sprite_entry *e) { draw_sprites_1 (e, 1, 0, 0, 0, 0, 0); } -static void draw_sprites_normal_sp_lo_at (struct sprite_entry *e) { draw_sprites_1 (e, 0, 0, 0, 0, 1, 0); } -static void draw_sprites_normal_dp_lo_at (struct sprite_entry *e) { draw_sprites_1 (e, 0, 1, 0, 0, 1, 0); } -static void draw_sprites_ham_sp_lo_at (struct sprite_entry *e) { draw_sprites_1 (e, 1, 0, 0, 0, 1, 0); } +static void NOINLINE draw_sprites_normal_sp_lo_nat (struct sprite_entry *e) { draw_sprites_1 (e, 0, 0, 0, 0, 0, 0); } +static void NOINLINE draw_sprites_normal_dp_lo_nat (struct sprite_entry *e) { draw_sprites_1 (e, 0, 1, 0, 0, 0, 0); } +static void NOINLINE draw_sprites_ham_sp_lo_nat (struct sprite_entry *e) { draw_sprites_1 (e, 1, 0, 0, 0, 0, 0); } +static void NOINLINE draw_sprites_normal_sp_lo_at (struct sprite_entry *e) { draw_sprites_1 (e, 0, 0, 0, 0, 1, 0); } +static void NOINLINE draw_sprites_normal_dp_lo_at (struct sprite_entry *e) { draw_sprites_1 (e, 0, 1, 0, 0, 1, 0); } +static void NOINLINE draw_sprites_ham_sp_lo_at (struct sprite_entry *e) { draw_sprites_1 (e, 1, 0, 0, 0, 1, 0); } /* hires bitplane, lores sprites */ -static void draw_sprites_normal_sp_hi_nat (struct sprite_entry *e) { draw_sprites_1 (e, 0, 0, 1, 0, 0, 0); } -static void draw_sprites_normal_dp_hi_nat (struct sprite_entry *e) { draw_sprites_1 (e, 0, 1, 1, 0, 0, 0); } -static void draw_sprites_ham_sp_hi_nat (struct sprite_entry *e) { draw_sprites_1 (e, 1, 0, 1, 0, 0, 0); } -static void draw_sprites_normal_sp_hi_at (struct sprite_entry *e) { draw_sprites_1 (e, 0, 0, 1, 0, 1, 0); } -static void draw_sprites_normal_dp_hi_at (struct sprite_entry *e) { draw_sprites_1 (e, 0, 1, 1, 0, 1, 0); } -static void draw_sprites_ham_sp_hi_at (struct sprite_entry *e) { draw_sprites_1 (e, 1, 0, 1, 0, 1, 0); } +static void NOINLINE draw_sprites_normal_sp_hi_nat (struct sprite_entry *e) { draw_sprites_1 (e, 0, 0, 1, 0, 0, 0); } +static void NOINLINE draw_sprites_normal_dp_hi_nat (struct sprite_entry *e) { draw_sprites_1 (e, 0, 1, 1, 0, 0, 0); } +static void NOINLINE draw_sprites_ham_sp_hi_nat (struct sprite_entry *e) { draw_sprites_1 (e, 1, 0, 1, 0, 0, 0); } +static void NOINLINE draw_sprites_normal_sp_hi_at (struct sprite_entry *e) { draw_sprites_1 (e, 0, 0, 1, 0, 1, 0); } +static void NOINLINE draw_sprites_normal_dp_hi_at (struct sprite_entry *e) { draw_sprites_1 (e, 0, 1, 1, 0, 1, 0); } +static void NOINLINE draw_sprites_ham_sp_hi_at (struct sprite_entry *e) { draw_sprites_1 (e, 1, 0, 1, 0, 1, 0); } /* not very optimized */ STATIC_INLINE void draw_sprites_aga (struct sprite_entry *e) { int diff = RES_HIRES - bplres; if (diff > 0) - draw_sprites_1 (e, bplham, bpldualpf, 0, diff, e->has_attached, 1); + draw_sprites_1 (e, dp_for_drawing->ham_seen, bpldualpf, 0, diff, e->has_attached, 1); else - draw_sprites_1 (e, bplham, bpldualpf, -diff, 0, e->has_attached, 1); + draw_sprites_1 (e, dp_for_drawing->ham_seen, bpldualpf, -diff, 0, e->has_attached, 1); } @@ -827,7 +843,7 @@ STATIC_INLINE void draw_sprites_ecs (str { if (e->has_attached) if (bplres == 1) - if (bplham) + if (dp_for_drawing->ham_seen) draw_sprites_ham_sp_hi_at (e); else if (bpldualpf) @@ -835,7 +851,7 @@ STATIC_INLINE void draw_sprites_ecs (str else draw_sprites_normal_sp_hi_at (e); else - if (bplham) + if (dp_for_drawing->ham_seen) draw_sprites_ham_sp_lo_at (e); else if (bpldualpf) @@ -844,7 +860,7 @@ STATIC_INLINE void draw_sprites_ecs (str draw_sprites_normal_sp_lo_at (e); else if (bplres == 1) - if (bplham) + if (dp_for_drawing->ham_seen) draw_sprites_ham_sp_hi_nat (e); else if (bpldualpf) @@ -852,7 +868,7 @@ STATIC_INLINE void draw_sprites_ecs (str else draw_sprites_normal_sp_hi_nat (e); else - if (bplham) + if (dp_for_drawing->ham_seen) draw_sprites_ham_sp_lo_nat (e); else if (bpldualpf) @@ -928,14 +944,14 @@ STATIC_INLINE void pfield_doline_1 (uae_ /* See above for comments on inlining. These functions should _not_ be inlined themselves. */ -static void pfield_doline_n1 (uae_u32 *data, int count) { pfield_doline_1 (data, count, 1); } -static void pfield_doline_n2 (uae_u32 *data, int count) { pfield_doline_1 (data, count, 2); } -static void pfield_doline_n3 (uae_u32 *data, int count) { pfield_doline_1 (data, count, 3); } -static void pfield_doline_n4 (uae_u32 *data, int count) { pfield_doline_1 (data, count, 4); } -static void pfield_doline_n5 (uae_u32 *data, int count) { pfield_doline_1 (data, count, 5); } -static void pfield_doline_n6 (uae_u32 *data, int count) { pfield_doline_1 (data, count, 6); } -static void pfield_doline_n7 (uae_u32 *data, int count) { pfield_doline_1 (data, count, 7); } -static void pfield_doline_n8 (uae_u32 *data, int count) { pfield_doline_1 (data, count, 8); } +static void NOINLINE pfield_doline_n1 (uae_u32 *data, int count) { pfield_doline_1 (data, count, 1); } +static void NOINLINE pfield_doline_n2 (uae_u32 *data, int count) { pfield_doline_1 (data, count, 2); } +static void NOINLINE pfield_doline_n3 (uae_u32 *data, int count) { pfield_doline_1 (data, count, 3); } +static void NOINLINE pfield_doline_n4 (uae_u32 *data, int count) { pfield_doline_1 (data, count, 4); } +static void NOINLINE pfield_doline_n5 (uae_u32 *data, int count) { pfield_doline_1 (data, count, 5); } +static void NOINLINE pfield_doline_n6 (uae_u32 *data, int count) { pfield_doline_1 (data, count, 6); } +static void NOINLINE pfield_doline_n7 (uae_u32 *data, int count) { pfield_doline_1 (data, count, 7); } +static void NOINLINE pfield_doline_n8 (uae_u32 *data, int count) { pfield_doline_1 (data, count, 8); } static void pfield_doline (int lineno) { @@ -1097,6 +1113,7 @@ STATIC_INLINE void do_flush_screen (int if (gfxvidinfo.maxblocklines != 0 && first_block_line != -2) { flush_block (first_block_line, last_block_line); } + unlockscr (); if (start <= stop) flush_screen (start, stop); } @@ -1106,10 +1123,10 @@ static enum { color_match_acolors, color /* Set up colors_for_drawing to the state at the beginning of the currently drawn line. Try to avoid copying color tables around whenever possible. */ -static void adjust_drawing_colors (int ctable, int bplham) +static void adjust_drawing_colors (int ctable, int need_full) { if (drawing_color_matches != ctable) { - if (bplham) { + if (need_full) { color_reg_cpy (&colors_for_drawing, curr_color_tables + ctable); color_match_type = color_match_full; } else { @@ -1118,7 +1135,7 @@ static void adjust_drawing_colors (int c color_match_type = color_match_acolors; } drawing_color_matches = ctable; - } else if (bplham && color_match_type != color_match_full) { + } else if (need_full && color_match_type != color_match_full) { color_reg_cpy (&colors_for_drawing, &curr_color_tables[ctable]); color_match_type = color_match_full; } @@ -1162,8 +1179,12 @@ STATIC_INLINE void do_color_changes (lin lastpos = nextpos_in_range; } if (i != dip_for_drawing->last_color_change) { - color_reg_set (&colors_for_drawing, regno, value); - colors_for_drawing.acolors[regno] = getxcolor (value); + if (regno == -1) + bplham = value; + else { + color_reg_set (&colors_for_drawing, regno, value); + colors_for_drawing.acolors[regno] = getxcolor (value); + } } if (lastpos >= visible_right_border) break; @@ -1178,9 +1199,8 @@ static void pfield_expand_dp_bplcon (voi int plf1pri, plf2pri; bplres = dp_for_drawing->bplres; bplplanecnt = dp_for_drawing->nr_planes; - bplham = ((dp_for_drawing->bplcon0 & 0x800) == 0x800 - && (bplplanecnt == 6 - || ((currprefs.chipset_mask & CSMASK_AGA) != 0 && bplplanecnt == 8))); + 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) */ @@ -1274,11 +1294,11 @@ STATIC_INLINE void pfield_draw_line (int pfield_init_linetoscr (); pfield_doline (lineno); - adjust_drawing_colors (dp_for_drawing->ctable, bplham || bplehb); + adjust_drawing_colors (dp_for_drawing->ctable, dp_for_drawing->ham_seen || bplehb); /* The problem is that we must call decode_ham() BEFORE we do the sprites. */ - if (! border && bplham) { + if (! border && dp_for_drawing->ham_seen) { init_ham_decoding (); if (dip_for_drawing->nr_color_changes == 0) { /* The easy case: need to do HAM decoding only once for the @@ -1286,8 +1306,9 @@ STATIC_INLINE void pfield_draw_line (int decode_ham (visible_left_border, visible_right_border); } else /* Argh. */ { do_color_changes (dummy_worker, decode_ham); - adjust_drawing_colors (dp_for_drawing->ctable, bplham || bplehb); + adjust_drawing_colors (dp_for_drawing->ctable, dp_for_drawing->ham_seen || bplehb); } + bplham = dp_for_drawing->ham_at_start; } { @@ -1295,21 +1316,21 @@ STATIC_INLINE void pfield_draw_line (int for (i = 0; i < dip_for_drawing->nr_sprites; i++) { if (currprefs.chipset_mask & CSMASK_AGA) draw_sprites_aga (curr_sprite_entries + dip_for_drawing->first_sprite_entry + i); - else + else draw_sprites_ecs (curr_sprite_entries + dip_for_drawing->first_sprite_entry + i); } } do_color_changes (pfield_do_fill_line, pfield_do_linetoscr); if (dh == dh_emerg) - memcpy (row_map[gfx_ypos], xlinebuffer + linetoscr_x_adjust_bytes, gfxvidinfo.rowbytes); + memcpy (row_map[gfx_ypos], xlinebuffer + linetoscr_x_adjust_bytes, gfxvidinfo.pixbytes * gfxvidinfo.width); do_flush_line (gfx_ypos); if (do_double) { if (dh == dh_emerg) - memcpy (row_map[follow_ypos], xlinebuffer + linetoscr_x_adjust_bytes, gfxvidinfo.rowbytes); + memcpy (row_map[follow_ypos], xlinebuffer + linetoscr_x_adjust_bytes, gfxvidinfo.pixbytes * gfxvidinfo.width); else if (dh == dh_buf) - memcpy (row_map[follow_ypos], row_map[gfx_ypos], gfxvidinfo.rowbytes); + memcpy (row_map[follow_ypos], row_map[gfx_ypos], gfxvidinfo.pixbytes * gfxvidinfo.width); do_flush_line (follow_ypos); } if (currprefs.gfx_lores == 2) @@ -1342,14 +1363,14 @@ STATIC_INLINE void pfield_draw_line (int do_color_changes (pfield_do_fill_line, pfield_do_fill_line); if (dh == dh_emerg) - memcpy (row_map[gfx_ypos], xlinebuffer + linetoscr_x_adjust_bytes, gfxvidinfo.rowbytes); + memcpy (row_map[gfx_ypos], xlinebuffer + linetoscr_x_adjust_bytes, gfxvidinfo.pixbytes * gfxvidinfo.width); do_flush_line (gfx_ypos); if (do_double) { if (dh == dh_emerg) - memcpy (row_map[follow_ypos], xlinebuffer + linetoscr_x_adjust_bytes, gfxvidinfo.rowbytes); + memcpy (row_map[follow_ypos], xlinebuffer + linetoscr_x_adjust_bytes, gfxvidinfo.pixbytes * gfxvidinfo.width); else if (dh == dh_buf) - memcpy (row_map[follow_ypos], row_map[gfx_ypos], gfxvidinfo.rowbytes); + memcpy (row_map[follow_ypos], row_map[gfx_ypos], gfxvidinfo.pixbytes * gfxvidinfo.width); /* If dh == dh_line, do_flush_line will re-use the rendered line * from linemem. */ do_flush_line (follow_ypos); @@ -1365,8 +1386,8 @@ STATIC_INLINE void pfield_draw_line (int static void center_image (void) { - prev_x_adjust = visible_left_border; - prev_y_adjust = thisframe_y_adjust; + 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) @@ -1469,37 +1490,181 @@ static void init_drawing_frame (void) drawing_color_matches = -1; } +/* + * Some code to put status information on the screen. + */ + +#define TD_PADX 10 +#define TD_PADY 2 +#define TD_WIDTH 32 +#define TD_LED_WIDTH 24 +#define TD_LED_HEIGHT 4 + +#define TD_RIGHT 1 +#define TD_BOTTOM 2 + +static int td_pos = (TD_RIGHT|TD_BOTTOM); + +#define TD_NUM_WIDTH 7 +#define TD_NUM_HEIGHT 7 + +#define TD_TOTAL_HEIGHT (TD_PADY * 2 + TD_NUM_HEIGHT) + +#define NUMBERS_NUM 14 + +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_INLINE void putpixel (int x, xcolnr c8) +{ + switch(gfxvidinfo.pixbytes) + { + case 1: + xlinebuffer[x] = (uae_u8)c8; + break; + case 2: + { + uae_u16 *p = (uae_u16 *)xlinebuffer + x; + *p = (uae_u16)c8; + break; + } + case 3: + /* no 24 bit yet */ + break; + case 4: + { + uae_u32 *p = (uae_u32 *)xlinebuffer + x; + *p = c8; + break; + } + } +} + +static void write_tdnumber (int x, int y, int num) +{ + 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') + putpixel (x + j, xcolors[0xfff]); + else if (*numptr == '+') + putpixel (x + j, xcolors[0x000]); + numptr++; + } +} + +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; + else + x_start = TD_PADX; + + y = line - (gfxvidinfo.height - TD_TOTAL_HEIGHT); + xlinebuffer = gfxvidinfo.linemem; + if (xlinebuffer == 0) + xlinebuffer = row_map[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; + if (led > 0) { + int pled = led - 1; + int track = gui_data.drive_track[pled]; + pos = 1 + pled; + on_rgb = 0x0c0; + off_rgb = 0x030; + if (1 /*!gui_data.drive_disabled[pled]*/) { + num1 = -1; + num2 = track / 10; + num3 = track % 10; + on = gui_data.drive_motor[pled]; + if (gui_data.drive_writing[pled]) + on_rgb = 0xc00; + } + /*side = gui_data.drive_side;*/ + } else { + pos = 0; + on = gui_data.powerled; + on_rgb = 0xc00; + off_rgb = 0x300; + } + c = xcolors[on ? on_rgb : off_rgb]; + + x = x_start + pos * TD_WIDTH; + for (j = 0; j < TD_LED_WIDTH; j++) + putpixel (x + j, c); + + 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; + if (num1 > 0) { + write_tdnumber (x + offs, y - TD_PADY, num1); + offs += TD_NUM_WIDTH; + } + 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); + } + } + } +} + void finish_drawing_frame (void) { int i; -#ifndef SMART_UPDATE - /* @@@ This isn't exactly right yet. FIXME */ - if (!interlace_seen) { - do_flush_screen (first_drawn_line, last_drawn_line); - return; - } -#endif if (! lockscr ()) { notice_screen_contents_lost (); return; } + +#ifndef SMART_UPDATE + /* @@@ This isn't exactly right yet. FIXME */ + if (!interlace_seen) + do_flush_screen (first_drawn_line, last_drawn_line); + else + unlockscr (); + return; +#endif for (i = 0; i < max_ypos_thisframe; i++) { int where; + int i1 = i + min_ypos_for_screen; int line = i + thisframe_y_adjust_real; if (linestate[line] == LINE_UNDECIDED) break; - where = amiga2aspect_line_map[i+min_ypos_for_screen]; - if (where >= gfxvidinfo.height) + where = amiga2aspect_line_map[i1]; + if (where >= gfxvidinfo.height - (currprefs.leds_on_screen ? TD_TOTAL_HEIGHT : 0)) break; if (where == -1) continue; - pfield_draw_line (line, where, amiga2aspect_line_map[i+min_ypos_for_screen+1]); + pfield_draw_line (line, where, amiga2aspect_line_map[i1 + 1]); } - unlockscr (); + if (currprefs.leds_on_screen) { + for (i = 0; i < TD_TOTAL_HEIGHT; i++) { + int line = gfxvidinfo.height - TD_TOTAL_HEIGHT + i; + draw_status_line (line); + do_flush_line (line); + } + } + do_flush_screen (first_drawn_line, last_drawn_line); } @@ -1568,10 +1733,6 @@ void vsync_handle_redraw (int long_frame } else if (savestate_state == STATE_DORESTORE) { savestate_state = STATE_RESTORE; uae_reset (); - restore_state (savestate_filename); -#if 0 - activate_debugger (); -#endif } if (quit_program < 0) {