src/emu/machine/mc146818.c
| r12592 | r12593 | |
| 5 | 5 | Implementation of the MC146818 chip |
| 6 | 6 | |
| 7 | 7 | Real time clock chip with battery buffered ram (or CMOS) |
| 8 | | Used in IBM PC/AT, several PC clones, Amstrad NC200 |
| 8 | Used in IBM PC/AT, several PC clones, Amstrad NC200, Apollo workstations |
| 9 | 9 | |
| 10 | 10 | Nathan Woods (npwoods@mess.org) |
| 11 | 11 | Peter Trauner (peter.trauner@jk.uni-linz.ac.at) |
| r12592 | r12593 | |
| 196 | 196 | return; |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | | if (m_type == MC146818_UTC) { |
| 200 | | // hack: set correct real time even for overloaded emulation |
| 201 | | // (at least for apollo) |
| 202 | | static osd_ticks_t t0 = 0; |
| 203 | | osd_ticks_t t1 = osd_ticks(); |
| 204 | | int n_seconds; |
| 205 | | |
| 206 | | if (t0 == 0) { |
| 207 | | t0 = t1; |
| 208 | | } |
| 209 | | |
| 210 | | n_seconds = (t1 - t0) / osd_ticks_per_second(); |
| 211 | | t0 = t1 - (t1 - t0) % osd_ticks_per_second(); |
| 212 | | if (n_seconds <= 0) { |
| 213 | | // we were called to early |
| 214 | | return; |
| 215 | | } |
| 216 | | |
| 217 | | m_data[0] += n_seconds; |
| 218 | | } else { |
| 219 | | m_data[0] += 1; |
| 220 | | } |
| 221 | | |
| 222 | 199 | if (BCD_MODE) |
| 223 | 200 | { |
| 224 | | m_data[0]=bcd_adjust(m_data[0]/*+1*/); |
| 201 | m_data[0]=bcd_adjust(m_data[0]+1); |
| 225 | 202 | if (m_data[0]>=0x60) |
| 226 | 203 | { |
| 227 | 204 | m_data[0]=0; |
| r12592 | r12593 | |
| 264 | 241 | } |
| 265 | 242 | else |
| 266 | 243 | { |
| 267 | | /*m_data[0]=m_data[0]+1;*/ |
| 244 | m_data[0]=m_data[0]+1; |
| 268 | 245 | if (m_data[0]>=60) |
| 269 | 246 | { |
| 270 | | m_data[0] -= 60; |
| 247 | m_data[0]=0; |
| 271 | 248 | m_data[2]=m_data[2]+1; |
| 272 | 249 | if (m_data[2]>=60) { |
| 273 | 250 | m_data[2]=0; |
| r12592 | r12593 | |
| 403 | 380 | |
| 404 | 381 | current_time = (m_type == MC146818_UTC) ? systime.utc_time: systime.local_time; |
| 405 | 382 | |
| 406 | | // temporary hack to go back 20 year (e.g. from 2010 -> 1990) |
| 407 | | // current_time.year -= 20; |
| 408 | | |
| 409 | 383 | // logerror("mc146818_set_base_datetime %02d/%02d/%02d %02d:%02d:%02d\n", |
| 410 | 384 | // current_time.year % 100, current_time.month + 1, current_time.mday, |
| 411 | 385 | // current_time.hour,current_time.minute, current_time.second); |