From ee610f7e9755451a2f815be0ed14b710fe658171 Mon Sep 17 00:00:00 2001 From: James Wallace Date: Fri, 13 Jan 2023 20:42:16 +0000 Subject: bfm/bfm_bd1.cpp, bfm/bfm_bda.cpp: Fixed window/clear operations. (#10818) Fixes graphical issues in SC5 games. --- src/mame/bfm/bfm_bd1.cpp | 55 ++++++++++-------------------------------------- src/mame/bfm/bfm_bda.cpp | 54 +++++++++++++++++++++-------------------------- 2 files changed, 35 insertions(+), 74 deletions(-) diff --git a/src/mame/bfm/bfm_bd1.cpp b/src/mame/bfm/bfm_bd1.cpp index 8c04f4014c8..9e1e5dd946e 100644 --- a/src/mame/bfm/bfm_bd1.cpp +++ b/src/mame/bfm/bfm_bd1.cpp @@ -238,48 +238,27 @@ void bfm_bd1_device::blank(int data) switch ( data & 0x03 ) { case 0x00: //blank all - for (int i = 0; i < 15; i++) - { - m_attrs[i] = AT_BLANK; - } + std::fill(std::begin(m_attrs), std::end(m_attrs), AT_BLANK); break; case 0x01: // blank inside window if (m_window_size > 0) { - for (int i = m_window_start; i < m_window_end ; i++) - { - m_attrs[i] = AT_BLANK; - } + std::fill_n(m_attrs + m_window_start, m_window_size, AT_BLANK); } break; case 0x02: // blank outside window if (m_window_size > 0) { - if (m_window_start > 0) - { - for (int i = 0; i < m_window_start; i++) - { - m_attrs[i] = AT_BLANK; - } - } + std::fill_n(m_attrs, m_window_start, AT_BLANK); - if (m_window_end < 15 ) - { - for (int i = m_window_end; i < 15- m_window_end ; i++) - { - m_attrs[i] = AT_BLANK; - } - } + std::fill_n(m_attrs + m_window_end, (16 - m_window_end), AT_BLANK); } break; case 0x03: // clear blanking - for (int i = 0; i < 15; i++) - { - m_attrs[i] = 0; - } + std::fill(std::begin(m_attrs), std::end(m_attrs), AT_NORMAL); break; } } @@ -348,7 +327,7 @@ int bfm_bd1_device::write_char(int data) if (m_window_size > 0) { std::fill_n(m_chars + m_window_start, m_window_size, 0); - std::fill_n(m_attrs + m_window_start, m_window_size, 0); + std::fill_n(m_attrs + m_window_start, m_window_size, AT_NORMAL); } break; @@ -356,29 +335,17 @@ int bfm_bd1_device::write_char(int data) case 0x02: // clr outside window if (m_window_size > 0) { - if (m_window_start > 0) - { - for (int i = 0; i < m_window_start; i++) - { - memset(m_chars+i,0,i); - memset(m_attrs+i,0,i); - } - } + std::fill_n(m_chars, m_window_start, 0); + std::fill_n(m_attrs, m_window_start, 0); - if (m_window_end < 15) - { - for (int i = m_window_end; i < 15- m_window_end ; i++) - { - memset(m_chars+i,0,i); - memset(m_attrs+i,0,i); - } - } + std::fill_n(m_chars + m_window_end, (16 - m_window_end), 0); + std::fill_n(m_attrs + m_window_end, (16 - m_window_end), AT_NORMAL); } break; case 0x03: // clr entire display std::fill(std::begin(m_chars), std::end(m_chars), 0); - std::fill(std::begin(m_attrs), std::end(m_attrs), 0); + std::fill(std::begin(m_attrs), std::end(m_attrs), AT_NORMAL); } break; diff --git a/src/mame/bfm/bfm_bda.cpp b/src/mame/bfm/bfm_bda.cpp index 8aa98b0305c..8be4a23947c 100644 --- a/src/mame/bfm/bfm_bda.cpp +++ b/src/mame/bfm/bfm_bda.cpp @@ -141,7 +141,7 @@ void bfm_bda_device::device_reset() (*m_brightness)[0] = 0; std::fill(std::begin(m_chars), std::end(m_chars), 0); - std::fill(std::begin(m_attrs), std::end(m_attrs), 0); + std::fill(std::begin(m_attrs), std::end(m_attrs), AT_NORMAL); } uint16_t bfm_bda_device::set_display(uint16_t segin) @@ -166,49 +166,27 @@ void bfm_bda_device::blank(int data) switch ( data & 0x03 ) // TODO: wrong case values??? { case 0x00: //blank all - for (int i = 0; i < 15; i++) - { - m_attrs[i] = AT_BLANK; - } + std::fill(std::begin(m_attrs), std::end(m_attrs), AT_BLANK); break; - case 0x01: // blank inside window if (m_window_size > 0) { - for (int i = m_window_start; i < m_window_end ; i++) - { - m_attrs[i] = AT_BLANK; - } + std::fill_n(m_attrs + m_window_start, m_window_size, AT_BLANK); } break; case 0x02: // blank outside window if (m_window_size > 0) { - if ( m_window_start > 0 ) - { - for (int i = 0; i < m_window_start; i++) - { - m_attrs[i] = AT_BLANK; - } - } - - if (m_window_end < 15 ) - { - for (int i = m_window_end; i < 15- m_window_end ; i++) - { - m_attrs[i] = AT_BLANK; - } - } + //Do a blank from 0 to the window start, then one from the window end to the display end + std::fill_n(m_attrs + 0, m_window_start, AT_BLANK); + std::fill_n(m_attrs + m_window_end, (16 - m_window_end), AT_BLANK); } break; case 0x03: // clear blanking - for (int i = 0; i < 15; i++) - { - m_attrs[i] = 0; - } + std::fill(std::begin(m_attrs), std::end(m_attrs), AT_NORMAL); break; } } @@ -304,10 +282,26 @@ int bfm_bda_device::write_char(int data) if (m_window_size > 0) { std::fill_n(m_chars + m_window_start, m_window_size, 0); - std::fill_n(m_attrs + m_window_start, m_window_size, 0); + std::fill_n(m_attrs + m_window_start, m_window_size, AT_NORMAL); } break; + + case 0x02: // clr outside window + if (m_window_size > 0) + { + std::fill_n(m_chars, m_window_start, 0); + std::fill_n(m_attrs, m_window_start, AT_NORMAL); + + std::fill_n(m_chars + m_window_end, (16 - m_window_end), 0); + std::fill_n(m_attrs + m_window_end, (16 - m_window_end), AT_NORMAL); + } + break; + + case 0x03: // clr entire display + std::fill(std::begin(m_chars), std::end(m_chars), 0); + std::fill(std::begin(m_attrs), std::end(m_attrs), AT_NORMAL); } + break; } break; -- cgit v1.2.3