From 93ced0c2fe01d312d6b1f74366b4e2ebf79d6d29 Mon Sep 17 00:00:00 2001 From: Angelo Salese Date: Tue, 4 May 2010 12:57:53 +0000 Subject: [PATCH] Naomi: implemented RTC start-up values [Angelo Salese] --- src/mame/machine/dc.c | 45 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/src/mame/machine/dc.c b/src/mame/machine/dc.c index 20d140b3e06..83ea99163a2 100644 --- a/src/mame/machine/dc.c +++ b/src/mame/machine/dc.c @@ -1569,11 +1569,53 @@ static TIMER_CALLBACK(dc_rtc_increment) dc_rtcregister[RTC2] = (dc_rtcregister[RTC2] + 1) & 0xFFFF; if (dc_rtcregister[RTC2] == 0) dc_rtcregister[RTC1] = (dc_rtcregister[RTC1] + 1) & 0xFFFF; + + popmessage("%d",dc_rtcregister[RTC1] << 16 | dc_rtcregister[RTC2]); +} + +/* fill the RTC registers with the proper start-up values */ +static void rtc_initial_setup(running_machine *machine) +{ + static UINT32 current_time; + static int year_count,cur_year,i; + static const int month_to_day_conversion[12] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }; + mame_system_time systime; + mame_get_base_datetime(machine, &systime); + + memset(dc_rtcregister, 0, sizeof(dc_rtcregister)); + + /* put the seconds */ + current_time = systime.local_time.second; + /* put the minutes */ + current_time+= systime.local_time.minute*60; + /* put the hours */ + current_time+= systime.local_time.hour*60*60; + /* put the days (note -1) */ + current_time+= (systime.local_time.mday-1)*60*60*24; + /* take the current year here for calculating leaps */ + cur_year = (systime.local_time.year); + + /* take the months - despite popular beliefs, leap years aren't just evenly divisible by 4 */ + if(((((cur_year % 4) == 0) && ((cur_year % 100) != 0)) || ((cur_year % 400) == 0)) && systime.local_time.month > 2) + current_time+= (month_to_day_conversion[systime.local_time.month]+1)*60*60*24; + else + current_time+= (month_to_day_conversion[systime.local_time.month])*60*60*24; + + /* put the years */ + year_count = (cur_year-1949); + + for(i=0;i> 16; + + dc_rtc_timer = timer_alloc(machine, dc_rtc_increment, 0); } MACHINE_START( dc ) { - dc_rtc_timer = timer_alloc(machine, dc_rtc_increment, 0); + rtc_initial_setup(machine); } MACHINE_RESET( dc ) @@ -1583,7 +1625,6 @@ MACHINE_RESET( dc ) memset(dc_sysctrl_regs, 0, sizeof(dc_sysctrl_regs)); memset(maple_regs, 0, sizeof(maple_regs)); - memset(dc_rtcregister, 0, sizeof(dc_rtcregister)); memset(dc_coin_counts, 0, sizeof(dc_coin_counts)); timer_adjust_periodic(dc_rtc_timer, attotime_zero, 0, ATTOTIME_IN_SEC(1));