summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author MooglyGuy <therealmogminer@gmail.com>2019-06-29 17:49:40 +0200
committer MooglyGuy <therealmogminer@gmail.com>2019-06-29 17:49:55 +0200
commit86b0229ba2687ea9a2bcf8d825b9c0a554304b4b (patch)
tree210c446d04627111b7ecd4e8cfd1918f18a79717
parent35f7b6de846d868929eb75e282c4279024e34216 (diff)
-dpb_brushstore: Finished implementing functionality, needs testing. [Ryan Holtz]
-rw-r--r--src/mame/video/dpb_brushstore.cpp239
-rw-r--r--src/mame/video/dpb_brushstore.h38
2 files changed, 262 insertions, 15 deletions
diff --git a/src/mame/video/dpb_brushstore.cpp b/src/mame/video/dpb_brushstore.cpp
index dd212550e4f..33089a067f2 100644
--- a/src/mame/video/dpb_brushstore.cpp
+++ b/src/mame/video/dpb_brushstore.cpp
@@ -29,9 +29,13 @@ DEFINE_DEVICE_TYPE(DPB7000_BRUSHSTORE, dpb7000_brush_store_card_device, "dpb_bru
dpb7000_brush_store_card_device::dpb7000_brush_store_card_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, DPB7000_BRUSHSTORE, tag, owner, clock)
, m_pal_base(nullptr)
+ , m_pal_addr(0)
+ , m_pal_data(0)
, m_addr(0)
, m_a0_chr(0)
- , m_bck(true)
+ , m_data(0)
+ , m_is_read(false)
+ , m_is_write(false)
, m_lumen(false)
, m_chren(false)
, m_ca0(false)
@@ -39,10 +43,13 @@ dpb7000_brush_store_card_device::dpb7000_brush_store_card_device(const machine_c
, m_fcs(false)
, m_func(0)
, m_b_bus_a(false)
+ , m_data_in(false)
+ , m_fast_wipe(false)
+ , m_store_write(false)
+ , m_oe_brush(false)
+ , m_brush_write(false)
, m_store_write_out(*this)
- , m_k_data_out(*this)
- , m_lum_data_out(*this)
- , m_chr_data_out(*this)
+ , m_data_out{{*this}, {*this}, {*this}}
, m_pal(*this, "pal")
{
}
@@ -59,15 +66,21 @@ const tiny_rom_entry *dpb7000_brush_store_card_device::device_rom_region() const
void dpb7000_brush_store_card_device::device_start()
{
+ save_item(NAME(m_pal_addr));
+ save_item(NAME(m_pal_data));
+
save_item(NAME(m_addr));
save_item(NAME(m_a0_chr));
+ save_item(NAME(m_data));
+
+ save_item(NAME(m_is_read));
+ save_item(NAME(m_is_write));
save_item(NAME(m_ras));
save_item(NAME(m_cas));
save_pointer(NAME(m_rav), STRIPE_COUNT);
save_pointer(NAME(m_cav), STRIPE_COUNT);
- save_item(NAME(m_bck));
save_item(NAME(m_lumen));
save_item(NAME(m_chren));
@@ -79,15 +92,24 @@ void dpb7000_brush_store_card_device::device_start()
save_item(NAME(m_func));
save_item(NAME(m_b_bus_a));
+ save_item(NAME(m_data_in));
+ save_item(NAME(m_fast_wipe));
+ save_item(NAME(m_store_write));
+ save_item(NAME(m_oe));
+ save_item(NAME(m_oe_brush));
+ save_item(NAME(m_brush_write));
+
+ save_item(NAME(m_write_enable));
+ save_item(NAME(m_brush_latches));
+ save_item(NAME(m_input_latches));
+
m_store_write_out.resolve_safe();
- m_k_data_out.resolve_safe();
- m_lum_data_out.resolve_safe();
- m_chr_data_out.resolve_safe();
m_pal_base = m_pal->base();
for (size_t i = 0; i < STRIPE_COUNT; i++)
{
+ m_data_out[i].resolve_safe();
m_stripes[i] = make_unique_clear<uint8_t[]>(0x10000);
save_pointer(NAME(m_stripes[i]), 0x10000, i);
}
@@ -95,15 +117,21 @@ void dpb7000_brush_store_card_device::device_start()
void dpb7000_brush_store_card_device::device_reset()
{
+ m_pal_addr = 0;
+ m_pal_data = 0;
+
m_addr = 0;
m_a0_chr = 0;
+ m_data = 0;
+
+ m_is_read = false;
+ m_is_write = false;
m_ras = false;
m_cas = false;
memset(m_rav, 0, STRIPE_COUNT);
memset(m_cav, 0, STRIPE_COUNT);
- m_bck = true;
m_lumen = false;
m_chren = false;
@@ -115,6 +143,17 @@ void dpb7000_brush_store_card_device::device_reset()
m_func = 0;
m_b_bus_a = false;
+ m_data_in = false;
+ m_fast_wipe = false;
+ m_store_write = false;
+ memset(m_oe, 0, STRIPE_COUNT);
+ m_oe_brush = false;
+ m_brush_write = false;
+
+ memset(m_write_enable, 0, STRIPE_COUNT);
+ memset(m_brush_latches, 0, STRIPE_COUNT);
+ memset(m_input_latches, 0, STRIPE_COUNT);
+
for (size_t i = 0; i < STRIPE_COUNT; i++)
{
memset(&m_stripes[i][0], 0, 0x10000);
@@ -123,11 +162,20 @@ void dpb7000_brush_store_card_device::device_reset()
uint16_t dpb7000_brush_store_card_device::read()
{
- return 0;
+ m_is_read = true;
+ m_is_write = false;
+ uint8_t msb = m_brush_latches[STRIPE_CHR];
+ uint8_t lsb = m_oe[STRIPE_K] ? m_brush_latches[STRIPE_K] : (m_oe[STRIPE_LUM] ? m_brush_latches[STRIPE_LUM] : 0);
+ return (msb << 8) | lsb;
}
void dpb7000_brush_store_card_device::write(uint16_t data)
{
+ m_is_read = false;
+ m_is_write = true;
+ m_data = data;
+ update_input_latches();
+ m_is_write = false;
}
@@ -143,23 +191,73 @@ void dpb7000_brush_store_card_device::a0_chr_w(int state)
void dpb7000_brush_store_card_device::ras_w(int state)
{
+ const bool old = m_ras;
m_ras = (bool)state;
+ if (old && !m_ras)
+ {
+ m_rav[STRIPE_CHR] = (m_addr & ~1) | m_a0_chr;
+ m_rav[STRIPE_K] = m_addr;
+ m_rav[STRIPE_LUM] = m_addr;
+ }
}
void dpb7000_brush_store_card_device::cas_w(int state)
{
+ const bool old = m_cas;
m_cas = (bool)state;
+ if (old && !m_cas)
+ {
+ m_cav[STRIPE_CHR] = (m_addr & ~1) | m_a0_chr;
+ m_cav[STRIPE_K] = m_addr;
+ m_cav[STRIPE_LUM] = m_addr;
+
+ for (size_t i = 0; i < STRIPE_COUNT; i++)
+ {
+ const uint8_t addr = (m_rav[i] << 8) | m_cav[i];
+ if (m_oe_brush && !m_write_enable[i])
+ {
+ m_brush_latches[i] = m_stripes[i][addr];
+ m_data_out[i](m_brush_latches[i]);
+ }
+ else if (m_write_enable[i])
+ {
+ switch (i)
+ {
+ case STRIPE_CHR:
+ m_stripes[i][addr] = m_oe[i] ? m_brush_latches[i] :
+ ((m_fast_wipe && m_ca0) ? m_input_latches[STRIPE_K] : m_input_latches[i]);
+ break;
+ case STRIPE_LUM:
+ m_stripes[i][addr] = m_oe[i] ? m_brush_latches[i] : m_input_latches[i];
+ break;
+ case STRIPE_K:
+ m_stripes[i][addr] = m_oe[STRIPE_LUM] ? m_brush_latches[STRIPE_LUM] : m_input_latches[STRIPE_LUM];
+ break;
+ }
+ }
+ }
+ }
}
void dpb7000_brush_store_card_device::lumen_w(int state)
{
+ const bool old = m_lumen;
m_lumen = (bool)state;
+ if (old != m_lumen)
+ {
+ update_write_enables();
+ }
}
void dpb7000_brush_store_card_device::chren_w(int state)
{
+ const bool old = m_chren;
m_chren = (bool)state;
+ if (old != m_lumen)
+ {
+ update_write_enables();
+ }
}
@@ -170,21 +268,140 @@ void dpb7000_brush_store_card_device::ca0_w(int state)
void dpb7000_brush_store_card_device::ksel_w(int state)
{
+ const bool old = m_ksel;
m_ksel = (bool)state;
+ if (old != m_ksel)
+ {
+ update_pal_addr();
+ update_write_enables();
+ }
}
-
void dpb7000_brush_store_card_device::fcs_w(int state)
{
+ const bool old = m_fcs;
m_fcs = (bool)state;
+ if (old != m_fcs)
+ {
+ update_pal_addr();
+ }
}
void dpb7000_brush_store_card_device::func_w(uint8_t data)
{
+ const uint8_t old = m_func;
m_func = data;
+ if (old != m_func)
+ {
+ update_pal_addr();
+ }
}
void dpb7000_brush_store_card_device::b_bus_a_w(int state)
{
+ const bool old = m_b_bus_a;
m_b_bus_a = (bool)state;
+ if (old != m_b_bus_a)
+ {
+ update_pal_addr();
+ }
+}
+
+void dpb7000_brush_store_card_device::update_pal_addr()
+{
+ const uint8_t old = m_pal_addr;
+ m_pal_addr = m_func;
+ m_pal_addr |= m_ksel ? 0x10 : 0x00;
+ m_pal_addr |= m_b_bus_a ? 0x20 : 0x00;
+ m_pal_addr |= m_fcs ? 0x40 : 0x00;
+ if (old != m_pal_addr)
+ {
+ update_pal_output();
+ }
+}
+
+void dpb7000_brush_store_card_device::update_pal_output()
+{
+ const uint8_t old = m_pal_data;
+ m_pal_data = m_pal_base[m_pal_addr];
+ if (old != m_pal_data)
+ {
+ data_in_w(BIT(m_pal_data, 0));
+ fast_wipe_w(BIT(m_pal_data, 1));
+ store_write_w(BIT(m_pal_data, 2));
+ oe_k_w(BIT(m_pal_data, 3));
+ oe_chr_w(BIT(m_pal_data, 4));
+ oe_lum_w(BIT(m_pal_data, 5));
+ oe_brush_w(BIT(m_pal_data, 6));
+ brush_write_w(BIT(m_pal_data, 7));
+ }
+}
+
+void dpb7000_brush_store_card_device::data_in_w(bool state)
+{
+ m_data_in = state;
+}
+
+void dpb7000_brush_store_card_device::fast_wipe_w(bool state)
+{
+ m_fast_wipe = state;
+}
+
+void dpb7000_brush_store_card_device::store_write_w(bool state)
+{
+ const bool old = m_store_write;
+ m_store_write = state;
+ if (old != m_store_write)
+ {
+ m_store_write_out(!m_store_write);
+ }
+}
+
+void dpb7000_brush_store_card_device::oe_k_w(bool state)
+{
+ m_oe[STRIPE_K] = state;
+}
+
+void dpb7000_brush_store_card_device::oe_chr_w(bool state)
+{
+ m_oe[STRIPE_CHR] = state;
}
+
+void dpb7000_brush_store_card_device::oe_lum_w(bool state)
+{
+ m_oe[STRIPE_LUM] = state;
+}
+
+void dpb7000_brush_store_card_device::oe_brush_w(bool state)
+{
+ m_oe_brush = state;
+}
+
+void dpb7000_brush_store_card_device::brush_write_w(bool state)
+{
+ m_brush_write = state;
+ update_write_enables();
+}
+
+void dpb7000_brush_store_card_device::update_write_enables()
+{
+ m_write_enable[STRIPE_CHR] = m_chren && m_brush_write && !m_ksel;
+ m_write_enable[STRIPE_LUM] = m_lumen && m_brush_write && !m_ksel;
+ m_write_enable[STRIPE_K] = m_lumen && m_brush_write && m_ksel;
+}
+
+void dpb7000_brush_store_card_device::update_input_latches()
+{
+ if (m_is_write && m_data_in)
+ {
+ m_input_latches[STRIPE_LUM] = (uint8_t)m_data;
+ if (!m_ksel)
+ {
+ m_input_latches[STRIPE_CHR] = (uint8_t)(m_data >> 8);
+ }
+ else
+ {
+ m_input_latches[STRIPE_K] = (uint8_t)(m_data >> 8);
+ }
+ }
+} \ No newline at end of file
diff --git a/src/mame/video/dpb_brushstore.h b/src/mame/video/dpb_brushstore.h
index 8909bd31f9c..4698d5aa85c 100644
--- a/src/mame/video/dpb_brushstore.h
+++ b/src/mame/video/dpb_brushstore.h
@@ -50,6 +50,21 @@ protected:
virtual void device_reset() override;
virtual const tiny_rom_entry *device_rom_region() const override;
+ void update_pal_addr();
+ void update_pal_output();
+
+ void data_in_w(bool state);
+ void fast_wipe_w(bool state);
+ void store_write_w(bool state);
+ void oe_k_w(bool state);
+ void oe_chr_w(bool state);
+ void oe_lum_w(bool state);
+ void oe_brush_w(bool state);
+ void brush_write_w(bool state);
+
+ void update_write_enables();
+ void update_input_latches();
+
enum : size_t
{
STRIPE_CHR,
@@ -59,16 +74,21 @@ protected:
};
uint8_t *m_pal_base;
+ uint8_t m_pal_addr;
+ uint8_t m_pal_data;
uint8_t m_addr;
uint8_t m_a0_chr;
+ uint16_t m_data;
+
+ bool m_is_read;
+ bool m_is_write;
bool m_ras;
bool m_cas;
uint8_t m_rav[STRIPE_COUNT];
uint8_t m_cav[STRIPE_COUNT];
- bool m_bck;
bool m_lumen;
bool m_chren;
@@ -80,13 +100,23 @@ protected:
uint8_t m_func;
bool m_b_bus_a;
+ bool m_data_in;
+ bool m_fast_wipe;
+ bool m_store_write;
+ bool m_oe[STRIPE_COUNT];
+ bool m_oe_brush;
+ bool m_brush_write;
+
+ bool m_write_enable[STRIPE_COUNT];
+ uint8_t m_brush_latches[STRIPE_COUNT];
+ uint8_t m_stripe_outputs[STRIPE_COUNT];
+ uint8_t m_input_latches[STRIPE_COUNT]; // AC (Y), AB (U), ABB (V)
+
std::unique_ptr<uint8_t[]> m_stripes[STRIPE_COUNT];
// Output Lines
devcb_write_line m_store_write_out;
- devcb_write8 m_k_data_out;
- devcb_write8 m_lum_data_out;
- devcb_write8 m_chr_data_out;
+ devcb_write8 m_data_out[STRIPE_COUNT];
// Devices
required_memory_region m_pal;