Mercurial > repos > blastem
comparison config.c @ 2413:64cf80e683aa
Initial support for Colecovision emulation
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 04 Jan 2024 22:56:35 -0800 |
parents | af3075c1e421 |
children | 2972a8e16ed2 |
comparison
equal
deleted
inserted
replaced
2412:ed7b4d869989 | 2413:64cf80e683aa |
---|---|
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 8 | 319 #define CONFIG_VERSION 9 |
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 { |
442 free(parts); | 442 free(parts); |
443 } | 443 } |
444 free(exts[0]);//All extensions in this list share an allocation, first one is a pointer to the buffer | 444 free(exts[0]);//All extensions in this list share an allocation, first one is a pointer to the buffer |
445 free(exts); | 445 free(exts); |
446 } | 446 } |
447 case 8: { | |
448 uint32_t num_exts; | |
449 char **exts = get_extension_list(config, &num_exts); | |
450 char *need_add[] = {"col"}; | |
451 uint32_t num_need_add = sizeof(need_add)/sizeof(*need_add); | |
452 for (uint32_t i = 0; i < num_exts && num_need_add; i++) | |
453 { | |
454 for (uint32_t j = 0; j < num_need_add; j++) | |
455 { | |
456 if (!strcmp(exts[i], need_add[j])) { | |
457 num_need_add--; | |
458 need_add[j] = need_add[num_need_add]; | |
459 break; | |
460 } | |
461 } | |
462 } | |
463 if (num_need_add) { | |
464 const char **parts = calloc(2 * (num_exts + num_need_add) - 1, sizeof(char*)); | |
465 uint32_t dest = 0; | |
466 for (uint32_t i = 0; i < num_exts; i++) | |
467 { | |
468 parts[dest++] = exts[i]; | |
469 parts[dest++] = " "; | |
470 } | |
471 for (uint32_t i = 0; i < num_need_add - 1; i++) | |
472 { | |
473 parts[dest++] = need_add[i]; | |
474 parts[dest++] = " "; | |
475 } | |
476 parts[dest++] = need_add[num_need_add - 1]; | |
477 config = tern_insert_path(config, "ui\0extensions\0", (tern_val){.ptrval = alloc_concat_m(dest, parts)}, TVAL_PTR); | |
478 free(parts); | |
479 } | |
480 free(exts[0]);//All extensions in this list share an allocation, first one is a pointer to the buffer | |
481 free(exts); | |
482 } | |
447 } | 483 } |
448 char buffer[16]; | 484 char buffer[16]; |
449 sprintf(buffer, "%d", CONFIG_VERSION); | 485 sprintf(buffer, "%d", CONFIG_VERSION); |
450 return tern_insert_ptr(config, "version", strdup(buffer)); | 486 return tern_insert_ptr(config, "version", strdup(buffer)); |
451 } | 487 } |