-dpb_combiner: Hooked up clocked logic and screen device. [Ryan Holtz]

This commit is contained in:
mooglyguy 2019-06-17 21:06:11 +02:00
parent c3e19ca3ad
commit c1e1e1122c
3 changed files with 162 additions and 19 deletions

View File

@ -217,6 +217,15 @@ public:
m_height = vtotal;
m_visarea.set(hbend, hbstart - 1, vbend, vbstart - 1);
}
void set_raw_fractional(u32 pixclock, double htotal, double hbend, double hbstart, double vtotal, double vbend, double vbstart)
{
m_clock = pixclock;
m_refresh = HZ_TO_ATTOSECONDS(pixclock) * htotal * vtotal;
m_vblank = m_refresh / vtotal * (vtotal - (vbstart - vbend));
m_width = (int)ceil(htotal);
m_height = (int)ceil(vtotal);
m_visarea.set((int)ceil(hbend), (int)floor(hbstart) - 1, (int)ceil(vbend), (int)floor(vbstart) - 1);
}
void set_raw(const XTAL &xtal, u16 htotal, u16 hbend, u16 hbstart, u16 vtotal, u16 vbend, u16 vbstart) { set_raw(xtal.value(), htotal, hbend, hbstart, vtotal, vbend, vbstart); }
void set_refresh(attoseconds_t rate) { m_refresh = rate; }
template <typename T> void set_refresh_hz(T &&hz) { set_refresh(HZ_TO_ATTOSECONDS(std::forward<T>(hz))); }

View File

