diff options
Diffstat (limited to 'src/emu/cpu/hmcs40/hmcs40.c')
-rw-r--r-- | src/emu/cpu/hmcs40/hmcs40.c | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/src/emu/cpu/hmcs40/hmcs40.c b/src/emu/cpu/hmcs40/hmcs40.c index 1adef6ea242..d76385cf2ba 100644 --- a/src/emu/cpu/hmcs40/hmcs40.c +++ b/src/emu/cpu/hmcs40/hmcs40.c @@ -11,23 +11,12 @@ */ -enum -{ - FAMILY_HMCS42 = 0, - FAMILY_HMCS43, - FAMILY_HMCS44, - FAMILY_HMCS45, - FAMILY_HMCS46, - FAMILY_HMCS47, -}; - #define IS_PMOS 0 #define IS_CMOS ~0 #include "hmcs40.h" #include "debugger.h" -#include "hmcs40op.inc" // MCU types @@ -90,7 +79,7 @@ ADDRESS_MAP_END // device definitions hmcs43_cpu_device::hmcs43_cpu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT16 polarity, const char *shortname) - : hmcs40_cpu_device(mconfig, type, name, tag, owner, clock, FAMILY_HMCS43, polarity, 3, 10, 11, ADDRESS_MAP_NAME(program_1k), 7, ADDRESS_MAP_NAME(data_80x4), shortname, __FILE__) + : hmcs40_cpu_device(mconfig, type, name, tag, owner, clock, HMCS40_FAMILY_HMCS43, polarity, 3 /* stack levels */, 10 /* pc width */, 11 /* prg width */, ADDRESS_MAP_NAME(program_1k), 7 /* data width */, ADDRESS_MAP_NAME(data_80x4), shortname, __FILE__) { } hd38750_device::hd38750_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) @@ -108,7 +97,7 @@ hd44758_device::hd44758_device(const machine_config &mconfig, const char *tag, d hmcs44_cpu_device::hmcs44_cpu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT16 polarity, const char *shortname) - : hmcs40_cpu_device(mconfig, type, name, tag, owner, clock, FAMILY_HMCS44, polarity, 4, 11, 12, ADDRESS_MAP_NAME(program_2k), 8, ADDRESS_MAP_NAME(data_160x4), shortname, __FILE__) + : hmcs40_cpu_device(mconfig, type, name, tag, owner, clock, HMCS40_FAMILY_HMCS44, polarity, 4, 11, 12, ADDRESS_MAP_NAME(program_2k), 8, ADDRESS_MAP_NAME(data_160x4), shortname, __FILE__) { } hd38800_device::hd38800_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) @@ -126,7 +115,7 @@ hd44808_device::hd44808_device(const machine_config &mconfig, const char *tag, d hmcs45_cpu_device::hmcs45_cpu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT16 polarity, const char *shortname) - : hmcs40_cpu_device(mconfig, type, name, tag, owner, clock, FAMILY_HMCS45, polarity, 4, 11, 12, ADDRESS_MAP_NAME(program_2k), 8, ADDRESS_MAP_NAME(data_160x4), shortname, __FILE__) + : hmcs40_cpu_device(mconfig, type, name, tag, owner, clock, HMCS40_FAMILY_HMCS45, polarity, 4, 11, 12, ADDRESS_MAP_NAME(program_2k), 8, ADDRESS_MAP_NAME(data_160x4), shortname, __FILE__) { } hd38820_device::hd38820_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) @@ -188,6 +177,7 @@ void hmcs40_cpu_device::device_start() m_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(hmcs40_cpu_device::simple_timer_cb), this)); reset_prescaler(); + // resolve callbacks m_read_r0.resolve_safe(0); m_read_r1.resolve_safe(0); m_read_r2.resolve_safe(0); @@ -215,6 +205,7 @@ void hmcs40_cpu_device::device_start() m_prev_op = 0; m_i = 0; m_eint_line = 0; + m_halt = 0; m_pc = 0; m_prev_pc = 0; m_page = 0; @@ -242,6 +233,8 @@ void hmcs40_cpu_device::device_start() save_item(NAME(m_prev_op)); save_item(NAME(m_i)); save_item(NAME(m_eint_line)); + save_item(NAME(m_halt)); + save_item(NAME(m_timer_halted_remain)); save_item(NAME(m_pc)); save_item(NAME(m_prev_pc)); save_item(NAME(m_page)); @@ -477,9 +470,25 @@ void hmcs40_cpu_device::do_interrupt() void hmcs40_cpu_device::execute_set_input(int line, int state) { + state = (state) ? 1 : 0; + + // halt/unhalt mcu + if (line == HMCS40_INPUT_LINE_HLT && state != m_halt) + { + if (state) + { + m_timer_halted_remain = m_timer->remaining(); + m_timer->reset(); + } + else + m_timer->adjust(m_timer_halted_remain); + + m_halt = state; + return; + } + if (line != 0 && line != 1) return; - state = (state) ? 1 : 0; // external interrupt request on rising edge if (state && !m_int[line]) @@ -551,6 +560,13 @@ inline void hmcs40_cpu_device::increment_pc() void hmcs40_cpu_device::execute_run() { + // in HLT state, the internal clock is not running + if (m_halt) + { + m_icount = 0; + return; + } + while (m_icount > 0) { // LPU is handled 1 cycle later |