mirror of
https://github.com/holub/mame
synced 2025-04-23 08:49:55 +03:00
Change 6840ptm to use an array of devcb_write_line, nw
This commit is contained in:
parent
042f15a578
commit
8be20c8cbf
@ -72,9 +72,7 @@ const device_type PTM6840 = &device_creator<ptm6840_device>;
|
||||
ptm6840_device::ptm6840_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
: device_t(mconfig, PTM6840, "6840 PTM", tag, owner, clock, "ptm6840", __FILE__),
|
||||
m_internal_clock(0.0),
|
||||
m_out0_cb(*this),
|
||||
m_out1_cb(*this),
|
||||
m_out2_cb(*this),
|
||||
m_out_cb{*this, *this, *this},
|
||||
m_irq_cb(*this)
|
||||
{
|
||||
m_external_clock[0] = m_external_clock[1] = m_external_clock[2] = 0.0;
|
||||
@ -87,9 +85,9 @@ ptm6840_device::ptm6840_device(const machine_config &mconfig, const char *tag, d
|
||||
void ptm6840_device::device_start()
|
||||
{
|
||||
// resolve callbacks
|
||||
m_out0_cb.resolve_safe();
|
||||
m_out1_cb.resolve_safe();
|
||||
m_out2_cb.resolve_safe();
|
||||
m_out_cb[0].resolve_safe();
|
||||
m_out_cb[1].resolve_safe();
|
||||
m_out_cb[2].resolve_safe();
|
||||
m_irq_cb.resolve_safe();
|
||||
|
||||
for (auto & elem : m_external_clock)
|
||||
@ -388,18 +386,7 @@ void ptm6840_device::reload_count(int idx)
|
||||
if ((m_mode[idx] == 4) || (m_mode[idx] == 6))
|
||||
{
|
||||
m_output[idx] = 1;
|
||||
switch (idx)
|
||||
{
|
||||
case 0:
|
||||
m_out0_cb(m_output[0]);
|
||||
break;
|
||||
case 1:
|
||||
m_out1_cb(m_output[1]);
|
||||
break;
|
||||
case 2:
|
||||
m_out2_cb(m_output[2]);
|
||||
break;
|
||||
}
|
||||
m_out_cb[idx](m_output[idx]);
|
||||
}
|
||||
|
||||
// Set the timer
|
||||
@ -525,18 +512,7 @@ WRITE8_MEMBER( ptm6840_device::write )
|
||||
if (!(m_control_reg[idx] & COUNT_OUT_EN))
|
||||
{
|
||||
// Output cleared
|
||||
switch (idx)
|
||||
{
|
||||
case 0:
|
||||
m_out0_cb(0);
|
||||
break;
|
||||
case 1:
|
||||
m_out1_cb(0);
|
||||
break;
|
||||
case 2:
|
||||
m_out2_cb(0);
|
||||
break;
|
||||
}
|
||||
m_out_cb[idx](0);
|
||||
}
|
||||
|
||||
// Reset?
|
||||
@ -621,51 +597,32 @@ void ptm6840_device::timeout(int idx)
|
||||
|
||||
if (m_control_reg[idx] & COUNT_OUT_EN)
|
||||
{
|
||||
if (m_mode[idx] == 0 || m_mode[idx] == 2)
|
||||
switch (m_mode[idx])
|
||||
{
|
||||
m_output[idx] = m_output[idx] ? 0 : 1;
|
||||
PLOG(("**ptm6840 %s t%d output %d **\n", tag(), idx, m_output[idx]));
|
||||
|
||||
switch (idx)
|
||||
{
|
||||
case 0:
|
||||
m_out0_cb(m_output[0]);
|
||||
break;
|
||||
case 1:
|
||||
m_out1_cb(m_output[1]);
|
||||
break;
|
||||
case 2:
|
||||
m_out2_cb(m_output[2]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((m_mode[idx] == 4)||(m_mode[idx] == 6))
|
||||
{
|
||||
if (!m_fired[idx])
|
||||
{
|
||||
m_output[idx] = 1;
|
||||
case 0:
|
||||
case 2:
|
||||
m_output[idx] = m_output[idx] ^ 1;
|
||||
PLOG(("**ptm6840 %s t%d output %d **\n", tag(), idx, m_output[idx]));
|
||||
m_out_cb[idx](m_output[idx]);
|
||||
break;
|
||||
|
||||
switch (idx)
|
||||
case 4:
|
||||
case 6:
|
||||
if (!m_fired[idx])
|
||||
{
|
||||
case 0:
|
||||
m_out0_cb(m_output[0]);
|
||||
break;
|
||||
case 1:
|
||||
m_out1_cb(m_output[1]);
|
||||
break;
|
||||
case 2:
|
||||
m_out2_cb(m_output[2]);
|
||||
break;
|
||||
m_output[idx] = 1;
|
||||
PLOG(("**ptm6840 %s t%d output %d **\n", tag(), idx, m_output[idx]));
|
||||
|
||||
m_out_cb[idx](m_output[idx]);
|
||||
|
||||
// No changes in output until reinit
|
||||
m_fired[idx] = 1;
|
||||
|
||||
m_status_reg |= (1 << idx);
|
||||
m_status_read_since_int &= ~(1 << idx);
|
||||
update_interrupts();
|
||||
}
|
||||
|
||||
// No changes in output until reinit
|
||||
m_fired[idx] = 1;
|
||||
|
||||
m_status_reg |= (1 << idx);
|
||||
m_status_read_since_int &= ~(1 << idx);
|
||||
update_interrupts();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_enabled[idx]= 0;
|
||||
|
@ -28,13 +28,13 @@
|
||||
ptm6840_device::set_external_clocks(*device, _clk0, _clk1, _clk2);
|
||||
|
||||
#define MCFG_PTM6840_OUT0_CB(_devcb) \
|
||||
devcb = &ptm6840_device::set_out0_callback(*device, DEVCB_##_devcb);
|
||||
devcb = &ptm6840_device::set_out_callback(*device, 0, DEVCB_##_devcb);
|
||||
|
||||
#define MCFG_PTM6840_OUT1_CB(_devcb) \
|
||||
devcb = &ptm6840_device::set_out1_callback(*device, DEVCB_##_devcb);
|
||||
devcb = &ptm6840_device::set_out_callback(*device, 1, DEVCB_##_devcb);
|
||||
|
||||
#define MCFG_PTM6840_OUT2_CB(_devcb) \
|
||||
devcb = &ptm6840_device::set_out2_callback(*device, DEVCB_##_devcb);
|
||||
devcb = &ptm6840_device::set_out_callback(*device, 2, DEVCB_##_devcb);
|
||||
|
||||
#define MCFG_PTM6840_IRQ_CB(_devcb) \
|
||||
devcb = &ptm6840_device::set_irq_callback(*device, DEVCB_##_devcb);
|
||||
@ -53,9 +53,7 @@ public:
|
||||
|
||||
static void set_internal_clock(device_t &device, double clock) { downcast<ptm6840_device &>(device).m_internal_clock = clock; }
|
||||
static void set_external_clocks(device_t &device, double clock0, double clock1, double clock2) { downcast<ptm6840_device &>(device).m_external_clock[0] = clock0; downcast<ptm6840_device &>(device).m_external_clock[1] = clock1; downcast<ptm6840_device &>(device).m_external_clock[2] = clock2; }
|
||||
template<class _Object> static devcb_base &set_out0_callback(device_t &device, _Object object) { return downcast<ptm6840_device &>(device).m_out0_cb.set_callback(object); }
|
||||
template<class _Object> static devcb_base &set_out1_callback(device_t &device, _Object object) { return downcast<ptm6840_device &>(device).m_out1_cb.set_callback(object); }
|
||||
template<class _Object> static devcb_base &set_out2_callback(device_t &device, _Object object) { return downcast<ptm6840_device &>(device).m_out2_cb.set_callback(object); }
|
||||
template<class _Object> static devcb_base &set_out_callback(device_t &device, int index, _Object object) { return downcast<ptm6840_device &>(device).m_out_cb[index].set_callback(object); }
|
||||
template<class _Object> static devcb_base &set_irq_callback(device_t &device, _Object object) { return downcast<ptm6840_device &>(device).m_irq_cb.set_callback(object); }
|
||||
|
||||
int status(int clock) const { return m_enabled[clock]; } // get whether timer is enabled
|
||||
@ -130,10 +128,8 @@ private:
|
||||
double m_internal_clock;
|
||||
double m_external_clock[3];
|
||||
|
||||
devcb_write_line m_out0_cb;
|
||||
devcb_write_line m_out1_cb;
|
||||
devcb_write_line m_out2_cb;
|
||||
devcb_write_line m_irq_cb; // function called if IRQ line changes
|
||||
devcb_write_line m_out_cb[3];
|
||||
devcb_write_line m_irq_cb;
|
||||
|
||||
UINT8 m_control_reg[3];
|
||||
UINT8 m_output[3]; // Output states
|
||||
|
Loading…
Reference in New Issue
Block a user