@ -27,18 +27,24 @@ DEFINE_DEVICE_TYPE(DPB7000_COMBINER, dpb7000_combiner_card_device, "dpb_combiner
dpb7000_combiner_card_device::dpb7000_combiner_card_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, DPB7000_COMBINER, tag, owner, clock)
, m_latched_lum_sum(0)
, m_latched_chr_sum(0)
, m_lum_out(0)
, m_chr_out(0)
, m_chr_i_in(false)
, m_chr_i(false)
, m_palette_l(false)
, m_cursor_enb(false)
, m_cursor_col(false)
, m_cursor_luma(0)
, m_fsck(false)
, m_cursor_y(0)
, m_cursor_u(0)
, m_cursor_v(0)
, m_invert_mask(0)
, m_lum(*this)
, m_chr(*this)
, m_fsck(nullptr)
, m_fsck_timer(nullptr)
, m_screen(*this, "screen")
, m_mult_ge(*this, "mult_ge") // Lum I
, m_mult_gd(*this, "mult_gd") // Lum II
, m_mult_gc(*this, "mult_gc") // Chroma I
@ -51,18 +57,21 @@ void dpb7000_combiner_card_device::device_start()
{
save_item(NAME(m_lum_in));
save_item(NAME(m_latched_lum));
save_item(NAME(m_selected_lum));
save_item(NAME(m_chr_in));
save_item(NAME(m_latched_chr));
save_item(NAME(m_selected_chr));
save_item(NAME(m_ext_in));
save_item(NAME(m_blank_lum));
save_item(NAME(m_blank));
save_item(NAME(m_chr_i_in));
save_item(NAME(m_chr_i));
save_item(NAME(m_palette_l));
save_item(NAME(m_cursor_enb));
save_item(NAME(m_cursor_col));
save_item(NAME(m_fsck));
save_item(NAME(m_cursor_luma));
save_item(NAME(m_cursor_y));
save_item(NAME(m_cursor_u));
save_item(NAME(m_cursor_v));
save_item(NAME(m_invert_mask));
@ -72,26 +81,44 @@ void dpb7000_combiner_card_device::device_start()
save_item(NAME(m_matte_u));
save_item(NAME(m_matte_v));
save_item(NAME(m_blank_or_suppress));
save_item(NAME(m_output_matte_y));
save_item(NAME(m_output_matte_u));
save_item(NAME(m_output_matte_v));
save_item(NAME(m_output_matte_ext));
m_lum.resolve_safe();
m_chr.resolve_safe();
m_fsck_timer = timer_alloc(FSCK_TIMER);
m_fsck_timer->adjust(attotime::never);
}
void dpb7000_combiner_card_device::device_reset()
{
memset(m_lum_in, 0, 2);
memset(m_latched_lum, 0, 2);
memset(m_selected_lum, 0, 2);
memset(m_chr_in, 0, 2);
memset(m_latched_chr, 0, 2);
memset(m_selected_lum, 0, 2);
memset(m_ext_in, 0, 2);
memset(m_blank_lum, 0, 2);
memset(m_blank, 0, 2);
m_chr_i_in = false;
m_chr_i = false;
m_palette_l = false;
m_cursor_enb = false;
m_cursor_col = false;
m_fsck = false;
m_cursor_luma = 0;
memset(m_blank_or_suppress, 0, 2);
memset(m_output_matte_y, 0, 2);
memset(m_output_matte_u, 0, 2);
memset(m_output_matte_v, 0, 2);
memset(m_output_matte_ext, 0, 2);
m_cursor_y = 0;
m_cursor_u = 0;
m_cursor_v = 0;
m_invert_mask = 0;
@ -100,6 +127,8 @@ void dpb7000_combiner_card_device::device_reset()
memset(m_matte_y, 0, 2);
memset(m_matte_u, 0, 2);
memset(m_matte_v, 0, 2);
m_fsck_timer->adjust(attotime::from_hz(clock()), 0, attotime::from_hz(clock()));
}
void dpb7000_combiner_card_device::device_add_mconfig(machine_config &config)
@ -109,18 +138,84 @@ void dpb7000_combiner_card_device::device_add_mconfig(machine_config &config)
TMC28KU(config, m_mult_gc);
TMC28KU(config, m_mult_gb);
TMC28KU(config, m_mult_ga);
SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
m_screen->set_raw_fractional(clock(), 910, 0, 640, 262.5, 0, 240);
m_screen->set_screen_update(FUNC(dpb7000_combiner_card_device::screen_update));
}
void dpb7000_combiner_card_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
if (id == FSCK_TIMER)
{
fsck_tick();
m_fsck = !m_fsck;
if (m_fsck)
{
fsck_tick();
}
}
}
void dpb7000_combiner_card_device::fsck_tick()
{
for (int i = 0; i < 2; i++)
{
m_latched_lum[i] = m_lum_in[i];
m_latched_chr[i] = m_chr_in[i];
m_selected_lum[i] = m_output_matte_y[i] ? m_matte_y[i] : m_latched_lum[i];
m_selected_chr[i] = m_output_matte_u[i] ? m_matte_u[i] : (m_output_matte_v[i] ? m_matte_v[i] : m_latched_chr[i]);
m_selected_ext[i] = m_output_matte_ext[i] ? m_matte_ext[i] : m_ext_in[i];
}
// MPY-8HUJ GA
const uint8_t ext_product = m_palette_l ? (((uint16_t)m_selected_ext[0] * (uint16_t)m_selected_ext[1] + 0x80) >> 8) : 0xff;
// 74LS175 FF and 74S157 FG
const bool y1 = (bool)(m_palette_l ? BIT(m_invert_mask, 3) : BIT(m_invert_mask, 4));
const bool y2 = !y1;
// 74S86 EE/EF/FD/FE
const uint8_t a = ext_product ^ (y1 ? 0xff : 0x00);
const uint8_t b = ext_product ^ (y2 ? 0xff : 0x00);
// MPY-8HUJ GE
const uint8_t lum1_product = ((uint16_t)m_selected_lum[0] * (uint16_t)a + 0x80) >> 8;
// MPY-8HUJ GD
const uint8_t lum2_product = ((uint16_t)m_selected_lum[1] * (uint16_t)b + 0x80) >> 8;
// MPY-8HUJ GC
const uint8_t chr1_product = ((uint16_t)m_selected_chr[0] * (uint16_t)a + 0x80) >> 8;
// MPY-8HUJ GB
const uint8_t chr2_product = ((uint16_t)m_selected_chr[1] * (uint16_t)b + 0x80) >> 8;
// 74S283 FC/ED, 74S374 DD
m_latched_lum_sum = lum1_product + lum2_product;
// 74S283 FB/EC, 74S374 DC
m_latched_chr_sum = chr1_product + chr2_product;
m_lum_out = m_cursor_enb ? (m_cursor_col ? (m_chr_i ? m_cursor_u : m_cursor_v) : 0x7f) : m_latched_lum_sum;
m_chr_out = m_cursor_enb ? (m_cursor_col ? m_cursor_y : 0x7f) : m_latched_chr_sum;
m_lum(m_lum_out);
m_chr(m_chr_out);
m_screen->update_now();
}
uint32_t dpb7000_combiner_card_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
for (int y = cliprect.min_y; y <= cliprect.max_y; y++)
{
uint32_t *dest = &bitmap.pix32(y, cliprect.min_x);
for (int x = cliprect.min_x; x <= cliprect.max_x && x < 256; x++)
{
*dest++ = 0xff000000 | (m_lum_out << 16) | (m_lum_out << 8) | m_lum_out;
}
}
return 0;
}
void dpb7000_combiner_card_device::reg_w(uint16_t data)
@ -130,7 +225,7 @@ void dpb7000_combiner_card_device::reg_w(uint16_t data)
switch ((data >> 10) & 0xf)
{
case 1: // CY
m_cursor_luma = (uint8_t)data;
m_cursor_y = (uint8_t)data;
break;
case 2: // CU
m_cursor_u = (uint8_t)data;
@ -140,6 +235,7 @@ void dpb7000_combiner_card_device::reg_w(uint16_t data)
break;
case 4: // ES
m_invert_mask = (uint8_t)data;
update_matte_selects();
break;
case 5: // EI
m_matte_ext[0] = (uint8_t)data;
@ -149,6 +245,7 @@ void dpb7000_combiner_card_device::reg_w(uint16_t data)
break;
case 8: // IS
m_select_matte[0] = BIT(data, 0);
update_matte_selects();
break;
case 9: // IY
m_matte_y[0] = (uint8_t)data;
@ -161,6 +258,7 @@ void dpb7000_combiner_card_device::reg_w(uint16_t data)
break;
case 12: // IIS
m_select_matte[1] = BIT(data, 0);
update_matte_selects();
break;
case 13: // IIY
m_matte_y[1] = (uint8_t)data;
@ -184,14 +282,16 @@ void dpb7000_combiner_card_device::lum2_w(uint8_t data)
m_lum_in[1] = data;
}
void dpb7000_combiner_card_device::blank_lum1(int state)
void dpb7000_combiner_card_device::blank1(int state)
{
m_blank_lum[0] = (bool)state;
m_blank[0] = (bool)state;
update_matte_selects();
}
void dpb7000_combiner_card_device::blank_lum2(int state)
void dpb7000_combiner_card_device::blank2(int state)
{
m_blank_lum[1] = (bool)state;
m_blank[1] = (bool)state;
update_matte_selects();
}
void dpb7000_combiner_card_device::chr1_w(uint8_t data)
@ -207,21 +307,23 @@ void dpb7000_combiner_card_device::chr2_w(uint8_t data)
void dpb7000_combiner_card_device::chr_flag_w(int state)
{
m_chr_i_in = (bool)state;
update_matte_selects();
}
void dpb7000_combiner_card_device::ext1_w(uint8_t data)
{
m_ext_in[0] = data;
m_ext_in[0] = BIT(m_invert_mask, 4) ? (data ^ 0xff) : data;
}
void dpb7000_combiner_card_device::ext2_w(uint8_t data)
{
m_ext_in[1] = data;
m_ext_in[1] = BIT(m_invert_mask, 4) ? (data ^ 0xff) : data;
}
void dpb7000_combiner_card_device::palette_l_w(int state)
{
m_palette_l = (bool)state;
update_matte_selects();
}
void dpb7000_combiner_card_device::cursor_enb_w(int state)
@ -233,3 +335,15 @@ void dpb7000_combiner_card_device::cursor_col_w(int state)
{
m_cursor_col = (bool)state;
}
void dpb7000_combiner_card_device::update_matte_selects()
{
for (int i = 0; i < 2; i++)
{
m_blank_or_suppress[i] = m_select_matte[i] || m_blank[i];
m_output_matte_y[i] = m_blank_or_suppress[i] && m_palette_l;
m_output_matte_u[i] = m_output_matte_y[i] && m_chr_i;
m_output_matte_v[i] = m_output_matte_y[i] && !m_chr_i;
m_output_matte_ext[i] = !BIT(m_invert_mask, i) && m_blank[i];
}
}

