mirror of
https://github.com/holub/mame
synced 2025-07-02 16:49:22 +03:00
Formally differentiate between logic inputs (e.g. switches) and int
inputs (e.g. resistor ladders or selection switches). (nw)
This commit is contained in:
parent
a45743bbc4
commit
7a023dd4e6
@ -27,6 +27,7 @@ const device_type NETLIST_SOUND = &device_creator<netlist_mame_sound_device_t>;
|
||||
/* subdevices */
|
||||
|
||||
const device_type NETLIST_ANALOG_INPUT = &device_creator<netlist_mame_analog_input_t>;
|
||||
const device_type NETLIST_INT_INPUT = &device_creator<netlist_mame_int_input_t>;
|
||||
const device_type NETLIST_LOGIC_INPUT = &device_creator<netlist_mame_logic_input_t>;
|
||||
const device_type NETLIST_STREAM_INPUT = &device_creator<netlist_mame_stream_input_t>;
|
||||
|
||||
@ -113,11 +114,11 @@ void netlist_mame_analog_output_t::device_start()
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// netlist_mame_logic_input_t
|
||||
// netlist_mame_int_input_t
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
netlist_mame_logic_input_t::netlist_mame_logic_input_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
: device_t(mconfig, NETLIST_ANALOG_INPUT, "Netlist Logic Input", tag, owner, clock, "netlist_logic_input", __FILE__),
|
||||
netlist_mame_int_input_t::netlist_mame_int_input_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
: device_t(mconfig, NETLIST_INT_INPUT, "Netlist Logic Input", tag, owner, clock, "netlist_logic_input", __FILE__),
|
||||
netlist_mame_sub_interface(*owner),
|
||||
m_param(nullptr),
|
||||
m_mask(0xffffffff),
|
||||
@ -126,16 +127,16 @@ netlist_mame_logic_input_t::netlist_mame_logic_input_t(const machine_config &mco
|
||||
{
|
||||
}
|
||||
|
||||
void netlist_mame_logic_input_t::static_set_params(device_t &device, const char *param_name, const UINT32 mask, const UINT32 shift)
|
||||
void netlist_mame_int_input_t::static_set_params(device_t &device, const char *param_name, const UINT32 mask, const UINT32 shift)
|
||||
{
|
||||
netlist_mame_logic_input_t &netlist = downcast<netlist_mame_logic_input_t &>(device);
|
||||
netlist_mame_int_input_t &netlist = downcast<netlist_mame_int_input_t &>(device);
|
||||
LOG_DEV_CALLS(("static_set_params %s\n", device.tag()));
|
||||
netlist.m_param_name = param_name;
|
||||
netlist.m_shift = shift;
|
||||
netlist.m_mask = mask;
|
||||
}
|
||||
|
||||
void netlist_mame_logic_input_t::device_start()
|
||||
void netlist_mame_int_input_t::device_start()
|
||||
{
|
||||
LOG_DEV_CALLS(("start %s\n", tag()));
|
||||
netlist::param_t *p = downcast<netlist_mame_device_t *>(this->owner())->setup().find_param(m_param_name);
|
||||
@ -146,6 +147,38 @@ void netlist_mame_logic_input_t::device_start()
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// netlist_mame_logic_input_t
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
netlist_mame_logic_input_t::netlist_mame_logic_input_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
: device_t(mconfig, NETLIST_LOGIC_INPUT, "Netlist Logic Input", tag, owner, clock, "netlist_logic_input", __FILE__),
|
||||
netlist_mame_sub_interface(*owner),
|
||||
m_param(nullptr),
|
||||
m_shift(0),
|
||||
m_param_name("")
|
||||
{
|
||||
}
|
||||
|
||||
void netlist_mame_logic_input_t::static_set_params(device_t &device, const char *param_name, const UINT32 shift)
|
||||
{
|
||||
netlist_mame_logic_input_t &netlist = downcast<netlist_mame_logic_input_t &>(device);
|
||||
LOG_DEV_CALLS(("static_set_params %s\n", device.tag()));
|
||||
netlist.m_param_name = param_name;
|
||||
netlist.m_shift = shift;
|
||||
}
|
||||
|
||||
void netlist_mame_logic_input_t::device_start()
|
||||
{
|
||||
LOG_DEV_CALLS(("start %s\n", tag()));
|
||||
netlist::param_t *p = downcast<netlist_mame_device_t *>(this->owner())->setup().find_param(m_param_name);
|
||||
m_param = dynamic_cast<netlist::param_logic_t *>(p);
|
||||
if (m_param == nullptr)
|
||||
{
|
||||
fatalerror("device %s wrong parameter type for %s\n", basetag(), m_param_name.cstr());
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// netlist_mame_stream_input_t
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
@ -36,9 +36,13 @@
|
||||
netlist_analog_output_delegate(& _class :: _member, \
|
||||
# _class "::" # _member, _class_tag, (_class *)nullptr) );
|
||||
|
||||
#define MCFG_NETLIST_LOGIC_INPUT(_basetag, _tag, _name, _shift, _mask) \
|
||||
#define MCFG_NETLIST_LOGIC_INPUT(_basetag, _tag, _name, _shift) \
|
||||
MCFG_DEVICE_ADD(_basetag ":" _tag, NETLIST_LOGIC_INPUT, 0) \
|
||||
netlist_mame_logic_input_t::static_set_params(*device, _name, _mask, _shift);
|
||||
netlist_mame_logic_input_t::static_set_params(*device, _name, _shift);
|
||||
|
||||
#define MCFG_NETLIST_INT_INPUT(_basetag, _tag, _name, _shift, _mask) \
|
||||
MCFG_DEVICE_ADD(_basetag ":" _tag, NETLIST_INT_INPUT, 0) \
|
||||
netlist_mame_int_input_t::static_set_params(*device, _name, _mask, _shift);
|
||||
|
||||
#define MCFG_NETLIST_STREAM_INPUT(_basetag, _chan, _name) \
|
||||
MCFG_DEVICE_ADD(_basetag ":cin" # _chan, NETLIST_STREAM_INPUT, 0) \
|
||||
@ -52,6 +56,9 @@
|
||||
#define NETLIST_LOGIC_PORT_CHANGED(_base, _tag) \
|
||||
PORT_CHANGED_MEMBER(_base ":" _tag, netlist_mame_logic_input_t, input_changed, 0)
|
||||
|
||||
#define NETLIST_INT_PORT_CHANGED(_base, _tag) \
|
||||
PORT_CHANGED_MEMBER(_base ":" _tag, netlist_mame_logic_input_t, input_changed, 0)
|
||||
|
||||
#define NETLIST_ANALOG_PORT_CHANGED(_base, _tag) \
|
||||
PORT_CHANGED_MEMBER(_base ":" _tag, netlist_mame_analog_input_t, input_changed, 0)
|
||||
|
||||
@ -404,17 +411,17 @@ private:
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// netlist_mame_logic_input_t
|
||||
// netlist_mame_int_input_t
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
class netlist_mame_logic_input_t : public device_t,
|
||||
class netlist_mame_int_input_t : public device_t,
|
||||
public netlist_mame_sub_interface
|
||||
{
|
||||
public:
|
||||
|
||||
// construction/destruction
|
||||
netlist_mame_logic_input_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
virtual ~netlist_mame_logic_input_t() { }
|
||||
netlist_mame_int_input_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
virtual ~netlist_mame_int_input_t() { }
|
||||
|
||||
static void static_set_params(device_t &device, const char *param_name, const UINT32 mask, const UINT32 shift);
|
||||
|
||||
@ -449,6 +456,51 @@ private:
|
||||
pstring m_param_name;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// netlist_mame_logic_input_t
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
class netlist_mame_logic_input_t : public device_t,
|
||||
public netlist_mame_sub_interface
|
||||
{
|
||||
public:
|
||||
|
||||
// construction/destruction
|
||||
netlist_mame_logic_input_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
virtual ~netlist_mame_logic_input_t() { }
|
||||
|
||||
static void static_set_params(device_t &device, const char *param_name, const UINT32 shift);
|
||||
|
||||
inline void write(const UINT32 val)
|
||||
{
|
||||
const UINT32 v = (val >> m_shift) & 1;
|
||||
if (v != m_param->Value())
|
||||
synchronize(0, v);
|
||||
}
|
||||
|
||||
inline DECLARE_INPUT_CHANGED_MEMBER(input_changed) { write(newval); }
|
||||
DECLARE_WRITE_LINE_MEMBER(write_line) { write(state); }
|
||||
DECLARE_WRITE8_MEMBER(write8) { write(data); }
|
||||
DECLARE_WRITE16_MEMBER(write16) { write(data); }
|
||||
DECLARE_WRITE32_MEMBER(write32) { write(data); }
|
||||
DECLARE_WRITE64_MEMBER(write64) { write(data); }
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_start() override;
|
||||
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override
|
||||
{
|
||||
if (is_sound_device())
|
||||
update_to_current_time();
|
||||
m_param->setTo(param);
|
||||
}
|
||||
|
||||
private:
|
||||
netlist::param_logic_t *m_param;
|
||||
UINT32 m_shift;
|
||||
pstring m_param_name;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// netlist_mame_stream_input_t
|
||||
// ----------------------------------------------------------------------------------------
|
||||
@ -709,6 +761,7 @@ extern const device_type NETLIST_CPU;
|
||||
extern const device_type NETLIST_SOUND;
|
||||
extern const device_type NETLIST_ANALOG_INPUT;
|
||||
extern const device_type NETLIST_LOGIC_INPUT;
|
||||
extern const device_type NETLIST_INT_INPUT;
|
||||
|
||||
extern const device_type NETLIST_ANALOG_OUTPUT;
|
||||
extern const device_type NETLIST_STREAM_INPUT;
|
||||
|
@ -27,7 +27,7 @@ NETLIB_RESET(switch1)
|
||||
|
||||
NETLIB_UPDATE(switch1)
|
||||
{
|
||||
if (m_POS.Value() == 0)
|
||||
if (!m_POS.Value())
|
||||
{
|
||||
m_R.set_R(R_OFF);
|
||||
}
|
||||
@ -57,7 +57,7 @@ NETLIB_RESET(switch2)
|
||||
|
||||
NETLIB_UPDATE(switch2)
|
||||
{
|
||||
if (m_POS.Value() == 0)
|
||||
if (!m_POS.Value())
|
||||
{
|
||||
m_R1.set_R(R_ON);
|
||||
m_R2.set_R(R_OFF);
|
||||
|
@ -47,7 +47,7 @@ NETLIB_OBJECT(switch1)
|
||||
NETLIB_UPDATE_PARAMI();
|
||||
|
||||
NETLIB_SUB(R_base) m_R;
|
||||
param_int_t m_POS;
|
||||
param_logic_t m_POS;
|
||||
};
|
||||
|
||||
NETLIB_OBJECT(switch2)
|
||||
@ -71,7 +71,7 @@ NETLIB_OBJECT(switch2)
|
||||
|
||||
NETLIB_SUB(R_base) m_R1;
|
||||
NETLIB_SUB(R_base) m_R2;
|
||||
param_int_t m_POS;
|
||||
param_logic_t m_POS;
|
||||
};
|
||||
|
||||
} //namespace devices
|
||||
|
@ -455,11 +455,11 @@ static MACHINE_CONFIG_FRAGMENT( irem_audio_base )
|
||||
MCFG_NETLIST_SETUP(kidniki)
|
||||
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
|
||||
|
||||
MCFG_NETLIST_LOGIC_INPUT("snd_nl", "ibd", "I_BD0.IN", 0, 1)
|
||||
MCFG_NETLIST_LOGIC_INPUT("snd_nl", "isd", "I_SD0.IN", 0, 1)
|
||||
MCFG_NETLIST_LOGIC_INPUT("snd_nl", "ich", "I_CH0.IN", 0, 1)
|
||||
MCFG_NETLIST_LOGIC_INPUT("snd_nl", "ioh", "I_OH0.IN", 0, 1)
|
||||
MCFG_NETLIST_LOGIC_INPUT("snd_nl", "sinh", "SINH.IN", 0, 1)
|
||||
MCFG_NETLIST_LOGIC_INPUT("snd_nl", "ibd", "I_BD0.IN", 0)
|
||||
MCFG_NETLIST_LOGIC_INPUT("snd_nl", "isd", "I_SD0.IN", 0)
|
||||
MCFG_NETLIST_LOGIC_INPUT("snd_nl", "ich", "I_CH0.IN", 0)
|
||||
MCFG_NETLIST_LOGIC_INPUT("snd_nl", "ioh", "I_OH0.IN", 0)
|
||||
MCFG_NETLIST_LOGIC_INPUT("snd_nl", "sinh", "SINH.IN", 0)
|
||||
|
||||
MCFG_NETLIST_STREAM_INPUT("snd_nl", 0, "R_AY45M_A.R")
|
||||
MCFG_NETLIST_STREAM_INPUT("snd_nl", 1, "R_AY45M_B.R")
|
||||
|
@ -372,10 +372,10 @@ static MACHINE_CONFIG_START( pong, pong_state )
|
||||
MCFG_NETLIST_ANALOG_MULT_OFFSET(1.0 / 100.0 * RES_K(50), RES_K(56) )
|
||||
MCFG_NETLIST_ANALOG_INPUT("maincpu", "pot0", "ic_b9_POT.DIAL")
|
||||
MCFG_NETLIST_ANALOG_INPUT("maincpu", "pot1", "ic_a9_POT.DIAL")
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "sw1a", "sw1a.POS", 0, 0x01)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "sw1b", "sw1b.POS", 0, 0x01)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "coinsw", "coinsw.POS", 0, 0x01)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "antenna", "antenna.IN", 0, 0x01)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "sw1a", "sw1a.POS", 0)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "sw1b", "sw1b.POS", 0)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "coinsw", "coinsw.POS", 0)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "antenna", "antenna.IN", 0)
|
||||
|
||||
MCFG_NETLIST_ANALOG_OUTPUT("maincpu", "snd0", "sound", pong_state, sound_cb, "")
|
||||
MCFG_NETLIST_ANALOG_OUTPUT("maincpu", "vid0", "videomix", fixedfreq_device, update_vid, "fixfreq")
|
||||
@ -403,21 +403,21 @@ static MACHINE_CONFIG_START( breakout, breakout_state )
|
||||
|
||||
MCFG_NETLIST_ANALOG_INPUT("maincpu", "pot1", "POTP1.DIAL")
|
||||
MCFG_NETLIST_ANALOG_INPUT("maincpu", "pot2", "POTP2.DIAL")
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "coinsw1", "COIN1.POS", 0, 0x01)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "coinsw2", "COIN2.POS", 0, 0x01)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "startsw1", "START1.POS", 0, 0x01)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "startsw2", "START2.POS", 0, 0x01)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "servesw", "SERVE.POS", 0, 0x01)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "sw4", "S4.POS", 0, 0x01)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "sw3", "S3.POS", 0, 0x01)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "sw2", "S2.POS", 0, 0x01)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "coinsw1", "COIN1.POS", 0)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "coinsw2", "COIN2.POS", 0)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "startsw1", "START1.POS", 0)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "startsw2", "START2.POS", 0)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "servesw", "SERVE.POS", 0)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "sw4", "S4.POS", 0)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "sw3", "S3.POS", 0)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "sw2", "S2.POS", 0)
|
||||
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "sw1_1", "S1_1.POS", 0, 0x01)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "sw1_2", "S1_2.POS", 0, 0x01)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "sw1_3", "S1_3.POS", 0, 0x01)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "sw1_4", "S1_4.POS", 0, 0x01)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "sw1_1", "S1_1.POS", 0)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "sw1_2", "S1_2.POS", 0)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "sw1_3", "S1_3.POS", 0)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "sw1_4", "S1_4.POS", 0)
|
||||
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "antenna", "antenna.IN", 0, 0x01)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "antenna", "antenna.IN", 0)
|
||||
|
||||
MCFG_NETLIST_ANALOG_OUTPUT("maincpu", "snd0", "sound", breakout_state, sound_cb, "")
|
||||
MCFG_NETLIST_ANALOG_OUTPUT("maincpu", "vid0", "videomix", fixedfreq_device, update_vid, "fixfreq")
|
||||
@ -462,20 +462,14 @@ static MACHINE_CONFIG_START( pongd, pong_state )
|
||||
MCFG_DEVICE_ADD("maincpu", NETLIST_CPU, NETLIST_CLOCK)
|
||||
MCFG_NETLIST_SETUP(pongdoubles)
|
||||
|
||||
#if 0
|
||||
MCFG_NETLIST_ANALOG_INPUT("maincpu", "vr0", "ic_b9_R.R")
|
||||
MCFG_NETLIST_ANALOG_INPUT_MULT_OFFSET(1.0 / 100.0 * RES_K(50), RES_K(56) )
|
||||
MCFG_NETLIST_ANALOG_INPUT("maincpu", "vr1", "ic_a9_R.R")
|
||||
MCFG_NETLIST_ANALOG_INPUT_MULT_OFFSET(1.0 / 100.0 * RES_K(50), RES_K(56) )
|
||||
#endif
|
||||
MCFG_NETLIST_ANALOG_INPUT("maincpu", "pot0", "A10_POT.DIAL")
|
||||
MCFG_NETLIST_ANALOG_INPUT("maincpu", "pot1", "B10_POT.DIAL")
|
||||
MCFG_NETLIST_ANALOG_INPUT("maincpu", "pot2", "B9B_POT.DIAL")
|
||||
MCFG_NETLIST_ANALOG_INPUT("maincpu", "pot3", "B9A_POT.DIAL")
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "sw1a", "DIPSW1.POS", 0, 0x01)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "sw1b", "DIPSW2.POS", 0, 0x01)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "coinsw", "COIN_SW.POS", 0, 0x01)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "startsw", "START_SW.POS", 0, 0x01)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "sw1a", "DIPSW1.POS", 0)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "sw1b", "DIPSW2.POS", 0)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "coinsw", "COIN_SW.POS", 0)
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "startsw", "START_SW.POS", 0)
|
||||
#if 0
|
||||
MCFG_NETLIST_LOGIC_INPUT("maincpu", "antenna", "antenna.IN", 0, 0x01)
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user