diff --git a/src/machine/m_europc.c b/src/machine/m_europc.c index 7e08d3109..df464e73e 100644 --- a/src/machine/m_europc.c +++ b/src/machine/m_europc.c @@ -280,7 +280,7 @@ rtc_start(nvr_t *nvr) struct tm tm; /* Initialize the internal and chip times. */ - if (enable_sync) { + if (enable_sync & TIME_SYNC_ENABLED) { /* Use the internal clock's time. */ nvr_time_get(&tm); rtc_time_set(nvr->regs, &tm); diff --git a/src/machine/m_xt_t1000.c b/src/machine/m_xt_t1000.c index 2b5d33186..97924dd5e 100644 --- a/src/machine/m_xt_t1000.c +++ b/src/machine/m_xt_t1000.c @@ -258,7 +258,7 @@ tc8521_start(nvr_t *nvr) struct tm tm; /* Initialize the internal and chip times. */ - if (enable_sync) { + if (enable_sync & TIME_SYNC_ENABLED) { /* Use the internal clock's time. */ nvr_time_get(&tm); tc8521_time_set(nvr->regs, &tm); diff --git a/src/nvr.c b/src/nvr.c index 2037b68e9..65d8114a4 100644 --- a/src/nvr.c +++ b/src/nvr.c @@ -181,10 +181,13 @@ nvr_init(nvr_t *nvr) /* Initialize the internal clock as needed. */ memset(&intclk, 0x00, sizeof(intclk)); - if (enable_sync) { + if (enable_sync & TIME_SYNC_ENABLED) { /* Get the current time of day, and convert to local time. */ (void)time(&now); - tm = localtime(&now); + if(enable_sync & TIME_SYNC_UTC) + tm = gmtime(&now); + else + tm = localtime(&now); /* Set the internal clock. */ nvr_time_set(tm); diff --git a/src/nvr.h b/src/nvr.h index 11321fd6a..7928a4a7c 100644 --- a/src/nvr.h +++ b/src/nvr.h @@ -55,6 +55,11 @@ #define RTC_DCB(x) ((((x) & 0xf0) >> 4) * 10 + ((x) & 0x0f)) #define RTC_BCDINC(x,y) RTC_BCD(RTC_DCB(x) + y) +/* Time sync options */ +#define TIME_SYNC_DISABLED 0 +#define TIME_SYNC_ENABLED 1 +#define TIME_SYNC_UTC 2 + /* Define a generic RTC/NVRAM device. */ typedef struct _nvr_ { diff --git a/src/nvr_at.c b/src/nvr_at.c index e6cd8cc71..773bb5502 100644 --- a/src/nvr_at.c +++ b/src/nvr_at.c @@ -554,7 +554,7 @@ nvr_write(uint16_t addr, uint8_t val, void *priv) if ((local->addr < RTC_REGA) || ((local->cent != 0xff) && (local->addr == local->cent))) { if ((local->addr != 1) && (local->addr != 3) && (local->addr != 5)) { - if ((old != val) && !enable_sync) { + if ((old != val) && !(enable_sync & TIME_SYNC_ENABLED)) { /* Update internal clock. */ time_get(nvr, &tm); nvr_time_set(&tm); @@ -630,7 +630,7 @@ nvr_start(nvr_t *nvr) struct tm tm; /* Initialize the internal and chip times. */ - if (enable_sync) { + if (time_sync & TIME_SYNC_ENABLED) { /* Use the internal clock's time. */ nvr_time_get(&tm); time_set(nvr, &tm); diff --git a/src/win/win_settings.c b/src/win/win_settings.c index 16d8ea151..838450cd1 100644 --- a/src/win/win_settings.c +++ b/src/win/win_settings.c @@ -202,7 +202,7 @@ win_settings_init(void) temp_dynarec = cpu_use_dynarec; #endif temp_fpu = enable_external_fpu; - temp_sync = enable_sync; + temp_sync = enable_sync & TIME_SYNC_ENABLED; /* Video category */ temp_gfxcard = gfxcard; @@ -305,7 +305,7 @@ win_settings_changed(void) i = i || (temp_dynarec != cpu_use_dynarec); #endif i = i || (temp_fpu != enable_external_fpu); - i = i || (temp_sync != enable_sync); + i = i || (temp_sync != (enable_sync & TIME_SYNC_ENABLED)); /* Video category */ i = i || (gfxcard != temp_gfxcard);