Keep MSVC and me happy :) (no whatsnew)

This commit is contained in:
Phil Bennett 2010-08-25 11:13:20 +00:00
parent 0584baf45f
commit b49370f475
2 changed files with 194 additions and 194 deletions

View File

@ -40,7 +40,7 @@ enum
//------------------------------------------------- //-------------------------------------------------
riot6532_device_config::riot6532_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) riot6532_device_config::riot6532_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
: device_config(mconfig, static_alloc_device_config, "RIOT6532", tag, owner, clock) : device_config(mconfig, static_alloc_device_config, "RIOT6532", tag, owner, clock)
{ {
} }
@ -52,7 +52,7 @@ riot6532_device_config::riot6532_device_config(const machine_config &mconfig, co
device_config *riot6532_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) device_config *riot6532_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
{ {
return global_alloc(riot6532_device_config(mconfig, tag, owner, clock)); return global_alloc(riot6532_device_config(mconfig, tag, owner, clock));
} }
@ -62,7 +62,7 @@ device_config *riot6532_device_config::static_alloc_device_config(const machine_
device_t *riot6532_device_config::alloc_device(running_machine &machine) const device_t *riot6532_device_config::alloc_device(running_machine &machine) const
{ {
return auto_alloc(&machine, riot6532_device(machine, *this)); return auto_alloc(&machine, riot6532_device(machine, *this));
} }
@ -74,22 +74,22 @@ device_t *riot6532_device_config::alloc_device(running_machine &machine) const
void riot6532_device_config::device_config_complete() void riot6532_device_config::device_config_complete()
{ {
// inherit a copy of the static data // inherit a copy of the static data
const riot6532_interface *intf = reinterpret_cast<const riot6532_interface *>(static_config()); const riot6532_interface *intf = reinterpret_cast<const riot6532_interface *>(static_config());
if (intf != NULL) if (intf != NULL)
{ {
*static_cast<riot6532_interface *>(this) = *intf; *static_cast<riot6532_interface *>(this) = *intf;
} }
// or initialize to defaults if none provided // or initialize to defaults if none provided
else else
{ {
memset(&m_in_a_func, 0, sizeof(m_in_a_func)); memset(&m_in_a_func, 0, sizeof(m_in_a_func));
memset(&m_in_b_func, 0, sizeof(m_in_b_func)); memset(&m_in_b_func, 0, sizeof(m_in_b_func));
memset(&m_out_a_func, 0, sizeof(m_out_a_func)); memset(&m_out_a_func, 0, sizeof(m_out_a_func));
memset(&m_out_b_func, 0, sizeof(m_out_b_func)); memset(&m_out_b_func, 0, sizeof(m_out_b_func));
memset(&m_irq_func, 0, sizeof(m_irq_func)); memset(&m_irq_func, 0, sizeof(m_irq_func));
} }
} }
@ -108,13 +108,13 @@ void riot6532_device::update_irqstate()
int state = (m_irqstate & m_irqenable); int state = (m_irqstate & m_irqenable);
if (m_irq_func.write != NULL) if (m_irq_func.write != NULL)
{ {
devcb_call_write_line(&m_irq_func, (state != 0) ? ASSERT_LINE : CLEAR_LINE); devcb_call_write_line(&m_irq_func, (state != 0) ? ASSERT_LINE : CLEAR_LINE);
} }
else else
{ {
logerror("%s:6532RIOT chip #%d: no irq callback function\n", cpuexec_describe_context(&m_machine), m_index); logerror("%s:6532RIOT chip #%d: no irq callback function\n", cpuexec_describe_context(&m_machine), m_index);
} }
} }
@ -156,21 +156,21 @@ UINT8 riot6532_device::get_timer()
{ {
/* if idle, return 0 */ /* if idle, return 0 */
if (m_timerstate == TIMER_IDLE) if (m_timerstate == TIMER_IDLE)
{ {
return 0; return 0;
} }
/* if counting, return the number of ticks remaining */ /* if counting, return the number of ticks remaining */
else if (m_timerstate == TIMER_COUNTING) else if (m_timerstate == TIMER_COUNTING)
{ {
return attotime_to_ticks(timer_timeleft(m_timer), clock()) >> m_timershift; return attotime_to_ticks(timer_timeleft(m_timer), clock()) >> m_timershift;
} }
/* if finishing, return the number of ticks without the shift */ /* if finishing, return the number of ticks without the shift */
else else
{ {
return attotime_to_ticks(timer_timeleft(m_timer), clock()); return attotime_to_ticks(timer_timeleft(m_timer), clock());
} }
} }
@ -182,8 +182,8 @@ UINT8 riot6532_device::get_timer()
TIMER_CALLBACK( riot6532_device::timer_end_callback ) TIMER_CALLBACK( riot6532_device::timer_end_callback )
{ {
riot6532_device *via = reinterpret_cast<riot6532_device *>(ptr); riot6532_device *via = reinterpret_cast<riot6532_device *>(ptr);
via->timer_end(); via->timer_end();
} }
void riot6532_device::timer_end() void riot6532_device::timer_end()
@ -220,8 +220,8 @@ void riot6532_device::timer_end()
WRITE8_DEVICE_HANDLER( riot6532_w ) WRITE8_DEVICE_HANDLER( riot6532_w )
{ {
riot6532_device *via = reinterpret_cast<riot6532_device *>(device); riot6532_device *via = downcast<riot6532_device *>(device);
via->reg_w(offset, data); via->reg_w(offset, data);
} }
void riot6532_device::reg_w(UINT8 offset, UINT8 data) void riot6532_device::reg_w(UINT8 offset, UINT8 data)
@ -244,9 +244,9 @@ void riot6532_device::reg_w(UINT8 offset, UINT8 data)
/* writes here clear the timer flag */ /* writes here clear the timer flag */
if (m_timerstate != TIMER_FINISHING || get_timer() != 0xff) if (m_timerstate != TIMER_FINISHING || get_timer() != 0xff)
{ {
m_irqstate &= ~TIMER_FLAG; m_irqstate &= ~TIMER_FLAG;
} }
update_irqstate(); update_irqstate();
/* update the timer */ /* update the timer */
@ -260,13 +260,13 @@ void riot6532_device::reg_w(UINT8 offset, UINT8 data)
{ {
/* A1 contains the A7 IRQ enable */ /* A1 contains the A7 IRQ enable */
if (offset & 2) if (offset & 2)
{ {
m_irqenable |= PA7_FLAG; m_irqenable |= PA7_FLAG;
} }
else else
{ {
m_irqenable &= ~PA7_FLAG; m_irqenable &= ~PA7_FLAG;
} }
/* A0 specifies the edge detect direction: 0=negative, 1=positive */ /* A0 specifies the edge detect direction: 0=negative, 1=positive */
m_pa7dir = (offset & 1) << 7; m_pa7dir = (offset & 1) << 7;
@ -280,29 +280,29 @@ void riot6532_device::reg_w(UINT8 offset, UINT8 data)
/* if A0 == 1, we are writing to the port's DDR */ /* if A0 == 1, we are writing to the port's DDR */
if (offset & 1) if (offset & 1)
{ {
port->m_ddr = data; port->m_ddr = data;
} }
/* if A0 == 0, we are writing to the port's output */ /* if A0 == 0, we are writing to the port's output */
else else
{ {
port->m_out = data; port->m_out = data;
if (port->m_out_func.write != NULL) if (port->m_out_func.write != NULL)
{ {
devcb_call_write8(&port->m_out_func, 0, data); devcb_call_write8(&port->m_out_func, 0, data);
} }
else else
{ {
logerror("%s:6532RIOT chip %s: Port %c is being written to but has no handler. %02X\n", cpuexec_describe_context(&m_machine), tag(), 'A' + (offset & 1), data); logerror("%s:6532RIOT chip %s: Port %c is being written to but has no handler. %02X\n", cpuexec_describe_context(&m_machine), tag(), 'A' + (offset & 1), data);
} }
} }
/* writes to port A need to update the PA7 state */ /* writes to port A need to update the PA7 state */
if (port == &m_port[0]) if (port == &m_port[0])
{ {
update_pa7_state(); update_pa7_state();
} }
} }
} }
@ -313,8 +313,8 @@ void riot6532_device::reg_w(UINT8 offset, UINT8 data)
READ8_DEVICE_HANDLER( riot6532_r ) READ8_DEVICE_HANDLER( riot6532_r )
{ {
riot6532_device *via = reinterpret_cast<riot6532_device *>(device); riot6532_device *via = downcast<riot6532_device *>(device);
return via->reg_r(offset); return via->reg_r(offset);
} }
UINT8 riot6532_device::reg_r(UINT8 offset) UINT8 riot6532_device::reg_r(UINT8 offset)
@ -338,19 +338,19 @@ UINT8 riot6532_device::reg_r(UINT8 offset)
/* A3 contains the timer IRQ enable */ /* A3 contains the timer IRQ enable */
if (offset & 8) if (offset & 8)
{ {
m_irqenable |= TIMER_FLAG; m_irqenable |= TIMER_FLAG;
} }
else else
{ {
m_irqenable &= ~TIMER_FLAG; m_irqenable &= ~TIMER_FLAG;
} }
/* implicitly clears the timer flag */ /* implicitly clears the timer flag */
if (m_timerstate != TIMER_FINISHING || val != 0xff) if (m_timerstate != TIMER_FINISHING || val != 0xff)
{ {
m_irqstate &= ~TIMER_FLAG; m_irqstate &= ~TIMER_FLAG;
} }
update_irqstate(); update_irqstate();
} }
@ -362,9 +362,9 @@ UINT8 riot6532_device::reg_r(UINT8 offset)
/* if A0 == 1, we are reading the port's DDR */ /* if A0 == 1, we are reading the port's DDR */
if (offset & 1) if (offset & 1)
{ {
val = port->m_ddr; val = port->m_ddr;
} }
/* if A0 == 0, we are reading the port as an input */ /* if A0 == 0, we are reading the port as an input */
else else
@ -376,14 +376,14 @@ UINT8 riot6532_device::reg_r(UINT8 offset)
/* changes to port A need to update the PA7 state */ /* changes to port A need to update the PA7 state */
if (port == &m_port[0]) if (port == &m_port[0])
{ {
update_pa7_state(); update_pa7_state();
} }
} }
else else
{ {
logerror("%s:6532RIOT chip %s: Port %c is being read but has no handler\n", cpuexec_describe_context(&m_machine), tag(), 'A' + (offset & 1)); logerror("%s:6532RIOT chip %s: Port %c is being read but has no handler\n", cpuexec_describe_context(&m_machine), tag(), 'A' + (offset & 1));
} }
/* apply the DDR to the result */ /* apply the DDR to the result */
val = apply_ddr(port); val = apply_ddr(port);
@ -399,8 +399,8 @@ UINT8 riot6532_device::reg_r(UINT8 offset)
void riot6532_porta_in_set(running_device *device, UINT8 data, UINT8 mask) void riot6532_porta_in_set(running_device *device, UINT8 data, UINT8 mask)
{ {
riot6532_device *via = reinterpret_cast<riot6532_device *>(device); riot6532_device *via = downcast<riot6532_device *>(device);
via->porta_in_set(data, mask); via->porta_in_set(data, mask);
} }
void riot6532_device::porta_in_set(UINT8 data, UINT8 mask) void riot6532_device::porta_in_set(UINT8 data, UINT8 mask)
@ -416,8 +416,8 @@ void riot6532_device::porta_in_set(UINT8 data, UINT8 mask)
void riot6532_portb_in_set(running_device *device, UINT8 data, UINT8 mask) void riot6532_portb_in_set(running_device *device, UINT8 data, UINT8 mask)
{ {
riot6532_device *via = reinterpret_cast<riot6532_device *>(device); riot6532_device *via = downcast<riot6532_device *>(device);
via->portb_in_set(data, mask); via->portb_in_set(data, mask);
} }
void riot6532_device::portb_in_set(UINT8 data, UINT8 mask) void riot6532_device::portb_in_set(UINT8 data, UINT8 mask)
@ -432,8 +432,8 @@ void riot6532_device::portb_in_set(UINT8 data, UINT8 mask)
UINT8 riot6532_porta_in_get(running_device *device) UINT8 riot6532_porta_in_get(running_device *device)
{ {
riot6532_device *via = reinterpret_cast<riot6532_device *>(device); riot6532_device *via = downcast<riot6532_device *>(device);
return via->porta_in_get(); return via->porta_in_get();
} }
UINT8 riot6532_device::porta_in_get() UINT8 riot6532_device::porta_in_get()
@ -448,8 +448,8 @@ UINT8 riot6532_device::porta_in_get()
UINT8 riot6532_portb_in_get(running_device *device) UINT8 riot6532_portb_in_get(running_device *device)
{ {
riot6532_device *via = reinterpret_cast<riot6532_device *>(device); riot6532_device *via = downcast<riot6532_device *>(device);
return via->portb_in_get(); return via->portb_in_get();
} }
UINT8 riot6532_device::portb_in_get() UINT8 riot6532_device::portb_in_get()
@ -464,8 +464,8 @@ UINT8 riot6532_device::portb_in_get()
UINT8 riot6532_porta_out_get(running_device *device) UINT8 riot6532_porta_out_get(running_device *device)
{ {
riot6532_device *via = reinterpret_cast<riot6532_device *>(device); riot6532_device *via = downcast<riot6532_device *>(device);
return via->porta_out_get(); return via->porta_out_get();
} }
UINT8 riot6532_device::porta_out_get() UINT8 riot6532_device::porta_out_get()
@ -480,8 +480,8 @@ UINT8 riot6532_device::porta_out_get()
UINT8 riot6532_portb_out_get(running_device *device) UINT8 riot6532_portb_out_get(running_device *device)
{ {
riot6532_device *via = reinterpret_cast<riot6532_device *>(device); riot6532_device *via = downcast<riot6532_device *>(device);
return via->portb_out_get(); return via->portb_out_get();
} }
UINT8 riot6532_device::portb_out_get() UINT8 riot6532_device::portb_out_get()
@ -499,8 +499,8 @@ UINT8 riot6532_device::portb_out_get()
//------------------------------------------------- //-------------------------------------------------
riot6532_device::riot6532_device(running_machine &_machine, const riot6532_device_config &config) riot6532_device::riot6532_device(running_machine &_machine, const riot6532_device_config &config)
: device_t(_machine, config), : device_t(_machine, config),
m_config(config) m_config(config)
{ {
} }
@ -517,33 +517,33 @@ void riot6532_device::device_start()
m_index = m_machine.m_devicelist.index(RIOT6532, tag()); m_index = m_machine.m_devicelist.index(RIOT6532, tag());
/* configure the ports */ /* configure the ports */
devcb_resolve_read8(&m_port[0].m_in_func, &m_config.m_in_a_func, this); devcb_resolve_read8(&m_port[0].m_in_func, &m_config.m_in_a_func, this);
devcb_resolve_write8(&m_port[0].m_out_func, &m_config.m_out_a_func, this); devcb_resolve_write8(&m_port[0].m_out_func, &m_config.m_out_a_func, this);
devcb_resolve_read8(&m_port[1].m_in_func, &m_config.m_in_b_func, this); devcb_resolve_read8(&m_port[1].m_in_func, &m_config.m_in_b_func, this);
devcb_resolve_write8(&m_port[1].m_out_func, &m_config.m_out_b_func, this); devcb_resolve_write8(&m_port[1].m_out_func, &m_config.m_out_b_func, this);
/* resolve irq func */ /* resolve irq func */
devcb_resolve_write_line(&m_irq_func, &m_config.m_irq_func, this); devcb_resolve_write_line(&m_irq_func, &m_config.m_irq_func, this);
/* allocate timers */ /* allocate timers */
m_timer = timer_alloc(&m_machine, timer_end_callback, (void *)this); m_timer = timer_alloc(&m_machine, timer_end_callback, (void *)this);
/* register for save states */ /* register for save states */
state_save_register_device_item(this, 0, m_port[0].m_in); state_save_register_device_item(this, 0, m_port[0].m_in);
state_save_register_device_item(this, 0, m_port[0].m_out); state_save_register_device_item(this, 0, m_port[0].m_out);
state_save_register_device_item(this, 0, m_port[0].m_ddr); state_save_register_device_item(this, 0, m_port[0].m_ddr);
state_save_register_device_item(this, 0, m_port[1].m_in); state_save_register_device_item(this, 0, m_port[1].m_in);
state_save_register_device_item(this, 0, m_port[1].m_out); state_save_register_device_item(this, 0, m_port[1].m_out);
state_save_register_device_item(this, 0, m_port[1].m_ddr); state_save_register_device_item(this, 0, m_port[1].m_ddr);
state_save_register_device_item(this, 0, m_irqstate); state_save_register_device_item(this, 0, m_irqstate);
state_save_register_device_item(this, 0, m_irqenable); state_save_register_device_item(this, 0, m_irqenable);
state_save_register_device_item(this, 0, m_pa7dir); state_save_register_device_item(this, 0, m_pa7dir);
state_save_register_device_item(this, 0, m_pa7prev); state_save_register_device_item(this, 0, m_pa7prev);
state_save_register_device_item(this, 0, m_timershift); state_save_register_device_item(this, 0, m_timershift);
state_save_register_device_item(this, 0, m_timerstate); state_save_register_device_item(this, 0, m_timerstate);
} }

