summaryrefslogtreecommitdiffstats
path: root/src/devices/machine/tms9902.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/machine/tms9902.cpp')
-rw-r--r--src/devices/machine/tms9902.cpp64
1 files changed, 26 insertions, 38 deletions
diff --git a/src/devices/machine/tms9902.cpp b/src/devices/machine/tms9902.cpp
index 6c5b54a6095..68c0f671155 100644
--- a/src/devices/machine/tms9902.cpp
+++ b/src/devices/machine/tms9902.cpp
@@ -63,13 +63,6 @@
#define LOGSETTING(...) LOGMASKED(LOG_SETTING, __VA_ARGS__)
-enum
-{
- DECTIMER,
- RECVTIMER,
- SENDTIMER
-};
-
// Polling frequency. We use a much higher value to allow for line state changes
// happening between character transmissions (which happen in parallel in real
// communications but which must be serialized here)
@@ -254,39 +247,36 @@ void tms9902_device::rcv_break(bool value)
//------------------------------------------------
/*
- Timer callback
+ Timer callbacks
*/
-void tms9902_device::device_timer(emu_timer &timer, device_timer_id id, int param)
+
+TIMER_CALLBACK_MEMBER(tms9902_device::decrementer_expired)
{
- switch (id)
- {
- // This call-back is called by the MAME timer system when the decrementer
- // reaches 0.
- case DECTIMER:
- m_TIMERR = m_TIMELP;
- m_TIMELP = true;
- field_interrupts();
- break;
+ // This call-back is called when the decrementer reaches 0.
+ m_TIMERR = m_TIMELP;
+ m_TIMELP = true;
+ field_interrupts();
+}
+TIMER_CALLBACK_MEMBER(tms9902_device::recv_tick)
+{
// Callback for the autonomous operations of the chip. This is normally
// controlled by an external clock of 3-4 MHz, internally divided by 3 or 4,
// depending on CLK4M. With this timer, reception of characters becomes
// possible.
- case RECVTIMER:
- m_rcv_cb(ASSERT_LINE);
- break;
+ m_rcv_cb(ASSERT_LINE);
+}
- case SENDTIMER:
- // Byte has been sent
- m_XSRE = true;
+TIMER_CALLBACK_MEMBER(tms9902_device::send_tick)
+{
+ // Byte has been sent
+ m_XSRE = true;
- // In the meantime, the CPU may have pushed a new byte into the XBR
- // so we loop until all data are transferred
- if (!m_XBRE && m_CTSin)
- {
- initiate_transmit();
- }
- break;
+ // In the meantime, the CPU may have pushed a new byte into the XBR
+ // so we loop until all data are transferred
+ if (!m_XBRE && m_CTSin)
+ {
+ initiate_transmit();
}
}
@@ -297,10 +287,8 @@ void tms9902_device::reload_interval_timer()
{
if (m_TMR)
{ /* reset clock interval */
- m_dectimer->adjust(
- attotime::from_double((double) m_TMR / (m_clock_rate / ((m_CLK4M) ? 4. : 3.) / 64.)),
- 0,
- attotime::from_double((double) m_TMR / (m_clock_rate / ((m_CLK4M) ? 4. : 3.) / 64.)));
+ attotime rate = attotime::from_double((double) m_TMR / (m_clock_rate / ((m_CLK4M) ? 4. : 3.) / 64.));
+ m_dectimer->adjust(rate, 0, rate);
}
else
{ /* clock interval == 0 -> no timer */
@@ -925,9 +913,9 @@ void tms9902_device::device_start()
m_xmit_cb.resolve_safe();
m_ctrl_cb.resolve_safe();
- m_dectimer = timer_alloc(DECTIMER);
- m_recvtimer = timer_alloc(RECVTIMER);
- m_sendtimer = timer_alloc(SENDTIMER);
+ m_dectimer = timer_alloc(FUNC(tms9902_device::decrementer_expired), this);
+ m_recvtimer = timer_alloc(FUNC(tms9902_device::recv_tick), this);
+ m_sendtimer = timer_alloc(FUNC(tms9902_device::send_tick), this);
save_item(NAME(m_LDCTRL));
save_item(NAME(m_LDIR));