From ac76ec42c7048342b8494ae45b3746dd12806940 Mon Sep 17 00:00:00 2001 From: robcfg Date: Thu, 2 May 2019 22:27:49 +0200 Subject: [PATCH] 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;