machine_config::machine_config(const game_driver &gamedrv, emu_options &options) : m_minimum_quantum(attotime::zero), m_default_layout(nullptr), m_gamedrv(gamedrv), m_options(options) { // construct the config (*gamedrv.machine_config)(*this, nullptr, nullptr); bool is_selected_driver = core_stricmp(gamedrv.name,options.system_name())==0; // intialize slot devices - make sure that any required devices have been allocated for (device_slot_interface &slot : slot_interface_iterator(root_device())) { device_t &owner = slot.device(); std::string selval; bool isdefault = (options.priority(owner.tag()+1)==OPTION_PRIORITY_DEFAULT); if (is_selected_driver && options.exists(owner.tag()+1)) selval = options.main_value(owner.tag()+1); else if (slot.default_option() != nullptr) selval.assign(slot.default_option()); if (!selval.empty()) { const device_slot_option *option = slot.option(selval.c_str()); if (option && (isdefault || option->selectable())) { device_t *new_dev = device_add(&owner, option->name(), option->devtype(), option->clock()); const char *default_bios = option->default_bios(); if (default_bios != nullptr) device_t::static_set_default_bios_tag(*new_dev, default_bios); machine_config_constructor additions = option->machine_config(); if (additions != nullptr) (*additions)(const_cast<machine_config &>(*this), new_dev, new_dev); const input_device_default *input_device_defaults = option->input_device_defaults(); if (input_device_defaults) device_t::static_set_input_default(*new_dev, input_device_defaults); } else throw emu_fatalerror("Unknown slot option '%s' in slot '%s'", selval.c_str(), owner.tag()+1); } } // when finished, set the game driver driver_device::static_set_game(*m_root_device, gamedrv); // then notify all devices that their configuration is complete for (device_t &device : device_iterator(root_device())) if (!device.configured()) device.config_complete(); }
machine_config::machine_config(const game_driver &gamedrv, emu_options &options) : m_minimum_quantum(attotime::zero) , m_gamedrv(gamedrv) , m_options(options) , m_root_device() , m_default_layouts([] (char const *a, char const *b) { return 0 > std::strcmp(a, b); }) , m_current_device(nullptr) { // add the root device device_add("root", gamedrv.type, 0); // intialize slot devices - make sure that any required devices have been allocated for (device_slot_interface &slot : slot_interface_iterator(root_device())) { device_t &owner = slot.device(); const char *slot_option_name = owner.tag() + 1; // figure out which device goes into this slot bool const has_option = options.has_slot_option(slot_option_name); const char *selval; bool is_default; if (!has_option) { // The only time we should be getting here is when emuopts.cpp is invoking // us to evaluate slot/image options, and the internal state of emuopts.cpp has // not caught up yet selval = slot.default_option(); is_default = true; } else { const slot_option &opt = options.slot_option(slot_option_name); selval = opt.value().c_str(); is_default = !opt.specified(); } if (selval && *selval) { // TODO: make this thing more self-contained so it can apply itself - shouldn't need to know all this here device_slot_interface::slot_option const *option = slot.option(selval); if (option && (is_default || option->selectable())) { // create the device token const tok(begin_configuration(owner)); device_t *const new_dev = device_add(option->name(), option->devtype(), option->clock()); slot.set_card_device(new_dev); char const *const default_bios = option->default_bios(); if (default_bios != nullptr) new_dev->set_default_bios_tag(default_bios); auto additions = option->machine_config(); if (additions) additions(new_dev); input_device_default const *const input_device_defaults = option->input_device_defaults(); if (input_device_defaults) new_dev->set_input_default(input_device_defaults); } else throw emu_fatalerror("Unknown slot option '%s' in slot '%s'", selval, owner.tag()+1); } } // then notify all devices that their configuration is complete for (device_t &device : device_iterator(root_device())) if (!device.configured()) device.config_complete(); }
void menu_main::populate() { /* add input menu items */ item_append(_("Input (general)"), "", 0, (void *)INPUT_GROUPS); item_append(_("Input (this Machine)"), "", 0, (void *)INPUT_SPECIFIC); /* add optional input-related menus */ if (ui().machine_info().has_analog()) item_append(_("Analog Controls"), "", 0, (void *)ANALOG); if (ui().machine_info().has_dips()) item_append(_("Dip Switches"), "", 0, (void *)SETTINGS_DIP_SWITCHES); if (ui().machine_info().has_configs()) { item_append(_("Machine Configuration"), "", 0, (void *)SETTINGS_DRIVER_CONFIG); } /* add bookkeeping menu */ item_append(_("Bookkeeping Info"), "", 0, (void *)BOOKKEEPING); /* add game info menu */ item_append(_("Machine Information"), "", 0, (void *)GAME_INFO); for (device_image_interface &image : image_interface_iterator(machine().root_device())) { if (image.user_loadable()) { /* add image info menu */ item_append(_("Image Information"), "", 0, (void *)IMAGE_MENU_IMAGE_INFO); /* add file manager menu */ item_append(_("File Manager"), "", 0, (void *)IMAGE_MENU_FILE_MANAGER); break; } } /* add tape control menu */ if (cassette_device_iterator(machine().root_device()).first() != nullptr) item_append(_("Tape Control"), "", 0, (void *)TAPE_CONTROL); if (pty_interface_iterator(machine().root_device()).first() != nullptr) item_append(_("Pseudo terminals"), "", 0, (void *)PTY_INFO); if (ui().machine_info().has_bioses()) item_append(_("Bios Selection"), "", 0, (void *)BIOS_SELECTION); /* add slot info menu */ if (slot_interface_iterator(machine().root_device()).first() != nullptr) item_append(_("Slot Devices"), "", 0, (void *)SLOT_DEVICES); /* add Barcode reader menu */ if (barcode_reader_device_iterator(machine().root_device()).first() != nullptr) item_append(_("Barcode Reader"), "", 0, (void *)BARCODE_READ); /* add network info menu */ if (network_interface_iterator(machine().root_device()).first() != nullptr) item_append(_("Network Devices"), "", 0, (void*)NETWORK_DEVICES); /* add keyboard mode menu */ if (ui().machine_info().has_keyboard() && machine().ioport().natkeyboard().can_post()) item_append(_("Keyboard Mode"), "", 0, (void *)KEYBOARD_MODE); /* add sliders menu */ item_append(_("Slider Controls"), "", 0, (void *)SLIDERS); /* add video options menu */ item_append(_("Video Options"), "", 0, (machine().render().target_by_index(1) != nullptr) ? (void *)VIDEO_TARGETS : (void *)VIDEO_OPTIONS); /* add crosshair options menu */ if (machine().crosshair().get_usage()) item_append(_("Crosshair Options"), "", 0, (void *)CROSSHAIR); /* add cheat menu */ if (machine().options().cheat()) item_append(_("Cheat"), "", 0, (void *)CHEAT); if (machine().options().plugins()) item_append(_("Plugin Options"), "", 0, (void *)PLUGINS); // add dats menu if (mame_machine_manager::instance()->lua()->call_plugin("", "data_list")) item_append(_("External DAT View"), "", 0, (void *)EXTERNAL_DATS); item_append(menu_item_type::SEPARATOR); /* add favorite menu */ if (!mame_machine_manager::instance()->favorite().isgame_favorite()) item_append(_("Add To Favorites"), "", 0, (void *)ADD_FAVORITE); else item_append(_("Remove From Favorites"), "", 0, (void *)REMOVE_FAVORITE); item_append(menu_item_type::SEPARATOR); // item_append(_("Quit from Machine"), nullptr, 0, (void *)QUIT_GAME); /* add reset and exit menus */ item_append(_("Select New Machine"), "", 0, (void *)SELECT_GAME); }