machine_config::machine_config(const game_driver &gamedrv, emu_options &options) : m_minimum_quantum(attotime::zero), m_perfect_cpu_quantum(NULL), m_watchdog_vblank_count(0), m_watchdog_time(attotime::zero), m_nvram_handler(NULL), m_memcard_handler(NULL), m_video_attributes(0), m_gfxdecodeinfo(NULL), m_total_colors(0), m_default_layout(NULL), m_gamedrv(gamedrv), m_options(options) { // construct the config (*gamedrv.machine_config)(*this, NULL); // intialize slot devices - make sure that any required devices have been allocated device_slot_interface *slot = NULL; for (bool gotone = m_devicelist.first(slot); gotone; gotone = slot->next(slot)) { const slot_interface *intf = slot->get_slot_interfaces(); if (intf != NULL) { device_t &owner = slot->device(); const char *selval = options.value(owner.tag()); if (!options.exists(owner.tag())) selval = slot->get_default_card(devicelist(), options); if (selval != NULL && strlen(selval)!=0) { bool found = false; for (int i = 0; intf[i].name != NULL; i++) { if (strcmp(selval, intf[i].name) == 0) { device_t *new_dev = device_add(&owner, intf[i].name, intf[i].devtype, 0); found = true; if (!options.exists(owner.tag())) device_t::static_set_input_default(*new_dev, slot->input_ports_defaults()); } } if (!found) throw emu_fatalerror("Unknown slot option '%s' in slot '%s'", selval, owner.tag()); } } } // when finished, set the game driver device_t *root = m_devicelist.find("root"); if (root == NULL) throw emu_fatalerror("Machine configuration missing driver_device"); driver_device::static_set_game(*root, gamedrv); // then notify all devices that their configuration is complete for (device_t *device = m_devicelist.first(); device != NULL; device = device->next()) if (!device->configured()) device->config_complete(); }
bool device_image_interface::open_image_file(emu_options &options) { const char* path = options.value(instance_name()); if (strlen(path)>0) { set_init_phase(); if (load_internal(path, FALSE, 0, NULL, TRUE)==IMAGE_INIT_PASS) { if (software_entry()==NULL) return true; } } return false; }
bool device_image_interface::open_image_file(emu_options &options) { const char* path = options.value(instance_name()); if (*path != 0) { set_init_phase(); if (load_internal(path, false, 0, nullptr, true) == image_init_result::PASS) { if (software_entry()==nullptr) return true; } } return false; }
void driver_switch::assign_drivers(emu_options &opts) { static const struct { const char *name; const game_driver * const *driver; } drivers_table[] = { #ifndef TINY_BUILD { "mame", mamedrivers }, { "plus", mameplusdrivers }, { "homebrew", mamehbdrivers }, { "decrypted", mamedecrypteddrivers }, #ifdef MAMEMESS { "console", messdrivers }, #endif /* MAMEMESS */ #else { "mame", tinydrivers }, #endif /* !TINY_BUILD */ { NULL } }; UINT32 enabled = 0; int i, n; bool mechanical = opts.bool_value(OPTION_DISABLE_MECHANICAL_DRIVER); #ifndef TINY_BUILD const char *drv_option = opts.value(OPTION_DRIVER_CONFIG); if (drv_option) { char *temp = mame_strdup(drv_option); if (temp) { char *p = strtok(temp, ","); while (p) { char *s = core_strtrim(p); //get individual driver name if (s[0]) { if (mame_stricmp(s, "all") == 0) { enabled = (UINT32)-1; break; } for (i = 0; drivers_table[i].name; i++) if (mame_stricmp(s, drivers_table[i].name) == 0) { enabled |= 1 << i; break; } if (!drivers_table[i].name) mame_printf_warning(_("Illegal value for %s = %s\n"), OPTION_DRIVER_CONFIG, s); } osd_free(s); p = strtok(NULL, ","); } osd_free(temp); } } #endif /* !TINY_BUILD */ if (enabled == 0) enabled = 1; // default to mamedrivers n = 0; for (i = 0; drivers_table[i].name; i++) if (enabled & (1 << i)) { for (int c = 0; drivers_table[i].driver[c]; c++) if (mame_stricmp(drivers_table[i].driver[c]->name, "___empty")) if (!mechanical || !(drivers_table[i].driver[c]->flags & GAME_MECHANICAL)) driver_list::s_drivers_sorted[n++] = drivers_table[i].driver[c]; } // ___empty driver add once driver_list::s_drivers_sorted[n++] = &GAME_NAME(___empty); driver_list::s_driver_count = n; qsort(driver_list::s_drivers_sorted, n, sizeof(*driver_list::s_drivers_sorted), driver_list::driver_sort_callback); }