mirror of
https://github.com/holub/mame
synced 2025-06-09 22:33:00 +03:00
Defend clocks_to_attotime and attotime_to_clocks against the possibility of the device clock being 0 (nw)
This commit is contained in:
parent
9f12134990
commit
a0bf95bc4d
@ -360,7 +360,9 @@ void device_t::calculate_derived_clock()
|
|||||||
|
|
||||||
attotime device_t::clocks_to_attotime(u64 numclocks) const
|
attotime device_t::clocks_to_attotime(u64 numclocks) const
|
||||||
{
|
{
|
||||||
if (numclocks < m_clock)
|
if (m_clock == 0)
|
||||||
|
return attotime::never;
|
||||||
|
else if (numclocks < m_clock)
|
||||||
return attotime(0, numclocks * m_attoseconds_per_clock);
|
return attotime(0, numclocks * m_attoseconds_per_clock);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -378,6 +380,9 @@ attotime device_t::clocks_to_attotime(u64 numclocks) const
|
|||||||
|
|
||||||
u64 device_t::attotime_to_clocks(const attotime &duration) const
|
u64 device_t::attotime_to_clocks(const attotime &duration) const
|
||||||
{
|
{
|
||||||
|
if (m_clock == 0)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
return mulu_32x32(duration.seconds(), m_clock) + u64(duration.attoseconds()) / u64(m_attoseconds_per_clock);
|
return mulu_32x32(duration.seconds(), m_clock) + u64(duration.attoseconds()) / u64(m_attoseconds_per_clock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user