--- xmil/calendar.c 2004/08/01 05:31:29 1.1 +++ xmil/calendar.c 2004/08/12 14:03:14 1.3 @@ -1,6 +1,8 @@ #include "compiler.h" #include "parts.h" #include "timemng.h" +#include "pccore.h" +#include "nevent.h" #include "calendar.h" @@ -62,16 +64,6 @@ secinc_exit: // ---- -void calendar_initialize(void) { - - timemng_gettime(&cal.dt); -} - -void calendar_inc(void) { - - secinc(&cal.dt); -} - void calendar_getdate(UINT8 *bcd) { bcd[0] = AdjustAfterMultiply((UINT8)(cal.dt.year % 100)); @@ -107,3 +99,22 @@ void calendar_settime(const UINT8 *bcd) cal.dt.second = AdjustBeforeDivision(bcd[2]); } + +// ---- + +void neitem_rtc(UINT id) { + + nevent_repeat(id); + cal.steps++; + if (cal.steps >= 5) { + cal.steps -= 5; + secinc(&cal.dt); + } +} + +void calendar_reset(void) { + + timemng_gettime(&cal.dt); + nevent_set(NEVENT_RTC, pccore.realclock / 5, neitem_rtc, NEVENT_RELATIVE); +} +