static DEVICE_NVRAM(timekeeper) { timekeeper_state *c = get_safe_token(device); if( read_or_write ) { mame_fwrite( file, c->data, c->size ); } else { if( file ) { mame_fread( file, c->data, c->size ); } else { if( c->default_data != NULL ) { memcpy( c->data, c->default_data, c->size ); } else { memset( c->data, 0xff, c->size ); } } counters_to_ram( c ); } }
void timekeeper_device::nvram_default() { if( m_default_data != NULL ) { memcpy( m_data, m_default_data, m_size ); } else { memset( m_data, 0xff, m_size ); } if ( m_offset_flags >= 0 ) m_data[ m_offset_flags ] = 0; counters_to_ram(); }
static void timekeeper_nvram( int chip, mame_file *file, int read_or_write ) { struct timekeeper_chip *c; if( chip >= MAX_TIMEKEEPER_CHIPS ) { logerror( "timekeeper_nvram( %d ) invalid chip\n", chip ); return; } c = &timekeeper[ chip ]; if( read_or_write ) { mame_fwrite( file, c->data, c->size ); } else { if( file ) { mame_fread( file, c->data, c->size ); } counters_to_ram( chip ); } }
void TimeKeeperTick() { #if defined FBA_DEBUG if (!DebugDev_TimeKprInitted) bprintf(PRINT_ERROR, _T("TimeKeeperTick called without init\n")); #endif INT32 carry; if( ( Chip.seconds & SECONDS_ST ) != 0 || ( Chip.control & CONTROL_W ) != 0 ) { return; } carry = inc_bcd( &Chip.seconds, MASK_SECONDS, 0x00, 0x59 ); if( carry ) { carry = inc_bcd( &Chip.minutes, MASK_MINUTES, 0x00, 0x59 ); } if( carry ) { carry = inc_bcd( &Chip.hours, MASK_HOURS, 0x00, 0x23 ); } if( carry ) { UINT8 month; UINT8 year; UINT8 maxdays; static const UINT8 daysinmonth[] = { 0x31, 0x28, 0x31, 0x30, 0x31, 0x30, 0x31, 0x31, 0x30, 0x31, 0x30, 0x31 }; inc_bcd( &Chip.day, MASK_DAY, 0x01, 0x07 ); month = from_bcd( Chip.month ); year = from_bcd( Chip.year ); if( month == 2 && ( year % 4 ) == 0 ) { maxdays = 0x29; } else if( month >= 1 && month <= 12 ) { maxdays = daysinmonth[ month - 1 ]; } else { maxdays = 0x31; } carry = inc_bcd( &Chip.date, MASK_DATE, 0x01, maxdays ); } if( carry ) { carry = inc_bcd( &Chip.month, MASK_MONTH, 0x01, 0x12 ); } if( carry ) { carry = inc_bcd( &Chip.year, MASK_YEAR, 0x00, 0x99 ); } if( carry ) { carry = inc_bcd( &Chip.century, MASK_CENTURY, 0x00, 0x99 ); if( (Chip.type == TIMEKEEPER_M48T58 || Chip.type == TIMEKEEPER_M48T35) && ( Chip.day & DAY_CEB ) != 0 ) { Chip.day ^= DAY_CB; } } if( ( Chip.control & CONTROL_R ) == 0 ) { counters_to_ram(); } }
void timekeeper_device::nvram_read(emu_file &file) { file.read( m_data, m_size ); counters_to_ram(); }
void timekeeper_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) { if( ( m_seconds & SECONDS_ST ) != 0 || ( m_control & CONTROL_W ) != 0 ) { return; } int carry = inc_bcd( &m_seconds, MASK_SECONDS, 0x00, 0x59 ); if( carry ) { carry = inc_bcd( &m_minutes, MASK_MINUTES, 0x00, 0x59 ); } if( carry ) { carry = inc_bcd( &m_hours, MASK_HOURS, 0x00, 0x23 ); } if( carry ) { UINT8 maxdays; static const UINT8 daysinmonth[] = { 0x31, 0x28, 0x31, 0x30, 0x31, 0x30, 0x31, 0x31, 0x30, 0x31, 0x30, 0x31 }; inc_bcd( &m_day, MASK_DAY, 0x01, 0x07 ); UINT8 month = from_bcd( m_month ); UINT8 year = from_bcd( m_year ); if( month == 2 && ( year % 4 ) == 0 ) { maxdays = 0x29; } else if( month >= 1 && month <= 12 ) { maxdays = daysinmonth[ month - 1 ]; } else { maxdays = 0x31; } carry = inc_bcd( &m_date, MASK_DATE, 0x01, maxdays ); } if( carry ) { carry = inc_bcd( &m_month, MASK_MONTH, 0x01, 0x12 ); } if( carry ) { carry = inc_bcd( &m_year, MASK_YEAR, 0x00, 0x99 ); } if( carry ) { carry = inc_bcd( &m_century, MASK_CENTURY, 0x00, 0x99 ); if( type() == M48T35 || type() == M48T58 ) { if( ( m_day & DAY_CEB ) != 0 ) { m_day ^= DAY_CB; } } } if( ( m_control & CONTROL_R ) == 0 ) { counters_to_ram(); } }
static TIMER_CALLBACK( timekeeper_tick ) { timekeeper_state *c = (timekeeper_state *) ptr; int carry; if( ( c->seconds & SECONDS_ST ) != 0 || ( c->control & CONTROL_W ) != 0 ) { return; } carry = inc_bcd( &c->seconds, MASK_SECONDS, 0x00, 0x59 ); if( carry ) { carry = inc_bcd( &c->minutes, MASK_MINUTES, 0x00, 0x59 ); } if( carry ) { carry = inc_bcd( &c->hours, MASK_HOURS, 0x00, 0x23 ); } if( carry ) { UINT8 month; UINT8 year; UINT8 maxdays; static const UINT8 daysinmonth[] = { 0x31, 0x28, 0x31, 0x30, 0x31, 0x30, 0x31, 0x31, 0x30, 0x31, 0x30, 0x31 }; inc_bcd( &c->day, MASK_DAY, 0x01, 0x07 ); month = from_bcd( c->month ); year = from_bcd( c->year ); if( month == 2 && ( year % 4 ) == 0 ) { maxdays = 0x29; } else if( month >= 1 && month <= 12 ) { maxdays = daysinmonth[ month - 1 ]; } else { maxdays = 0x31; } carry = inc_bcd( &c->date, MASK_DATE, 0x01, maxdays ); } if( carry ) { carry = inc_bcd( &c->month, MASK_MONTH, 0x01, 0x12 ); } if( carry ) { carry = inc_bcd( &c->year, MASK_YEAR, 0x00, 0x99 ); } if( carry ) { carry = inc_bcd( &c->century, MASK_CENTURY, 0x00, 0x99 ); if( c->device->type == M48T35 || c->device->type == M48T58 ) { if( ( c->day & DAY_CEB ) != 0 ) { c->day ^= DAY_CB; } } } if( ( c->control & CONTROL_R ) == 0 ) { counters_to_ram( c ); } }
static void timekeeper_tick( int chip ) { struct timekeeper_chip *c = &timekeeper[ chip ]; int carry; if( ( c->seconds & SECONDS_ST ) != 0 || ( c->control & CONTROL_W ) != 0 ) { return; } carry = inc_bcd( &c->seconds, MASK_SECONDS, 0x00, 0x59 ); if( carry ) { carry = inc_bcd( &c->minutes, MASK_MINUTES, 0x00, 0x59 ); } if( carry ) { carry = inc_bcd( &c->hours, MASK_HOURS, 0x00, 0x23 ); } if( carry ) { UINT8 month; UINT8 year; UINT8 maxdays; static const UINT8 daysinmonth[] = { 0x31, 0x28, 0x31, 0x30, 0x31, 0x30, 0x31, 0x31, 0x30, 0x31, 0x30, 0x31 }; inc_bcd( &c->day, MASK_DAY, 0x01, 0x07 ); month = from_bcd( c->month ); year = from_bcd( c->year ); if( month == 2 && ( year % 4 ) == 0 ) { maxdays = 0x29; } else if( month >= 1 && month <= 12 ) { maxdays = daysinmonth[ month - 1 ]; } else { maxdays = 0x31; } carry = inc_bcd( &c->date, MASK_DATE, 0x01, maxdays ); } if( carry ) { carry = inc_bcd( &c->month, MASK_MONTH, 0x01, 0x12 ); } if( carry ) { carry = inc_bcd( &c->year, MASK_YEAR, 0x00, 0x99 ); } if( carry ) { carry = inc_bcd( &c->century, MASK_CENTURY, 0x00, 0x99 ); if( c->type == TIMEKEEPER_M48T58 && ( c->day & DAY_CEB ) != 0 ) { c->day ^= DAY_CB; } } if( ( c->control & CONTROL_R ) == 0 ) { counters_to_ram( chip ); } }