void mc146818_device::set_base_datetime() { system_time systime; system_time::full_time current_time; machine().base_datetime(systime); current_time = (m_use_utc) ? systime.utc_time: systime.local_time; // logerror("mc146818_set_base_datetime %02d/%02d/%02d %02d:%02d:%02d\n", // current_time.year % 100, current_time.month + 1, current_time.mday, // current_time.hour,current_time.minute, current_time.second); set_seconds(current_time.second); set_minutes(current_time.minute); set_hours(current_time.hour); set_dayofweek(current_time.weekday + 1); set_dayofmonth(current_time.mday); set_month(current_time.month + 1); if(m_binyear) set_year((current_time.year - m_epoch) % (m_data[REG_B] & REG_B_DM ? 0x100 : 100)); // pcd actually depends on this else set_year((current_time.year - m_epoch) % 100); if (m_century_index >= 0) m_data[m_century_index] = to_ram(current_time.year / 100); }
void mc146818_device::set_base_datetime() { system_time systime; system_time::full_time current_time; machine().base_datetime(systime); current_time = (m_use_utc) ? systime.utc_time: systime.local_time; // logerror("mc146818_set_base_datetime %02d/%02d/%02d %02d:%02d:%02d\n", // current_time.year % 100, current_time.month + 1, current_time.mday, // current_time.hour,current_time.minute, current_time.second); set_seconds(current_time.second); set_minutes(current_time.minute); set_hours(current_time.hour); set_dayofweek(current_time.weekday + 1); set_dayofmonth(current_time.mday); set_month(current_time.month + 1); set_year(current_time.year % 100); if (m_century_index >= 0) m_data[m_century_index] = to_ram(current_time.year / 100); }
void mc146818_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) { switch (id) { case TIMER_PERIODIC: m_data[REG_C] |= REG_C_PF; update_irq(); break; case TIMER_CLOCK: if (!(m_data[REG_B] & REG_B_SET)) { /// TODO: find out how the real chip deals with updates when binary/bcd values are already outside the normal range int seconds = get_seconds() + 1; if (seconds < 60) { set_seconds(seconds); } else { set_seconds(0); int minutes = get_minutes() + 1; if (minutes < 60) { set_minutes(minutes); } else { set_minutes(0); int hours = get_hours() + 1; if (hours < 24) { set_hours(hours); } else { set_hours(0); int dayofweek = get_dayofweek() + 1; if (dayofweek <= 7) { set_dayofweek(dayofweek); } else { set_dayofweek(1); } int dayofmonth = get_dayofmonth() + 1; if (dayofmonth <= gregorian_days_in_month(get_month(), get_year() + 2000)) { set_dayofmonth(dayofmonth); } else { set_dayofmonth(1); int month = get_month() + 1; if (month <= 12) { set_month(month); } else { set_month(1); set_year((get_year() + 1) % 100); } } } } } if ((m_data[REG_ALARM_SECONDS] == m_data[REG_SECONDS] || (m_data[REG_ALARM_SECONDS] & ALARM_DONTCARE) == ALARM_DONTCARE) && (m_data[REG_ALARM_MINUTES] == m_data[REG_MINUTES] || (m_data[REG_ALARM_MINUTES] & ALARM_DONTCARE) == ALARM_DONTCARE) && (m_data[REG_ALARM_HOURS] == m_data[REG_HOURS] || (m_data[REG_ALARM_HOURS] & ALARM_DONTCARE) == ALARM_DONTCARE)) { // set the alarm interrupt flag AF m_data[REG_C] |= REG_C_AF; } // set the update-ended interrupt Flag UF m_data[REG_C] |= REG_C_UF; update_irq(); m_last_refresh = machine().time(); } break; } }