summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Dirk Best <mail@dirk-best.de>2016-12-26 00:43:35 +0100
committer Dirk Best <mail@dirk-best.de>2016-12-26 16:55:17 +0100
commit2f1e8456ccd380f1c887ceb27f22de59ac09461e (patch)
tree2ba1aa25ce14342c19e4819b7411bfa8e5a20712
parent7b41cc2c47e97b3361b8e665adc92a456e8233c7 (diff)
74153: Rewrite
-rw-r--r--src/devices/machine/74153.cpp228
-rw-r--r--src/devices/machine/74153.h128
-rw-r--r--src/mame/drivers/carpolo.cpp4
-rw-r--r--src/mame/includes/carpolo.h6
-rw-r--r--src/mame/machine/carpolo.cpp58
5 files changed, 208 insertions, 216 deletions
diff --git a/src/devices/machine/74153.cpp b/src/devices/machine/74153.cpp
index 591fcdedbd1..00860636da6 100644
--- a/src/devices/machine/74153.cpp
+++ b/src/devices/machine/74153.cpp
@@ -1,172 +1,164 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/*****************************************************************************
+// license: BSD-3-Clause
+// copyright-holders: Dirk Best
+/***************************************************************************
- 74153 Dual 4-line to 1-line data selectors/multiplexers
+ SN54/74153
+***************************************************************************/
- Pin layout and functions to access pins:
+#include <algorithm>
+#include "74153.h"
- enable_w(0) [1] /1G VCC [16]
- b_w [2] B /2G [15] enable_w(1)
- input_line_w(0,3) [3] 1C3 A [14] a_w
- input_line_w(0,2) [4] 1C2 2C3 [13] input_line_w(1,3)
- input_line_w(0,1) [5] 1C1 2C2 [12] input_line_w(1,2)
- input_line_w(0,0) [6] 1C0 2C1 [11] input_line_w(1,1)
- output_r(0) [7] 1Y 2C0 [10] input_line_w(1,0)
- [8] GND 2Y [9] output_r(1)
+//**************************************************************************
+// DEVICE DEFINITIONS
+//**************************************************************************
- Truth table (all logic levels indicate the actual voltage on the line):
+const device_type TTL153 = &device_creator<ttl153_device>;
- INPUTS | OUTPUT
- |
- G | B A | C0 C1 C2 C3 | Y
- --+------+-------------+---
-1 H | X X | X X X X | L
-2 L | L L | X X X X | C0
-3 L | L H | X X X X | C1
-4 L | H L | X X X X | C2
-5 L | H H | X X X X | C3
- --+------+-------------+---
- L = lo (0)
- H = hi (1)
- X = any state
-*****************************************************************************/
+//**************************************************************************
+// LIVE DEVICE
+//**************************************************************************
-#include "emu.h"
-#include "machine/74153.h"
-
-
-const device_type TTL74153 = &device_creator<ttl74153_device>;
+//-------------------------------------------------
+// ttl153_device - constructor
+//-------------------------------------------------
-ttl74153_device::ttl74153_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
- : device_t(mconfig, TTL74153, "74153 TTL", tag, owner, clock, "74153", __FILE__),
- m_a(0),
- m_b(0)
+ttl153_device::ttl153_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ device_t(mconfig, TTL153, "SN54/74153", tag, owner, clock, "ttl153", __FILE__),
+ m_za_cb(*this),
+ m_zb_cb(*this),
+ m_s{ false, false },
+ m_ia{ false, false, false, false },
+ m_ib{ false, false, false, false }
{
- m_input_lines[0][0] = 0;
- m_input_lines[0][1] = 0;
- m_input_lines[0][2] = 0;
- m_input_lines[0][3] = 0;
- m_input_lines[1][0] = 0;
- m_input_lines[1][1] = 0;
- m_input_lines[1][2] = 0;
- m_input_lines[1][3] = 0;
-
- for (auto & elem : m_enable)
- elem = 0;
-
- for (auto & elem : m_output)
- elem = 0;
-
- for (auto & elem : m_last_output)
- elem = 0;
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
-void ttl74153_device::device_start()
+void ttl153_device::device_start()
{
- m_output_cb.bind_relative_to(*owner());
-
- save_item(NAME(m_enable));
- save_item(NAME(m_last_output));
- save_item(NAME(m_input_lines[0][0]));
- save_item(NAME(m_input_lines[0][1]));
- save_item(NAME(m_input_lines[0][2]));
- save_item(NAME(m_input_lines[0][3]));
- save_item(NAME(m_input_lines[1][0]));
- save_item(NAME(m_input_lines[1][1]));
- save_item(NAME(m_input_lines[1][2]));
- save_item(NAME(m_input_lines[1][3]));
- save_item(NAME(m_a));
- save_item(NAME(m_b));
+ // resolve callbacks
+ m_za_cb.resolve_safe();
+ m_zb_cb.resolve_safe();
+
+ // register for save states
+ save_pointer(NAME(m_s), 2);
+ save_pointer(NAME(m_ia), 4);
+ save_pointer(NAME(m_ib), 4);
}
//-------------------------------------------------
// device_reset - device-specific reset
//-------------------------------------------------
-void ttl74153_device::device_reset()
+void ttl153_device::device_reset()
{
- m_a = 1;
- m_b = 1;
- m_enable[0] = 1;
- m_enable[1] = 1;
- m_input_lines[0][0] = 1;
- m_input_lines[0][1] = 1;
- m_input_lines[0][2] = 1;
- m_input_lines[0][3] = 1;
- m_input_lines[1][0] = 1;
- m_input_lines[1][1] = 1;
- m_input_lines[1][2] = 1;
- m_input_lines[1][3] = 1;
-
- m_last_output[0] = -1;
- m_last_output[1] = -1;
+ std::fill(std::begin(m_s), std::end(m_s), false);
+ std::fill(std::begin(m_ia), std::end(m_ia), false);
+ std::fill(std::begin(m_ib), std::end(m_ib), false);
}
+//-------------------------------------------------
+// update_a - update output a state
+//-------------------------------------------------
-void ttl74153_device::update()
+void ttl153_device::update_a()
{
- int sel;
- int section;
-
-
- sel = (m_b << 1) | m_a;
+ // calculate state
+ bool za = 0;
+ za |= m_ia[0] && !m_s[1] && !m_s[0];
+ za |= m_ia[1] && !m_s[1] && m_s[0];
+ za |= m_ia[2] && m_s[1] && !m_s[0];
+ za |= m_ia[3] && m_s[1] && m_s[0];
+
+ // output
+ m_za_cb(za ? 1 : 0);
+}
+//-------------------------------------------------
+// update_b - update output b state
+//-------------------------------------------------
- /* process both sections */
- for (section = 0; section < 2; section++)
- {
- if (m_enable[section])
- m_output[section] = 0; // row 1 in truth table
- else
- m_output[section] = m_input_lines[section][sel];
- }
+void ttl153_device::update_b()
+{
+ // calculate state
+ bool zb = 0;
+ zb |= m_ib[0] && !m_s[1] && !m_s[0];
+ zb |= m_ib[1] && !m_s[1] && m_s[0];
+ zb |= m_ib[2] && m_s[1] && !m_s[0];
+ zb |= m_ib[3] && m_s[1] && m_s[0];
+
+ // output
+ m_zb_cb(zb ? 1 : 0);
+}
- /* call callback if either of the outputs changed */
- if (!m_output_cb.isnull() &&
- ((m_output[0] != m_last_output[0]) || (m_output[1] != m_last_output[1])))
- {
- m_last_output[0] = m_output[0];
- m_last_output[1] = m_output[1];
+//**************************************************************************
+// INTERFACE
+//**************************************************************************
- m_output_cb();
- }
+WRITE_LINE_MEMBER( ttl153_device::s0_w )
+{
+ m_s[0] = bool(state);
+ update_a();
+ update_b();
}
-
-void ttl74153_device::a_w(int data)
+WRITE_LINE_MEMBER( ttl153_device::s1_w )
{
- m_a = data ? 1 : 0;
+ m_s[1] = bool(state);
+ update_a();
+ update_b();
}
+WRITE_LINE_MEMBER( ttl153_device::i0a_w )
+{
+ m_ia[0] = bool(state);
+ update_a();
+}
-void ttl74153_device::b_w(int data)
+WRITE_LINE_MEMBER( ttl153_device::i1a_w )
{
- m_b = data ? 1 : 0;
+ m_ia[1] = bool(state);
+ update_a();
}
+WRITE_LINE_MEMBER( ttl153_device::i2a_w )
+{
+ m_ia[2] = bool(state);
+ update_a();
+}
-void ttl74153_device::input_line_w(int section, int input_line, int data)
+WRITE_LINE_MEMBER( ttl153_device::i3a_w )
{
- m_input_lines[section][input_line] = data ? 1 : 0;
+ m_ia[3] = bool(state);
+ update_a();
}
+WRITE_LINE_MEMBER( ttl153_device::i0b_w )
+{
+ m_ib[0] = bool(state);
+ update_b();
+}
-void ttl74153_device::enable_w(int section, int data)
+WRITE_LINE_MEMBER( ttl153_device::i1b_w )
{
- m_enable[section] = data ? 1 : 0;
+ m_ib[1] = bool(state);
+ update_b();
}
+WRITE_LINE_MEMBER( ttl153_device::i2b_w )
+{
+ m_ib[2] = bool(state);
+ update_b();
+}
-int ttl74153_device::output_r(int section)
+WRITE_LINE_MEMBER( ttl153_device::i3b_w )
{
- return m_output[section];
+ m_ib[3] = bool(state);
+ update_b();
}
diff --git a/src/devices/machine/74153.h b/src/devices/machine/74153.h
index 77194610742..aa8a5c22115 100644
--- a/src/devices/machine/74153.h
+++ b/src/devices/machine/74153.h
@@ -1,65 +1,77 @@
-// license:BSD-3-Clause
-// copyright-holders:Aaron Giles
-/*****************************************************************************
+// license: BSD-3-Clause
+// copyright-holders: Dirk Best
+/***************************************************************************
- 74153 Dual 4-line to 1-line data selectors/multiplexers
+ SN54/74153
+ Dual 4-Input Multiplexer
- Pin layout and functions to access pins:
+ ___ ___
+ EA/1G 1 |* u | 16 VCC
+ S1/B 2 | | 15 EB/2G
+ I3A/1C3 3 | | 14 S0/A
+ I2A/1C2 4 | | 13 I3B/2C3
+ I1A/1C1 5 | | 12 I2B/2C2
+ I0A/1C0 6 | | 11 I1B/2C1
+ ZA/1Y 7 | | 10 I0B/2C0
+ GND 8 |_______| 9 ZB/2Y
- enable_w(0) [1] /1G VCC [16]
- b_w [2] B /2G [15] enable_w(1)
- input_line_w(0,3) [3] 1C3 A [14] a_w
- input_line_w(0,2) [4] 1C2 2C3 [13] input_line_w(1,3)
- input_line_w(0,1) [5] 1C1 2C2 [12] input_line_w(1,2)
- input_line_w(0,0) [6] 1C0 2C1 [11] input_line_w(1,1)
- output_r(0) [7] 1Y 2C0 [10] input_line_w(1,0)
- [8] GND 2Y [9] output_r(1)
+***************************************************************************/
+#pragma once
- Truth table (all logic levels indicate the actual voltage on the line):
+#ifndef MAME_DEVICES_MACHINE_74153_H
+#define MAME_DEVICES_MACHINE_74153_H
- INPUTS | OUTPUT
- |
- G | B A | C0 C1 C2 C3 | Y
- --+------+-------------+---
- H | X X | X X X X | L
- L | L L | X X X X | C0
- L | L H | X X X X | C1
- L | H L | X X X X | C2
- L | H H | X X X X | C3
- --+------+-------------+---
- L = lo (0)
- H = hi (1)
- X = any state
+#include "emu.h"
-*****************************************************************************/
-#ifndef TTL74153_H
-#define TTL74153_H
+//**************************************************************************
+// INTERFACE CONFIGURATION MACROS
+//**************************************************************************
+#define MCFG_TTL153_ADD(_tag) \
+ MCFG_DEVICE_ADD(_tag, TTL153, 0)
-typedef device_delegate<void (void)> ttl74153_output_delegate;
+#define MCFG_TTL153_ZA_CB(_devcb) \
+ devcb = &ttl153_device::set_za_callback(*device, DEVCB_##_devcb);
-#define TTL74153_OUTPUT_CB(_name) void _name(void)
+#define MCFG_TTL153_ZB_CB(_devcb) \
+ devcb = &ttl153_device::set_zb_callback(*device, DEVCB_##_devcb);
-class ttl74153_device : public device_t
+//**************************************************************************
+// TYPE DEFINITIONS
+//**************************************************************************
+
+class ttl153_device : public device_t
{
public:
- ttl74153_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
- ~ttl74153_device() {}
+ // construction/destruction
+ ttl153_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+
+ // configuration
+ template<class _Object> static devcb_base &set_za_callback(device_t &device, _Object object)
+ { return downcast<ttl153_device &>(device).m_za_cb.set_callback(object); }
+
+ template<class _Object> static devcb_base &set_zb_callback(device_t &device, _Object object)
+ { return downcast<ttl153_device &>(device).m_zb_cb.set_callback(object); }
- static void set_output_callback(device_t &device, ttl74153_output_delegate callback) { downcast<ttl74153_device &>(device).m_output_cb = callback; }
+ // select
+ DECLARE_WRITE_LINE_MEMBER(s0_w);
+ DECLARE_WRITE_LINE_MEMBER(s1_w);
- /* must call update() after setting the inputs */
- void update();
+ // input a
+ DECLARE_WRITE_LINE_MEMBER(i0a_w);
+ DECLARE_WRITE_LINE_MEMBER(i1a_w);
+ DECLARE_WRITE_LINE_MEMBER(i2a_w);
+ DECLARE_WRITE_LINE_MEMBER(i3a_w);
- void a_w(int data);
- void b_w(int data);
- void input_line_w(int section, int input_line, int data);
- void enable_w(int section, int data);
- int output_r(int section);
+ // input b
+ DECLARE_WRITE_LINE_MEMBER(i0b_w);
+ DECLARE_WRITE_LINE_MEMBER(i1b_w);
+ DECLARE_WRITE_LINE_MEMBER(i2b_w);
+ DECLARE_WRITE_LINE_MEMBER(i3b_w);
protected:
// device-level overrides
@@ -67,26 +79,20 @@ protected:
virtual void device_reset() override;
private:
- // internal state
- ttl74153_output_delegate m_output_cb;
+ void update_a();
+ void update_b();
- /* inputs */
- int m_a; /* pin 14 */
- int m_b; /* pin 2 */
- int m_input_lines[2][4]; /* pins 3-6,10-13 */
- int m_enable[2]; /* pins 1,15 */
+ // callbacks
+ devcb_write_line m_za_cb;
+ devcb_write_line m_zb_cb;
- /* output */
- int m_output[2]; /* pins 7,9 */
-
- /* internals */
- int m_last_output[2];
+ // state
+ bool m_s[2];
+ bool m_ia[4];
+ bool m_ib[4];
};
-extern const device_type TTL74153;
-
-
-#define MCFG_74153_OUTPUT_CB(_class, _method) \
- ttl74153_device::set_output_callback(*device, ttl74153_output_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
+// device type definition
+extern const device_type TTL153;
-#endif
+#endif // MAME_DEVICES_MACHINE_74153_H
diff --git a/src/mame/drivers/carpolo.cpp b/src/mame/drivers/carpolo.cpp
index b111489223e..a01cc10da50 100644
--- a/src/mame/drivers/carpolo.cpp
+++ b/src/mame/drivers/carpolo.cpp
@@ -275,7 +275,9 @@ static MACHINE_CONFIG_START( carpolo, carpolo_state )
MCFG_DEVICE_ADD("74148_3s", TTL74148, 0)
MCFG_74148_OUTPUT_CB(carpolo_state, ttl74148_3s_cb)
- MCFG_DEVICE_ADD("74153_1k", TTL74153, 0)
+ MCFG_TTL153_ADD("74153_1k")
+ MCFG_TTL153_ZA_CB(WRITELINE(carpolo_state, ls153_za_w)) // pia1 pb5
+ MCFG_TTL153_ZB_CB(WRITELINE(carpolo_state, ls153_zb_w)) // pia1 pb4
/* video hardware */
MCFG_SCREEN_ADD("screen", RASTER)
diff --git a/src/mame/includes/carpolo.h b/src/mame/includes/carpolo.h
index bec5661a453..6935e9a62d8 100644
--- a/src/mame/includes/carpolo.h
+++ b/src/mame/includes/carpolo.h
@@ -50,9 +50,11 @@ public:
uint8_t m_car_border_collision_cause;
uint8_t m_priority_0_extension;
uint8_t m_last_wheel_value[4];
+ int m_ls153_za;
+ int m_ls153_zb;
required_device<cpu_device> m_maincpu;
required_device<ttl74148_device> m_ttl74148_3s;
- required_device<ttl74153_device> m_ttl74153_1k;
+ required_device<ttl153_device> m_ttl74153_1k;
required_device<ttl7474_device> m_ttl7474_2s_1;
required_device<ttl7474_device> m_ttl7474_2s_2;
required_device<ttl7474_device> m_ttl7474_2u_1;
@@ -108,6 +110,8 @@ public:
DECLARE_WRITE_LINE_MEMBER(carpolo_7474_2s_2_q_cb);
DECLARE_WRITE_LINE_MEMBER(carpolo_7474_2u_1_q_cb);
DECLARE_WRITE_LINE_MEMBER(carpolo_7474_2u_2_q_cb);
+ DECLARE_WRITE_LINE_MEMBER(ls153_za_w);
+ DECLARE_WRITE_LINE_MEMBER(ls153_zb_w);
TTL74148_OUTPUT_CB(ttl74148_3s_cb);
diff --git a/src/mame/machine/carpolo.cpp b/src/mame/machine/carpolo.cpp
index 721e23cbda1..636987a260b 100644
--- a/src/mame/machine/carpolo.cpp
+++ b/src/mame/machine/carpolo.cpp
@@ -253,30 +253,16 @@ INTERRUPT_GEN_MEMBER(carpolo_state::carpolo_timer_interrupt)
/* finally read the accelerator pedals */
port_value = ioport("PEDALS")->read();
- for (player = 0; player < 4; player++)
- {
- /* one line indicates if the pedal is pressed and the other
- how much, resulting in only two different possible levels */
- if (port_value & 0x01)
- {
- m_ttl74153_1k->input_line_w(0, player, 1);
- m_ttl74153_1k->input_line_w(1, player, 0);
- }
- else if (port_value & 0x02)
- {
- m_ttl74153_1k->input_line_w(0, player, 1);
- m_ttl74153_1k->input_line_w(1, player, 1);
- }
- else
- {
- m_ttl74153_1k->input_line_w(0, player, 0);
- /* the other line is irrelevant */
- }
-
- port_value >>= 2;
- }
-
- m_ttl74153_1k->update();
+ // one line indicates if the pedal is pressed and the other
+ // how much, resulting in only two different possible levels
+ m_ttl74153_1k->i0a_w(BIT(port_value, 0) | BIT(port_value, 1));
+ m_ttl74153_1k->i1a_w(BIT(port_value, 2) | BIT(port_value, 3));
+ m_ttl74153_1k->i2a_w(BIT(port_value, 4) | BIT(port_value, 5));
+ m_ttl74153_1k->i3a_w(BIT(port_value, 6) | BIT(port_value, 7));
+ m_ttl74153_1k->i0b_w(BIT(port_value, 1));
+ m_ttl74153_1k->i1b_w(BIT(port_value, 3));
+ m_ttl74153_1k->i2b_w(BIT(port_value, 5));
+ m_ttl74153_1k->i3b_w(BIT(port_value, 7));
}
// FIXME: Remove trampolines
@@ -344,6 +330,16 @@ WRITE8_MEMBER(carpolo_state::carpolo_timer_interrupt_clear_w)
*
*************************************/
+WRITE_LINE_MEMBER( carpolo_state::ls153_za_w )
+{
+ m_ls153_za = state;
+}
+
+WRITE_LINE_MEMBER( carpolo_state::ls153_zb_w )
+{
+ m_ls153_zb = state;
+}
+
WRITE8_MEMBER(carpolo_state::pia_0_port_a_w)
{
/* bit 0 - Coin counter
@@ -374,10 +370,8 @@ WRITE8_MEMBER(carpolo_state::pia_0_port_b_w)
bit 6 - Select pedal 0
bit 7 - Select pdeal 1 */
- m_ttl74153_1k->a_w(data & 0x40);
- m_ttl74153_1k->b_w(data & 0x80);
-
- m_ttl74153_1k->update();
+ m_ttl74153_1k->s0_w(BIT(data, 6));
+ m_ttl74153_1k->s1_w(BIT(data, 7));
}
READ8_MEMBER(carpolo_state::pia_0_port_b_r)
@@ -385,8 +379,7 @@ READ8_MEMBER(carpolo_state::pia_0_port_b_r)
/* bit 4 - Pedal bit 0
bit 5 - Pedal bit 1 */
- return (m_ttl74153_1k->output_r(0) << 5) |
- (m_ttl74153_1k->output_r(1) << 4);
+ return (m_ls153_za << 5) | (m_ls153_zb << 4);
}
@@ -486,9 +479,4 @@ void carpolo_state::machine_reset()
m_ttl7474_1a_2->clear_w (1);
m_ttl7474_1a_2->preset_w(1);
-
-
- /* set up the pedal handling chips */
- m_ttl74153_1k->enable_w(0, 0);
- m_ttl74153_1k->enable_w(1, 0);
}