From c1a3dc4ddab1236b31ea5823e1fb239e448c95d6 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sun, 31 Jan 2016 15:39:10 +0200 Subject: [PATCH] Dark palette fix and monochrome video out. --- drawing.cpp | 72 ++++++++++++++++++++++++++++++++++++++++--- include/drawing.h | 2 +- od-win32/win32gfx.cpp | 7 ++++- 3 files changed, 75 insertions(+), 6 deletions(-) diff --git a/drawing.cpp b/drawing.cpp index 5c1448c6..b6ed85fd 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -152,6 +152,10 @@ int xgreencolor_s, xgreencolor_b, xgreencolor_m; int xbluecolor_s, xbluecolor_b, xbluecolor_m; struct color_entry colors_for_drawing; +static struct color_entry direct_colors_for_drawing; + +static xcolnr *p_acolors; +static xcolnr *p_xcolors; /* The size of these arrays is pretty arbitrary; it was chosen to be "more than enough". The coordinates used for indexing into these arrays are @@ -192,6 +196,7 @@ static uae_u8 *row_map_genlock_buffer; static uae_u8 row_tmp[MAX_PIXELS_PER_LINE * 32 / 8]; static int max_drawn_amiga_line; uae_u8 **row_map_genlock; +uae_u8 *row_map_color_burst_buffer; /* line_draw_funcs: pfield_do_linetoscr, pfield_do_fill_line, decode_ham */ typedef void (*line_draw_func)(int, int, bool); @@ -242,9 +247,10 @@ static int first_block_line, last_block_line; 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, ecsshres; +static int bplbypass, bplcolorburst, bplcolorburst_field; static bool issprites; static int bplres; -static int plf1pri, plf2pri, bplxor, bpldelay_sh; +static int plf1pri, plf2pri, bplxor, bpland, bpldelay_sh; static uae_u32 plf_sprite_mask; static int sbasecol[2] = { 16, 16 }; static int hposblank; @@ -1709,6 +1715,12 @@ static int pfield_do_linetoscr_sprite_shdelay(int spix, int dpix, int dpix_end) static void pfield_set_linetoscr (void) { xlinecheck(start, stop); + p_acolors = colors_for_drawing.acolors; + p_xcolors = xcolors; + bpland = 0xff; + if (bplbypass) { + p_acolors = direct_colors_for_drawing.acolors; + } spritepixels = spritepixels_buffer; pfield_do_linetoscr_spriteonly = pfield_do_nothing; #ifdef AGA @@ -2027,6 +2039,7 @@ static void init_ham_decoding (void) static void decode_ham (int pix, int stoppos, bool blank) { int todraw_amiga = res_shift_from_window (stoppos - pix); + int hdp = ham_decode_pixel; if (!bplham) { while (todraw_amiga-- > 0) { @@ -2413,6 +2426,11 @@ void init_row_map (void) if (init_genlock_data) { row_map_genlock_buffer = xcalloc(uae_u8, gfxvidinfo.drawbuffer.width_allocated * (gfxvidinfo.drawbuffer.height_allocated + 2)); } + xfree(row_map_color_burst_buffer); + row_map_color_burst_buffer = NULL; + if (currprefs.cs_color_burst) { + row_map_color_burst_buffer = xcalloc(uae_u8, gfxvidinfo.drawbuffer.height_allocated + 2); + } j = oldheight == 0 ? max_uae_height : oldheight; for (i = gfxvidinfo.drawbuffer.height_allocated; i < max_uae_height + 1 && i < j + 1; i++) { row_map[i] = row_tmp; @@ -2565,6 +2583,9 @@ static void pfield_expand_dp_bplcon (void) if ((currprefs.chipset_mask & CSMASK_ECS_DENISE) && (dp_for_drawing->bplcon2 & 0x0200)) bplehb = 0; issprites = dip_for_drawing->nr_sprites > 0; + bplcolorburst = (dp_for_drawing->bplcon0 & 0x200) != 0; + if (!bplcolorburst) + bplcolorburst_field = 0; #ifdef ECS_DENISE int oecsshres = ecsshres; ecsshres = bplres == RES_SUPERHIRES && (currprefs.chipset_mask & CSMASK_ECS_DENISE) && !(currprefs.chipset_mask & CSMASK_AGA); @@ -2579,6 +2600,22 @@ static void pfield_expand_dp_bplcon (void) bpldualpfpri = (dp_for_drawing->bplcon2 & 0x40) == 0x40; #ifdef AGA + // BYPASS: HAM and EHB select bits are ignored + if (bplbypass != (dp_for_drawing->bplcon0 & 0x20) != 0) { + bpland = 0xff; + bplbypass = (dp_for_drawing->bplcon0 & 0x20) != 0; + pfield_mode_changed = true; + } + if (bplbypass) { + if (bplham && bplplanecnt == 6) + bpland = 0x0f; + if (bplham && bplplanecnt == 8) + bpland = 0xfc; + bplham = 0; + if (bplehb) + bpland = 31; + bplehb = 0; + } 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; @@ -2874,6 +2911,9 @@ static void pfield_draw_line (struct vidbuffer *vb, int lineno, int gfx_ypos, in xlinebuffer -= linetoscr_x_adjust_pixbytes; xlinebuffer_genlock = row_map_genlock[gfx_ypos] - linetoscr_x_adjust_pixels; + if (row_map_color_burst_buffer) + row_map_color_burst_buffer[gfx_ypos] = bplcolorburst; + if (border == 0) { pfield_expand_dp_bplcon (); @@ -3710,8 +3750,18 @@ static void finish_drawing_frame (void) } } - if (currprefs.genlock_image && !currprefs.monitoremu && gfxvidinfo.tempbuffer.bufmem_allocated && currprefs.genlock) { - pfield_set_linetoscr(); + if (!currprefs.monitoremu && gfxvidinfo.tempbuffer.bufmem_allocated && ((!bplcolorburst_field && currprefs.cs_color_burst) || (currprefs.gfx_grayscale))) { + setspecialmonitorpos(&gfxvidinfo.tempbuffer); + emulate_grayscale(vb, &gfxvidinfo.tempbuffer); + vb = gfxvidinfo.outbuffer = &gfxvidinfo.tempbuffer; + if (vb->nativepositioning) + setnativeposition(vb); + gfxvidinfo.drawbuffer.tempbufferinuse = true; + do_flush_screen(vb, 0, vb->outheight); + didflush = true; + } + + if (currprefs.genlock_image && !currprefs.monitoremu && !currprefs.cs_color_burst && gfxvidinfo.tempbuffer.bufmem_allocated && currprefs.genlock) { setspecialmonitorpos(&gfxvidinfo.tempbuffer); if (init_genlock_data != specialmonitor_need_genlock()) { need_genlock_data = init_genlock_data = specialmonitor_need_genlock(); @@ -4065,13 +4115,27 @@ void reset_drawing (void) center_reset = true; specialmonitoron = false; + bplcolorburst_field = 1; +} + +static void gen_direct_drawing_table(void) +{ +#ifdef AGA + // BYPASS color table + for (int i = 0; i < 256; i++) { + uae_u32 v = (i << 16) | (i << 8) | i; + direct_colors_for_drawing.acolors[i] = CONVERT_RGB(v); + } +#endif } void drawing_init (void) { refresh_indicator_init(); - gen_pfield_tables (); + gen_pfield_tables(); + + gen_direct_drawing_table(); uae_sem_init (&gui_sem, 0, 1); #ifdef PICASSO96 diff --git a/include/drawing.h b/include/drawing.h index 9f25ef44..62cf0aeb 100644 --- a/include/drawing.h +++ b/include/drawing.h @@ -126,7 +126,7 @@ struct color_entry { #define CONVERT_RGB(c) 0 #endif -STATIC_INLINE xcolnr getxcolor (int c) +STATIC_INLINE xcolnr getxcolor(int c) { #ifdef AGA if (direct_rgb) diff --git a/od-win32/win32gfx.cpp b/od-win32/win32gfx.cpp index 755d6399..c69fc79d 100644 --- a/od-win32/win32gfx.cpp +++ b/od-win32/win32gfx.cpp @@ -1948,6 +1948,9 @@ int check_prefs_changed_gfx (void) c |= currprefs.gfx_lores_mode != changed_prefs.gfx_lores_mode ? (2 | 8) : 0; c |= currprefs.gfx_scandoubler != changed_prefs.gfx_scandoubler ? (2 | 8) : 0; + c |= currprefs.gfx_threebitcolors != changed_prefs.gfx_threebitcolors ? (256) : 0; + c |= currprefs.gfx_grayscale != changed_prefs.gfx_grayscale ? (512) : 0; + c |= currprefs.gfx_apmode[APMODE_NATIVE].gfx_display != changed_prefs.gfx_apmode[APMODE_NATIVE].gfx_display ? (2|4|8) : 0; c |= currprefs.gfx_apmode[APMODE_RTG].gfx_display != changed_prefs.gfx_apmode[APMODE_RTG].gfx_display ? (2|4|8) : 0; c |= currprefs.gfx_blackerthanblack != changed_prefs.gfx_blackerthanblack ? (2 | 8) : 0; @@ -2037,6 +2040,8 @@ int check_prefs_changed_gfx (void) currprefs.gfx_lores_mode = changed_prefs.gfx_lores_mode; currprefs.gfx_scandoubler = changed_prefs.gfx_scandoubler; + currprefs.gfx_threebitcolors = changed_prefs.gfx_threebitcolors; + currprefs.gfx_grayscale = changed_prefs.gfx_grayscale; currprefs.gfx_apmode[APMODE_NATIVE].gfx_display = changed_prefs.gfx_apmode[APMODE_NATIVE].gfx_display; currprefs.gfx_apmode[APMODE_RTG].gfx_display = changed_prefs.gfx_apmode[APMODE_RTG].gfx_display; currprefs.gfx_blackerthanblack = changed_prefs.gfx_blackerthanblack; @@ -4401,7 +4406,7 @@ static BOOL doInit (void) allocsoftbuffer (_T("draw"), &gfxvidinfo.drawbuffer, currentmode->flags, 1600, 1280, currentmode->current_depth); } - if (currprefs.monitoremu || currprefs.cs_cd32fmv || (currprefs.genlock && currprefs.genlock_image)) { + if (currprefs.monitoremu || currprefs.cs_cd32fmv || (currprefs.genlock && currprefs.genlock_image) || currprefs.cs_color_burst || currprefs.gfx_grayscale) { allocsoftbuffer (_T("monemu"), &gfxvidinfo.tempbuffer, currentmode->flags, currentmode->amiga_width > 1024 ? currentmode->amiga_width : 1024, currentmode->amiga_height > 1024 ? currentmode->amiga_height : 1024, -- 2.47.3