config: replace numeric enable_sync
setting with time_sync
string
This shouldn't break existing configs. Existing "enable_sync" setings are automatically replaced with an appropriate "time_sync" value. In case "enable_sync" and "time_sync" settings are both present in a configuration file (shouldn't happen without manually editing the config), "time_sync" takes precedence.
This commit is contained in:
@@ -104,7 +104,7 @@ extern int cpu_manufacturer, /* (C) cpu manufacturer */
|
|||||||
cpu, /* (C) cpu type */
|
cpu, /* (C) cpu type */
|
||||||
cpu_use_dynarec, /* (C) cpu uses/needs Dyna */
|
cpu_use_dynarec, /* (C) cpu uses/needs Dyna */
|
||||||
enable_external_fpu; /* (C) enable external FPU */
|
enable_external_fpu; /* (C) enable external FPU */
|
||||||
extern int enable_sync; /* (C) enable time sync */
|
extern int time_sync; /* (C) enable time sync */
|
||||||
extern int network_type; /* (C) net provider type */
|
extern int network_type; /* (C) net provider type */
|
||||||
extern int network_card; /* (C) net interface num */
|
extern int network_card; /* (C) net interface num */
|
||||||
extern char network_host[512]; /* (C) host network intf */
|
extern char network_host[512]; /* (C) host network intf */
|
||||||
|
29
src/config.c
29
src/config.c
@@ -528,10 +528,24 @@ load_machine(void)
|
|||||||
|
|
||||||
enable_external_fpu = !!config_get_int(cat, "cpu_enable_fpu", 0);
|
enable_external_fpu = !!config_get_int(cat, "cpu_enable_fpu", 0);
|
||||||
|
|
||||||
enable_sync = !!config_get_int(cat, "enable_sync", 1);
|
p = config_get_string(cat, "time_sync", NULL);
|
||||||
|
if (p != NULL) {
|
||||||
|
if (!strcmp(p, "disabled"))
|
||||||
|
time_sync = TIME_SYNC_DISABLED;
|
||||||
|
else
|
||||||
|
if (!strcmp(p, "local"))
|
||||||
|
time_sync = TIME_SYNC_ENABLED;
|
||||||
|
else
|
||||||
|
if (!strcmp(p, "utc") || !strcmp(p, "gmt"))
|
||||||
|
time_sync = TIME_SYNC_ENABLED | TIME_SYNC_UTC;
|
||||||
|
else
|
||||||
|
time_sync = TIME_SYNC_ENABLED;
|
||||||
|
} else
|
||||||
|
time_sync = !!config_get_int(cat, "enable_sync", 1);
|
||||||
|
|
||||||
/* Remove this after a while.. */
|
/* Remove this after a while.. */
|
||||||
config_delete_var(cat, "nvr_path");
|
config_delete_var(cat, "nvr_path");
|
||||||
|
config_delete_var(cat, "enable_sync");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1278,7 +1292,7 @@ config_load(void)
|
|||||||
machine = machine_get_machine_from_internal_name("ibmpc");
|
machine = machine_get_machine_from_internal_name("ibmpc");
|
||||||
gfxcard = GFX_CGA;
|
gfxcard = GFX_CGA;
|
||||||
vid_api = plat_vidapi("default");
|
vid_api = plat_vidapi("default");
|
||||||
enable_sync = 1;
|
time_sync = TIME_SYNC_ENABLED;
|
||||||
joystick_type = 7;
|
joystick_type = 7;
|
||||||
if (hdc_name) {
|
if (hdc_name) {
|
||||||
free(hdc_name);
|
free(hdc_name);
|
||||||
@@ -1455,10 +1469,13 @@ save_machine(void)
|
|||||||
else
|
else
|
||||||
config_set_int(cat, "cpu_enable_fpu", enable_external_fpu);
|
config_set_int(cat, "cpu_enable_fpu", enable_external_fpu);
|
||||||
|
|
||||||
if (enable_sync == 1)
|
if (time_sync & TIME_SYNC_ENABLED)
|
||||||
config_delete_var(cat, "enable_sync");
|
if (time_sync & TIME_SYNC_UTC)
|
||||||
else
|
config_set_string(cat, "time_sync", "utc");
|
||||||
config_set_int(cat, "enable_sync", enable_sync);
|
else
|
||||||
|
config_set_string(cat, "time_sync", "local");
|
||||||
|
else
|
||||||
|
config_set_string(cat, "time_sync", "disabled");
|
||||||
|
|
||||||
delete_section_if_empty(cat);
|
delete_section_if_empty(cat);
|
||||||
}
|
}
|
||||||
|
@@ -280,7 +280,7 @@ rtc_start(nvr_t *nvr)
|
|||||||
struct tm tm;
|
struct tm tm;
|
||||||
|
|
||||||
/* Initialize the internal and chip times. */
|
/* Initialize the internal and chip times. */
|
||||||
if (enable_sync & TIME_SYNC_ENABLED) {
|
if (time_sync & TIME_SYNC_ENABLED) {
|
||||||
/* Use the internal clock's time. */
|
/* Use the internal clock's time. */
|
||||||
nvr_time_get(&tm);
|
nvr_time_get(&tm);
|
||||||
rtc_time_set(nvr->regs, &tm);
|
rtc_time_set(nvr->regs, &tm);
|
||||||
|
@@ -258,7 +258,7 @@ tc8521_start(nvr_t *nvr)
|
|||||||
struct tm tm;
|
struct tm tm;
|
||||||
|
|
||||||
/* Initialize the internal and chip times. */
|
/* Initialize the internal and chip times. */
|
||||||
if (enable_sync & TIME_SYNC_ENABLED) {
|
if (time_sync & TIME_SYNC_ENABLED) {
|
||||||
/* Use the internal clock's time. */
|
/* Use the internal clock's time. */
|
||||||
nvr_time_get(&tm);
|
nvr_time_get(&tm);
|
||||||
tc8521_time_set(nvr->regs, &tm);
|
tc8521_time_set(nvr->regs, &tm);
|
||||||
|
@@ -181,10 +181,10 @@ nvr_init(nvr_t *nvr)
|
|||||||
|
|
||||||
/* Initialize the internal clock as needed. */
|
/* Initialize the internal clock as needed. */
|
||||||
memset(&intclk, 0x00, sizeof(intclk));
|
memset(&intclk, 0x00, sizeof(intclk));
|
||||||
if (enable_sync & TIME_SYNC_ENABLED) {
|
if (time_sync & TIME_SYNC_ENABLED) {
|
||||||
/* Get the current time of day, and convert to local time. */
|
/* Get the current time of day, and convert to local time. */
|
||||||
(void)time(&now);
|
(void)time(&now);
|
||||||
if(enable_sync & TIME_SYNC_UTC)
|
if(time_sync & TIME_SYNC_UTC)
|
||||||
tm = gmtime(&now);
|
tm = gmtime(&now);
|
||||||
else
|
else
|
||||||
tm = localtime(&now);
|
tm = localtime(&now);
|
||||||
|
@@ -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 < RTC_REGA) || ((local->cent != 0xff) && (local->addr == local->cent))) {
|
||||||
if ((local->addr != 1) && (local->addr != 3) && (local->addr != 5)) {
|
if ((local->addr != 1) && (local->addr != 3) && (local->addr != 5)) {
|
||||||
if ((old != val) && !(enable_sync & TIME_SYNC_ENABLED)) {
|
if ((old != val) && !(time_sync & TIME_SYNC_ENABLED)) {
|
||||||
/* Update internal clock. */
|
/* Update internal clock. */
|
||||||
time_get(nvr, &tm);
|
time_get(nvr, &tm);
|
||||||
nvr_time_set(&tm);
|
nvr_time_set(&tm);
|
||||||
|
2
src/pc.c
2
src/pc.c
@@ -119,7 +119,7 @@ int cpu_manufacturer = 0, /* (C) cpu manufacturer */
|
|||||||
cpu_use_dynarec = 0, /* (C) cpu uses/needs Dyna */
|
cpu_use_dynarec = 0, /* (C) cpu uses/needs Dyna */
|
||||||
cpu = 3, /* (C) cpu type */
|
cpu = 3, /* (C) cpu type */
|
||||||
enable_external_fpu = 0; /* (C) enable external FPU */
|
enable_external_fpu = 0; /* (C) enable external FPU */
|
||||||
int enable_sync = 0; /* (C) enable time sync */
|
int time_sync = 0; /* (C) enable time sync */
|
||||||
|
|
||||||
/* Statistics. */
|
/* Statistics. */
|
||||||
extern int
|
extern int
|
||||||
|
@@ -202,7 +202,7 @@ win_settings_init(void)
|
|||||||
temp_dynarec = cpu_use_dynarec;
|
temp_dynarec = cpu_use_dynarec;
|
||||||
#endif
|
#endif
|
||||||
temp_fpu = enable_external_fpu;
|
temp_fpu = enable_external_fpu;
|
||||||
temp_sync = enable_sync & TIME_SYNC_ENABLED;
|
temp_sync = time_sync & TIME_SYNC_ENABLED;
|
||||||
|
|
||||||
/* Video category */
|
/* Video category */
|
||||||
temp_gfxcard = gfxcard;
|
temp_gfxcard = gfxcard;
|
||||||
@@ -305,7 +305,7 @@ win_settings_changed(void)
|
|||||||
i = i || (temp_dynarec != cpu_use_dynarec);
|
i = i || (temp_dynarec != cpu_use_dynarec);
|
||||||
#endif
|
#endif
|
||||||
i = i || (temp_fpu != enable_external_fpu);
|
i = i || (temp_fpu != enable_external_fpu);
|
||||||
i = i || (temp_sync != (enable_sync & TIME_SYNC_ENABLED));
|
i = i || (temp_sync != (time_sync & TIME_SYNC_ENABLED));
|
||||||
|
|
||||||
/* Video category */
|
/* Video category */
|
||||||
i = i || (gfxcard != temp_gfxcard);
|
i = i || (gfxcard != temp_gfxcard);
|
||||||
@@ -403,7 +403,7 @@ win_settings_save(void)
|
|||||||
cpu_use_dynarec = temp_dynarec;
|
cpu_use_dynarec = temp_dynarec;
|
||||||
#endif
|
#endif
|
||||||
enable_external_fpu = temp_fpu;
|
enable_external_fpu = temp_fpu;
|
||||||
enable_sync = temp_sync;
|
time_sync = temp_sync;
|
||||||
|
|
||||||
/* Video category */
|
/* Video category */
|
||||||
gfxcard = temp_gfxcard;
|
gfxcard = temp_gfxcard;
|
||||||
|
Reference in New Issue
Block a user