sm510: k input wakeup is not edge triggered

This commit is contained in:
hap 2022-02-03 11:34:08 +01:00
parent be0f235ad9
commit 758b08fa27
4 changed files with 11 additions and 38 deletions

View File

@ -32,8 +32,6 @@ enum
void sm510_base_device::device_start()
{
assert(SM510_INPUT_LINE_K1 == 0);
m_program = &space(AS_PROGRAM);
m_data = &space(AS_DATA);
m_prgmask = (1 << m_prgwidth) - 1;
@ -67,8 +65,7 @@ void sm510_base_device::device_start()
m_div = 0;
m_1s = false;
m_1s_rise = false;
m_k_rise = false;
std::fill_n(m_k_input, std::size(m_k_input), 0);
m_ext_wakeup = false;
m_l = 0;
m_x = 0;
m_y = 0;
@ -102,8 +99,7 @@ void sm510_base_device::device_start()
save_item(NAME(m_div));
save_item(NAME(m_1s));
save_item(NAME(m_1s_rise));
save_item(NAME(m_k_rise));
save_item(NAME(m_k_input));
save_item(NAME(m_ext_wakeup));
save_item(NAME(m_l));
save_item(NAME(m_x));
save_item(NAME(m_y));
@ -251,14 +247,10 @@ void sm510_base_device::init_divider()
void sm510_base_device::execute_set_input(int line, int state)
{
if (!valid_wakeup_line(line))
if (line != SM510_EXT_WAKEUP_LINE)
return;
// rising edge of any K input
if (state && !m_k_input[line])
m_k_rise = true;
m_k_input[line] = state;
m_ext_wakeup = bool(state);
}
void sm510_base_device::do_interrupt()
@ -292,8 +284,7 @@ void sm510_base_device::execute_run()
while (m_icount > 0)
{
// in halt mode, wake up after 1S signal or K input
bool wakeup = m_k_rise || m_1s_rise;
m_k_rise = false;
bool wakeup = m_ext_wakeup || m_1s_rise;
m_1s_rise = false;
if (m_halt)

View File

@ -16,15 +16,9 @@
// I/O ports setup
// when in halt state, any K input going high can wake up the CPU,
// driver is required to use set_input_line(SM510_INPUT_LINE_K1/K2/K3/K4, state)
enum
{
SM510_INPUT_LINE_K1 = 0,
SM510_INPUT_LINE_K2,
SM510_INPUT_LINE_K3,
SM510_INPUT_LINE_K4
};
// when in halt state, any active K input can wake up the CPU,
// driver is required to use set_input_line(SM510_EXT_WAKEUP_LINE, state)
#define SM510_EXT_WAKEUP_LINE 0
// ACL input pin
#define SM510_INPUT_LINE_ACL INPUT_LINE_RESET
@ -97,8 +91,7 @@ protected:
virtual u64 execute_cycles_to_clocks(u64 cycles) const noexcept override { return (cycles * m_clk_div); } // "
virtual u32 execute_min_cycles() const noexcept override { return 1; }
virtual u32 execute_max_cycles() const noexcept override { return 3+1; }
virtual u32 execute_input_lines() const noexcept override { return 4; }
virtual bool execute_input_edge_triggered(int inputnum) const noexcept override { return valid_wakeup_line(inputnum); }
virtual u32 execute_input_lines() const noexcept override { return 1; }
virtual void execute_set_input(int line, int state) override;
virtual void execute_run() override;
@ -115,7 +108,6 @@ protected:
virtual void reset_vector() { do_branch(3, 7, 0); }
virtual void wakeup_vector() { do_branch(1, 0, 0); } // after halt
virtual bool valid_wakeup_line(int line) const { return (line >= 0 && line < 4); }
int m_prgwidth;
int m_datawidth;
@ -140,8 +132,7 @@ protected:
u8 m_r;
u8 m_r_out;
int m_r_mask_option;
int m_k_input[4];
bool m_k_rise;
bool m_ext_wakeup;
bool m_halt;
int m_clk_div;

View File

@ -12,12 +12,6 @@
#include "sm510base.h"
// I/O ports setup
// It does not have K pins, but can wake up after halt on R2.2
#define SM590_INPUT_LINE_R22 SM510_INPUT_LINE_K3
// pinout reference
/*
@ -115,7 +109,6 @@ protected:
virtual void reset_vector() override { do_branch(0, 0, 0); }
virtual void wakeup_vector() override { do_branch(0, 1, 0); }
virtual bool valid_wakeup_line(int line) const override { return (line == SM590_INPUT_LINE_R22); }
// opcode handlers
// 00-3f

View File

@ -291,9 +291,7 @@ u8 hh_sm510_state::read_inputs(int columns, int fixed)
void hh_sm510_state::update_k_line()
{
// this is necessary because the MCU can wake up on K input activity
u8 input = input_r();
for (int i = 0; i < 4; i++)
m_maincpu->set_input_line(i, BIT(input, i) ? ASSERT_LINE : CLEAR_LINE);
m_maincpu->set_input_line(0, input_r() ? ASSERT_LINE : CLEAR_LINE);
}
INPUT_CHANGED_MEMBER(hh_sm510_state::input_changed)