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:
David Hrdlička
2018-08-01 18:07:52 +02:00
parent a4f6bfde58
commit c7388eb174
8 changed files with 33 additions and 16 deletions

View File

@@ -104,7 +104,7 @@ extern int cpu_manufacturer, /* (C) cpu manufacturer */
cpu, /* (C) cpu type */
cpu_use_dynarec, /* (C) cpu uses/needs Dyna */
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_card; /* (C) net interface num */
extern char network_host[512]; /* (C) host network intf */

View File

@@ -528,10 +528,24 @@ load_machine(void)
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.. */
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");
gfxcard = GFX_CGA;
vid_api = plat_vidapi("default");
enable_sync = 1;
time_sync = TIME_SYNC_ENABLED;
joystick_type = 7;
if (hdc_name) {
free(hdc_name);
@@ -1455,10 +1469,13 @@ save_machine(void)
else
config_set_int(cat, "cpu_enable_fpu", enable_external_fpu);
if (enable_sync == 1)
config_delete_var(cat, "enable_sync");
else
config_set_int(cat, "enable_sync", enable_sync);
if (time_sync & TIME_SYNC_ENABLED)
if (time_sync & TIME_SYNC_UTC)
config_set_string(cat, "time_sync", "utc");
else
config_set_string(cat, "time_sync", "local");
else
config_set_string(cat, "time_sync", "disabled");
delete_section_if_empty(cat);
}

View File

@@ -280,7 +280,7 @@ rtc_start(nvr_t *nvr)
struct tm tm;
/* Initialize the internal and chip times. */
if (enable_sync & TIME_SYNC_ENABLED) {
if (time_sync & TIME_SYNC_ENABLED) {
/* Use the internal clock's time. */
nvr_time_get(&tm);
rtc_time_set(nvr->regs, &tm);

View File

@@ -258,7 +258,7 @@ tc8521_start(nvr_t *nvr)
struct tm tm;
/* Initialize the internal and chip times. */
if (enable_sync & TIME_SYNC_ENABLED) {
if (time_sync & TIME_SYNC_ENABLED) {
/* Use the internal clock's time. */
nvr_time_get(&tm);
tc8521_time_set(nvr->regs, &tm);

View File

@@ -181,10 +181,10 @@ nvr_init(nvr_t *nvr)
/* Initialize the internal clock as needed. */
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. */
(void)time(&now);
if(enable_sync & TIME_SYNC_UTC)
if(time_sync & TIME_SYNC_UTC)
tm = gmtime(&now);
else
tm = localtime(&now);

View File

@@ -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 & TIME_SYNC_ENABLED)) {
if ((old != val) && !(time_sync & TIME_SYNC_ENABLED)) {
/* Update internal clock. */
time_get(nvr, &tm);
nvr_time_set(&tm);

View File

@@ -119,7 +119,7 @@ int cpu_manufacturer = 0, /* (C) cpu manufacturer */
cpu_use_dynarec = 0, /* (C) cpu uses/needs Dyna */
cpu = 3, /* (C) cpu type */
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. */
extern int

View File

@@ -202,7 +202,7 @@ win_settings_init(void)
temp_dynarec = cpu_use_dynarec;
#endif
temp_fpu = enable_external_fpu;
temp_sync = enable_sync & TIME_SYNC_ENABLED;
temp_sync = time_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 & TIME_SYNC_ENABLED));
i = i || (temp_sync != (time_sync & TIME_SYNC_ENABLED));
/* Video category */
i = i || (gfxcard != temp_gfxcard);
@@ -403,7 +403,7 @@ win_settings_save(void)
cpu_use_dynarec = temp_dynarec;
#endif
enable_external_fpu = temp_fpu;
enable_sync = temp_sync;
time_sync = temp_sync;
/* Video category */
gfxcard = temp_gfxcard;