summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/m6502/m5074x.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/cpu/m6502/m5074x.cpp')
-rw-r--r--src/devices/cpu/m6502/m5074x.cpp131
1 files changed, 57 insertions, 74 deletions
diff --git a/src/devices/cpu/m6502/m5074x.cpp b/src/devices/cpu/m6502/m5074x.cpp
index 46e6fffc9ae..eb24e461e1f 100644
--- a/src/devices/cpu/m6502/m5074x.cpp
+++ b/src/devices/cpu/m6502/m5074x.cpp
@@ -43,7 +43,7 @@ DEFINE_DEVICE_TYPE(M50753, m50753_device, "m50753", "Mitsubishi M50753")
m5074x_device::m5074x_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, int addrbits, address_map_constructor internal_map) :
m740_device(mconfig, type, tag, owner, clock),
m_program_config("program", ENDIANNESS_LITTLE, 8, addrbits, 0, internal_map),
- m_read_p(*this),
+ m_read_p(*this, 0),
m_write_p(*this),
m_intctrl(0),
m_tmrctrl(0),
@@ -57,6 +57,7 @@ m5074x_device::m5074x_device(const machine_config &mconfig, device_type type, co
m_tmrxlatch(0),
m_last_all_ints(0)
{
+ std::fill(std::begin(m_pullups), std::end(m_pullups), 0);
}
//-------------------------------------------------
@@ -65,13 +66,10 @@ m5074x_device::m5074x_device(const machine_config &mconfig, device_type type, co
void m5074x_device::device_start()
{
- m_read_p.resolve_all_safe(0);
- m_write_p.resolve_all_safe();
-
- for (int i = 0; i < NUM_TIMERS; i++)
- {
- m_timers[i] = timer_alloc(i, nullptr);
- }
+ m_timers[TIMER_1] = timer_alloc(FUNC(m5074x_device::timer1_tick), this);
+ m_timers[TIMER_2] = timer_alloc(FUNC(m5074x_device::timer2_tick), this);
+ m_timers[TIMER_X] = timer_alloc(FUNC(m5074x_device::timerx_tick), this);
+ m_timers[TIMER_ADC] = timer_alloc(FUNC(m5074x_device::adc_complete), this);
m740_device::device_start();
@@ -121,42 +119,39 @@ void m5074x_device::device_reset()
m_tmr1 = m_tmr2 = m_tmrx = 0;
}
-void m5074x_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+TIMER_CALLBACK_MEMBER(m5074x_device::timer1_tick)
{
- switch (id)
- {
- case TIMER_1:
- m_tmr1--;
+ m_tmr1--;
- if (m_tmr1 <= 0)
- {
- m_intctrl |= IRQ_TMR1REQ;
- m_tmr1 = m_tmr1latch;
- recalc_irqs();
- }
- break;
+ if (m_tmr1 <= 0)
+ {
+ m_intctrl |= IRQ_TMR1REQ;
+ m_tmr1 = m_tmr1latch;
+ recalc_irqs();
+ }
+}
- case TIMER_2:
- m_tmr2--;
+TIMER_CALLBACK_MEMBER(m5074x_device::timer2_tick)
+{
+ m_tmr2--;
- if (m_tmr2 <= 0)
- {
- m_intctrl |= IRQ_TMR2REQ;
- m_tmr2 = m_tmr2latch;
- recalc_irqs();
- }
- break;
+ if (m_tmr2 <= 0)
+ {
+ m_intctrl |= IRQ_TMR2REQ;
+ m_tmr2 = m_tmr2latch;
+ recalc_irqs();
+ }
+}
- case TIMER_X:
- m_tmrx--;
+TIMER_CALLBACK_MEMBER(m5074x_device::timerx_tick)
+{
+ m_tmrx--;
- if (m_tmrx <= 0)
- {
- m_tmrctrl |= TMRC_TMRXREQ;
- m_tmrx = m_tmrxlatch;
- recalc_irqs();
- }
- break;
+ if (m_tmrx <= 0)
+ {
+ m_tmrctrl |= TMRC_TMRXREQ;
+ m_tmrx = m_tmrxlatch;
+ recalc_irqs();
}
}
@@ -315,7 +310,7 @@ uint8_t m5074x_device::ports_r(offs_t offset)
return m_ddrs[3];
case 0xa:
- return read_port(4);
+ return read_port(4) & 0x0f;
case 0xb:
return m_ddrs[4];
@@ -329,53 +324,53 @@ void m5074x_device::ports_w(offs_t offset, uint8_t data)
switch (offset)
{
case 0: // p0
- send_port(0, data & m_ddrs[0]);
+ send_port(0, (data & m_ddrs[0]) | (m_pullups[0] & ~m_ddrs[0]));
m_ports[0] = data;
break;
case 1: // p0 ddr
- send_port(0, m_ports[0] & data);
+ send_port(0, (m_ports[0] & data) | (m_pullups[0] & ~data));
m_ddrs[0] = data;
break;
case 2: // p1
- send_port(1, data & m_ddrs[1]);
+ send_port(1, (data & m_ddrs[1]) | (m_pullups[1] & ~m_ddrs[1]));
m_ports[1] = data;
break;
case 3: // p1 ddr
- send_port(1, m_ports[1] & data);
+ send_port(1, (m_ports[1] & data) | (m_pullups[1] & ~data));
m_ddrs[1] = data;
break;
case 4: // p2
- send_port(2, data & m_ddrs[2]);
+ send_port(2, (data & m_ddrs[2]) | (m_pullups[2] & ~m_ddrs[2]));
m_ports[2] = data;
break;
case 5: // p2 ddr
- send_port(2, m_ports[2] & data);
+ send_port(2, (m_ports[2] & data) | (m_pullups[2] & ~data));
m_ddrs[2] = data;
break;
case 8: // p3
- send_port(3, data & m_ddrs[3]);
+ send_port(3, (data & m_ddrs[3]) | (m_pullups[3] & ~m_ddrs[3]));
m_ports[3] = data;
break;
case 9: // p3 ddr
- send_port(3, m_ports[3] & data);
+ send_port(3, (m_ports[3] & data) | (m_pullups[3] & ~data));
m_ddrs[3] = data;
break;
- case 0xa: // p4
- send_port(4, data & m_ddrs[4]);
- m_ports[4] = data;
+ case 0xa: // p4 (4-bit open drain)
+ send_port(4, (data & m_ddrs[4] & 0x0f) | (m_pullups[4] & ~m_ddrs[4]));
+ m_ports[4] = data & 0x0f;
break;
case 0xb: // p4 ddr
- send_port(4, m_ports[4] & data);
- m_ddrs[4] = data;
+ send_port(4, (m_ports[4] & data & 0x0f) | (m_pullups[4] & ~data));
+ m_ddrs[4] = data & 0x0f;
break;
}
}
@@ -496,7 +491,7 @@ void m50753_device::m50753_map(address_map &map)
map(0x00e0, 0x00eb).rw(FUNC(m50753_device::ports_r), FUNC(m50753_device::ports_w));
map(0x00ee, 0x00ee).r(FUNC(m50753_device::in_r));
map(0x00ef, 0x00ef).r(FUNC(m50753_device::ad_r));
- map(0x00f2, 0x00f2).w(FUNC(m50753_device::ad_start_w));
+ map(0x00f2, 0x00f2).nopr().w(FUNC(m50753_device::ad_start_w));
map(0x00f3, 0x00f3).rw(FUNC(m50753_device::ad_control_r), FUNC(m50753_device::ad_control_w));
map(0x00f5, 0x00f5).rw(FUNC(m50753_device::pwm_control_r), FUNC(m50753_device::pwm_control_w));
map(0x00f9, 0x00ff).rw(FUNC(m50753_device::tmrirq_r), FUNC(m50753_device::tmrirq_w));
@@ -515,8 +510,8 @@ m50753_device::m50753_device(const machine_config &mconfig, const char *tag, dev
m50753_device::m50753_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) :
m5074x_device(mconfig, type, tag, owner, clock, 16, address_map_constructor(FUNC(m50753_device::m50753_map), this)),
- m_ad_in(*this),
- m_in_p(*this),
+ m_ad_in(*this, 0),
+ m_in_p(*this, 0),
m_ad_control(0),
m_pwm_enabled(false)
{
@@ -526,9 +521,6 @@ void m50753_device::device_start()
{
m5074x_device::device_start();
- m_ad_in.resolve_all_safe(0);
- m_in_p.resolve_safe(0);
-
save_item(NAME(m_ad_control));
save_item(NAME(m_pwm_enabled));
}
@@ -606,23 +598,14 @@ void m50753_device::execute_set_input(int inputnum, int state)
recalc_irqs();
}
-void m50753_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+TIMER_CALLBACK_MEMBER(m50753_device::adc_complete)
{
- switch (id)
- {
- case TIMER_ADC:
- m_timers[TIMER_ADC]->adjust(attotime::never);
+ m_timers[TIMER_ADC]->adjust(attotime::never);
- // if interrupt source is the ADC, do it.
- if (m_ad_control & 4)
- {
- m_intctrl |= IRQ_50753_INTADC;
- recalc_irqs();
- }
- break;
-
- default:
- m5074x_device::device_timer(timer, id, param, ptr);
- break;
+ // if interrupt source is the ADC, do it.
+ if (m_ad_control & 4)
+ {
+ m_intctrl |= IRQ_50753_INTADC;
+ recalc_irqs();
}
}