diff options
| author | 2024-07-11 21:14:24 +0200 | |
|---|---|---|
| committer | 2024-07-11 21:15:43 +0200 | |
| commit | df8be6280057cdb94c4a83dc67b1363f5f536cb4 (patch) | |
| tree | 39faf57cf25bfa19c78b137fe7fee0da6195a90e | |
| parent | c60d4a0760d4e5dfeec53fae04a7d5dcd8af078e (diff) | |
h8_sci: add safety check in internal_update for possible negative ticks,
h8325: mask unused sci register bits
| -rw-r--r-- | src/devices/cpu/h8/h8325.cpp | 21 | ||||
| -rw-r--r-- | src/devices/cpu/h8/h8_sci.cpp | 3 |
2 files changed, 15 insertions, 9 deletions
diff --git a/src/devices/cpu/h8/h8325.cpp b/src/devices/cpu/h8/h8325.cpp index fb99154031b..eb81ee9caa0 100644 --- a/src/devices/cpu/h8/h8325.cpp +++ b/src/devices/cpu/h8/h8325.cpp @@ -7,8 +7,6 @@ H8/325 family emulation TODO: - - serial controllers are slightly different, has 3 interrupt sources - instead of 4 - HCSR @ 0xfffe (port 3 handshake) - FNCR @ 0xffff (16-bit timer noise canceler) @@ -115,17 +113,24 @@ void h8325_device::map(address_map &map) map(0xffd2, 0xffd3).rw(m_timer8[1], FUNC(h8_timer8_channel_device::tcor_r), FUNC(h8_timer8_channel_device::tcor_w)); map(0xffd4, 0xffd4).rw(m_timer8[1], FUNC(h8_timer8_channel_device::tcnt_r), FUNC(h8_timer8_channel_device::tcnt_w)); - map(0xffd8, 0xffd8).rw(m_sci[0], FUNC(h8_sci_device::smr_r), FUNC(h8_sci_device::smr_w)); + map(0xffd8, 0xffd8).lr8(NAME([this]() { return m_sci[0]->smr_r() | 0x04; })); + map(0xffd8, 0xffd8).lw8(NAME([this](u8 data) { m_sci[0]->smr_w(data & ~0x04); })); map(0xffd9, 0xffd9).rw(m_sci[0], FUNC(h8_sci_device::brr_r), FUNC(h8_sci_device::brr_w)); - map(0xffda, 0xffda).rw(m_sci[0], FUNC(h8_sci_device::scr_r), FUNC(h8_sci_device::scr_w)); + map(0xffda, 0xffda).lr8(NAME([this]() { return m_sci[0]->scr_r() | 0x0c; })); + map(0xffda, 0xffda).lw8(NAME([this](u8 data) { m_sci[0]->scr_w(data & ~0x0c); })); map(0xffdb, 0xffdb).rw(m_sci[0], FUNC(h8_sci_device::tdr_r), FUNC(h8_sci_device::tdr_w)); - map(0xffdc, 0xffdc).rw(m_sci[0], FUNC(h8_sci_device::ssr_r), FUNC(h8_sci_device::ssr_w)); + map(0xffdc, 0xffdc).lr8(NAME([this]() { return m_sci[0]->ssr_r() | 0x07; })); + map(0xffdc, 0xffdc).lw8(NAME([this](u8 data) { m_sci[0]->ssr_w(data & ~0x07); })); map(0xffdd, 0xffdd).r(m_sci[0], FUNC(h8_sci_device::rdr_r)); - map(0xffe0, 0xffe0).rw(m_sci[1], FUNC(h8_sci_device::smr_r), FUNC(h8_sci_device::smr_w)); + + map(0xffe0, 0xffe0).lr8(NAME([this]() { return m_sci[1]->smr_r() | 0x04; })); + map(0xffe0, 0xffe0).lw8(NAME([this](u8 data) { m_sci[1]->smr_w(data & ~0x04); })); map(0xffe1, 0xffe1).rw(m_sci[1], FUNC(h8_sci_device::brr_r), FUNC(h8_sci_device::brr_w)); - map(0xffe2, 0xffe2).rw(m_sci[1], FUNC(h8_sci_device::scr_r), FUNC(h8_sci_device::scr_w)); + map(0xffe2, 0xffe2).lr8(NAME([this]() { return m_sci[1]->scr_r() | 0x0c; })); + map(0xffe2, 0xffe2).lw8(NAME([this](u8 data) { m_sci[1]->scr_w(data & ~0x0c); })); map(0xffe3, 0xffe3).rw(m_sci[1], FUNC(h8_sci_device::tdr_r), FUNC(h8_sci_device::tdr_w)); - map(0xffe4, 0xffe4).rw(m_sci[1], FUNC(h8_sci_device::ssr_r), FUNC(h8_sci_device::ssr_w)); + map(0xffe4, 0xffe4).lr8(NAME([this]() { return m_sci[1]->ssr_r() | 0x07; })); + map(0xffe4, 0xffe4).lw8(NAME([this](u8 data) { m_sci[1]->ssr_w(data & ~0x07); })); map(0xffe5, 0xffe5).r(m_sci[1], FUNC(h8_sci_device::rdr_r)); } diff --git a/src/devices/cpu/h8/h8_sci.cpp b/src/devices/cpu/h8/h8_sci.cpp index 0144e9a25c0..5cdb3f2bdeb 100644 --- a/src/devices/cpu/h8/h8_sci.cpp +++ b/src/devices/cpu/h8/h8_sci.cpp @@ -413,7 +413,8 @@ u64 h8_sci_device::internal_update(u64 current_time) m_clock_event = 0; if(m_clock_event) { - m_sync_timer->adjust(attotime::from_ticks(m_clock_event - m_cpu->now_as_cycles(), m_cpu->system_clock())); + if(s64 ticks = m_clock_event - m_cpu->now_as_cycles(); ticks >= 0LL) + m_sync_timer->adjust(attotime::from_ticks(ticks, m_cpu->system_clock())); m_cpu->internal_update(); } |
