Mercurial > repos > blastem
comparison config.c @ 2521:8cf7cadc17ee
Initial SC-3000 support
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 11 Oct 2024 00:46:53 -0700 |
parents | 2972a8e16ed2 |
children | 90a40be940f7 |
comparison
equal
deleted
inserted
replaced
2520:0e9d7ef03983 | 2521:8cf7cadc17ee |
---|---|
314 val.ptrval = tern_insert_node(val.ptrval, "axes", axes); | 314 val.ptrval = tern_insert_node(val.ptrval, "axes", axes); |
315 } | 315 } |
316 *pads = tern_insert_node(*pads, key, val.ptrval); | 316 *pads = tern_insert_node(*pads, key, val.ptrval); |
317 } | 317 } |
318 | 318 |
319 #define CONFIG_VERSION 9 | 319 #define CONFIG_VERSION 10 |
320 static tern_node *migrate_config(tern_node *config, int from_version) | 320 static tern_node *migrate_config(tern_node *config, int from_version) |
321 { | 321 { |
322 tern_node *def_config = parse_bundled_config("default.cfg"); | 322 tern_node *def_config = parse_bundled_config("default.cfg"); |
323 switch(from_version) | 323 switch(from_version) |
324 { | 324 { |
477 config = tern_insert_path(config, "ui\0extensions\0", (tern_val){.ptrval = alloc_concat_m(dest, parts)}, TVAL_PTR); | 477 config = tern_insert_path(config, "ui\0extensions\0", (tern_val){.ptrval = alloc_concat_m(dest, parts)}, TVAL_PTR); |
478 free(parts); | 478 free(parts); |
479 } | 479 } |
480 free(exts[0]);//All extensions in this list share an allocation, first one is a pointer to the buffer | 480 free(exts[0]);//All extensions in this list share an allocation, first one is a pointer to the buffer |
481 free(exts); | 481 free(exts); |
482 break; | |
483 } | |
484 case 9: { | |
485 //Add pre-SMS 8-bit image formats to ui.extensions | |
486 uint32_t num_exts; | |
487 char **ext_list = get_extension_list(config, &num_exts); | |
488 char *old = num_exts ? ext_list[0] : NULL; | |
489 uint32_t new_size = num_exts + 3; | |
490 uint8_t need_sc = 1, need_sg = 1, need_sf7 = 1; | |
491 for (uint32_t i = 0; i < num_exts; i++) | |
492 { | |
493 if (!strcmp(ext_list[i], "sc")) { | |
494 need_sc = 0; | |
495 new_size--; | |
496 } else if (!strcmp(ext_list[i], "sg")) { | |
497 need_sg = 0; | |
498 new_size--; | |
499 } else if (!strcmp(ext_list[i], "sf7")) { | |
500 need_sf7 = 0; | |
501 new_size--; | |
502 } | |
503 } | |
504 if (new_size != num_exts) { | |
505 ext_list = realloc(ext_list, sizeof(char*) * new_size); | |
506 if (need_sc) { | |
507 ext_list[num_exts++] = "sc"; | |
508 } | |
509 if (need_sg) { | |
510 ext_list[num_exts++] = "sg"; | |
511 } | |
512 if (need_sf7) { | |
513 ext_list[num_exts++] = "sf7"; | |
514 } | |
515 } | |
516 char *combined = alloc_join(new_size, (char const **)ext_list, ' '); | |
517 config = tern_insert_path(config, "ui\0extensions\0", (tern_val){.ptrval = combined}, TVAL_PTR); | |
518 break; | |
482 } | 519 } |
483 } | 520 } |
484 char buffer[16]; | 521 char buffer[16]; |
485 sprintf(buffer, "%d", CONFIG_VERSION); | 522 sprintf(buffer, "%d", CONFIG_VERSION); |
486 return tern_insert_ptr(config, "version", strdup(buffer)); | 523 return tern_insert_ptr(config, "version", strdup(buffer)); |