comparison sms.c @ 2604:c768bbd912f1

Give sega 8-bit consoles separate system_type enum values and allow selecting them from the command line
author Michael Pavone <pavone@retrodev.com>
date Thu, 13 Feb 2025 23:07:31 -0800
parents 251cc75574af
children
comparison
equal deleted inserted replaced
2603:acb8f0f70a68 2604:c768bbd912f1
1528 { 1528 {
1529 sms_context *sms = (sms_context *)system; 1529 sms_context *sms = (sms_context *)system;
1530 load_cassette(sms, media); 1530 load_cassette(sms, media);
1531 } 1531 }
1532 1532
1533 sms_context *alloc_configure_sms(system_media *media, uint32_t opts, uint8_t force_region) 1533 sms_context *alloc_configure_sms(system_media *media, system_type stype, uint32_t opts, uint8_t force_region)
1534 { 1534 {
1535 sms_context *sms = calloc(1, sizeof(sms_context)); 1535 sms_context *sms = calloc(1, sizeof(sms_context));
1536 tern_node *rom_db = get_rom_db(); 1536 tern_node *rom_db = get_rom_db();
1537 const memmap_chunk base_map[] = { 1537 const memmap_chunk base_map[] = {
1538 {0xC000, 0x10000, sizeof(sms->ram)-1, .flags = MMAP_READ|MMAP_WRITE|MMAP_CODE, .buffer = sms->ram} 1538 {0xC000, 0x10000, sizeof(sms->ram)-1, .flags = MMAP_READ|MMAP_WRITE|MMAP_CODE, .buffer = sms->ram}
1539 }; 1539 };
1540 sms->header.info = configure_rom_sms(rom_db, media->buffer, media->size, base_map, sizeof(base_map)/sizeof(base_map[0])); 1540 sms->header.info = configure_rom_sms(rom_db, media->buffer, media->size, base_map, sizeof(base_map)/sizeof(base_map[0]));
1541 uint32_t rom_size = sms->header.info.rom_size; 1541 uint32_t rom_size = sms->header.info.rom_size;
1542 z80_options *zopts = malloc(sizeof(z80_options)); 1542 z80_options *zopts = malloc(sizeof(z80_options));
1543 tern_node *model_def; 1543 tern_node *model_def;
1544 uint8_t is_gamegear = !strcasecmp(media->extension, "gg"); 1544 uint8_t vdp_type = VDP_SMS2;
1545 uint8_t is_sc3000 = !strcasecmp(media->extension, "sc"); 1545 switch (stype)
1546 if (is_gamegear) { 1546 {
1547 case SYSTEM_GAME_GEAR:
1547 model_def = tern_find_node(get_systems_config(), "gg"); 1548 model_def = tern_find_node(get_systems_config(), "gg");
1548 } else if (!strcasecmp(media->extension, "sg")) { 1549 vdp_type = VDP_GAMEGEAR;
1550 break;
1551 case SYSTEM_SG1000:
1549 model_def = tern_find_node(get_systems_config(), "sg1000"); 1552 model_def = tern_find_node(get_systems_config(), "sg1000");
1550 } else if (is_sc3000) { 1553 vdp_type = VDP_TMS9918A;
1554 break;
1555 case SYSTEM_SC3000:
1551 model_def = tern_find_node(get_systems_config(), "sc3000"); 1556 model_def = tern_find_node(get_systems_config(), "sc3000");
1552 } else { 1557 vdp_type = VDP_TMS9918A;
1558 break;
1559 default:
1553 model_def = get_model(config, SYSTEM_SMS); 1560 model_def = get_model(config, SYSTEM_SMS);
1561 break;
1554 } 1562 }
1555 char *vdp_str = tern_find_ptr(model_def, "vdp"); 1563 char *vdp_str = tern_find_ptr(model_def, "vdp");
1556 uint8_t vdp_type = is_gamegear ? VDP_GAMEGEAR : is_sc3000 ? VDP_TMS9918A : VDP_SMS2;
1557 if (vdp_str) { 1564 if (vdp_str) {
1558 if (!strcmp(vdp_str, "sms1")) { 1565 if (!strcmp(vdp_str, "sms1")) {
1559 vdp_type = VDP_SMS; 1566 vdp_type = VDP_SMS;
1560 } else if (!strcmp(vdp_str, "sms2")) { 1567 } else if (!strcmp(vdp_str, "sms2")) {
1561 vdp_type = VDP_SMS2; 1568 vdp_type = VDP_SMS2;
1574 memmap_chunk *chunk = sms->header.info.map + i; 1581 memmap_chunk *chunk = sms->header.info.map + i;
1575 if ((chunk->flags == MMAP_READ) && !chunk->buffer && chunk->start > 0xC000) { 1582 if ((chunk->flags == MMAP_READ) && !chunk->buffer && chunk->start > 0xC000) {
1576 chunk->buffer = sms->ram + ((chunk->start - 0xC000) & 0x1FFF); 1583 chunk->buffer = sms->ram + ((chunk->start - 0xC000) & 0x1FFF);
1577 } 1584 }
1578 } 1585 }
1586 uint8_t is_gamegear = stype == SYSTEM_GAME_GEAR, is_sc3000 = stype == SYSTEM_SC3000;
1579 char *io_type = tern_find_ptr(model_def, "io"); 1587 char *io_type = tern_find_ptr(model_def, "io");
1580 if (io_type) { 1588 if (io_type) {
1581 if (!strcmp(io_type, "gamegear")) { 1589 if (!strcmp(io_type, "gamegear")) {
1582 is_gamegear = 1; 1590 is_gamegear = 1;
1583 is_sc3000 = 0; 1591 is_sc3000 = 0;
1670 sms->header.deserialize = deserialize; 1678 sms->header.deserialize = deserialize;
1671 sms->header.start_vgm_log = start_vgm_log; 1679 sms->header.start_vgm_log = start_vgm_log;
1672 sms->header.stop_vgm_log = stop_vgm_log; 1680 sms->header.stop_vgm_log = stop_vgm_log;
1673 sms->header.toggle_debug_view = toggle_debug_view; 1681 sms->header.toggle_debug_view = toggle_debug_view;
1674 sms->header.cassette_action = cassette_action; 1682 sms->header.cassette_action = cassette_action;
1675 sms->header.type = SYSTEM_SMS; 1683 sms->header.type = stype;
1676 if (is_sc3000) { 1684 if (is_sc3000) {
1677 sms->header.lockon_change = lockon_change; 1685 sms->header.lockon_change = lockon_change;
1678 } 1686 }
1679 1687
1680 return sms; 1688 return sms;