const rom_entry *rom_first_parameter(const device_t &device) { const rom_entry *romp = device.rom_region(); while (romp && !ROMENTRY_ISEND(romp) && !ROMENTRY_ISPARAMETER(romp)) romp++; return (romp != nullptr && !ROMENTRY_ISEND(romp)) ? romp : nullptr; }
static void determine_bios_rom(rom_load_data *romdata) { const char *specbios = romdata->machine().options().bios(); const char *defaultname = NULL; const rom_entry *rom; int default_no = 1; int bios_count = 0; device_t &rootdevice = romdata->machine().config().root_device(); rootdevice.set_system_bios(0); /* first determine the default BIOS name */ for (rom = rootdevice.rom_region(); !ROMENTRY_ISEND(rom); rom++) if (ROMENTRY_ISDEFAULT_BIOS(rom)) defaultname = ROM_GETNAME(rom); /* look for a BIOS with a matching name */ for (rom = rootdevice.rom_region(); !ROMENTRY_ISEND(rom); rom++) if (ROMENTRY_ISSYSTEM_BIOS(rom)) { const char *biosname = ROM_GETNAME(rom); int bios_flags = ROM_GETBIOSFLAGS(rom); char bios_number[20]; /* Allow '-bios n' to still be used */ sprintf(bios_number, "%d", bios_flags - 1); if (mame_stricmp(bios_number, specbios) == 0 || mame_stricmp(biosname, specbios) == 0) rootdevice.set_system_bios(bios_flags); if (defaultname != NULL && mame_stricmp(biosname, defaultname) == 0) default_no = bios_flags; bios_count++; } /* if none found, use the default */ if (rootdevice.system_bios() == 0 && bios_count > 0) { /* if we got neither an empty string nor 'default' then warn the user */ if (specbios[0] != 0 && strcmp(specbios, "default") != 0 && romdata != NULL) { romdata->errorstring.catprintf("%s: invalid bios\n", specbios); romdata->warnings++; } /* set to default */ rootdevice.set_system_bios(default_no); } rootdevice.set_default_bios(default_no); LOG(("Using System BIOS: %d\n", rootdevice.system_bios())); }
void ui_menu_bios_selection::handle() { /* process the menu */ const ui_menu_event *menu_event = process(0); if (menu_event != nullptr && menu_event->itemref != nullptr) { if ((FPTR)menu_event->itemref == 1 && menu_event->iptkey == IPT_UI_SELECT) machine().schedule_hard_reset(); else if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT) { device_t *dev = (device_t *)menu_event->itemref; int cnt = 0; for (const rom_entry *rom = dev->rom_region(); !ROMENTRY_ISEND(rom); rom++) { if (ROMENTRY_ISSYSTEM_BIOS(rom)) cnt ++; } int val = dev->system_bios() + ((menu_event->iptkey == IPT_UI_LEFT) ? -1 : +1); if (val<1) val=cnt; if (val>cnt) val=1; dev->set_system_bios(val); if (strcmp(dev->tag(),":")==0) { std::string error; machine().options().set_value("bios", val-1, OPTION_PRIORITY_CMDLINE, error); assert(error.empty()); } else { std::string error; std::string value = string_format("%s,bios=%d", machine().options().main_value(dev->owner()->tag()+1), val-1); machine().options().set_value(dev->owner()->tag()+1, value.c_str(), OPTION_PRIORITY_CMDLINE, error); assert(error.empty()); } reset(UI_MENU_RESET_REMEMBER_REF); } } }
const struct RomModule *rom_next_region(const struct RomModule *romp) { romp++; while (!ROMENTRY_ISREGIONEND(romp)) romp++; return ROMENTRY_ISEND(romp) ? NULL : romp; }
const rom_entry *rom_next_parameter(const rom_entry *romp) { romp++; while (!ROMENTRY_ISREGIONEND(romp) && !ROMENTRY_ISPARAMETER(romp)) romp++; return ROMENTRY_ISEND(romp) ? nullptr : romp; }
const rom_entry *rom_next_region(const rom_entry *romp) { romp++; while (!ROMENTRY_ISREGIONEND(romp)) romp++; return ROMENTRY_ISEND(romp) ? NULL : romp; }
void rom_load_manager::determine_bios_rom(device_t *device, const char *specbios) { const char *defaultname = nullptr; const rom_entry *rom; int default_no = 1; int bios_count = 0; device->set_system_bios(0); /* first determine the default BIOS name */ for (rom = device->rom_region(); !ROMENTRY_ISEND(rom); rom++) if (ROMENTRY_ISDEFAULT_BIOS(rom)) defaultname = ROM_GETNAME(rom); /* look for a BIOS with a matching name */ for (rom = device->rom_region(); !ROMENTRY_ISEND(rom); rom++) if (ROMENTRY_ISSYSTEM_BIOS(rom)) { const char *biosname = ROM_GETNAME(rom); int bios_flags = ROM_GETBIOSFLAGS(rom); char bios_number[20]; /* Allow '-bios n' to still be used */ sprintf(bios_number, "%d", bios_flags - 1); if (core_stricmp(bios_number, specbios) == 0 || core_stricmp(biosname, specbios) == 0) device->set_system_bios(bios_flags); if (defaultname != nullptr && core_stricmp(biosname, defaultname) == 0) default_no = bios_flags; bios_count++; } /* if none found, use the default */ if (device->system_bios() == 0 && bios_count > 0) { /* if we got neither an empty string nor 'default' then warn the user */ if (specbios[0] != 0 && strcmp(specbios, "default") != 0) { strcatprintf(m_errorstring, "%s: invalid bios\n", specbios); m_errors++; } /* set to default */ device->set_system_bios(default_no); } device->set_default_bios(default_no); LOG(("For \"%s\" using System BIOS: %d\n", device->tag().c_str(), device->system_bios())); }
const rom_entry *rom_next_region(const rom_entry *romp) { romp++; while (!ROMENTRY_ISREGIONEND(romp)) romp++; while (ROMENTRY_ISPARAMETER(romp)) romp++; return ROMENTRY_ISEND(romp) ? nullptr : romp; }
void ui_menu_machine_configure::setup_bios() { if (m_drv->rom == nullptr) return; std::string specbios(m_opts.bios()); std::string default_name; for (const rom_entry *rom = m_drv->rom; !ROMENTRY_ISEND(rom); ++rom) if (ROMENTRY_ISDEFAULT_BIOS(rom)) default_name = ROM_GETNAME(rom); int bios_count = 0; for (const rom_entry *rom = m_drv->rom; !ROMENTRY_ISEND(rom); ++rom) { if (ROMENTRY_ISSYSTEM_BIOS(rom)) { std::string name(ROM_GETHASHDATA(rom)); std::string biosname(ROM_GETNAME(rom)); int bios_flags = ROM_GETBIOSFLAGS(rom); std::string bios_number = std::to_string(bios_flags - 1); // check biosnumber and name if (bios_number == specbios || biosname == specbios) m_curbios = bios_count; if (biosname == default_name) { name.append(_(" (default)")); if (specbios == "default") m_curbios = bios_count; } m_bios.emplace_back(name, bios_flags - 1); bios_count++; } } }
void info_xml_creator::output_bios() { // skip if no ROMs if (m_drivlist.driver().rom == NULL) return; // iterate over ROM entries and look for BIOSes for (const rom_entry *rom = m_drivlist.driver().rom; !ROMENTRY_ISEND(rom); rom++) if (ROMENTRY_ISSYSTEM_BIOS(rom)) { // output extracted name and descriptions fprintf(m_output, "\t\t<biosset"); fprintf(m_output, " name=\"%s\"", xml_normalize_string(ROM_GETNAME(rom))); fprintf(m_output, " description=\"%s\"", xml_normalize_string(ROM_GETHASHDATA(rom))); if (ROM_GETBIOSFLAGS(rom) == 1) fprintf(m_output, " default=\"yes\""); fprintf(m_output, "/>\n"); } }
void ui_menu_bios_selection::populate() { /* cycle through all devices for this system */ device_iterator deviter(machine().root_device()); for (device_t *device = deviter.first(); device != nullptr; device = deviter.next()) { if (device->rom_region()) { const char *val = "default"; for (const rom_entry *rom = device->rom_region(); !ROMENTRY_ISEND(rom); rom++) { if (ROMENTRY_ISSYSTEM_BIOS(rom) && ROM_GETBIOSFLAGS(rom)==device->system_bios()) { val = ROM_GETHASHDATA(rom); } } item_append(strcmp(device->tag(),":")==0 ? "driver" : device->tag()+1, val, MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW, (void *)device); } } item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr); item_append(_("Reset"), nullptr, 0, (void *)1); }
void ui_menu_bios_selection::populate() { /* cycle through all devices for this system */ for (device_t &device : device_iterator(machine().root_device())) { if (device.rom_region()) { const char *val = "default"; for (const rom_entry *rom = device.rom_region(); !ROMENTRY_ISEND(rom); rom++) { if (ROMENTRY_ISSYSTEM_BIOS(rom) && ROM_GETBIOSFLAGS(rom) == device.system_bios()) { val = ROM_GETHASHDATA(rom); } } item_append(device.owner() == nullptr ? "driver" : device.tag()+1, val, MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW, (void *)&device); } } item_append(ui_menu_item_type::SEPARATOR); item_append(_("Reset"), nullptr, 0, (void *)1); }
static void print_game_bios(FILE *out, const game_driver *game) { const rom_entry *rom; /* skip if no ROMs */ if (game->rom == NULL) return; /* iterate over ROM entries and look for BIOSes */ for (rom = game->rom; !ROMENTRY_ISEND(rom); rom++) if (ROMENTRY_ISSYSTEM_BIOS(rom)) { const char *name = ROM_GETNAME(rom); const char *description = ROM_GETHASHDATA(rom); /* output extracted name and descriptions */ fprintf(out, "\t\t<biosset"); fprintf(out, " name=\"%s\"", xml_normalize_string(name)); fprintf(out, " description=\"%s\"", xml_normalize_string(description)); if (ROM_GETBIOSFLAGS(rom) == 1) fprintf(out, " default=\"yes\""); fprintf(out, "/>\n"); } }
const rom_entry *rom_first_region(const device_t &device) { const rom_entry *romp = device.rom_region(); return (romp != NULL && !ROMENTRY_ISEND(romp)) ? romp : NULL; }
static struct DriversInfo* GetDriversInfo(int driver_index) { if (drivers_info == NULL) { UINT16 ndriver; drivers_info = (DriversInfo*)malloc(sizeof(struct DriversInfo) * GetNumGames()); for (ndriver = 0; ndriver < GetNumGames(); ndriver++) { const game_driver *gamedrv = &driver_list::driver(ndriver); struct DriversInfo *gameinfo = &drivers_info[ndriver]; const rom_entry *region, *rom; machine_config config(*gamedrv, MameUIGlobal()); const rom_source *source; int num_speakers; gameinfo->isClone = (GetParentRomSetIndex(gamedrv) != -1); gameinfo->isBroken = ((gamedrv->flags & GAME_NOT_WORKING) != 0); gameinfo->supportsSaveState = ((gamedrv->flags & GAME_SUPPORTS_SAVE) != 0); gameinfo->isHarddisk = FALSE; gameinfo->isVertical = (gamedrv->flags & ORIENTATION_SWAP_XY) ? TRUE : FALSE; for (source = rom_first_source(config); source != NULL; source = rom_next_source(*source)) for (region = rom_first_region(*source); region; region = rom_next_region(region)) if (ROMREGION_ISDISKDATA(region)) gameinfo->isHarddisk = TRUE; gameinfo->hasOptionalBIOS = FALSE; if (gamedrv->rom != NULL) for (rom = gamedrv->rom; !ROMENTRY_ISEND(rom); rom++) if (ROMENTRY_ISSYSTEM_BIOS(rom)) { gameinfo->hasOptionalBIOS = TRUE; break; } num_speakers = numberOfSpeakers(&config); gameinfo->isStereo = (num_speakers > 1); gameinfo->screenCount = numberOfScreens(&config); gameinfo->isVector = isDriverVector(&config); // ((drv.video_attributes & VIDEO_TYPE_VECTOR) != 0); gameinfo->usesRoms = FALSE; for (source = rom_first_source(config); source != NULL; source = rom_next_source(*source)) for (region = rom_first_region(*source); region; region = rom_next_region(region)) for (rom = rom_first_file(region); rom; rom = rom_next_file(rom)) { gameinfo->usesRoms = TRUE; break; } gameinfo->usesSamples = FALSE; samples_device_iterator iter(config.root_device()); if (iter.first() != NULL) gameinfo->usesSamples = TRUE; gameinfo->numPlayers = 0; gameinfo->numButtons = 0; memset(gameinfo->usesController, 0, sizeof gameinfo->usesController); gameinfo->parentIndex = -1; if (gameinfo->isClone) { int i; for (i = 0; i < GetNumGames(); i++) { if (GetParentRomSetIndex(gamedrv) == i) { gameinfo->parentIndex = i; break; } } } gameinfo->biosIndex = -1; if (DriverIsBios(ndriver)) gameinfo->biosIndex = ndriver; else if (gameinfo->hasOptionalBIOS) { int parentIndex; if (gameinfo->isClone) parentIndex = gameinfo->parentIndex; else parentIndex = ndriver; while (1) { parentIndex = GetGameNameIndex(driver_list::driver(parentIndex).parent); if (parentIndex == -1) { dprintf("bios for %s is not found", driver_list::driver(ndriver).name); break; } if (DriverIsBios(parentIndex)) { gameinfo->biosIndex = parentIndex; break; } } } gameinfo->usesTrackball = FALSE; gameinfo->usesLightGun = FALSE; if (gamedrv->ipt != NULL) { input_port_config *port; ioport_list portlist; astring errors; device_iterator iter(config.root_device()); for (device_t *device = iter.first(); device != NULL; device = iter.next()) if (device->input_ports()!=NULL) input_port_list_init(*device, portlist, errors); for (port = portlist.first(); port != NULL; port = port->next()) { const input_field_config *field; for (field = port->first_field(); field != NULL; field = field->next()) { UINT32 type; type = field->type; if (type == IPT_END) break; if (type == IPT_DIAL || type == IPT_PADDLE || type == IPT_TRACKBALL_X || type == IPT_TRACKBALL_Y || type == IPT_AD_STICK_X || type == IPT_AD_STICK_Y) gameinfo->usesTrackball = TRUE; if (type == IPT_LIGHTGUN_X || type == IPT_LIGHTGUN_Y) gameinfo->usesLightGun = TRUE; if (type == IPT_MOUSE_X || type == IPT_MOUSE_Y) gameinfo->usesMouse = TRUE; } } } } UpdateController(); } return &drivers_info[driver_index]; }
static struct DriversInfo* GetDriversInfo(int driver_index) { if (drivers_info == NULL) { int ndriver; drivers_info = (DriversInfo*)malloc(sizeof(struct DriversInfo) * GetNumGames()); for (ndriver = 0; ndriver < GetNumGames(); ndriver++) { const game_driver *gamedrv = drivers[ndriver]; struct DriversInfo *gameinfo = &drivers_info[ndriver]; const rom_entry *region, *rom; machine_config *config; const rom_source *source; int num_speakers; /* Allocate machine config */ config = global_alloc(machine_config(gamedrv->machine_config)); gameinfo->isClone = (GetParentRomSetIndex(gamedrv) != -1); gameinfo->isBroken = ((gamedrv->flags & GAME_NOT_WORKING) != 0); gameinfo->supportsSaveState = ((gamedrv->flags & GAME_SUPPORTS_SAVE) != 0); gameinfo->isHarddisk = FALSE; gameinfo->isVertical = (gamedrv->flags & ORIENTATION_SWAP_XY) ? TRUE : FALSE; for (source = rom_first_source(gamedrv, config); source != NULL; source = rom_next_source(gamedrv, config, source)) { for (region = rom_first_region(gamedrv, source); region; region = rom_next_region(region)) { if (ROMREGION_ISDISKDATA(region)) gameinfo->isHarddisk = TRUE; } } gameinfo->hasOptionalBIOS = FALSE; if (gamedrv->rom != NULL) { for (rom = gamedrv->rom; !ROMENTRY_ISEND(rom); rom++) { if (ROMENTRY_ISSYSTEM_BIOS(rom)) { gameinfo->hasOptionalBIOS = TRUE; break; } } } num_speakers = numberOfSpeakers(config); gameinfo->isStereo = (num_speakers > 1); gameinfo->screenCount = numberOfScreens(config); gameinfo->isVector = isDriverVector(config); // ((drv.video_attributes & VIDEO_TYPE_VECTOR) != 0); gameinfo->usesRoms = FALSE; for (source = rom_first_source(gamedrv, config); source != NULL; source = rom_next_source(gamedrv, config, source)) { for (region = rom_first_region(gamedrv, source); region; region = rom_next_region(region)) { for (rom = rom_first_file(region); rom; rom = rom_next_file(rom)) { gameinfo->usesRoms = TRUE; break; } } } gameinfo->usesSamples = FALSE; { const device_config_sound_interface *sound; const char * const * samplenames = NULL; for (bool gotone = config->m_devicelist.first(sound); gotone; gotone = sound->next(sound)) { if (sound->devconfig().type() == SOUND_SAMPLES) { const samples_interface *intf = (const samples_interface *)sound->devconfig().static_config(); samplenames = intf->samplenames; if (samplenames != 0 && samplenames[0] != 0) { gameinfo->usesSamples = TRUE; break; } } } } gameinfo->numPlayers = 0; gameinfo->numButtons = 0; memset(gameinfo->usesController, 0, sizeof gameinfo->usesController); gameinfo->parentIndex = -1; if (gameinfo->isClone) { int i; for (i = 0; i < GetNumGames(); i++) { if (GetParentRomSetIndex(gamedrv) == i) { gameinfo->parentIndex = i; break; } } } gameinfo->biosIndex = -1; if (DriverIsBios(ndriver)) gameinfo->biosIndex = ndriver; else if (gameinfo->hasOptionalBIOS) { int parentIndex; if (gameinfo->isClone) parentIndex = gameinfo->parentIndex; else parentIndex = ndriver; while (1) { parentIndex = GetGameNameIndex(drivers[parentIndex]->parent); if (parentIndex == -1) { dprintf("bios for %s is not found", drivers[ndriver]->name); break; } if (DriverIsBios(parentIndex)) { gameinfo->biosIndex = parentIndex; break; } } } /* Free the structure */ global_free(config); gameinfo->usesTrackball = FALSE; gameinfo->usesLightGun = FALSE; if (gamedrv->ipt != NULL) { const input_port_config *port; ioport_list portlist; input_port_list_init(portlist, gamedrv->ipt, NULL, 0, FALSE); for (port = portlist.first(); port != NULL; port = port->next()) { const input_field_config *field; for (field = port->fieldlist; field != NULL; field = field->next) { UINT32 type; type = field->type; if (type == IPT_END) break; if (type == IPT_DIAL || type == IPT_PADDLE || type == IPT_TRACKBALL_X || type == IPT_TRACKBALL_Y || type == IPT_AD_STICK_X || type == IPT_AD_STICK_Y) gameinfo->usesTrackball = TRUE; if (type == IPT_LIGHTGUN_X || type == IPT_LIGHTGUN_Y) gameinfo->usesLightGun = TRUE; if (type == IPT_MOUSE_X || type == IPT_MOUSE_Y) gameinfo->usesMouse = TRUE; } } } } UpdateController(); } return &drivers_info[driver_index]; }
void ui_menu_device_config::populate() { astring string; device_t *dev; string.printf("[This option is%s currently mounted in the running system]\n\n", m_mounted ? "" : " NOT"); string.catprintf("Option: %s\n", m_option->name()); dev = const_cast<machine_config &>(machine().config()).device_add(&machine().config().root_device(), m_option->name(), m_option->devtype(), 0); string.catprintf("Device: %s\n", dev->name()); if (!m_mounted) string.cat("\nIf you select this option, the following items will be enabled:\n"); else string.cat("\nThe selected option enables the following items:\n"); // loop over all CPUs execute_interface_iterator execiter(*dev); if (execiter.count() > 0) { string.cat("* CPU:\n"); tagmap_t<UINT8> exectags; for (device_execute_interface *exec = execiter.first(); exec != NULL; exec = execiter.next()) { if (exectags.add(exec->device().tag(), 1, FALSE) == TMERR_DUPLICATE) continue; // get cpu specific clock that takes internal multiplier/dividers into account int clock = exec->device().clock(); // count how many identical CPUs we have int count = 1; const char *name = exec->device().name(); execute_interface_iterator execinneriter(*dev); for (device_execute_interface *scan = execinneriter.first(); scan != NULL; scan = execinneriter.next()) { if (exec->device().type() == scan->device().type() && strcmp(name, scan->device().name()) == 0 && exec->device().clock() == scan->device().clock()) if (exectags.add(scan->device().tag(), 1, FALSE) != TMERR_DUPLICATE) count++; } // if more than one, prepend a #x in front of the CPU name if (count > 1) string.catprintf(" %d" UTF8_MULTIPLY, count); else string.cat(" "); string.cat(name); // display clock in kHz or MHz if (clock >= 1000000) string.catprintf(" %d.%06d" UTF8_NBSP "MHz\n", clock / 1000000, clock % 1000000); else string.catprintf(" %d.%03d" UTF8_NBSP "kHz\n", clock / 1000, clock % 1000); } } // display screen information screen_device_iterator scriter(*dev); if (scriter.count() > 0) { string.cat("* Video:\n"); for (screen_device *screen = scriter.first(); screen != NULL; screen = scriter.next()) { string.catprintf(" Screen '%s': ", screen->tag()); if (screen->screen_type() == SCREEN_TYPE_VECTOR) string.cat("Vector\n"); else { const rectangle &visarea = screen->visible_area(); string.catprintf("%d " UTF8_MULTIPLY " %d (%s) %f" UTF8_NBSP "Hz\n", visarea.width(), visarea.height(), (machine().system().flags & ORIENTATION_SWAP_XY) ? "V" : "H", ATTOSECONDS_TO_HZ(screen->frame_period().attoseconds)); } } } // loop over all sound chips sound_interface_iterator snditer(*dev); if (snditer.count() > 0) { string.cat("* Sound:\n"); tagmap_t<UINT8> soundtags; for (device_sound_interface *sound = snditer.first(); sound != NULL; sound = snditer.next()) { if (soundtags.add(sound->device().tag(), 1, FALSE) == TMERR_DUPLICATE) continue; // count how many identical sound chips we have int count = 1; sound_interface_iterator sndinneriter(*dev); for (device_sound_interface *scan = sndinneriter.first(); scan != NULL; scan = sndinneriter.next()) { if (sound->device().type() == scan->device().type() && sound->device().clock() == scan->device().clock()) if (soundtags.add(scan->device().tag(), 1, FALSE) != TMERR_DUPLICATE) count++; } // if more than one, prepend a #x in front of the CPU name if (count > 1) string.catprintf(" %d" UTF8_MULTIPLY, count); else string.cat(" "); string.cat(sound->device().name()); // display clock in kHz or MHz int clock = sound->device().clock(); if (clock >= 1000000) string.catprintf(" %d.%06d" UTF8_NBSP "MHz\n", clock / 1000000, clock % 1000000); else if (clock != 0) string.catprintf(" %d.%03d" UTF8_NBSP "kHz\n", clock / 1000, clock % 1000); else string.cat("\n"); } } // scan for BIOS settings int bios = 0; if (dev->rom_region()) { astring bios_str; // first loop through roms in search of default bios (shortname) for (const rom_entry *rom = dev->rom_region(); !ROMENTRY_ISEND(rom); rom++) if (ROMENTRY_ISDEFAULT_BIOS(rom)) bios_str.cpy(ROM_GETNAME(rom)); // then loop again to count bios options and to get the default bios complete name for (const rom_entry *rom = dev->rom_region(); !ROMENTRY_ISEND(rom); rom++) { if (ROMENTRY_ISSYSTEM_BIOS(rom)) { bios++; if (bios_str == ROM_GETNAME(rom)) bios_str.cpy(ROM_GETHASHDATA(rom)); } } if (bios) string.catprintf("* BIOS settings:\n %d options [default: %s]\n", bios, bios_str.cstr()); } int input = 0, input_mj = 0, input_hana = 0, input_gamble = 0, input_analog = 0, input_adjust = 0; int input_keypad = 0, input_keyboard = 0, dips = 0, confs = 0; astring errors, dips_opt, confs_opt; ioport_list portlist; device_iterator iptiter(*dev); for (device_t *iptdev = iptiter.first(); iptdev != NULL; iptdev = iptiter.next()) portlist.append(*iptdev, errors); // check if the device adds inputs to the system for (ioport_port *port = portlist.first(); port != NULL; port = port->next()) for (ioport_field *field = port->first_field(); field != NULL; field = field->next()) { if (field->type() >= IPT_MAHJONG_FIRST && field->type() < IPT_MAHJONG_LAST) input_mj++; else if (field->type() >= IPT_HANAFUDA_FIRST && field->type() < IPT_HANAFUDA_LAST) input_hana++; else if (field->type() >= IPT_GAMBLING_FIRST && field->type() < IPT_GAMBLING_LAST) input_gamble++; else if (field->type() >= IPT_ANALOG_FIRST && field->type() < IPT_ANALOG_LAST) input_analog++; else if (field->type() == IPT_ADJUSTER) input_adjust++; else if (field->type() == IPT_KEYPAD) input_keypad++; else if (field->type() == IPT_KEYBOARD) input_keyboard++; else if (field->type() >= IPT_START1 && field->type() < IPT_UI_FIRST) input++; else if (field->type() == IPT_DIPSWITCH) { dips++; dips_opt.cat(" ").cat(field->name()); for (ioport_setting *setting = field->first_setting(); setting != NULL; setting = setting->next()) { if (setting->value() == field->defvalue()) { dips_opt.catprintf(" [default: %s]\n", setting->name()); break; } } } else if (field->type() == IPT_CONFIG) { confs++; confs_opt.cat(" ").cat(field->name()); for (ioport_setting *setting = field->first_setting(); setting != NULL; setting = setting->next()) { if (setting->value() == field->defvalue()) { confs_opt.catprintf(" [default: %s]\n", setting->name()); break; } } } } if (dips) string.cat("* Dispwitch settings:\n").cat(dips_opt); if (confs) string.cat("* Configuration settings:\n").cat(confs_opt); if (input + input_mj + input_hana + input_gamble + input_analog + input_adjust + input_keypad + input_keyboard) string.cat("* Input device(s):\n"); if (input) string.catprintf(" User inputs [%d inputs]\n", input); if (input_mj) string.catprintf(" Mahjong inputs [%d inputs]\n", input_mj); if (input_hana) string.catprintf(" Hanafuda inputs [%d inputs]\n", input_hana); if (input_gamble) string.catprintf(" Gambling inputs [%d inputs]\n", input_gamble); if (input_analog) string.catprintf(" Analog inputs [%d inputs]\n", input_analog); if (input_adjust) string.catprintf(" Adjuster inputs [%d inputs]\n", input_adjust); if (input_keypad) string.catprintf(" Keypad inputs [%d inputs]\n", input_keypad); if (input_keyboard) string.catprintf(" Keyboard inputs [%d inputs]\n", input_keyboard); image_interface_iterator imgiter(*dev); if (imgiter.count() > 0) { string.cat("* Media Options:\n"); for (const device_image_interface *imagedev = imgiter.first(); imagedev != NULL; imagedev = imgiter.next()) string.catprintf(" %s [tag: %s]\n", imagedev->image_type_name(), imagedev->device().tag()); } slot_interface_iterator slotiter(*dev); if (slotiter.count() > 0) { string.cat("* Slot Options:\n"); for (const device_slot_interface *slot = slotiter.first(); slot != NULL; slot = slotiter.next()) string.catprintf(" %s [default: %s]\n", slot->device().tag(), slot->default_option() ? slot->default_option() : "----"); } if ((execiter.count() + scriter.count() + snditer.count() + imgiter.count() + slotiter.count() + bios + dips + confs + input + input_mj + input_hana + input_gamble + input_analog + input_adjust + input_keypad + input_keyboard) == 0) string.cat("[None]\n"); const_cast<machine_config &>(machine().config()).device_remove(&machine().config().root_device(), m_option->name()); item_append(string, NULL, MENU_FLAG_MULTILINE, NULL); }
static struct DriversInfo* GetDriversInfo(int driver_index) { if (drivers_info == NULL) { int ndriver; drivers_info = (DriversInfo*)malloc(sizeof(struct DriversInfo) * driver_list_get_count(drivers)); for (ndriver = 0; ndriver < driver_list_get_count(drivers); ndriver++) { const game_driver *gamedrv = drivers[ndriver]; struct DriversInfo *gameinfo = &drivers_info[ndriver]; const rom_entry *region, *rom; windows_options pCurrentOpts; load_options(pCurrentOpts, OPTIONS_GLOBAL, driver_index); machine_config config(*gamedrv,pCurrentOpts); const rom_source *source; int num_speakers; gameinfo->isClone = (GetParentRomSetIndex(gamedrv) != -1); gameinfo->isBroken = ((gamedrv->flags & GAME_NOT_WORKING) != 0); gameinfo->supportsSaveState = ((gamedrv->flags & GAME_SUPPORTS_SAVE) != 0); gameinfo->isHarddisk = FALSE; gameinfo->isVertical = (gamedrv->flags & ORIENTATION_SWAP_XY) ? TRUE : FALSE; for (source = rom_first_source(config); source != NULL; source = rom_next_source(*source)) { for (region = rom_first_region(*source); region; region = rom_next_region(region)) { if (ROMREGION_ISDISKDATA(region)) gameinfo->isHarddisk = TRUE; } } gameinfo->hasOptionalBIOS = FALSE; if (gamedrv->rom != NULL) { for (rom = gamedrv->rom; !ROMENTRY_ISEND(rom); rom++) { if (ROMENTRY_ISSYSTEM_BIOS(rom)) { gameinfo->hasOptionalBIOS = TRUE; break; } } } num_speakers = numberOfSpeakers(&config); gameinfo->isStereo = (num_speakers > 1); gameinfo->screenCount = numberOfScreens(&config); gameinfo->isVector = isDriverVector(&config); // ((drv.video_attributes & VIDEO_TYPE_VECTOR) != 0); gameinfo->usesRoms = FALSE; for (source = rom_first_source(config); source != NULL; source = rom_next_source(*source)) { for (region = rom_first_region(*source); region; region = rom_next_region(region)) { for (rom = rom_first_file(region); rom; rom = rom_next_file(rom)) { gameinfo->usesRoms = TRUE; break; } } } gameinfo->usesSamples = FALSE; { const device_config_sound_interface *sound = NULL; const char * const * samplenames = NULL; for (bool gotone = config.m_devicelist.first(sound); gotone; gotone = sound->next(sound)) { if (sound->devconfig().type() == SAMPLES) { const samples_interface *intf = (const samples_interface *)sound->devconfig().static_config(); samplenames = intf->samplenames; if (samplenames != 0 && samplenames[0] != 0) { gameinfo->usesSamples = TRUE; break; } } } } gameinfo->usesTrackball = FALSE; gameinfo->usesLightGun = FALSE; if (gamedrv->ipt != NULL) { const input_port_config *port; ioport_list portlist; input_port_list_init(portlist, gamedrv->ipt, NULL, 0, FALSE, NULL); for (device_config *cfg = config.m_devicelist.first(); cfg != NULL; cfg = cfg->next()) { if (cfg->input_ports()!=NULL) { input_port_list_init(portlist, cfg->input_ports(), NULL, 0, FALSE, cfg); } } for (port = portlist.first(); port != NULL; port = port->next()) { const input_field_config *field; for (field = port->fieldlist; field != NULL; field = field->next) { UINT32 type; type = field->type; if (type == IPT_END) break; if (type == IPT_DIAL || type == IPT_PADDLE || type == IPT_TRACKBALL_X || type == IPT_TRACKBALL_Y || type == IPT_AD_STICK_X || type == IPT_AD_STICK_Y) gameinfo->usesTrackball = TRUE; if (type == IPT_LIGHTGUN_X || type == IPT_LIGHTGUN_Y) gameinfo->usesLightGun = TRUE; if (type == IPT_MOUSE_X || type == IPT_MOUSE_Y) gameinfo->usesMouse = TRUE; } } } } } return &drivers_info[driver_index]; }
static void InitDriversInfo(void) { int ndriver; int num_speakers = 0; int total = driver_list::total(); const game_driver *gamedrv = NULL; struct DriversInfo *gameinfo = NULL; const rom_entry *region, *rom; for (ndriver = 0; ndriver < total; ndriver++) { gamedrv = &driver_list::driver(ndriver); gameinfo = &drivers_info[ndriver]; machine_config config(*gamedrv, MameUIGlobal()); gameinfo->isClone = (GetParentRomSetIndex(gamedrv) != -1); gameinfo->isBroken = (gamedrv->flags & MACHINE_NOT_WORKING) ? true : false; gameinfo->isHarddisk = FALSE; gameinfo->isVertical = (gamedrv->flags & ORIENTATION_SWAP_XY) ? TRUE : FALSE; device_iterator deviter(config.root_device()); for (device_t *device = deviter.first(); device; device = deviter.next()) for (region = rom_first_region(*device); region; region = rom_next_region(region)) if (ROMREGION_ISDISKDATA(region)) gameinfo->isHarddisk = TRUE; gameinfo->hasOptionalBIOS = FALSE; if (gamedrv->rom) for (rom = gamedrv->rom; !ROMENTRY_ISEND(rom); rom++) if (ROMENTRY_ISSYSTEM_BIOS(rom)) gameinfo->hasOptionalBIOS = TRUE; num_speakers = numberOfSpeakers(&config); gameinfo->isStereo = (num_speakers > 1); gameinfo->screenCount = numberOfScreens(&config); gameinfo->isVector = isDriverVector(&config); gameinfo->usesRoms = FALSE; for (device_t *device = deviter.first(); device; device = deviter.next()) for (region = rom_first_region(*device); region; region = rom_next_region(region)) for (rom = rom_first_file(region); rom; rom = rom_next_file(rom)) gameinfo->usesRoms = TRUE; gameinfo->usesSamples = FALSE; samples_device_iterator iter(config.root_device()); if (iter.first()) gameinfo->usesSamples = TRUE; gameinfo->usesTrackball = FALSE; gameinfo->usesLightGun = FALSE; if (gamedrv->ipt) { ioport_port *port; ioport_list portlist; std::string errors; device_iterator iter(config.root_device()); for (device_t *cfg = iter.first(); cfg; cfg = iter.next()) if (cfg->input_ports()) portlist.append(*cfg, errors); for (port = portlist.first(); port; port = port->next()) { ioport_field *field; for (field = port->first_field(); field; field = field->next()) { UINT32 type; type = field->type(); if (type == IPT_END) break; if (type == IPT_DIAL || type == IPT_PADDLE || type == IPT_TRACKBALL_X || type == IPT_TRACKBALL_Y || type == IPT_AD_STICK_X || type == IPT_AD_STICK_Y) gameinfo->usesTrackball = TRUE; if (type == IPT_LIGHTGUN_X || type == IPT_LIGHTGUN_Y) gameinfo->usesLightGun = TRUE; if (type == IPT_MOUSE_X || type == IPT_MOUSE_Y) gameinfo->usesMouse = TRUE; } } } } SetDriversInfo(); }
bool device_memory_interface::interface_validity_check(emu_options &options, const game_driver &driver) const { bool detected_overlap = DETECT_OVERLAPPING_MEMORY ? false : true; bool error = false; // loop over all address spaces for (address_spacenum spacenum = AS_0; spacenum < ADDRESS_SPACES; spacenum++) { const address_space_config *spaceconfig = space_config(spacenum); if (spaceconfig != NULL) { int datawidth = spaceconfig->m_databus_width; int alignunit = datawidth / 8; // construct the maps ::address_map *map = global_alloc(::address_map(device(), spacenum)); // if this is an empty map, just skip it if (map->m_entrylist.first() == NULL) { global_free(map); continue; } // validate the global map parameters if (map->m_spacenum != spacenum) { mame_printf_error("%s: %s device '%s' space %d has address space %d handlers!\n", driver.source_file, driver.name, device().tag(), spacenum, map->m_spacenum); error = true; } if (map->m_databits != datawidth) { mame_printf_error("%s: %s device '%s' uses wrong memory handlers for %s space! (width = %d, memory = %08x)\n", driver.source_file, driver.name, device().tag(), spaceconfig->m_name, datawidth, map->m_databits); error = true; } // loop over entries and look for errors for (address_map_entry *entry = map->m_entrylist.first(); entry != NULL; entry = entry->next()) { UINT32 bytestart = spaceconfig->addr2byte(entry->m_addrstart); UINT32 byteend = spaceconfig->addr2byte_end(entry->m_addrend); // look for overlapping entries if (!detected_overlap) { address_map_entry *scan; for (scan = map->m_entrylist.first(); scan != entry; scan = scan->next()) if (entry->m_addrstart <= scan->m_addrend && entry->m_addrend >= scan->m_addrstart && ((entry->m_read.m_type != AMH_NONE && scan->m_read.m_type != AMH_NONE) || (entry->m_write.m_type != AMH_NONE && scan->m_write.m_type != AMH_NONE))) { mame_printf_warning("%s: %s '%s' %s space has overlapping memory (%X-%X,%d,%d) vs (%X-%X,%d,%d)\n", driver.source_file, driver.name, device().tag(), spaceconfig->m_name, entry->m_addrstart, entry->m_addrend, entry->m_read.m_type, entry->m_write.m_type, scan->m_addrstart, scan->m_addrend, scan->m_read.m_type, scan->m_write.m_type); detected_overlap = true; break; } } // look for inverted start/end pairs if (byteend < bytestart) { mame_printf_error("%s: %s wrong %s memory read handler start = %08x > end = %08x\n", driver.source_file, driver.name, spaceconfig->m_name, entry->m_addrstart, entry->m_addrend); error = true; } // look for misaligned entries if ((bytestart & (alignunit - 1)) != 0 || (byteend & (alignunit - 1)) != (alignunit - 1)) { mame_printf_error("%s: %s wrong %s memory read handler start = %08x, end = %08x ALIGN = %d\n", driver.source_file, driver.name, spaceconfig->m_name, entry->m_addrstart, entry->m_addrend, alignunit); error = true; } // if this is a program space, auto-assign implicit ROM entries if (entry->m_read.m_type == AMH_ROM && entry->m_region == NULL) { entry->m_region = device().tag(); entry->m_rgnoffs = entry->m_addrstart; } // if this entry references a memory region, validate it if (entry->m_region != NULL && entry->m_share == 0) { // look for the region bool found = false; for (const rom_source *source = rom_first_source(device().mconfig()); source != NULL && !found; source = rom_next_source(*source)) for (const rom_entry *romp = rom_first_region(*source); !ROMENTRY_ISEND(romp) && !found; romp++) { const char *regiontag_c = ROMREGION_GETTAG(romp); if (regiontag_c != NULL) { astring fulltag; astring regiontag; // a leading : on a region name indicates an absolute region, so fix up accordingly if (entry->m_region[0] == ':') { regiontag = &entry->m_region[1]; } else { if (strchr(entry->m_region,':')) { regiontag = entry->m_region; } else { device().siblingtag(regiontag, entry->m_region); } } rom_region_name(fulltag, &driver, source, romp); if (fulltag.cmp(regiontag) == 0) { // verify the address range is within the region's bounds offs_t length = ROMREGION_GETLENGTH(romp); if (entry->m_rgnoffs + (byteend - bytestart + 1) > length) { mame_printf_error("%s: %s device '%s' %s space memory map entry %X-%X extends beyond region '%s' size (%X)\n", driver.source_file, driver.name, device().tag(), spaceconfig->m_name, entry->m_addrstart, entry->m_addrend, entry->m_region, length); error = true; } found = true; } } } // error if not found if (!found) { mame_printf_error("%s: %s device '%s' %s space memory map entry %X-%X references non-existant region '%s'\n", driver.source_file, driver.name, device().tag(), spaceconfig->m_name, entry->m_addrstart, entry->m_addrend, entry->m_region); error = true; } } // make sure all devices exist if ((entry->m_read.m_type == AMH_LEGACY_DEVICE_HANDLER && entry->m_read.m_tag != NULL && device().mconfig().devicelist().find(entry->m_read.m_tag) == NULL) || (entry->m_write.m_type == AMH_LEGACY_DEVICE_HANDLER && entry->m_write.m_tag != NULL && device().mconfig().devicelist().find(entry->m_write.m_tag) == NULL)) { mame_printf_error("%s: %s device '%s' %s space memory map entry references nonexistant device '%s'\n", driver.source_file, driver.name, device().tag(), spaceconfig->m_name, entry->m_write.m_tag); error = true; } // make sure ports exist // if ((entry->m_read.m_type == AMH_PORT && entry->m_read.m_tag != NULL && portlist.find(entry->m_read.m_tag) == NULL) || // (entry->m_write.m_type == AMH_PORT && entry->m_write.m_tag != NULL && portlist.find(entry->m_write.m_tag) == NULL)) // { // mame_printf_error("%s: %s device '%s' %s space memory map entry references nonexistant port tag '%s'\n", driver.source_file, driver.name, device().tag(), spaceconfig->m_name, entry->m_read.tag); // error = true; // } // validate bank and share tags if (entry->m_read.m_type == AMH_BANK && !validate_tag(driver, "bank", entry->m_read.m_tag)) error = true ; if (entry->m_write.m_type == AMH_BANK && !validate_tag(driver, "bank", entry->m_write.m_tag)) error = true; if (entry->m_share != NULL && !validate_tag(driver, "share", entry->m_share)) error = true; } // release the address map global_free(map); } } return error; }