summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author Vincent-Halver <Vincent.Halver@gmail.com>2025-07-06 10:29:48 -0700
committer GitHub <noreply@github.com>2025-07-07 03:29:48 +1000
commit681ed6f9667c6ebe052d498d7f3a08127f5500d5 (patch)
tree705a6d0ca33215feb8cf12b06d0a14c38ec8f7b4 /src
parented2a32944a8a416c859418aa91f42c179593f4b8 (diff)
philips/mcd212.cpp: Implemented cursor blinking (GitHub #13522). (#13624)
Diffstat (limited to 'src')
-rw-r--r--src/mame/philips/mcd212.cpp74
-rw-r--r--src/mame/philips/mcd212.h9
2 files changed, 52 insertions, 31 deletions
diff --git a/src/mame/philips/mcd212.cpp b/src/mame/philips/mcd212.cpp
index bb5f0987231..d8ab64377dc 100644
--- a/src/mame/philips/mcd212.cpp
+++ b/src/mame/philips/mcd212.cpp
@@ -740,39 +740,36 @@ void mcd212_device::mix_lines(uint32_t *plane_a, bool *transparent_a, uint32_t *
void mcd212_device::draw_cursor(uint32_t *scanline)
{
if (!(m_cursor_control & CURCNT_EN))
+ return; // Cursor is Disabled
+
+ uint8_t color_index = m_cursor_control & CURCNT_COLOR;
+ if (m_blink_active)
{
- return;
+ const bool invert = BIT(m_cursor_control, CURCNT_BLKC_SHIFT);
+ if (!invert)
+ return; // Normal Blink
+ else
+ color_index = ~color_index & 0xf; // Inverted Color Blink
}
- uint16_t y = (uint16_t)screen().vpos();
- const uint16_t cursor_x = m_cursor_position & 0x3ff;
+ const uint16_t cursor_x = m_cursor_position & 0x3ff;
const uint16_t cursor_y = ((m_cursor_position >> 12) & 0x3ff) + m_ica_height;
- if (y >= cursor_y && y < (cursor_y + 16))
+ const int32_t y = screen().vpos() - cursor_y;
+ const int width = get_screen_width();
+
+ if ((0 <= y) && (y < 16))
{
- const int width = get_screen_width();
- uint32_t color = s_4bpp_color[m_cursor_control & CURCNT_COLOR];
- y -= cursor_y;
- if (m_cursor_control & CURCNT_CUW)
- {
- for (int x = cursor_x; x < cursor_x + 64 && x < width; x++)
- {
- if (m_cursor_pattern[y] & (1 << (15 - ((x - cursor_x) >> 2))))
- {
- scanline[x++] = color;
- scanline[x++] = color;
- scanline[x++] = color;
- scanline[x] = color;
- }
- }
- }
- else
+ const uint32_t color = s_4bpp_color[color_index];
+ const uint8_t resolution = (m_cursor_control & CURCNT_CUW) ? 4 : 2;
+ for (int x = 0; x < 16; x++)
{
- for (int x = cursor_x; x < cursor_x + 32 && x < width; x++)
+ if (BIT(m_cursor_pattern[y], 15 - x))
{
- if (m_cursor_pattern[y] & (1 << (15 - ((x - cursor_x) >> 1))))
+ for (uint32_t j = 0; j < resolution; j++)
{
- scanline[x++] = color;
- scanline[x] = color;
+ const uint32_t index = cursor_x + x * resolution + j;
+ if (index < width)
+ scanline[index] = color;
}
}
}
@@ -943,6 +940,21 @@ TIMER_CALLBACK_MEMBER(mcd212_device::ica_tick)
m_dca[1] = get_dcp<1>();
m_ica_timer->adjust(screen().time_until_pos(0, 0));
+
+ // Cursor Blink
+ m_blink_time += 5 + BIT(m_dcr[0], DCR_FD_BIT); // FD bit * 8... Page 4-3 MCD
+ // Adjust the blink time once per frame
+ if (!m_blink_active && (m_blink_time >= ((m_cursor_control & CURCNT_CON) >> CURCNT_CON_SHIFT) * 60))
+ {
+ m_blink_active = true;
+ m_blink_time = 0;
+ }
+ // If blink off time is 0, immediately turn back on.
+ if (m_blink_active && (m_blink_time >= ((m_cursor_control & CURCNT_COF) >> CURCNT_COF_SHIFT) * 60))
+ {
+ m_blink_active = false;
+ m_blink_time = 0;
+ }
}
TIMER_CALLBACK_MEMBER(mcd212_device::dca_tick)
@@ -1121,6 +1133,7 @@ void mcd212_device::device_reset()
m_ica_height = 32;
m_total_height = 312;
+ m_blink_time = 0;
m_int_callback(CLEAR_LINE);
@@ -1169,10 +1182,6 @@ void mcd212_device::device_start()
m_dyuv_v_to_r[sw] = (351 * (sw - 128)) / 256;
}
- save_item(NAME(m_matte_flag[0]));
- save_item(NAME(m_matte_flag[1]));
- save_item(NAME(m_ica_height));
- save_item(NAME(m_total_height));
save_item(NAME(m_csrr));
save_item(NAME(m_csrw));
save_item(NAME(m_dcr));
@@ -1197,6 +1206,13 @@ void mcd212_device::device_start()
save_item(NAME(m_weight_factor[0]));
save_item(NAME(m_weight_factor[1]));
+ save_item(NAME(m_matte_flag));
+ save_item(NAME(m_ica_height));
+ save_item(NAME(m_total_height));
+
+ save_item(NAME(m_blink_time));
+ save_item(NAME(m_blink_active));
+
m_dca_timer = timer_alloc(FUNC(mcd212_device::dca_tick), this);
m_dca_timer->adjust(attotime::never);
diff --git a/src/mame/philips/mcd212.h b/src/mame/philips/mcd212.h
index 5fc8e609c78..095e4c3a6b4 100644
--- a/src/mame/philips/mcd212.h
+++ b/src/mame/philips/mcd212.h
@@ -88,10 +88,11 @@ protected:
{
CURCNT_COLOR = 0x00000f, // Cursor color
CURCNT_CUW = 0x008000, // Cursor width
- CURCNT_COF = 0x070000, // Cursor off time
CURCNT_COF_SHIFT = 16,
- CURCNT_CON = 0x280000, // Cursor on time
+ CURCNT_COF = 0b111 << CURCNT_COF_SHIFT, // Cursor off time
CURCNT_CON_SHIFT = 19,
+ CURCNT_CON = 0b111 << CURCNT_CON_SHIFT, // Cursor on time
+ CURCNT_BLKC_SHIFT = 22,
CURCNT_BLKC = 0x400000, // Blink type
CURCNT_EN = 0x800000, // Cursor enable
@@ -235,6 +236,10 @@ protected:
emu_timer *m_ica_timer = nullptr;
emu_timer *m_dca_timer = nullptr;
+ // Cursor State
+ uint16_t m_blink_time; // Counter that tracks how long since the last m_blink_active last changed.
+ bool m_blink_active = false;
+
static const uint32_t s_4bpp_color[16];
uint8_t get_weight_factor(const uint32_t Matte_idx);