From ac76ec42c7048342b8494ae45b3746dd12806940 Mon Sep 17 00:00:00 2001 From: robcfg Date: Thu, 2 May 2019 22:27:49 +0200 Subject: [PATCH 1/4] Working PAL color blend emulation. Next step is only perfom blend based on the colors luma values. --- src/devices/video/mc6847.cpp | 13 ++++++++++++- src/devices/video/mc6847.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/devices/video/mc6847.cpp b/src/devices/video/mc6847.cpp index 4ef156632b0..9ec19f56e2b 100644 --- a/src/devices/video/mc6847.cpp +++ b/src/devices/video/mc6847.cpp @@ -903,7 +903,14 @@ uint32_t mc6847_base_device::screen_update(screen_device &screen, bitmap_rgb32 & *bitmap_addr(bitmap, y + base_y, x) = border_value(m_data[y].m_mode[width - 1], palette, is_mc6847t1); /* artifacting */ - m_artifacter.process_artifacts<1>(bitmap_addr(bitmap, y + base_y, base_x), m_data[y].m_mode[0], palette); + if( m_artifacter.get_pal_artifacting() ) + { + if( y % 2) + m_artifacter.process_artifacts_pal<1>(bitmap, y - 1, base_x, base_y, m_data[y].m_mode[0], palette); + } + else + m_artifacter.process_artifacts<1>(bitmap_addr(bitmap, y + base_y, base_x), m_data[y].m_mode[0], palette); + } width = m_data[191].m_sample_count; @@ -1675,6 +1682,7 @@ ioport_constructor mc6847_base_device::device_input_ports() const mc6847_base_device::artifacter::artifacter() { + m_palartifacting = false; m_config = nullptr; m_artifacting = 0; m_saved_artifacting = 0; @@ -1824,6 +1832,7 @@ mc6847_ntsc_device::mc6847_ntsc_device(const machine_config &mconfig, const char mc6847_pal_device::mc6847_pal_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : mc6847_base_device(mconfig, MC6847_PAL, tag, owner, clock, pal_square_fontdata8x12, 313.0) { + m_artifacter.set_pal_artifacting(true); } @@ -1846,6 +1855,7 @@ mc6847y_ntsc_device::mc6847y_ntsc_device(const machine_config &mconfig, const ch mc6847y_pal_device::mc6847y_pal_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : mc6847_base_device(mconfig, MC6847Y_PAL, tag, owner, clock, pal_square_fontdata8x12, 313.0) { + m_artifacter.set_pal_artifacting(true); } @@ -1868,6 +1878,7 @@ mc6847t1_ntsc_device::mc6847t1_ntsc_device(const machine_config &mconfig, const mc6847t1_pal_device::mc6847t1_pal_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : mc6847_base_device(mconfig, MC6847T1_PAL, tag, owner, clock, pal_round_fontdata8x12, 313.0) { + m_artifacter.set_pal_artifacting(true); } diff --git a/src/devices/video/mc6847.h b/src/devices/video/mc6847.h index b9e8e02ed4c..c437d1fffd4 100644 --- a/src/devices/video/mc6847.h +++ b/src/devices/video/mc6847.h @@ -179,8 +179,37 @@ protected: // artifacting config void setup_config(device_t *device); void poll_config() { m_artifacting = (m_config!=nullptr) ? m_config->read() : 0; } + void set_pal_artifacting( bool palartifacting ) { m_palartifacting = palartifacting; } + bool get_pal_artifacting() { return m_palartifacting; } // artifacting application + template + void process_artifacts_pal(bitmap_rgb32 &bitmap, int y, int base_x, int base_y, uint8_t mode, const pixel_t *palette) + { + if( !m_artifacting || !m_palartifacting ) + return; + + //if( (mode & (MODE_AS|MODE_GM0)) == MODE_AS ) + { + uint32_t tmpPixel; + pixel_t *line1 = &bitmap.pix32(y + base_y, base_x); + pixel_t *line2 = &bitmap.pix32(y + base_y + 1, base_x); + + for( int pixel = 0; pixel < bitmap.width(); ++pixel ) + { + if( line1[pixel] != line2[pixel] ) + { + tmpPixel = (( ((line1[pixel] & 0xFF0000) >> 16) + ((line2[pixel] & 0xFF0000) >> 16) / 2) << 16); + tmpPixel |= (( ((line1[pixel] & 0xFF00 ) >> 8 ) + ((line2[pixel] & 0xFF00 ) >> 8 ) / 2) << 8 ); + tmpPixel |= ( ( line1[pixel] & 0xFF ) + (line2[pixel] & 0xFF ) ) / 2; + + line1[pixel] = tmpPixel; + line2[pixel] = tmpPixel; + } + } + } + } + template ATTR_FORCE_INLINE void process_artifacts(pixel_t *pixels, uint8_t mode, const pixel_t *palette) { @@ -218,6 +247,7 @@ protected: } private: + bool m_palartifacting; ioport_port *m_config; ioport_value m_artifacting; ioport_value m_saved_artifacting; From 2605c4d24396f689d64f5d86afa2f49ccff34d18 Mon Sep 17 00:00:00 2001 From: robcfg Date: Sat, 4 May 2019 00:30:36 +0200 Subject: [PATCH 2/4] Working blend based on the colors luma values. --- src/devices/video/mc6847.cpp | 19 +++++++++++++++++++ src/devices/video/mc6847.h | 18 +++++++++++++++--- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/devices/video/mc6847.cpp b/src/devices/video/mc6847.cpp index 9ec19f56e2b..6b02acddc7b 100644 --- a/src/devices/video/mc6847.cpp +++ b/src/devices/video/mc6847.cpp @@ -558,6 +558,8 @@ mc6847_base_device::mc6847_base_device(const machine_config &mconfig, device_typ { m_bw_palette[i] = black_and_white(s_palette[i]); } + + m_artifacter.create_luma_table( s_palette ); } @@ -1799,6 +1801,23 @@ mc6847_base_device::pixel_t mc6847_base_device::artifacter::mix_color(double fac +//------------------------------------------------- +// artifacter::create_luma_table +//------------------------------------------------- + +void mc6847_base_device::artifacter::create_luma_table( const pixel_t *palette ) +{ + // Luminance map for PAL color blend. Colors with same luminance value are blendable on a PAL display. + m_luminance_map.insert(std::pair(palette[0],2)); /* GREEN */ + m_luminance_map.insert(std::pair(palette[1],1)); /* YELLOW */ + m_luminance_map.insert(std::pair(palette[2],3)); /* BLUE */ + m_luminance_map.insert(std::pair(palette[3],3)); /* RED */ + m_luminance_map.insert(std::pair(palette[4],1)); /* BUFF */ + m_luminance_map.insert(std::pair(palette[5],2)); /* CYAN */ + m_luminance_map.insert(std::pair(palette[6],2)); /* MAGENTA */ + m_luminance_map.insert(std::pair(palette[7],2)); /* ORANGE */ +} + //************************************************************************** // VARIATIONS //************************************************************************** diff --git a/src/devices/video/mc6847.h b/src/devices/video/mc6847.h index c437d1fffd4..bd0994d23d7 100644 --- a/src/devices/video/mc6847.h +++ b/src/devices/video/mc6847.h @@ -13,7 +13,7 @@ #pragma once #include "screen.h" - +#include //************************************************************************** // MC6847 CONFIGURATION / INTERFACE @@ -181,6 +181,7 @@ protected: void poll_config() { m_artifacting = (m_config!=nullptr) ? m_config->read() : 0; } void set_pal_artifacting( bool palartifacting ) { m_palartifacting = palartifacting; } bool get_pal_artifacting() { return m_palartifacting; } + void create_luma_table( const pixel_t *palette ); // artifacting application template @@ -194,10 +195,18 @@ protected: uint32_t tmpPixel; pixel_t *line1 = &bitmap.pix32(y + base_y, base_x); pixel_t *line2 = &bitmap.pix32(y + base_y + 1, base_x); + std::map::const_iterator luma1; + std::map::const_iterator luma2; - for( int pixel = 0; pixel < bitmap.width(); ++pixel ) + for( int pixel = 0; pixel < bitmap.width() - (base_x * 2); ++pixel ) { - if( line1[pixel] != line2[pixel] ) + if( line1[pixel] == line2[pixel] ) + continue; + + luma1 = m_luminance_map.find( line1[pixel] ); + luma2 = m_luminance_map.find( line2[pixel] ); + + if( luma1 != m_luminance_map.end() && luma2 != m_luminance_map.end() && (luma1->second == luma2->second)) { tmpPixel = (( ((line1[pixel] & 0xFF0000) >> 16) + ((line2[pixel] & 0xFF0000) >> 16) / 2) << 16); tmpPixel |= (( ((line1[pixel] & 0xFF00 ) >> 8 ) + ((line2[pixel] & 0xFF00 ) >> 8 ) / 2) << 8 ); @@ -254,6 +263,9 @@ protected: pixel_t m_saved_c0, m_saved_c1; pixel_t m_expanded_colors[128]; + // PAL color blend emulation values. + std::map m_luminance_map; + void update_colors(pixel_t c0, pixel_t c1); static pixel_t mix_color(double factor, uint8_t c0, uint8_t c1); }; From 4b9988cec162729cac69175078e9329bcb103950 Mon Sep 17 00:00:00 2001 From: robcfg Date: Sun, 5 May 2019 00:39:08 +0200 Subject: [PATCH 3/4] Modified palette with colors taken from real composite video captures. --- src/devices/video/mc6847.cpp | 30 +++++++++++++++--------------- src/devices/video/mc6847.h | 13 ++++++++++--- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/devices/video/mc6847.cpp b/src/devices/video/mc6847.cpp index 6b02acddc7b..f4da1855751 100644 --- a/src/devices/video/mc6847.cpp +++ b/src/devices/video/mc6847.cpp @@ -99,24 +99,24 @@ const uint32_t mc6847_base_device::s_palette[mc6847_base_device::PALETTE_LENGTH] = { - rgb_t(0x07, 0xff, 0x00), /* GREEN */ - rgb_t(0xff, 0xff, 0x00), /* YELLOW */ - rgb_t(0x3b, 0x08, 0xff), /* BLUE */ - rgb_t(0xcc, 0x00, 0x3b), /* RED */ - rgb_t(0xff, 0xff, 0xff), /* BUFF */ - rgb_t(0x07, 0xe3, 0x99), /* CYAN */ - rgb_t(0xff, 0x1c, 0xff), /* MAGENTA */ - rgb_t(0xff, 0x81, 0x00), /* ORANGE */ + rgb_t(0x30, 0xd2, 0x00), /* GREEN */ + rgb_t(0xc1, 0xe5, 0x00), /* YELLOW */ + rgb_t(0x4c, 0x3a, 0xb4), /* BLUE */ + rgb_t(0x9a, 0x32, 0x36), /* RED */ + rgb_t(0xbf, 0xc8, 0xad), /* BUFF */ + rgb_t(0x41, 0xaf, 0x71), /* CYAN */ + rgb_t(0xc8, 0x4e, 0xf0), /* MAGENTA */ + rgb_t(0xd4, 0x7f, 0x00), /* ORANGE */ - rgb_t(0x00, 0x00, 0x00), /* BLACK */ - rgb_t(0x07, 0xff, 0x00), /* GREEN */ - rgb_t(0x00, 0x00, 0x00), /* BLACK */ - rgb_t(0xff, 0xff, 0xff), /* BUFF */ + rgb_t(0x26, 0x30, 0x16), /* BLACK */ + rgb_t(0x30, 0xd2, 0x00), /* GREEN */ + rgb_t(0x26, 0x30, 0x16), /* BLACK */ + rgb_t(0xbf, 0xc8, 0xad), /* BUFF */ rgb_t(0x00, 0x7c, 0x00), /* ALPHANUMERIC DARK GREEN */ - rgb_t(0x07, 0xff, 0x00), /* ALPHANUMERIC BRIGHT GREEN */ - rgb_t(0x91, 0x00, 0x00), /* ALPHANUMERIC DARK ORANGE */ - rgb_t(0xff, 0x81, 0x00) /* ALPHANUMERIC BRIGHT ORANGE */ + rgb_t(0x30, 0xd2, 0x00), /* ALPHANUMERIC BRIGHT GREEN */ + rgb_t(0x6b, 0x27, 0x00), /* ALPHANUMERIC DARK ORANGE */ + rgb_t(0xff, 0xb7, 0x00) /* ALPHANUMERIC BRIGHT ORANGE */ }; diff --git a/src/devices/video/mc6847.h b/src/devices/video/mc6847.h index bd0994d23d7..9903ec3b718 100644 --- a/src/devices/video/mc6847.h +++ b/src/devices/video/mc6847.h @@ -190,6 +190,7 @@ protected: if( !m_artifacting || !m_palartifacting ) return; + // TODO: Create a map of pairs of colors to resulting colors, and convert spaces to tabs. //if( (mode & (MODE_AS|MODE_GM0)) == MODE_AS ) { uint32_t tmpPixel; @@ -208,9 +209,15 @@ protected: if( luma1 != m_luminance_map.end() && luma2 != m_luminance_map.end() && (luma1->second == luma2->second)) { - tmpPixel = (( ((line1[pixel] & 0xFF0000) >> 16) + ((line2[pixel] & 0xFF0000) >> 16) / 2) << 16); - tmpPixel |= (( ((line1[pixel] & 0xFF00 ) >> 8 ) + ((line2[pixel] & 0xFF00 ) >> 8 ) / 2) << 8 ); - tmpPixel |= ( ( line1[pixel] & 0xFF ) + (line2[pixel] & 0xFF ) ) / 2; + /*tmpPixel = (((line1[pixel] & 0xFF000000) >> 25) + ((line2[pixel] & 0xFF000000) >> 24)) << 24; + tmpPixel |= (((line1[pixel] & 0x00FF0000) >> 17) + ((line2[pixel] & 0x00FF0000) >> 16)) << 16; + tmpPixel |= (((line1[pixel] & 0x0000FF00) >> 9) + ((line2[pixel] & 0x0000FF00) >> 8)) << 8; + tmpPixel |= (((line1[pixel] & 0x000000FF) >> 1) + ((line2[pixel] & 0x000000FF) >> 0)); */ + + //tmpPixel = (( ((uint32_t)(line1[pixel] & 0xFF000000) >> 24) + ((uint32_t)(line2[pixel] & 0xFF000000) >> 24) / 2) << 24); + tmpPixel = (( ((uint32_t)(line1[pixel] & 0xFF0000 ) >> 16) + ((uint32_t)(line2[pixel] & 0xFF0000 ) >> 16) / 2) << 16); + tmpPixel |= (( ((uint32_t)(line1[pixel] & 0xFF00 ) >> 8 ) + ((uint32_t)(line2[pixel] & 0xFF00 ) >> 8 ) / 2) << 8 ); + tmpPixel |= ( ((uint32_t) line1[pixel] & 0xFF ) + (uint32_t)(line2[pixel] & 0xFF ) ) / 2; line1[pixel] = tmpPixel; line2[pixel] = tmpPixel; From 1e3781bac1b63ea0a71ffbd9017fb295b7fa1db8 Mon Sep 17 00:00:00 2001 From: robcfg Date: Sun, 5 May 2019 19:46:35 +0200 Subject: [PATCH 4/4] Full support of PAL color blend. --- src/devices/video/mc6847.cpp | 54 ++++++++++++++++++------------- src/devices/video/mc6847.h | 63 ++++++++++++++---------------------- 2 files changed, 55 insertions(+), 62 deletions(-) diff --git a/src/devices/video/mc6847.cpp b/src/devices/video/mc6847.cpp index f4da1855751..3360a48c0e5 100644 --- a/src/devices/video/mc6847.cpp +++ b/src/devices/video/mc6847.cpp @@ -559,7 +559,7 @@ mc6847_base_device::mc6847_base_device(const machine_config &mconfig, device_typ m_bw_palette[i] = black_and_white(s_palette[i]); } - m_artifacter.create_luma_table( s_palette ); + m_artifacter.create_color_blend_table( s_palette ); } @@ -905,14 +905,14 @@ uint32_t mc6847_base_device::screen_update(screen_device &screen, bitmap_rgb32 & *bitmap_addr(bitmap, y + base_y, x) = border_value(m_data[y].m_mode[width - 1], palette, is_mc6847t1); /* artifacting */ - if( m_artifacter.get_pal_artifacting() ) - { - if( y % 2) - m_artifacter.process_artifacts_pal<1>(bitmap, y - 1, base_x, base_y, m_data[y].m_mode[0], palette); - } - else - m_artifacter.process_artifacts<1>(bitmap_addr(bitmap, y + base_y, base_x), m_data[y].m_mode[0], palette); - + if( m_artifacter.get_pal_artifacting() ) + { + if( y % 2) + m_artifacter.process_artifacts_pal<1>(bitmap, y - 1, base_x, base_y, m_data[y].m_mode[0], palette); + } + else + m_artifacter.process_artifacts<1>(bitmap_addr(bitmap, y + base_y, base_x), m_data[y].m_mode[0], palette); + } width = m_data[191].m_sample_count; @@ -1802,20 +1802,28 @@ mc6847_base_device::pixel_t mc6847_base_device::artifacter::mix_color(double fac //------------------------------------------------- -// artifacter::create_luma_table +// artifacter::create_color_blend_table //------------------------------------------------- -void mc6847_base_device::artifacter::create_luma_table( const pixel_t *palette ) +void mc6847_base_device::artifacter::create_color_blend_table( const pixel_t *palette ) { - // Luminance map for PAL color blend. Colors with same luminance value are blendable on a PAL display. - m_luminance_map.insert(std::pair(palette[0],2)); /* GREEN */ - m_luminance_map.insert(std::pair(palette[1],1)); /* YELLOW */ - m_luminance_map.insert(std::pair(palette[2],3)); /* BLUE */ - m_luminance_map.insert(std::pair(palette[3],3)); /* RED */ - m_luminance_map.insert(std::pair(palette[4],1)); /* BUFF */ - m_luminance_map.insert(std::pair(palette[5],2)); /* CYAN */ - m_luminance_map.insert(std::pair(palette[6],2)); /* MAGENTA */ - m_luminance_map.insert(std::pair(palette[7],2)); /* ORANGE */ + // PAL color blend map + m_palcolorblendmap.insert(std::pair,pixel_t>(std::pair(palette[3],palette[2]),rgb_t(0x7c, 0x2e, 0x81))); /* RED-BLUE */ + m_palcolorblendmap.insert(std::pair,pixel_t>(std::pair(palette[2],palette[3]),rgb_t(0x6b, 0x3e, 0x6b))); /* BLUE-RED */ + m_palcolorblendmap.insert(std::pair,pixel_t>(std::pair(palette[7],palette[6]),rgb_t(0xbe, 0x73, 0x65))); /* ORANGE-MAGENTA */ + m_palcolorblendmap.insert(std::pair,pixel_t>(std::pair(palette[6],palette[7]),rgb_t(0xde, 0x5f, 0x6a))); /* MAGENTA-ORANGE */ + m_palcolorblendmap.insert(std::pair,pixel_t>(std::pair(palette[7],palette[5]),rgb_t(0x7e, 0xa2, 0x00))); /* ORANGE-CYAN */ + m_palcolorblendmap.insert(std::pair,pixel_t>(std::pair(palette[5],palette[7]),rgb_t(0x99, 0x8d, 0x3c))); /* CYAN-ORANGE */ + m_palcolorblendmap.insert(std::pair,pixel_t>(std::pair(palette[5],palette[6]),rgb_t(0x82, 0x80, 0xc5))); /* CYAN-MAGENTA */ + m_palcolorblendmap.insert(std::pair,pixel_t>(std::pair(palette[6],palette[5]),rgb_t(0x89, 0x80, 0x9f))); /* MAGENTA-CYAN */ + m_palcolorblendmap.insert(std::pair,pixel_t>(std::pair(palette[0],palette[5]),rgb_t(0x44, 0xb7, 0x1b))); /* GREEN-CYAN */ + m_palcolorblendmap.insert(std::pair,pixel_t>(std::pair(palette[5],palette[0]),rgb_t(0x4a, 0xf2, 0x70))); /* CYAN-GREEN */ + m_palcolorblendmap.insert(std::pair,pixel_t>(std::pair(palette[1],palette[4]),rgb_t(0xdc, 0xd2, 0x57))); /* YELLOW-BUFF */ + m_palcolorblendmap.insert(std::pair,pixel_t>(std::pair(palette[4],palette[1]),rgb_t(0xd1, 0xf6, 0x95))); /* BUFF-YELLOW */ + m_palcolorblendmap.insert(std::pair,pixel_t>(std::pair(palette[0],palette[6]),rgb_t(0xa6, 0x86, 0x10))); /* GREEN-MAGENTA */ + m_palcolorblendmap.insert(std::pair,pixel_t>(std::pair(palette[6],palette[0]),rgb_t(0x6b, 0xbe, 0xb3))); /* MAGENTA-GREEN */ + m_palcolorblendmap.insert(std::pair,pixel_t>(std::pair(palette[0],palette[7]),rgb_t(0x91, 0xc5, 0x3b))); /* GREEN-ORANGE */ + m_palcolorblendmap.insert(std::pair,pixel_t>(std::pair(palette[7],palette[0]),rgb_t(0xad, 0xbc, 0x22))); /* ORANGE-GREEN */ } //************************************************************************** @@ -1851,7 +1859,7 @@ mc6847_ntsc_device::mc6847_ntsc_device(const machine_config &mconfig, const char mc6847_pal_device::mc6847_pal_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : mc6847_base_device(mconfig, MC6847_PAL, tag, owner, clock, pal_square_fontdata8x12, 313.0) { - m_artifacter.set_pal_artifacting(true); + m_artifacter.set_pal_artifacting(true); } @@ -1874,7 +1882,7 @@ mc6847y_ntsc_device::mc6847y_ntsc_device(const machine_config &mconfig, const ch mc6847y_pal_device::mc6847y_pal_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : mc6847_base_device(mconfig, MC6847Y_PAL, tag, owner, clock, pal_square_fontdata8x12, 313.0) { - m_artifacter.set_pal_artifacting(true); + m_artifacter.set_pal_artifacting(true); } @@ -1897,7 +1905,7 @@ mc6847t1_ntsc_device::mc6847t1_ntsc_device(const machine_config &mconfig, const mc6847t1_pal_device::mc6847t1_pal_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : mc6847_base_device(mconfig, MC6847T1_PAL, tag, owner, clock, pal_round_fontdata8x12, 313.0) { - m_artifacter.set_pal_artifacting(true); + m_artifacter.set_pal_artifacting(true); } diff --git a/src/devices/video/mc6847.h b/src/devices/video/mc6847.h index 9903ec3b718..c2923d50016 100644 --- a/src/devices/video/mc6847.h +++ b/src/devices/video/mc6847.h @@ -179,52 +179,37 @@ protected: // artifacting config void setup_config(device_t *device); void poll_config() { m_artifacting = (m_config!=nullptr) ? m_config->read() : 0; } - void set_pal_artifacting( bool palartifacting ) { m_palartifacting = palartifacting; } - bool get_pal_artifacting() { return m_palartifacting; } - void create_luma_table( const pixel_t *palette ); + void set_pal_artifacting( bool palartifacting ) { m_palartifacting = palartifacting; } + bool get_pal_artifacting() { return m_palartifacting; } + void create_color_blend_table( const pixel_t *palette ); // artifacting application template void process_artifacts_pal(bitmap_rgb32 &bitmap, int y, int base_x, int base_y, uint8_t mode, const pixel_t *palette) { - if( !m_artifacting || !m_palartifacting ) - return; + if( !m_artifacting || !m_palartifacting ) + return; - // TODO: Create a map of pairs of colors to resulting colors, and convert spaces to tabs. - //if( (mode & (MODE_AS|MODE_GM0)) == MODE_AS ) - { - uint32_t tmpPixel; - pixel_t *line1 = &bitmap.pix32(y + base_y, base_x); - pixel_t *line2 = &bitmap.pix32(y + base_y + 1, base_x); - std::map::const_iterator luma1; - std::map::const_iterator luma2; + if( (mode & MODE_AS) || ((mode & (MODE_AG|MODE_GM0) ) == MODE_AG) ) + { + pixel_t *line1 = &bitmap.pix32(y + base_y, base_x); + pixel_t *line2 = &bitmap.pix32(y + base_y + 1, base_x); + std::map,pixel_t>::const_iterator newColor; - for( int pixel = 0; pixel < bitmap.width() - (base_x * 2); ++pixel ) - { - if( line1[pixel] == line2[pixel] ) - continue; + for( int pixel = 0; pixel < bitmap.width() - (base_x * 2); ++pixel ) + { + if( line1[pixel] == line2[pixel] ) + continue; - luma1 = m_luminance_map.find( line1[pixel] ); - luma2 = m_luminance_map.find( line2[pixel] ); - - if( luma1 != m_luminance_map.end() && luma2 != m_luminance_map.end() && (luma1->second == luma2->second)) - { - /*tmpPixel = (((line1[pixel] & 0xFF000000) >> 25) + ((line2[pixel] & 0xFF000000) >> 24)) << 24; - tmpPixel |= (((line1[pixel] & 0x00FF0000) >> 17) + ((line2[pixel] & 0x00FF0000) >> 16)) << 16; - tmpPixel |= (((line1[pixel] & 0x0000FF00) >> 9) + ((line2[pixel] & 0x0000FF00) >> 8)) << 8; - tmpPixel |= (((line1[pixel] & 0x000000FF) >> 1) + ((line2[pixel] & 0x000000FF) >> 0)); */ - - //tmpPixel = (( ((uint32_t)(line1[pixel] & 0xFF000000) >> 24) + ((uint32_t)(line2[pixel] & 0xFF000000) >> 24) / 2) << 24); - tmpPixel = (( ((uint32_t)(line1[pixel] & 0xFF0000 ) >> 16) + ((uint32_t)(line2[pixel] & 0xFF0000 ) >> 16) / 2) << 16); - tmpPixel |= (( ((uint32_t)(line1[pixel] & 0xFF00 ) >> 8 ) + ((uint32_t)(line2[pixel] & 0xFF00 ) >> 8 ) / 2) << 8 ); - tmpPixel |= ( ((uint32_t) line1[pixel] & 0xFF ) + (uint32_t)(line2[pixel] & 0xFF ) ) / 2; - - line1[pixel] = tmpPixel; - line2[pixel] = tmpPixel; - } - } - } - } + newColor = m_palcolorblendmap.find(std::pair(line1[pixel],line2[pixel])); + if( newColor != m_palcolorblendmap.end() ) + { + line1[pixel] = newColor->second; + line2[pixel] = newColor->second; + } + } + } + } template ATTR_FORCE_INLINE void process_artifacts(pixel_t *pixels, uint8_t mode, const pixel_t *palette) @@ -271,7 +256,7 @@ protected: pixel_t m_expanded_colors[128]; // PAL color blend emulation values. - std::map m_luminance_map; + std::map,pixel_t> m_palcolorblendmap; void update_colors(pixel_t c0, pixel_t c1); static pixel_t mix_color(double factor, uint8_t c0, uint8_t c1);