View File

@ -16,6 +16,7 @@
#pragma once
#include "machine/tmc208k.h"
#include "screen.h"
//**************************************************************************
@ -33,8 +34,8 @@ public:
void reg_w(uint16_t data);
void lum1_w(uint8_t data);
void lum2_w(uint8_t data);
void blank_lum1(int state);
void blank_lum2(int state);
void blank1(int state);
void blank2(int state);
void chr1_w(uint8_t data);
void chr2_w(uint8_t data);
void chr_flag_w(int state);
@ -58,20 +59,32 @@ protected:
void fsck_tick();
uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
void update_matte_selects();
uint8_t m_lum_in[2];
uint8_t m_latched_lum[2];
uint8_t m_selected_lum[2];
uint8_t m_chr_in[2];
uint8_t m_latched_chr[2];
uint8_t m_selected_chr[2];
uint8_t m_ext_in[2];
uint8_t m_selected_ext[2];
uint8_t m_latched_lum_sum;
uint8_t m_latched_chr_sum;
uint8_t m_lum_out;
uint8_t m_chr_out;
bool m_blank_lum[2];
bool m_blank[2];
bool m_chr_i_in;
bool m_chr_i;
bool m_palette_l;
bool m_cursor_enb;
bool m_cursor_col;
bool m_fsck;
uint8_t m_cursor_luma;
uint8_t m_cursor_y;
uint8_t m_cursor_u;
uint8_t m_cursor_v;
uint8_t m_invert_mask;
@ -81,11 +94,18 @@ protected:
uint8_t m_matte_u[2];
uint8_t m_matte_v[2];
bool m_blank_or_suppress[2]; // FH
bool m_output_matte_y[2]; // EB
bool m_output_matte_u[2]; // EG
bool m_output_matte_v[2]; // EG
bool m_output_matte_ext[2]; // FA
devcb_write8 m_lum;
devcb_write8 m_chr;
emu_timer *m_fsck;
emu_timer *m_fsck_timer;
required_device<screen_device> m_screen;
required_device<tmc28ku_device> m_mult_ge;
required_device<tmc28ku_device> m_mult_gd;
required_device<tmc28ku_device> m_mult_gc;