static void ds1315_fill_raw_data( void ) { /* This routine will (hopefully) call a standard 'C' library routine to get the current date and time and then fill in the raw data struct. */ mame_system_time systime; int raw[8], i, j; /* get the current date/time from the core */ mame_get_current_datetime(Machine, &systime); raw[0] = 0; /* tenths and hundreths of seconds are always zero */ raw[1] = dec_2_bcd(systime.local_time.second); raw[2] = dec_2_bcd(systime.local_time.minute); raw[3] = dec_2_bcd(systime.local_time.hour); raw[4] = dec_2_bcd(systime.local_time.day); raw[5] = dec_2_bcd(systime.local_time.mday); raw[6] = dec_2_bcd(systime.local_time.month + 1); raw[7] = dec_2_bcd(systime.local_time.year - 1900); /* Epoch is 1900 */ /* Ok now we have the raw bcd bytes. Now we need to push them into our bit array */ for( i=0; i<64; i++ ) { j = i / 8; ds1315_raw_data[i] = (raw[j] & 0x0001); raw[j] = raw[j] >> 1; } /* After reading the sources for localtime(), I have determined the the buffer returned is a global variable, thus it does not need to be free()d. */ }
void europc_rtc_set_time(void) { mame_system_time systime; /* get the current date/time from the core */ mame_get_current_datetime(Machine, &systime); europc_rtc.data[0] = dec_2_bcd(systime.utc_time.second); europc_rtc.data[1] = dec_2_bcd(systime.utc_time.minute); europc_rtc.data[2] = dec_2_bcd(systime.utc_time.hour); europc_rtc.data[3] = dec_2_bcd(systime.utc_time.mday); europc_rtc.data[4] = dec_2_bcd(systime.utc_time.month + 1); europc_rtc.data[5] = dec_2_bcd(systime.utc_time.year % 100); }
static void srtc_update_time(running_machine *machine) { mame_system_time curtime, *systime = &curtime; mame_get_current_datetime(machine, &curtime); snes_rtc.rtc_ram[0] = systime->local_time.second % 10; snes_rtc.rtc_ram[1] = systime->local_time.second / 10; snes_rtc.rtc_ram[2] = systime->local_time.minute % 10; snes_rtc.rtc_ram[3] = systime->local_time.minute / 10; snes_rtc.rtc_ram[4] = systime->local_time.hour % 10; snes_rtc.rtc_ram[5] = systime->local_time.hour / 10; snes_rtc.rtc_ram[6] = systime->local_time.mday % 10; snes_rtc.rtc_ram[7] = systime->local_time.mday / 10; snes_rtc.rtc_ram[8] = systime->local_time.month; snes_rtc.rtc_ram[9] = (systime->local_time.year - 1900) % 10; snes_rtc.rtc_ram[10] = ((systime->local_time.year - 1900) / 10) % 10; snes_rtc.rtc_ram[11] = (systime->local_time.year - 1900) / 100; snes_rtc.rtc_ram[12] = systime->local_time.weekday % 7; }