View File

@ -23,7 +23,7 @@
//------------------------------------------------- //-------------------------------------------------
ttl74123_device_config::ttl74123_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) ttl74123_device_config::ttl74123_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
: device_config(mconfig, static_alloc_device_config, "TTL74123", tag, owner, clock) : device_config(mconfig, static_alloc_device_config, "TTL74123", tag, owner, clock)
{ {
} }
@ -35,7 +35,7 @@ ttl74123_device_config::ttl74123_device_config(const machine_config &mconfig, co
device_config *ttl74123_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) device_config *ttl74123_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
{ {
return global_alloc(ttl74123_device_config(mconfig, tag, owner, clock)); return global_alloc(ttl74123_device_config(mconfig, tag, owner, clock));
} }
@ -45,7 +45,7 @@ device_config *ttl74123_device_config::static_alloc_device_config(const machine_
device_t *ttl74123_device_config::alloc_device(running_machine &machine) const device_t *ttl74123_device_config::alloc_device(running_machine &machine) const
{ {
return auto_alloc(&machine, ttl74123_device(machine, *this)); return auto_alloc(&machine, ttl74123_device(machine, *this));
} }
@ -71,8 +71,8 @@ void ttl74123_device_config::device_config_complete()
//------------------------------------------------- //-------------------------------------------------
ttl74123_device::ttl74123_device(running_machine &_machine, const ttl74123_device_config &config) ttl74123_device::ttl74123_device(running_machine &_machine, const ttl74123_device_config &config)
: device_t(_machine, config), : device_t(_machine, config),
m_config(config) m_config(config)
{ {
} }
@ -84,17 +84,17 @@ ttl74123_device::ttl74123_device(running_machine &_machine, const ttl74123_devic
void ttl74123_device::device_start() void ttl74123_device::device_start()
{ {
m_timer = timer_alloc(&m_machine, clear_callback, (void *)this); m_timer = timer_alloc(&m_machine, clear_callback, (void *)this);
/* start with the defaults */ /* start with the defaults */
m_a = m_config.m_a; m_a = m_config.m_a;
m_b = m_config.m_b; m_b = m_config.m_b;
m_clear = m_config.m_clear; m_clear = m_config.m_clear;
/* register for state saving */ /* register for state saving */
state_save_register_device_item(this, 0, m_a); state_save_register_device_item(this, 0, m_a);
state_save_register_device_item(this, 0, m_b); state_save_register_device_item(this, 0, m_b);
state_save_register_device_item(this, 0, m_clear); state_save_register_device_item(this, 0, m_clear);
} }
@ -115,33 +115,33 @@ void ttl74123_device::device_reset()
attotime ttl74123_device::compute_duration() attotime ttl74123_device::compute_duration()
{ {
double duration; double duration;
switch (m_config.m_connection_type) switch (m_config.m_connection_type)
{ {
case TTL74123_NOT_GROUNDED_NO_DIODE: case TTL74123_NOT_GROUNDED_NO_DIODE:
duration = 0.28 * m_config.m_res * m_config.m_cap * (1.0 + (700.0 / m_config.m_res)); duration = 0.28 * m_config.m_res * m_config.m_cap * (1.0 + (700.0 / m_config.m_res));
break; break;
case TTL74123_NOT_GROUNDED_DIODE: case TTL74123_NOT_GROUNDED_DIODE:
duration = 0.25 * m_config.m_res * m_config.m_cap * (1.0 + (700.0 / m_config.m_res)); duration = 0.25 * m_config.m_res * m_config.m_cap * (1.0 + (700.0 / m_config.m_res));
break; break;
case TTL74123_GROUNDED: case TTL74123_GROUNDED:
default: default:
if (m_config.m_cap < CAP_U(0.1)) if (m_config.m_cap < CAP_U(0.1))
{ {
/* this is really a curve - a very flat one in the 0.1uF-.01uF range */ /* this is really a curve - a very flat one in the 0.1uF-.01uF range */
duration = 0.32 * m_config.m_res * m_config.m_cap; duration = 0.32 * m_config.m_res * m_config.m_cap;
} }
else else
{ {
duration = 0.33 * m_config.m_res * m_config.m_cap; duration = 0.33 * m_config.m_res * m_config.m_cap;
} }
break; break;
} }
return double_to_attotime(duration); return double_to_attotime(duration);
} }
@ -151,150 +151,150 @@ attotime ttl74123_device::compute_duration()
int ttl74123_device::timer_running() int ttl74123_device::timer_running()
{ {
return (attotime_compare(timer_timeleft(m_timer), attotime_zero) > 0) && return (attotime_compare(timer_timeleft(m_timer), attotime_zero) > 0) &&
(attotime_compare(timer_timeleft(m_timer), attotime_never) != 0); (attotime_compare(timer_timeleft(m_timer), attotime_never) != 0);
} }
/*------------------------------------------------- /*-------------------------------------------------
TIMER_CALLBACK( output_callback ) TIMER_CALLBACK( output_callback )
-------------------------------------------------*/ -------------------------------------------------*/
TIMER_CALLBACK( ttl74123_device::output_callback ) TIMER_CALLBACK( ttl74123_device::output_callback )
{ {
ttl74123_device *dev = reinterpret_cast<ttl74123_device*>(ptr); ttl74123_device *dev = reinterpret_cast<ttl74123_device*>(ptr);
dev->output(param); dev->output(param);
} }
void ttl74123_device::output(INT32 param) void ttl74123_device::output(INT32 param)
{ {
m_config.m_output_changed_cb(this, 0, param); m_config.m_output_changed_cb(this, 0, param);
} }
void ttl74123_device::set_output() void ttl74123_device::set_output()
{ {
int output = timer_running(); int output = timer_running();
timer_set( &m_machine, attotime_zero, (void *)this, output, output_callback ); timer_set( &m_machine, attotime_zero, (void *)this, output, output_callback );
if (LOG) logerror("74123 %s: Output: %d\n", tag(), output); if (LOG) logerror("74123 %s: Output: %d\n", tag(), output);
} }
TIMER_CALLBACK( ttl74123_device::clear_callback ) TIMER_CALLBACK( ttl74123_device::clear_callback )
{ {
ttl74123_device *dev = reinterpret_cast<ttl74123_device*>(ptr); ttl74123_device *dev = reinterpret_cast<ttl74123_device*>(ptr);
dev->clear(); dev->clear();
} }
void ttl74123_device::clear() void ttl74123_device::clear()
{ {
int output = timer_running(); int output = timer_running();
m_config.m_output_changed_cb(this, 0, output); m_config.m_output_changed_cb(this, 0, output);
} }
void ttl74123_device::start_pulse() void ttl74123_device::start_pulse()
{ {
attotime duration = compute_duration(); attotime duration = compute_duration();
if(timer_running()) if(timer_running())
{ {
/* retriggering, but not if we are called to quickly */ /* retriggering, but not if we are called to quickly */
attotime delay_time = attotime_make(0, ATTOSECONDS_PER_SECOND * m_config.m_cap * 220); attotime delay_time = attotime_make(0, ATTOSECONDS_PER_SECOND * m_config.m_cap * 220);
if(attotime_compare(timer_timeelapsed(m_timer), delay_time) >= 0) if(attotime_compare(timer_timeelapsed(m_timer), delay_time) >= 0)
{ {
timer_adjust_oneshot(m_timer, duration, 0); timer_adjust_oneshot(m_timer, duration, 0);
if (LOG) logerror("74123 %s: Retriggering pulse. Duration: %f\n", tag(), attotime_to_double(duration)); if (LOG) logerror("74123 %s: Retriggering pulse. Duration: %f\n", tag(), attotime_to_double(duration));
} }
else else
{ {
if (LOG) logerror("74123 %s: Retriggering failed.\n", tag()); if (LOG) logerror("74123 %s: Retriggering failed.\n", tag());
} }
} }
else else
{ {
/* starting */ /* starting */
timer_adjust_oneshot(m_timer, duration, 0); timer_adjust_oneshot(m_timer, duration, 0);
set_output(); set_output();
if (LOG) logerror("74123 %s: Starting pulse. Duration: %f\n", tag(), attotime_to_double(duration)); if (LOG) logerror("74123 %s: Starting pulse. Duration: %f\n", tag(), attotime_to_double(duration));
} }
} }
WRITE8_DEVICE_HANDLER( ttl74123_a_w ) WRITE8_DEVICE_HANDLER( ttl74123_a_w )
{ {
ttl74123_device *dev = reinterpret_cast<ttl74123_device *>(device); ttl74123_device *dev = downcast<ttl74123_device *>(device);
dev->a_w(data); dev->a_w(data);
} }
void ttl74123_device::a_w(UINT8 data) void ttl74123_device::a_w(UINT8 data)
{ {
/* start/regtrigger pulse if B=HI and falling edge on A (while clear is HI) */ /* start/regtrigger pulse if B=HI and falling edge on A (while clear is HI) */
if (!data && m_a && m_b && m_clear) if (!data && m_a && m_b && m_clear)
{ {
start_pulse(); start_pulse();
} }
m_a = data; m_a = data;
} }
WRITE8_DEVICE_HANDLER( ttl74123_b_w ) WRITE8_DEVICE_HANDLER( ttl74123_b_w )
{ {
ttl74123_device *dev = reinterpret_cast<ttl74123_device *>(device); ttl74123_device *dev = downcast<ttl74123_device *>(device);
dev->b_w(data); dev->b_w(data);
} }
void ttl74123_device::b_w(UINT8 data) void ttl74123_device::b_w(UINT8 data)
{ {
/* start/regtrigger pulse if A=LO and rising edge on B (while clear is HI) */ /* start/regtrigger pulse if A=LO and rising edge on B (while clear is HI) */
if (data && !m_b && !m_a && m_clear) if (data && !m_b && !m_a && m_clear)
{ {
start_pulse(); start_pulse();
} }
m_b = data; m_b = data;
} }
WRITE8_DEVICE_HANDLER( ttl74123_clear_w ) WRITE8_DEVICE_HANDLER( ttl74123_clear_w )
{ {
ttl74123_device *dev = reinterpret_cast<ttl74123_device *>(device); ttl74123_device *dev = downcast<ttl74123_device *>(device);
dev->clear_w(data); dev->clear_w(data);
} }
void ttl74123_device::clear_w(UINT8 data) void ttl74123_device::clear_w(UINT8 data)
{ {
/* start/regtrigger pulse if B=HI and A=LO and rising edge on clear */ /* start/regtrigger pulse if B=HI and A=LO and rising edge on clear */
if (data && !m_a && m_b && !m_clear) if (data && !m_a && m_b && !m_clear)
{ {
start_pulse(); start_pulse();
} }
else if (!data) /* clear the output */ else if (!data) /* clear the output */
{ {
timer_adjust_oneshot(m_timer, attotime_zero, 0); timer_adjust_oneshot(m_timer, attotime_zero, 0);
if (LOG) logerror("74123 #%s: Cleared\n", tag() ); if (LOG) logerror("74123 #%s: Cleared\n", tag() );
} }
m_clear = data; m_clear = data;
} }
WRITE8_DEVICE_HANDLER( ttl74123_reset_w ) WRITE8_DEVICE_HANDLER( ttl74123_reset_w )
{ {
ttl74123_device *dev = reinterpret_cast<ttl74123_device *>(device); ttl74123_device *dev = downcast<ttl74123_device *>(device);
dev->reset_w(); dev->reset_w();
} }
void ttl74123_device::reset_w() void ttl74123_device::reset_w()
{ {
set_output(); set_output();
} }
const device_type TTL74123 = ttl74123_device_config::static_alloc_device_config; const device_type TTL74123 = ttl74123_device_config::static_alloc_device_config;