attotime device_execute_interface::local_time() const { // if we're active, add in the time from the current slice if (executing()) { assert(m_cycles_running >= *m_icountptr); int cycles = m_cycles_running - *m_icountptr; return m_localtime + cycles_to_attotime(cycles); } return m_localtime; }
void sh2_device::sh2_timer_activate() { int max_delta = 0xfffff; UINT16 frc; m_timer->adjust(attotime::never); frc = m_frc; if(!(m_m[4] & OCFA)) { UINT16 delta = m_ocra - frc; if(delta < max_delta) max_delta = delta; } if(!(m_m[4] & OCFB) && (m_ocra <= m_ocrb || !(m_m[4] & 0x010000))) { UINT16 delta = m_ocrb - frc; if(delta < max_delta) max_delta = delta; } if(!(m_m[4] & OVF) && !(m_m[4] & 0x010000)) { int delta = 0x10000 - frc; if(delta < max_delta) max_delta = delta; } if(max_delta != 0xfffff) { int divider = div_tab[(m_m[5] >> 8) & 3]; if(divider) { max_delta <<= divider; m_frc_base = total_cycles(); m_timer->adjust(cycles_to_attotime(max_delta)); } else { logerror("SH2.%s: Timer event in %d cycles of external clock", tag(), max_delta); } }