fidelbase: small refactor (nw)

This commit is contained in:
hap 2019-03-29 19:10:18 +01:00
parent 5aecde7b83
commit a0d2c0c25c
2 changed files with 16 additions and 7 deletions

View File

@ -41,7 +41,7 @@ public:
// in case reset button is directly tied to maincpu reset pin
virtual DECLARE_INPUT_CHANGED_MEMBER(reset_button) { m_maincpu->set_input_line(INPUT_LINE_RESET, newval ? ASSERT_LINE : CLEAR_LINE); }
DECLARE_INPUT_CHANGED_MEMBER(div_changed);
DECLARE_INPUT_CHANGED_MEMBER(div_changed) { div_refresh(newval); }
protected:
// devices/pointers
@ -71,6 +71,7 @@ protected:
u8 div_trampoline_r(offs_t offset);
void div_set_cpu_freq(offs_t offset);
void div_trampoline(address_map &map);
void div_refresh(ioport_value val = 0xff);
u16 m_div_status;
ioport_value m_div_config;
emu_timer *m_div_timer;

View File

@ -66,9 +66,7 @@ void fidelbase_state::machine_reset()
chessbase_state::machine_reset();
// init cpu divider (optional)
ioport_port *inp = ioport("div_config");
if (inp != nullptr)
div_changed(*inp->field(0x03), nullptr, 0, inp->read());
div_refresh();
}
@ -139,14 +137,24 @@ void fidelbase_state::div_trampoline(address_map &map)
map(0x0000, 0xffff).rw(FUNC(fidelbase_state::div_trampoline_r), FUNC(fidelbase_state::div_trampoline_w));
}
INPUT_CHANGED_MEMBER(fidelbase_state::div_changed)
void fidelbase_state::div_refresh(ioport_value val)
{
if (val == 0xff)
{
// bail out if there is no cpu divider
ioport_port *inp = ioport("div_config");
if (inp == nullptr)
return;
val = inp->read();
}
m_maincpu->set_clock_scale(1.0);
m_div_status = ~0;
m_div_config = newval;
m_div_config = val;
// stop high frequency background timer if cpu divider is disabled
attotime period = (newval) ? attotime::from_hz(m_maincpu->clock()) : attotime::never;
attotime period = (val) ? attotime::from_hz(m_maincpu->clock()) : attotime::never;
m_div_timer->adjust(period, 0, period);
}