summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Lord-Nightmare <Lord-Nightmare@users.noreply.github.com>2020-07-05 22:21:22 -0400
committer Lord-Nightmare <Lord-Nightmare@users.noreply.github.com>2020-07-05 22:21:22 -0400
commit261fe5d3bd85a277df42c3e6264d1a2b105b3830 (patch)
tree2026ad8406c0b5e17d0fa6aa31f59ebbc00e588b
parent0fa6e8255b5a866ad0b42157653d7194cbc1738c (diff)
Williams System 11C "background" Audio Board: Add PIA portb and cb2 write callbacks and synchronize fences, and hook them up, this fixes the "MUSIC ERROR" and various bg-music feedback-triggered sounds in Williams System 11C pinballs, i.e. the "song" in Dr. Dude works correctly now. This is also preparation for renaming this device to "Williams D-11581 Audio Board" as the same PCB is also used on some Midway Y-unit arcade games, some Williams System 11A pinballs and all Williams System 11B pinballs (except Jokerz), not just on Williams System 11C pinballs. [Lord Nightmare]
-rw-r--r--src/mame/audio/s11c_bg.cpp50
-rw-r--r--src/mame/audio/s11c_bg.h29
-rw-r--r--src/mame/drivers/s11c.cpp21
-rw-r--r--src/mame/includes/s11c.h2
4 files changed, 58 insertions, 44 deletions
diff --git a/src/mame/audio/s11c_bg.cpp b/src/mame/audio/s11c_bg.cpp
index c57804523ad..acb8850242b 100644
--- a/src/mame/audio/s11c_bg.cpp
+++ b/src/mame/audio/s11c_bg.cpp
@@ -24,6 +24,8 @@ s11c_bg_device::s11c_bg_device(const machine_config &mconfig, const char *tag, d
, m_pia40(*this, "pia40")
, m_cpubank(*this, "bgbank")
, m_rom(*this, finder_base::DUMMY_TAG)
+ , m_cb2_cb(*this)
+ , m_pb_cb(*this)
{
}
@@ -38,19 +40,42 @@ void s11c_bg_device::s11c_bg_map(address_map &map)
map(0x8000, 0xffff).bankr("bgbank");
}
+TIMER_CALLBACK_MEMBER(s11c_bg_device::deferred_cb2_w)
+{
+ if (!m_cb2_cb.isnull())
+ m_cb2_cb(param);
+ else
+ logerror("S11C_BG CB2 writeback called, but callback is not registered!\n");
+}
+
+TIMER_CALLBACK_MEMBER(s11c_bg_device::deferred_pb_w)
+{
+ if (!m_pb_cb.isnull())
+ m_pb_cb(param);
+ else
+ logerror("S11C_BG PB writeback called, but callback is not registered!\n");
+}
+
+
WRITE_LINE_MEMBER( s11c_bg_device::pia40_cb2_w)
{
-// m_pia34->cb1_w(state); // To Widget MCB1 through CPU Data interface
+ machine().scheduler().synchronize(timer_expired_delegate(FUNC(s11c_bg_device::deferred_cb2_w),this), state);
}
void s11c_bg_device::pia40_pb_w(uint8_t data)
{
-// m_pia34->portb_w(data);
+ machine().scheduler().synchronize(timer_expired_delegate(FUNC(s11c_bg_device::deferred_pb_w),this), data);
}
-void s11c_bg_device::ctrl_w(uint8_t data)
+
+WRITE_LINE_MEMBER( s11c_bg_device::extra_w )
+{
+ m_pia40->cb2_w(state);
+}
+
+WRITE_LINE_MEMBER( s11c_bg_device::ctrl_w )
{
- m_pia40->cb1_w(data);
+ m_pia40->cb1_w(state);
}
void s11c_bg_device::data_w(uint8_t data)
@@ -65,15 +90,15 @@ void s11c_bg_device::device_add_mconfig(machine_config &config)
config.set_maximum_quantum(attotime::from_hz(50));
YM2151(config, m_ym2151, XTAL(3'579'545)); // "3.58 MHz" on schematics and parts list
- m_ym2151->irq_handler().set(FUNC(s11c_bg_device::ym2151_irq_w));
- m_ym2151->add_route(ALL_OUTPUTS, *this, 0.25);
+ m_ym2151->irq_handler().set(m_pia40, FUNC(pia6821_device::ca1_w)).invert(); // IRQ is not true state
+ m_ym2151->add_route(ALL_OUTPUTS, *this, 0.1);
MC1408(config, "dac", 0).add_route(ALL_OUTPUTS, *this, 0.25);
voltage_regulator_device &vref(VOLTAGE_REGULATOR(config, "vref"));
vref.add_route(0, "dac", 1.0, DAC_VREF_POS_INPUT);
vref.add_route(0, "dac", -1.0, DAC_VREF_NEG_INPUT);
- HC55516(config, m_hc55516, 0).add_route(ALL_OUTPUTS, *this, 0.5);
+ HC55516(config, m_hc55516, 0).add_route(ALL_OUTPUTS, *this, 0.6);
PIA6821(config, m_pia40, 0);
m_pia40->writepa_handler().set("dac", FUNC(dac_byte_interface::data_w));
@@ -86,6 +111,9 @@ void s11c_bg_device::device_add_mconfig(machine_config &config)
void s11c_bg_device::device_start()
{
+ /* resolve lines */
+ m_cb2_cb.resolve();
+ m_pb_cb.resolve();
}
void s11c_bg_device::device_reset()
@@ -96,14 +124,6 @@ void s11c_bg_device::device_reset()
m_cpu->pulse_input_line(INPUT_LINE_RESET, attotime::zero);
}
-WRITE_LINE_MEMBER( s11c_bg_device::ym2151_irq_w)
-{
- if(state == CLEAR_LINE)
- m_pia40->ca1_w(1);
- else
- m_pia40->ca1_w(0);
-}
-
void s11c_bg_device::bg_cvsd_clock_set_w(uint8_t data)
{
m_hc55516->clock_w(1);
diff --git a/src/mame/audio/s11c_bg.h b/src/mame/audio/s11c_bg.h
index b5d9330c677..34f7734e9af 100644
--- a/src/mame/audio/s11c_bg.h
+++ b/src/mame/audio/s11c_bg.h
@@ -23,11 +23,16 @@ public:
// construction/destruction
s11c_bg_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
- void bg_cvsd_clock_set_w(uint8_t data);
- void bg_cvsd_digit_clock_clear_w(uint8_t data);
- void bgbank_w(uint8_t data);
- void ctrl_w(uint8_t data);
- void data_w(uint8_t data);
+ // note to keep synchronization working, the host machine should have synchronization timer expired delegates
+ // before writing to the following 3 things:
+ DECLARE_WRITE_LINE_MEMBER(extra_w); // external write to board CB2 (J4 pin 12), does anything actually do this?
+ DECLARE_WRITE_LINE_MEMBER(ctrl_w); // external write to board CB1 (J4 pin 13)
+ void data_w(uint8_t data); // external write to board data bus (J4 pins 3 thru 10 for D0-D7)
+ virtual void device_reset() override; // external write to board /RESET (J4 pin 18)
+
+ // callbacks
+ auto cb2_cb() { return m_cb2_cb.bind(); }
+ auto pb_cb() { return m_pb_cb.bind(); }
template <typename T> void set_romregion(T &&tag) { m_rom.set_tag(std::forward<T>(tag)); }
@@ -35,9 +40,11 @@ public:
protected:
// overrides
virtual void device_start() override;
- virtual void device_reset() override;
virtual void device_add_mconfig(machine_config &config) override;
+ TIMER_CALLBACK_MEMBER(deferred_cb2_w);
+ TIMER_CALLBACK_MEMBER(deferred_pb_w);
+
private:
required_device<cpu_device> m_cpu;
required_device<ym2151_device> m_ym2151;
@@ -46,9 +53,15 @@ private:
required_memory_bank m_cpubank;
required_region_ptr<uint8_t> m_rom;
- DECLARE_WRITE_LINE_MEMBER(ym2151_irq_w);
- void pia40_pb_w(uint8_t data);
+ devcb_write_line m_cb2_cb;
+ devcb_write8 m_pb_cb;
+
DECLARE_WRITE_LINE_MEMBER(pia40_cb2_w);
+ void pia40_pb_w(uint8_t data);
+
+ void bg_cvsd_clock_set_w(uint8_t data);
+ void bg_cvsd_digit_clock_clear_w(uint8_t data);
+ void bgbank_w(uint8_t data);
};
DECLARE_DEVICE_TYPE(S11C_BG, s11c_bg_device)
diff --git a/src/mame/drivers/s11c.cpp b/src/mame/drivers/s11c.cpp
index 44e0e214c0f..87d74381e65 100644
--- a/src/mame/drivers/s11c.cpp
+++ b/src/mame/drivers/s11c.cpp
@@ -26,25 +26,6 @@ void s11c_state::s11c_main_map(address_map &map)
map(0x4000, 0xffff).rom();
}
-void s11c_state::s11c_audio_map(address_map &map)
-{
- map(0x0000, 0x07ff).mirror(0x0800).ram();
- map(0x1000, 0x1000).mirror(0x0fff).w(FUNC(s11c_state::bank_w));
- map(0x2000, 0x2003).mirror(0x0ffc).rw(m_pias, FUNC(pia6821_device::read), FUNC(pia6821_device::write));
- map(0x8000, 0xbfff).bankr("bank0");
- map(0xc000, 0xffff).bankr("bank1");
-}
-
-void s11c_state::s11c_bg_map(address_map &map)
-{
- map(0x0000, 0x07ff).mirror(0x1800).ram();
- map(0x2000, 0x2001).mirror(0x1ffe).rw(m_ym2151, FUNC(ym2151_device::read), FUNC(ym2151_device::write));
- map(0x4000, 0x4003).mirror(0x1ffc).rw(m_pia40, FUNC(pia6821_device::read), FUNC(pia6821_device::write));
- map(0x6000, 0x6000).mirror(0x07ff).w(FUNC(s11c_state::bg_cvsd_digit_clock_clear_w));
- map(0x6800, 0x6800).mirror(0x07ff).w(FUNC(s11c_state::bg_cvsd_clock_set_w));
- map(0x7800, 0x7800).mirror(0x07ff).w(FUNC(s11c_state::bgbank_w));
- map(0x8000, 0xffff).bankr("bgbank");
-}
static INPUT_PORTS_START( s11c )
PORT_START("SW.0")
@@ -219,6 +200,8 @@ void s11c_state::s11c(machine_config &config)
/* Add the background music card */
SPEAKER(config, "speaker").front_center();
S11C_BG(config, m_bg);
+ m_bg->pb_cb().set(m_pia34, FUNC(pia6821_device::portb_w));
+ m_bg->cb2_cb().set(m_pia34, FUNC(pia6821_device::cb1_w));
m_bg->set_romregion(m_bgcpu);
m_bg->add_route(ALL_OUTPUTS, "speaker", 1.0);
}
diff --git a/src/mame/includes/s11c.h b/src/mame/includes/s11c.h
index cabdfaf44b3..ee1ccae5442 100644
--- a/src/mame/includes/s11c.h
+++ b/src/mame/includes/s11c.h
@@ -28,8 +28,6 @@ protected:
private:
void s11c_main_map(address_map &map);
- void s11c_audio_map(address_map &map);
- void s11c_bg_map(address_map &map);
};