summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/m6502/m3745x.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/cpu/m6502/m3745x.cpp')
-rw-r--r--src/devices/cpu/m6502/m3745x.cpp59
1 files changed, 18 insertions, 41 deletions
diff --git a/src/devices/cpu/m6502/m3745x.cpp b/src/devices/cpu/m6502/m3745x.cpp
index df65754bd78..a8552e51d4b 100644
--- a/src/devices/cpu/m6502/m3745x.cpp
+++ b/src/devices/cpu/m6502/m3745x.cpp
@@ -40,9 +40,9 @@ DEFINE_DEVICE_TYPE(M37450, m37450_device, "m37450", "Mitsubishi M37450")
m3745x_device::m3745x_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, address_map_constructor internal_map) :
m740_device(mconfig, type, tag, owner, clock),
m_program_config("program", ENDIANNESS_LITTLE, 8, 16, 0, internal_map),
- m_read_p{{*this}, {*this}, {*this}, {*this}},
- m_write_p{{*this}, {*this}, {*this}, {*this}},
- m_read_ad{{*this}, {*this}, {*this}, {*this}, {*this}, {*this}, {*this}, {*this}},
+ m_read_p(*this, 0),
+ m_write_p(*this),
+ m_read_ad(*this, 0),
m_intreq1(0),
m_intreq2(0),
m_intctrl1(0),
@@ -58,20 +58,11 @@ m3745x_device::m3745x_device(const machine_config &mconfig, device_type type, co
void m3745x_device::device_start()
{
- for (int i = 0; i < 4; i++)
+ for (int i = TIMER_1; i <= TIMER_3; i++)
{
- m_read_p[i].resolve_safe(0);
- m_write_p[i].resolve_safe();
- }
- for (int i = 0; i < 8; i++)
- {
- m_read_ad[i].resolve_safe(0);
- }
-
- for (int i = 0; i < NUM_TIMERS; i++)
- {
- m_timers[i] = timer_alloc(i, nullptr);
+ m_timers[i] = machine().scheduler().timer_alloc(timer_expired_delegate());
}
+ m_timers[TIMER_ADC] = timer_alloc(FUNC(m3745x_device::adc_complete), this);
m740_device::device_start();
@@ -122,22 +113,13 @@ void m3745x_device::device_reset()
m_last_all_ints = 0;
}
-void m3745x_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+TIMER_CALLBACK_MEMBER(m3745x_device::adc_complete)
{
- switch (id)
- {
- case TIMER_ADC:
- m_timers[TIMER_ADC]->adjust(attotime::never);
-
- m_adctrl |= ADCTRL_COMPLETE;
- m_intreq2 |= IRQ2_ADC;
- recalc_irqs();
- break;
+ m_timers[TIMER_ADC]->adjust(attotime::never);
- default:
- printf("M3775x: unknown timer expire %d\n", id);
- break;
- }
+ m_adctrl |= ADCTRL_COMPLETE;
+ m_intreq2 |= IRQ2_ADC;
+ recalc_irqs();
}
void m3745x_device::execute_set_input(int inputnum, int state)
@@ -176,10 +158,6 @@ void m3745x_device::execute_set_input(int inputnum, int state)
m_intreq1 &= ~IRQ1_INT3;
}
break;
-
- case M3745X_SET_OVERFLOW: // the base 740 class can handle this
- m740_device::execute_set_input(M740_SET_OVERFLOW, state);
- break;
}
recalc_irqs();
@@ -249,7 +227,7 @@ uint8_t m3745x_device::read_port(uint8_t offset)
return incoming;
}
-READ8_MEMBER(m3745x_device::ports_r)
+uint8_t m3745x_device::ports_r(offs_t offset)
{
switch (offset)
{
@@ -278,7 +256,7 @@ READ8_MEMBER(m3745x_device::ports_r)
return 0xff;
}
-WRITE8_MEMBER(m3745x_device::ports_w)
+void m3745x_device::ports_w(offs_t offset, uint8_t data)
{
switch (offset)
{
@@ -319,7 +297,7 @@ WRITE8_MEMBER(m3745x_device::ports_w)
}
}
-READ8_MEMBER(m3745x_device::intregs_r)
+uint8_t m3745x_device::intregs_r(offs_t offset)
{
switch (offset)
{
@@ -341,7 +319,7 @@ READ8_MEMBER(m3745x_device::intregs_r)
return 0;
}
-WRITE8_MEMBER(m3745x_device::intregs_w)
+void m3745x_device::intregs_w(offs_t offset, uint8_t data)
{
switch (offset)
{
@@ -365,7 +343,7 @@ WRITE8_MEMBER(m3745x_device::intregs_w)
recalc_irqs();
}
-READ8_MEMBER(m3745x_device::adc_r)
+uint8_t m3745x_device::adc_r(offs_t offset)
{
switch (offset)
{
@@ -381,7 +359,7 @@ READ8_MEMBER(m3745x_device::adc_r)
return 0;
}
-WRITE8_MEMBER(m3745x_device::adc_w)
+void m3745x_device::adc_w(offs_t offset, uint8_t data)
{
switch (offset)
{
@@ -395,8 +373,7 @@ WRITE8_MEMBER(m3745x_device::adc_w)
// starting a conversion? this takes 50 cycles.
if (!(m_adctrl & ADCTRL_COMPLETE))
{
- double hz = (double)clock() / 50.0;
- m_timers[TIMER_ADC]->adjust(attotime::from_hz(hz));
+ m_timers[TIMER_ADC]->adjust(cycles_to_attotime(50));
}
break;
}