src/emu/validity.c
| r9023 | r9024 | |
| 86 | 86 | meets the general requirements |
| 87 | 87 | -------------------------------------------------*/ |
| 88 | 88 | |
| 89 | | bool validate_tag(const game_driver *driver, const char *object, const char *tag) |
| 89 | bool validate_tag(const game_driver &driver, const char *object, const char *tag) |
| 90 | 90 | { |
| 91 | 91 | const char *validchars = "abcdefghijklmnopqrstuvwxyz0123456789_.:"; |
| 92 | 92 | const char *begin = strrchr(tag, ':'); |
| r9023 | r9024 | |
| 100 | 100 | strcmp(tag, "left") == 0 || |
| 101 | 101 | strcmp(tag, "right") == 0) |
| 102 | 102 | { |
| 103 | | mame_printf_error("%s: %s has invalid generic tag '%s'\n", driver->source_file, driver->name, tag); |
| 103 | mame_printf_error("%s: %s has invalid generic tag '%s'\n", driver.source_file, driver.name, tag); |
| 104 | 104 | error = true; |
| 105 | 105 | } |
| 106 | 106 | |
| r9023 | r9024 | |
| 108 | 108 | { |
| 109 | 109 | if (*p != tolower((UINT8)*p)) |
| 110 | 110 | { |
| 111 | | mame_printf_error("%s: %s has %s with tag '%s' containing upper-case characters\n", driver->source_file, driver->name, object, tag); |
| 111 | mame_printf_error("%s: %s has %s with tag '%s' containing upper-case characters\n", driver.source_file, driver.name, object, tag); |
| 112 | 112 | error = true; |
| 113 | 113 | break; |
| 114 | 114 | } |
| 115 | 115 | if (*p == ' ') |
| 116 | 116 | { |
| 117 | | mame_printf_error("%s: %s has %s with tag '%s' containing spaces\n", driver->source_file, driver->name, object, tag); |
| 117 | mame_printf_error("%s: %s has %s with tag '%s' containing spaces\n", driver.source_file, driver.name, object, tag); |
| 118 | 118 | error = true; |
| 119 | 119 | break; |
| 120 | 120 | } |
| 121 | 121 | if (strchr(validchars, *p) == NULL) |
| 122 | 122 | { |
| 123 | | mame_printf_error("%s: %s has %s with tag '%s' containing invalid character '%c'\n", driver->source_file, driver->name, object, tag, *p); |
| 123 | mame_printf_error("%s: %s has %s with tag '%s' containing invalid character '%c'\n", driver.source_file, driver.name, object, tag, *p); |
| 124 | 124 | error = true; |
| 125 | 125 | break; |
| 126 | 126 | } |
| r9023 | r9024 | |
| 133 | 133 | |
| 134 | 134 | if (strlen(begin) == 0) |
| 135 | 135 | { |
| 136 | | mame_printf_error("%s: %s has %s with 0-length tag\n", driver->source_file, driver->name, object); |
| 136 | mame_printf_error("%s: %s has %s with 0-length tag\n", driver.source_file, driver.name, object); |
| 137 | 137 | error = true; |
| 138 | 138 | } |
| 139 | 139 | if (strlen(begin) < MIN_TAG_LENGTH) |
| 140 | 140 | { |
| 141 | | mame_printf_error("%s: %s has %s with tag '%s' < %d characters\n", driver->source_file, driver->name, object, tag, MIN_TAG_LENGTH); |
| 141 | mame_printf_error("%s: %s has %s with tag '%s' < %d characters\n", driver.source_file, driver.name, object, tag, MIN_TAG_LENGTH); |
| 142 | 142 | error = true; |
| 143 | 143 | } |
| 144 | 144 | if (strlen(begin) > MAX_TAG_LENGTH) |
| 145 | 145 | { |
| 146 | | mame_printf_error("%s: %s has %s with tag '%s' > %d characters\n", driver->source_file, driver->name, object, tag, MAX_TAG_LENGTH); |
| 146 | mame_printf_error("%s: %s has %s with tag '%s' > %d characters\n", driver.source_file, driver.name, object, tag, MAX_TAG_LENGTH); |
| 147 | 147 | error = true; |
| 148 | 148 | } |
| 149 | 149 | |
| r9023 | r9024 | |
| 314 | 314 | information |
| 315 | 315 | -------------------------------------------------*/ |
| 316 | 316 | |
| 317 | | static bool validate_driver(int drivnum, const machine_config *config, game_driver_map &names, game_driver_map &descriptions) |
| 317 | static bool validate_driver(const machine_config &config, game_driver_map &names, game_driver_map &descriptions) |
| 318 | 318 | { |
| 319 | | const game_driver *driver = drivers[drivnum]; |
| 319 | const game_driver &driver = config.gamedrv(); |
| 320 | 320 | const game_driver *clone_of; |
| 321 | 321 | const char *compatible_with; |
| 322 | 322 | const game_driver *other_drv; |
| r9023 | r9024 | |
| 326 | 326 | enum { NAME_LEN_PARENT = 8, NAME_LEN_CLONE = 16 }; |
| 327 | 327 | |
| 328 | 328 | /* check for duplicate names */ |
| 329 | | if (names.add(driver->name, driver, FALSE) == TMERR_DUPLICATE) |
| 329 | if (names.add(driver.name, &driver, FALSE) == TMERR_DUPLICATE) |
| 330 | 330 | { |
| 331 | | const game_driver *match = names.find(driver->name); |
| 332 | | mame_printf_error("%s: %s is a duplicate name (%s, %s)\n", driver->source_file, driver->name, match->source_file, match->name); |
| 331 | const game_driver *match = names.find(driver.name); |
| 332 | mame_printf_error("%s: %s is a duplicate name (%s, %s)\n", driver.source_file, driver.name, match->source_file, match->name); |
| 333 | 333 | error = true; |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | /* check for duplicate descriptions */ |
| 337 | | if (descriptions.add(driver->description, driver, FALSE) == TMERR_DUPLICATE) |
| 337 | if (descriptions.add(driver.description, &driver, FALSE) == TMERR_DUPLICATE) |
| 338 | 338 | { |
| 339 | | const game_driver *match = descriptions.find(driver->description); |
| 340 | | mame_printf_error("%s: %s is a duplicate description (%s, %s)\n", driver->source_file, driver->description, match->source_file, match->description); |
| 339 | const game_driver *match = descriptions.find(driver.description); |
| 340 | mame_printf_error("%s: %s is a duplicate description (%s, %s)\n", driver.source_file, driver.description, match->source_file, match->description); |
| 341 | 341 | error = true; |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | /* determine the clone */ |
| 345 | | is_clone = (strcmp(driver->parent, "0") != 0); |
| 346 | | clone_of = driver_get_clone(driver); |
| 345 | is_clone = (strcmp(driver.parent, "0") != 0); |
| 346 | clone_of = driver_get_clone(&driver); |
| 347 | 347 | if (clone_of && (clone_of->flags & GAME_IS_BIOS_ROOT)) |
| 348 | 348 | is_clone = false; |
| 349 | 349 | |
| r9023 | r9024 | |
| 351 | 351 | /* (100 is arbitrary, but tries to avoid tiny.mak dependencies) */ |
| 352 | 352 | if (driver_list_get_count(drivers) > 100 && !clone_of && is_clone) |
| 353 | 353 | { |
| 354 | | mame_printf_error("%s: %s is a non-existant clone\n", driver->source_file, driver->parent); |
| 354 | mame_printf_error("%s: %s is a non-existant clone\n", driver.source_file, driver.parent); |
| 355 | 355 | error = true; |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | /* look for recursive cloning */ |
| 359 | | if (clone_of == driver) |
| 359 | if (clone_of == &driver) |
| 360 | 360 | { |
| 361 | | mame_printf_error("%s: %s is set as a clone of itself\n", driver->source_file, driver->name); |
| 361 | mame_printf_error("%s: %s is set as a clone of itself\n", driver.source_file, driver.name); |
| 362 | 362 | error = true; |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | /* look for clones that are too deep */ |
| 366 | 366 | if (clone_of != NULL && (clone_of = driver_get_clone(clone_of)) != NULL && (clone_of->flags & GAME_IS_BIOS_ROOT) == 0) |
| 367 | 367 | { |
| 368 | | mame_printf_error("%s: %s is a clone of a clone\n", driver->source_file, driver->name); |
| 368 | mame_printf_error("%s: %s is a clone of a clone\n", driver.source_file, driver.name); |
| 369 | 369 | error = true; |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | /* make sure the driver name is 8 chars or less */ |
| 373 | | if ((is_clone && strlen(driver->name) > NAME_LEN_CLONE) || ((!is_clone) && strlen(driver->name) > NAME_LEN_PARENT)) |
| 373 | if ((is_clone && strlen(driver.name) > NAME_LEN_CLONE) || ((!is_clone) && strlen(driver.name) > NAME_LEN_PARENT)) |
| 374 | 374 | { |
| 375 | | mame_printf_error("%s: %s %s driver name must be %d characters or less\n", driver->source_file, driver->name, |
| 375 | mame_printf_error("%s: %s %s driver name must be %d characters or less\n", driver.source_file, driver.name, |
| 376 | 376 | is_clone ? "clone" : "parent", is_clone ? NAME_LEN_CLONE : NAME_LEN_PARENT); |
| 377 | 377 | error = true; |
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | /* make sure the year is only digits, '?' or '+' */ |
| 381 | | for (s = driver->year; *s; s++) |
| 381 | for (s = driver.year; *s; s++) |
| 382 | 382 | if (!isdigit((UINT8)*s) && *s != '?' && *s != '+') |
| 383 | 383 | { |
| 384 | | mame_printf_error("%s: %s has an invalid year '%s'\n", driver->source_file, driver->name, driver->year); |
| 384 | mame_printf_error("%s: %s has an invalid year '%s'\n", driver.source_file, driver.name, driver.year); |
| 385 | 385 | error = true; |
| 386 | 386 | break; |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | /* normalize driver->compatible_with */ |
| 390 | | compatible_with = driver->compatible_with; |
| 390 | compatible_with = driver.compatible_with; |
| 391 | 391 | if ((compatible_with != NULL) && !strcmp(compatible_with, "0")) |
| 392 | 392 | compatible_with = NULL; |
| 393 | 393 | |
| 394 | 394 | /* check for this driver being compatible with a non-existant driver */ |
| 395 | | if ((compatible_with != NULL) && (driver_get_name(driver->compatible_with) == NULL)) |
| 395 | if ((compatible_with != NULL) && (driver_get_name(driver.compatible_with) == NULL)) |
| 396 | 396 | { |
| 397 | | mame_printf_error("%s: is compatible with %s, which is not in drivers[]\n", driver->name, driver->compatible_with); |
| 397 | mame_printf_error("%s: is compatible with %s, which is not in drivers[]\n", driver.name, driver.compatible_with); |
| 398 | 398 | error = true; |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | /* check for clone_of and compatible_with being specified at the same time */ |
| 402 | | if ((driver_get_clone(driver) != NULL) && (compatible_with != NULL)) |
| 402 | if ((driver_get_clone(&driver) != NULL) && (compatible_with != NULL)) |
| 403 | 403 | { |
| 404 | | mame_printf_error("%s: both compatible_with and clone_of are specified\n", driver->name); |
| 404 | mame_printf_error("%s: both compatible_with and clone_of are specified\n", driver.name); |
| 405 | 405 | error = true; |
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | /* find any recursive dependencies on the current driver */ |
| 409 | | for (other_drv = driver_get_compatible(driver); other_drv != NULL; other_drv = driver_get_compatible(other_drv)) |
| 409 | for (other_drv = driver_get_compatible(&driver); other_drv != NULL; other_drv = driver_get_compatible(other_drv)) |
| 410 | 410 | { |
| 411 | | if (driver == other_drv) |
| 411 | if (&driver == other_drv) |
| 412 | 412 | { |
| 413 | | mame_printf_error("%s: recursive compatibility\n", driver->name); |
| 413 | mame_printf_error("%s: recursive compatibility\n", driver.name); |
| 414 | 414 | error = true; |
| 415 | 415 | break; |
| 416 | 416 | } |
| r9023 | r9024 | |
| 418 | 418 | |
| 419 | 419 | /* make sure sound-less drivers are flagged */ |
| 420 | 420 | const device_config_sound_interface *sound; |
| 421 | | if ((driver->flags & GAME_IS_BIOS_ROOT) == 0 && !config->m_devicelist.first(sound) && (driver->flags & GAME_NO_SOUND) == 0 && (driver->flags & GAME_NO_SOUND_HW) == 0) |
| 421 | if ((driver.flags & GAME_IS_BIOS_ROOT) == 0 && !config.m_devicelist.first(sound) && (driver.flags & GAME_NO_SOUND) == 0 && (driver.flags & GAME_NO_SOUND_HW) == 0) |
| 422 | 422 | { |
| 423 | | mame_printf_error("%s: %s missing GAME_NO_SOUND flag\n", driver->source_file, driver->name); |
| 423 | mame_printf_error("%s: %s missing GAME_NO_SOUND flag\n", driver.source_file, driver.name); |
| 424 | 424 | error = true; |
| 425 | 425 | } |
| 426 | 426 | |
| r9023 | r9024 | |
| 432 | 432 | validate_roms - validate ROM definitions |
| 433 | 433 | -------------------------------------------------*/ |
| 434 | 434 | |
| 435 | | static bool validate_roms(int drivnum, const machine_config *config, region_array *rgninfo, game_driver_map &roms) |
| 435 | static bool validate_roms(const machine_config &config, region_array *rgninfo, game_driver_map &roms) |
| 436 | 436 | { |
| 437 | | const game_driver *driver = drivers[drivnum]; |
| 437 | const game_driver &driver = config.gamedrv(); |
| 438 | 438 | int bios_flags = 0, last_bios = 0; |
| 439 | 439 | const char *last_rgnname = "???"; |
| 440 | 440 | const char *last_name = "???"; |
| r9023 | r9024 | |
| 442 | 442 | int items_since_region = 1; |
| 443 | 443 | bool error = false; |
| 444 | 444 | |
| 445 | | /* check for duplicate ROM entries */ |
| 446 | | /* |
| 447 | | if (driver->rom != NULL && (driver->flags & GAME_NO_STANDALONE) == 0) |
| 448 | | { |
| 449 | | char romaddr[20]; |
| 450 | | sprintf(romaddr, "%p", driver->rom); |
| 451 | | if (roms.add(romaddr, driver, FALSE) == TMERR_DUPLICATE) |
| 452 | | { |
| 453 | | const game_driver *match = roms.find(romaddr); |
| 454 | | mame_printf_error("%s: %s uses the same ROM set as (%s, %s)\n", driver->source_file, driver->description, match->source_file, match->name); |
| 455 | | error = true; |
| 456 | | } |
| 457 | | } |
| 458 | | */ |
| 459 | 445 | /* iterate, starting with the driver's ROMs and continuing with device ROMs */ |
| 460 | | for (const rom_source *source = rom_first_source(driver, config); source != NULL; source = rom_next_source(driver, config, source)) |
| 446 | for (const rom_source *source = rom_first_source(config); source != NULL; source = rom_next_source(*source)) |
| 461 | 447 | { |
| 462 | 448 | /* scan the ROM entries */ |
| 463 | | for (const rom_entry *romp = rom_first_region(driver, source); !ROMENTRY_ISEND(romp); romp++) |
| 449 | for (const rom_entry *romp = rom_first_region(*source); !ROMENTRY_ISEND(romp); romp++) |
| 464 | 450 | { |
| 465 | 451 | /* if this is a region, make sure it's valid, and record the length */ |
| 466 | 452 | if (ROMENTRY_ISREGION(romp)) |
| r9023 | r9024 | |
| 469 | 455 | |
| 470 | 456 | /* if we haven't seen any items since the last region, print a warning */ |
| 471 | 457 | if (items_since_region == 0) |
| 472 | | mame_printf_warning("%s: %s has empty ROM region '%s' (warning)\n", driver->source_file, driver->name, last_rgnname); |
| 458 | mame_printf_warning("%s: %s has empty ROM region '%s' (warning)\n", driver.source_file, driver.name, last_rgnname); |
| 473 | 459 | items_since_region = (ROMREGION_ISERASE(romp) || ROMREGION_ISDISKDATA(romp)) ? 1 : 0; |
| 474 | 460 | currgn = NULL; |
| 475 | 461 | last_rgnname = regiontag; |
| r9023 | r9024 | |
| 477 | 463 | /* check for a valid tag */ |
| 478 | 464 | if (regiontag == NULL) |
| 479 | 465 | { |
| 480 | | mame_printf_error("%s: %s has NULL ROM_REGION tag\n", driver->source_file, driver->name); |
| 466 | mame_printf_error("%s: %s has NULL ROM_REGION tag\n", driver.source_file, driver.name); |
| 481 | 467 | error = true; |
| 482 | 468 | } |
| 483 | 469 | |
| 484 | 470 | /* load by name entries must be 8 characters or less */ |
| 485 | 471 | else if (ROMREGION_ISLOADBYNAME(romp) && strlen(regiontag) > 8) |
| 486 | 472 | { |
| 487 | | mame_printf_error("%s: %s has load-by-name region '%s' with name >8 characters\n", driver->source_file, driver->name, regiontag); |
| 473 | mame_printf_error("%s: %s has load-by-name region '%s' with name >8 characters\n", driver.source_file, driver.name, regiontag); |
| 488 | 474 | error = true; |
| 489 | 475 | } |
| 490 | 476 | |
| r9023 | r9024 | |
| 494 | 480 | astring fulltag; |
| 495 | 481 | |
| 496 | 482 | /* iterate over all regions found so far */ |
| 497 | | rom_region_name(fulltag, driver, source, romp); |
| 483 | rom_region_name(fulltag, &driver, source, romp); |
| 498 | 484 | for (int rgnnum = 0; rgnnum < ARRAY_LENGTH(rgninfo->entries); rgnnum++) |
| 499 | 485 | { |
| 500 | 486 | /* stop when we hit an empty */ |
| r9023 | r9024 | |
| 509 | 495 | /* fail if we hit a duplicate */ |
| 510 | 496 | if (fulltag == rgninfo->entries[rgnnum].tag) |
| 511 | 497 | { |
| 512 | | mame_printf_error("%s: %s has duplicate ROM_REGION tag '%s'\n", driver->source_file, driver->name, fulltag.cstr()); |
| 498 | mame_printf_error("%s: %s has duplicate ROM_REGION tag '%s'\n", driver.source_file, driver.name, fulltag.cstr()); |
| 513 | 499 | error = true; |
| 514 | 500 | break; |
| 515 | 501 | } |
| r9023 | r9024 | |
| 528 | 514 | if (last_bios+1 != bios_flags) |
| 529 | 515 | { |
| 530 | 516 | const char *name = ROM_GETNAME(romp); |
| 531 | | mame_printf_error("%s: %s has non-sequential bios %s\n", driver->source_file, driver->name, name); |
| 517 | mame_printf_error("%s: %s has non-sequential bios %s\n", driver.source_file, driver.name, name); |
| 532 | 518 | error = true; |
| 533 | 519 | } |
| 534 | 520 | last_bios = bios_flags; |
| r9023 | r9024 | |
| 549 | 535 | for (s = last_name; *s; s++) |
| 550 | 536 | if (tolower((UINT8)*s) != *s) |
| 551 | 537 | { |
| 552 | | mame_printf_error("%s: %s has upper case ROM name %s\n", driver->source_file, driver->name, last_name); |
| 538 | mame_printf_error("%s: %s has upper case ROM name %s\n", driver.source_file, driver.name, last_name); |
| 553 | 539 | error = true; |
| 554 | 540 | break; |
| 555 | 541 | } |
| r9023 | r9024 | |
| 558 | 544 | hash = ROM_GETHASHDATA(romp); |
| 559 | 545 | if (!hash_verify_string(hash)) |
| 560 | 546 | { |
| 561 | | mame_printf_error("%s: rom '%s' has an invalid hash string '%s'\n", driver->name, last_name, hash); |
| 547 | mame_printf_error("%s: rom '%s' has an invalid hash string '%s'\n", driver.name, last_name, hash); |
| 562 | 548 | error = true; |
| 563 | 549 | } |
| 564 | 550 | } |
| r9023 | r9024 | |
| 574 | 560 | |
| 575 | 561 | if (ROM_GETOFFSET(romp) + ROM_GETLENGTH(romp) > currgn->length) |
| 576 | 562 | { |
| 577 | | mame_printf_error("%s: %s has ROM %s extending past the defined memory region\n", driver->source_file, driver->name, last_name); |
| 563 | mame_printf_error("%s: %s has ROM %s extending past the defined memory region\n", driver.source_file, driver.name, last_name); |
| 578 | 564 | error = true; |
| 579 | 565 | } |
| 580 | 566 | } |
| r9023 | r9024 | |
| 582 | 568 | |
| 583 | 569 | /* final check for empty regions */ |
| 584 | 570 | if (items_since_region == 0) |
| 585 | | mame_printf_warning("%s: %s has empty ROM region (warning)\n", driver->source_file, driver->name); |
| 571 | mame_printf_warning("%s: %s has empty ROM region (warning)\n", driver.source_file, driver.name); |
| 586 | 572 | } |
| 587 | 573 | |
| 588 | 574 | return error; |
| r9023 | r9024 | |
| 594 | 580 | configurations |
| 595 | 581 | -------------------------------------------------*/ |
| 596 | 582 | |
| 597 | | static bool validate_display(int drivnum, const machine_config *config) |
| 583 | static bool validate_display(const machine_config &config) |
| 598 | 584 | { |
| 599 | | const game_driver *driver = drivers[drivnum]; |
| 585 | const game_driver &driver = config.gamedrv(); |
| 600 | 586 | bool palette_modes = false; |
| 601 | 587 | bool error = false; |
| 602 | 588 | |
| 603 | | for (const screen_device_config *scrconfig = screen_first(*config); scrconfig != NULL; scrconfig = screen_next(scrconfig)) |
| 589 | for (const screen_device_config *scrconfig = screen_first(config); scrconfig != NULL; scrconfig = screen_next(scrconfig)) |
| 604 | 590 | if (scrconfig->format() == BITMAP_FORMAT_INDEXED16) |
| 605 | 591 | palette_modes = true; |
| 606 | 592 | |
| 607 | 593 | /* check for empty palette */ |
| 608 | | if (palette_modes && config->m_total_colors == 0) |
| 594 | if (palette_modes && config.m_total_colors == 0) |
| 609 | 595 | { |
| 610 | | mame_printf_error("%s: %s has zero palette entries\n", driver->source_file, driver->name); |
| 596 | mame_printf_error("%s: %s has zero palette entries\n", driver.source_file, driver.name); |
| 611 | 597 | error = true; |
| 612 | 598 | } |
| 613 | 599 | |
| r9023 | r9024 | |
| 620 | 606 | configuration |
| 621 | 607 | -------------------------------------------------*/ |
| 622 | 608 | |
| 623 | | static bool validate_gfx(int drivnum, const machine_config *config, region_array *rgninfo) |
| 609 | static bool validate_gfx(const machine_config &config, region_array *rgninfo) |
| 624 | 610 | { |
| 625 | | const game_driver *driver = drivers[drivnum]; |
| 611 | const game_driver &driver = config.gamedrv(); |
| 626 | 612 | bool error = false; |
| 627 | 613 | int gfxnum; |
| 628 | 614 | |
| 629 | 615 | /* bail if no gfx */ |
| 630 | | if (!config->m_gfxdecodeinfo) |
| 616 | if (!config.m_gfxdecodeinfo) |
| 631 | 617 | return false; |
| 632 | 618 | |
| 633 | 619 | /* iterate over graphics decoding entries */ |
| 634 | | for (gfxnum = 0; gfxnum < MAX_GFX_ELEMENTS && config->m_gfxdecodeinfo[gfxnum].gfxlayout != NULL; gfxnum++) |
| 620 | for (gfxnum = 0; gfxnum < MAX_GFX_ELEMENTS && config.m_gfxdecodeinfo[gfxnum].gfxlayout != NULL; gfxnum++) |
| 635 | 621 | { |
| 636 | | const gfx_decode_entry *gfx = &config->m_gfxdecodeinfo[gfxnum]; |
| 622 | const gfx_decode_entry *gfx = &config.m_gfxdecodeinfo[gfxnum]; |
| 637 | 623 | const char *region = gfx->memory_region; |
| 638 | | int xscale = (config->m_gfxdecodeinfo[gfxnum].xscale == 0) ? 1 : config->m_gfxdecodeinfo[gfxnum].xscale; |
| 639 | | int yscale = (config->m_gfxdecodeinfo[gfxnum].yscale == 0) ? 1 : config->m_gfxdecodeinfo[gfxnum].yscale; |
| 624 | int xscale = (config.m_gfxdecodeinfo[gfxnum].xscale == 0) ? 1 : config.m_gfxdecodeinfo[gfxnum].xscale; |
| 625 | int yscale = (config.m_gfxdecodeinfo[gfxnum].yscale == 0) ? 1 : config.m_gfxdecodeinfo[gfxnum].yscale; |
| 640 | 626 | const gfx_layout *gl = gfx->gfxlayout; |
| 641 | 627 | int israw = (gl->planeoffset[0] == GFX_RAW); |
| 642 | 628 | int planes = gl->planes; |
| r9023 | r9024 | |
| 655 | 641 | /* stop if we hit an empty */ |
| 656 | 642 | if (!rgninfo->entries[rgnnum].tag) |
| 657 | 643 | { |
| 658 | | mame_printf_error("%s: %s has gfx[%d] referencing non-existent region '%s'\n", driver->source_file, driver->name, gfxnum, region); |
| 644 | mame_printf_error("%s: %s has gfx[%d] referencing non-existent region '%s'\n", driver.source_file, driver.name, gfxnum, region); |
| 659 | 645 | error = true; |
| 660 | 646 | break; |
| 661 | 647 | } |
| r9023 | r9024 | |
| 686 | 672 | /* if not, this is an error */ |
| 687 | 673 | if ((start + len) / 8 > avail) |
| 688 | 674 | { |
| 689 | | mame_printf_error("%s: %s has gfx[%d] extending past allocated memory of region '%s'\n", driver->source_file, driver->name, gfxnum, region); |
| 675 | mame_printf_error("%s: %s has gfx[%d] extending past allocated memory of region '%s'\n", driver.source_file, driver.name, gfxnum, region); |
| 690 | 676 | error = true; |
| 691 | 677 | } |
| 692 | 678 | } |
| r9023 | r9024 | |
| 699 | 685 | { |
| 700 | 686 | if (total != RGN_FRAC(1,1)) |
| 701 | 687 | { |
| 702 | | mame_printf_error("%s: %s has gfx[%d] with unsupported layout total\n", driver->source_file, driver->name, gfxnum); |
| 688 | mame_printf_error("%s: %s has gfx[%d] with unsupported layout total\n", driver.source_file, driver.name, gfxnum); |
| 703 | 689 | error = true; |
| 704 | 690 | } |
| 705 | 691 | |
| 706 | 692 | if (xscale != 1 || yscale != 1) |
| 707 | 693 | { |
| 708 | | mame_printf_error("%s: %s has gfx[%d] with unsupported xscale/yscale\n", driver->source_file, driver->name, gfxnum); |
| 694 | mame_printf_error("%s: %s has gfx[%d] with unsupported xscale/yscale\n", driver.source_file, driver.name, gfxnum); |
| 709 | 695 | error = true; |
| 710 | 696 | } |
| 711 | 697 | } |
| r9023 | r9024 | |
| 713 | 699 | { |
| 714 | 700 | if (planes > MAX_GFX_PLANES) |
| 715 | 701 | { |
| 716 | | mame_printf_error("%s: %s has gfx[%d] with invalid planes\n", driver->source_file, driver->name, gfxnum); |
| 702 | mame_printf_error("%s: %s has gfx[%d] with invalid planes\n", driver.source_file, driver.name, gfxnum); |
| 717 | 703 | error = true; |
| 718 | 704 | } |
| 719 | 705 | |
| 720 | 706 | if (xscale * width > MAX_ABS_GFX_SIZE || yscale * height > MAX_ABS_GFX_SIZE) |
| 721 | 707 | { |
| 722 | | mame_printf_error("%s: %s has gfx[%d] with invalid xscale/yscale\n", driver->source_file, driver->name, gfxnum); |
| 708 | mame_printf_error("%s: %s has gfx[%d] with invalid xscale/yscale\n", driver.source_file, driver.name, gfxnum); |
| 723 | 709 | error = true; |
| 724 | 710 | } |
| 725 | 711 | } |
| r9023 | r9024 | |
| 735 | 721 | strings |
| 736 | 722 | -------------------------------------------------*/ |
| 737 | 723 | |
| 738 | | static int get_defstr_index(int_map &defstr_map, const char *name, const game_driver *driver, bool *error) |
| 724 | static int get_defstr_index(int_map &defstr_map, const char *name, const game_driver &driver, bool *error) |
| 739 | 725 | { |
| 740 | 726 | /* check for strings that should be DEF_STR */ |
| 741 | 727 | int strindex = defstr_map.find(name); |
| 742 | 728 | if (strindex != 0 && name != input_port_string_from_index(strindex) && error != NULL) |
| 743 | 729 | { |
| 744 | | mame_printf_error("%s: %s must use DEF_STR( %s )\n", driver->source_file, driver->name, name); |
| 730 | mame_printf_error("%s: %s must use DEF_STR( %s )\n", driver.source_file, driver.name, name); |
| 745 | 731 | *error = true; |
| 746 | 732 | } |
| 747 | 733 | |
| r9023 | r9024 | |
| 754 | 740 | analog input field |
| 755 | 741 | -------------------------------------------------*/ |
| 756 | 742 | |
| 757 | | static void validate_analog_input_field(const input_field_config *field, const game_driver *driver, bool *error) |
| 743 | static void validate_analog_input_field(const input_field_config *field, const game_driver &driver, bool *error) |
| 758 | 744 | { |
| 759 | 745 | INT32 analog_max = field->max; |
| 760 | 746 | INT32 analog_min = field->min; |
| r9023 | r9024 | |
| 769 | 755 | /* positional port size must fit in bits used */ |
| 770 | 756 | if (((field->mask >> shift) + 1) < field->max) |
| 771 | 757 | { |
| 772 | | mame_printf_error("%s: %s has an analog port with a positional port size bigger then the mask size\n", driver->source_file, driver->name); |
| 758 | mame_printf_error("%s: %s has an analog port with a positional port size bigger then the mask size\n", driver.source_file, driver.name); |
| 773 | 759 | *error = true; |
| 774 | 760 | } |
| 775 | 761 | } |
| r9023 | r9024 | |
| 778 | 764 | /* only positional controls use PORT_WRAPS */ |
| 779 | 765 | if (field->flags & ANALOG_FLAG_WRAPS) |
| 780 | 766 | { |
| 781 | | mame_printf_error("%s: %s only positional analog ports use PORT_WRAPS\n", driver->source_file, driver->name); |
| 767 | mame_printf_error("%s: %s only positional analog ports use PORT_WRAPS\n", driver.source_file, driver.name); |
| 782 | 768 | *error = true; |
| 783 | 769 | } |
| 784 | 770 | } |
| r9023 | r9024 | |
| 786 | 772 | /* analog ports must have a valid sensitivity */ |
| 787 | 773 | if (field->sensitivity == 0) |
| 788 | 774 | { |
| 789 | | mame_printf_error("%s: %s has an analog port with zero sensitivity\n", driver->source_file, driver->name); |
| 775 | mame_printf_error("%s: %s has an analog port with zero sensitivity\n", driver.source_file, driver.name); |
| 790 | 776 | *error = true; |
| 791 | 777 | } |
| 792 | 778 | |
| 793 | 779 | /* check that the default falls in the bitmask range */ |
| 794 | 780 | if (field->defvalue & ~field->mask) |
| 795 | 781 | { |
| 796 | | mame_printf_error("%s: %s has an analog port with a default value out of the bitmask range\n", driver->source_file, driver->name); |
| 782 | mame_printf_error("%s: %s has an analog port with a default value out of the bitmask range\n", driver.source_file, driver.name); |
| 797 | 783 | *error = true; |
| 798 | 784 | } |
| 799 | 785 | |
| r9023 | r9024 | |
| 813 | 799 | /* check that the default falls in the MINMAX range */ |
| 814 | 800 | if (default_value < analog_min || default_value > analog_max) |
| 815 | 801 | { |
| 816 | | mame_printf_error("%s: %s has an analog port with a default value out PORT_MINMAX range\n", driver->source_file, driver->name); |
| 802 | mame_printf_error("%s: %s has an analog port with a default value out PORT_MINMAX range\n", driver.source_file, driver.name); |
| 817 | 803 | *error = true; |
| 818 | 804 | } |
| 819 | 805 | |
| r9023 | r9024 | |
| 821 | 807 | /* we use the unadjusted min for testing */ |
| 822 | 808 | if (field->min & ~field->mask || analog_max & ~field->mask) |
| 823 | 809 | { |
| 824 | | mame_printf_error("%s: %s has an analog port with a PORT_MINMAX value out of the bitmask range\n", driver->source_file, driver->name); |
| 810 | mame_printf_error("%s: %s has an analog port with a PORT_MINMAX value out of the bitmask range\n", driver.source_file, driver.name); |
| 825 | 811 | *error = true; |
| 826 | 812 | } |
| 827 | 813 | |
| 828 | 814 | /* absolute analog ports do not use PORT_RESET */ |
| 829 | 815 | if (field->flags & ANALOG_FLAG_RESET) |
| 830 | 816 | { |
| 831 | | mame_printf_error("%s: %s - absolute analog ports do not use PORT_RESET\n", driver->source_file, driver->name); |
| 817 | mame_printf_error("%s: %s - absolute analog ports do not use PORT_RESET\n", driver.source_file, driver.name); |
| 832 | 818 | *error = true; |
| 833 | 819 | } |
| 834 | 820 | } |
| r9023 | r9024 | |
| 842 | 828 | /* relative devices do not use PORT_MINMAX */ |
| 843 | 829 | if (field->min != 0 || field->max != field->mask) |
| 844 | 830 | { |
| 845 | | mame_printf_error("%s: %s - relative ports do not use PORT_MINMAX\n", driver->source_file, driver->name); |
| 831 | mame_printf_error("%s: %s - relative ports do not use PORT_MINMAX\n", driver.source_file, driver.name); |
| 846 | 832 | *error = true; |
| 847 | 833 | } |
| 848 | 834 | |
| r9023 | r9024 | |
| 850 | 836 | /* the counter is at 0 on power up */ |
| 851 | 837 | if (field->defvalue != 0) |
| 852 | 838 | { |
| 853 | | mame_printf_error("%s: %s - relative ports do not use a default value other then 0\n", driver->source_file, driver->name); |
| 839 | mame_printf_error("%s: %s - relative ports do not use a default value other then 0\n", driver.source_file, driver.name); |
| 854 | 840 | *error = true; |
| 855 | 841 | } |
| 856 | 842 | } |
| r9023 | r9024 | |
| 863 | 849 | setting |
| 864 | 850 | -------------------------------------------------*/ |
| 865 | 851 | |
| 866 | | static void validate_dip_settings(const input_field_config *field, const game_driver *driver, int_map &defstr_map, bool *error) |
| 852 | static void validate_dip_settings(const input_field_config *field, const game_driver &driver, int_map &defstr_map, bool *error) |
| 867 | 853 | { |
| 868 | 854 | const char *demo_sounds = input_port_string_from_index(INPUT_STRING_Demo_Sounds); |
| 869 | 855 | const char *flipscreen = input_port_string_from_index(INPUT_STRING_Flip_Screen); |
| r9023 | r9024 | |
| 883 | 869 | /* make sure demo sounds default to on */ |
| 884 | 870 | if (field->name == demo_sounds && strindex == INPUT_STRING_On && field->defvalue != setting->value) |
| 885 | 871 | { |
| 886 | | mame_printf_error("%s: %s Demo Sounds must default to On\n", driver->source_file, driver->name); |
| 872 | mame_printf_error("%s: %s Demo Sounds must default to On\n", driver.source_file, driver.name); |
| 887 | 873 | *error = true; |
| 888 | 874 | } |
| 889 | 875 | |
| 890 | 876 | /* check for bad demo sounds options */ |
| 891 | 877 | if (field->name == demo_sounds && (strindex == INPUT_STRING_Yes || strindex == INPUT_STRING_No)) |
| 892 | 878 | { |
| 893 | | mame_printf_error("%s: %s has wrong Demo Sounds option %s (must be Off/On)\n", driver->source_file, driver->name, setting->name); |
| 879 | mame_printf_error("%s: %s has wrong Demo Sounds option %s (must be Off/On)\n", driver.source_file, driver.name, setting->name); |
| 894 | 880 | *error = true; |
| 895 | 881 | } |
| 896 | 882 | |
| 897 | 883 | /* check for bad flip screen options */ |
| 898 | 884 | if (field->name == flipscreen && (strindex == INPUT_STRING_Yes || strindex == INPUT_STRING_No)) |
| 899 | 885 | { |
| 900 | | mame_printf_error("%s: %s has wrong Flip Screen option %s (must be Off/On)\n", driver->source_file, driver->name, setting->name); |
| 886 | mame_printf_error("%s: %s has wrong Flip Screen option %s (must be Off/On)\n", driver.source_file, driver.name, setting->name); |
| 901 | 887 | *error = true; |
| 902 | 888 | } |
| 903 | 889 | |
| r9023 | r9024 | |
| 909 | 895 | /* check for inverted off/on dispswitch order */ |
| 910 | 896 | if (strindex == INPUT_STRING_On && next_strindex == INPUT_STRING_Off) |
| 911 | 897 | { |
| 912 | | mame_printf_error("%s: %s has inverted Off/On dipswitch order\n", driver->source_file, driver->name); |
| 898 | mame_printf_error("%s: %s has inverted Off/On dipswitch order\n", driver.source_file, driver.name); |
| 913 | 899 | *error = true; |
| 914 | 900 | } |
| 915 | 901 | |
| 916 | 902 | /* check for inverted yes/no dispswitch order */ |
| 917 | 903 | else if (strindex == INPUT_STRING_Yes && next_strindex == INPUT_STRING_No) |
| 918 | 904 | { |
| 919 | | mame_printf_error("%s: %s has inverted No/Yes dipswitch order\n", driver->source_file, driver->name); |
| 905 | mame_printf_error("%s: %s has inverted No/Yes dipswitch order\n", driver.source_file, driver.name); |
| 920 | 906 | *error = true; |
| 921 | 907 | } |
| 922 | 908 | |
| 923 | 909 | /* check for inverted upright/cocktail dispswitch order */ |
| 924 | 910 | else if (strindex == INPUT_STRING_Cocktail && next_strindex == INPUT_STRING_Upright) |
| 925 | 911 | { |
| 926 | | mame_printf_error("%s: %s has inverted Upright/Cocktail dipswitch order\n", driver->source_file, driver->name); |
| 912 | mame_printf_error("%s: %s has inverted Upright/Cocktail dipswitch order\n", driver.source_file, driver.name); |
| 927 | 913 | *error = true; |
| 928 | 914 | } |
| 929 | 915 | |
| r9023 | r9024 | |
| 931 | 917 | else if (strindex >= INPUT_STRING_9C_1C && strindex <= INPUT_STRING_1C_9C && next_strindex >= INPUT_STRING_9C_1C && next_strindex <= INPUT_STRING_1C_9C && |
| 932 | 918 | strindex >= next_strindex && memcmp(&setting->condition, &setting->next->condition, sizeof(setting->condition)) == 0) |
| 933 | 919 | { |
| 934 | | mame_printf_error("%s: %s has unsorted coinage %s > %s\n", driver->source_file, driver->name, setting->name, setting->next->name); |
| 920 | mame_printf_error("%s: %s has unsorted coinage %s > %s\n", driver.source_file, driver.name, setting->name, setting->next->name); |
| 935 | 921 | coin_error = *error = true; |
| 936 | 922 | } |
| 937 | 923 | } |
| r9023 | r9024 | |
| 942 | 928 | { |
| 943 | 929 | int entry; |
| 944 | 930 | |
| 945 | | mame_printf_error("%s: %s proper coin sort order should be:\n", driver->source_file, driver->name); |
| 931 | mame_printf_error("%s: %s proper coin sort order should be:\n", driver.source_file, driver.name); |
| 946 | 932 | for (entry = 0; entry < ARRAY_LENGTH(coin_list); entry++) |
| 947 | 933 | if (coin_list[entry]) |
| 948 | 934 | mame_printf_error("%s\n", input_port_string_from_index(INPUT_STRING_9C_1C + entry)); |
| r9023 | r9024 | |
| 954 | 940 | validate_inputs - validate input configuration |
| 955 | 941 | -------------------------------------------------*/ |
| 956 | 942 | |
| 957 | | static bool validate_inputs(int drivnum, const machine_config *config, int_map &defstr_map, ioport_list &portlist) |
| 943 | static bool validate_inputs(const machine_config &config, int_map &defstr_map, ioport_list &portlist) |
| 958 | 944 | { |
| 959 | 945 | const input_port_config *scanport; |
| 960 | 946 | const input_port_config *port; |
| 961 | 947 | const input_field_config *field; |
| 962 | | const game_driver *driver = drivers[drivnum]; |
| 948 | const game_driver &driver = config.gamedrv(); |
| 963 | 949 | int empty_string_found = FALSE; |
| 964 | 950 | char errorbuf[1024]; |
| 965 | 951 | bool error = false; |
| 966 | 952 | |
| 967 | 953 | /* skip if no ports */ |
| 968 | | if (driver->ipt == NULL) |
| 954 | if (driver.ipt == NULL) |
| 969 | 955 | return FALSE; |
| 970 | 956 | |
| 971 | 957 | /* allocate the input ports */ |
| 972 | | input_port_list_init(portlist, driver->ipt, errorbuf, sizeof(errorbuf), FALSE); |
| 958 | input_port_list_init(portlist, driver.ipt, errorbuf, sizeof(errorbuf), FALSE); |
| 973 | 959 | if (errorbuf[0] != 0) |
| 974 | 960 | { |
| 975 | | mame_printf_error("%s: %s has input port errors:\n%s\n", driver->source_file, driver->name, errorbuf); |
| 961 | mame_printf_error("%s: %s has input port errors:\n%s\n", driver.source_file, driver.name, errorbuf); |
| 976 | 962 | error = true; |
| 977 | 963 | } |
| 978 | 964 | |
| r9023 | r9024 | |
| 982 | 968 | for (scanport = port->next(); scanport != NULL; scanport = scanport->next()) |
| 983 | 969 | if (scanport->tag != NULL && strcmp(port->tag, scanport->tag) == 0) |
| 984 | 970 | { |
| 985 | | mame_printf_error("%s: %s has a duplicate input port tag '%s'\n", driver->source_file, driver->name, port->tag); |
| 971 | mame_printf_error("%s: %s has a duplicate input port tag '%s'\n", driver.source_file, driver.name, port->tag); |
| 986 | 972 | error = true; |
| 987 | 973 | } |
| 988 | 974 | |
| r9023 | r9024 | |
| 1003 | 989 | /* dip switch fields must have a name */ |
| 1004 | 990 | if (field->name == NULL) |
| 1005 | 991 | { |
| 1006 | | mame_printf_error("%s: %s has a DIP switch name or setting with no name\n", driver->source_file, driver->name); |
| 992 | mame_printf_error("%s: %s has a DIP switch name or setting with no name\n", driver.source_file, driver.name); |
| 1007 | 993 | error = true; |
| 1008 | 994 | } |
| 1009 | 995 | |
| r9023 | r9024 | |
| 1014 | 1000 | /* look for invalid (0) types which should be mapped to IPT_OTHER */ |
| 1015 | 1001 | if (field->type == IPT_INVALID) |
| 1016 | 1002 | { |
| 1017 | | mame_printf_error("%s: %s has an input port with an invalid type (0); use IPT_OTHER instead\n", driver->source_file, driver->name); |
| 1003 | mame_printf_error("%s: %s has an input port with an invalid type (0); use IPT_OTHER instead\n", driver.source_file, driver.name); |
| 1018 | 1004 | error = true; |
| 1019 | 1005 | } |
| 1020 | 1006 | |
| r9023 | r9024 | |
| 1024 | 1010 | /* check for empty string */ |
| 1025 | 1011 | if (field->name[0] == 0 && !empty_string_found) |
| 1026 | 1012 | { |
| 1027 | | mame_printf_error("%s: %s has an input with an empty string\n", driver->source_file, driver->name); |
| 1013 | mame_printf_error("%s: %s has an input with an empty string\n", driver.source_file, driver.name); |
| 1028 | 1014 | empty_string_found = error = true; |
| 1029 | 1015 | } |
| 1030 | 1016 | |
| 1031 | 1017 | /* check for trailing spaces */ |
| 1032 | 1018 | if (field->name[0] != 0 && field->name[strlen(field->name) - 1] == ' ') |
| 1033 | 1019 | { |
| 1034 | | mame_printf_error("%s: %s input '%s' has trailing spaces\n", driver->source_file, driver->name, field->name); |
| 1020 | mame_printf_error("%s: %s input '%s' has trailing spaces\n", driver.source_file, driver.name, field->name); |
| 1035 | 1021 | error = true; |
| 1036 | 1022 | } |
| 1037 | 1023 | |
| 1038 | 1024 | /* check for invalid UTF-8 */ |
| 1039 | 1025 | if (!utf8_is_valid_string(field->name)) |
| 1040 | 1026 | { |
| 1041 | | mame_printf_error("%s: %s input '%s' has invalid characters\n", driver->source_file, driver->name, field->name); |
| 1027 | mame_printf_error("%s: %s input '%s' has invalid characters\n", driver.source_file, driver.name, field->name); |
| 1042 | 1028 | error = true; |
| 1043 | 1029 | } |
| 1044 | 1030 | |
| r9023 | r9024 | |
| 1057 | 1043 | /* if none, error */ |
| 1058 | 1044 | if (scanport == NULL) |
| 1059 | 1045 | { |
| 1060 | | mame_printf_error("%s: %s has a condition referencing non-existent input port tag '%s'\n", driver->source_file, driver->name, field->condition.tag); |
| 1046 | mame_printf_error("%s: %s has a condition referencing non-existent input port tag '%s'\n", driver.source_file, driver.name, field->condition.tag); |
| 1061 | 1047 | error = true; |
| 1062 | 1048 | } |
| 1063 | 1049 | } |
| r9023 | r9024 | |
| 1074 | 1060 | /* if none, error */ |
| 1075 | 1061 | if (scanport == NULL) |
| 1076 | 1062 | { |
| 1077 | | mame_printf_error("%s: %s has a condition referencing non-existent input port tag '%s'\n", driver->source_file, driver->name, setting->condition.tag); |
| 1063 | mame_printf_error("%s: %s has a condition referencing non-existent input port tag '%s'\n", driver.source_file, driver.name, setting->condition.tag); |
| 1078 | 1064 | error = true; |
| 1079 | 1065 | } |
| 1080 | 1066 | } |
| r9023 | r9024 | |
| 1082 | 1068 | |
| 1083 | 1069 | error = error || validate_natural_keyboard_statics(); |
| 1084 | 1070 | |
| 1085 | | /* free the config */ |
| 1086 | 1071 | return error; |
| 1087 | 1072 | } |
| 1088 | 1073 | |
| r9023 | r9024 | |
| 1092 | 1077 | checks |
| 1093 | 1078 | -------------------------------------------------*/ |
| 1094 | 1079 | |
| 1095 | | static bool validate_devices(int drivnum, const machine_config *config, const ioport_list &portlist, region_array *rgninfo) |
| 1080 | static bool validate_devices(const machine_config &config, const ioport_list &portlist, region_array *rgninfo) |
| 1096 | 1081 | { |
| 1097 | 1082 | bool error = false; |
| 1098 | | const game_driver *driver = drivers[drivnum]; |
| 1083 | const game_driver &driver = config.gamedrv(); |
| 1099 | 1084 | |
| 1100 | | for (const device_config *devconfig = config->m_devicelist.first(); devconfig != NULL; devconfig = devconfig->next()) |
| 1085 | for (const device_config *devconfig = config.m_devicelist.first(); devconfig != NULL; devconfig = devconfig->next()) |
| 1101 | 1086 | { |
| 1102 | 1087 | /* validate the device tag */ |
| 1103 | 1088 | if (!validate_tag(driver, devconfig->name(), devconfig->tag())) |
| 1104 | 1089 | error = true; |
| 1105 | 1090 | |
| 1106 | 1091 | /* look for duplicates */ |
| 1107 | | for (const device_config *scanconfig = config->m_devicelist.first(); scanconfig != devconfig; scanconfig = scanconfig->next()) |
| 1092 | for (const device_config *scanconfig = config.m_devicelist.first(); scanconfig != devconfig; scanconfig = scanconfig->next()) |
| 1108 | 1093 | if (strcmp(scanconfig->tag(), devconfig->tag()) == 0) |
| 1109 | 1094 | { |
| 1110 | | mame_printf_warning("%s: %s has multiple devices with the tag '%s'\n", driver->source_file, driver->name, devconfig->tag()); |
| 1095 | mame_printf_warning("%s: %s has multiple devices with the tag '%s'\n", driver.source_file, driver.name, devconfig->tag()); |
| 1111 | 1096 | break; |
| 1112 | 1097 | } |
| 1113 | 1098 | |
| 1114 | 1099 | /* check for device-specific validity check */ |
| 1115 | | if (devconfig->validity_check(*driver)) |
| 1100 | if (devconfig->validity_check(driver)) |
| 1116 | 1101 | error = true; |
| 1117 | 1102 | |
| 1118 | 1103 | } |
| r9023 | r9024 | |
| 1135 | 1120 | osd_ticks_t input_checks = 0; |
| 1136 | 1121 | osd_ticks_t device_checks = 0; |
| 1137 | 1122 | |
| 1138 | | int drivnum, strnum; |
| 1123 | int strnum; |
| 1139 | 1124 | bool error = false; |
| 1140 | 1125 | UINT16 lsbtest; |
| 1141 | 1126 | UINT8 a, b; |
| r9023 | r9024 | |
| 1187 | 1172 | prep += get_profile_ticks(); |
| 1188 | 1173 | |
| 1189 | 1174 | /* iterate over all drivers */ |
| 1190 | | for (drivnum = 0; drivers[drivnum]; drivnum++) |
| 1175 | for (int drivnum = 0; drivers[drivnum]; drivnum++) |
| 1191 | 1176 | { |
| 1192 | | const game_driver *driver = drivers[drivnum]; |
| 1193 | | machine_config *config = NULL; |
| 1177 | const game_driver &driver = *drivers[drivnum]; |
| 1194 | 1178 | ioport_list portlist; |
| 1195 | 1179 | region_array rgninfo; |
| 1196 | 1180 | |
| 1197 | 1181 | /* non-debug builds only care about games in the same driver */ |
| 1198 | | if (curdriver != NULL && strcmp(curdriver->source_file, driver->source_file) != 0) |
| 1182 | if (curdriver != NULL && strcmp(curdriver->source_file, driver.source_file) != 0) |
| 1199 | 1183 | continue; |
| 1200 | 1184 | |
| 1201 | 1185 | try |
| 1202 | 1186 | { |
| 1203 | 1187 | /* expand the machine driver */ |
| 1204 | 1188 | expansion -= get_profile_ticks(); |
| 1205 | | config = global_alloc(machine_config(driver->machine_config)); |
| 1189 | machine_config config(driver); |
| 1206 | 1190 | expansion += get_profile_ticks(); |
| 1207 | 1191 | |
| 1208 | 1192 | /* validate the driver entry */ |
| 1209 | 1193 | driver_checks -= get_profile_ticks(); |
| 1210 | | error = validate_driver(drivnum, config, names, descriptions) || error; |
| 1194 | error = validate_driver(config, names, descriptions) || error; |
| 1211 | 1195 | driver_checks += get_profile_ticks(); |
| 1212 | 1196 | |
| 1213 | 1197 | /* validate the ROM information */ |
| 1214 | 1198 | rom_checks -= get_profile_ticks(); |
| 1215 | | error = validate_roms(drivnum, config, &rgninfo, roms) || error; |
| 1199 | error = validate_roms(config, &rgninfo, roms) || error; |
| 1216 | 1200 | rom_checks += get_profile_ticks(); |
| 1217 | 1201 | |
| 1218 | 1202 | /* validate input ports */ |
| 1219 | 1203 | input_checks -= get_profile_ticks(); |
| 1220 | | error = validate_inputs(drivnum, config, defstr, portlist) || error; |
| 1204 | error = validate_inputs(config, defstr, portlist) || error; |
| 1221 | 1205 | input_checks += get_profile_ticks(); |
| 1222 | 1206 | |
| 1223 | 1207 | /* validate the display */ |
| 1224 | 1208 | display_checks -= get_profile_ticks(); |
| 1225 | | error = validate_display(drivnum, config) || error; |
| 1209 | error = validate_display(config) || error; |
| 1226 | 1210 | display_checks += get_profile_ticks(); |
| 1227 | 1211 | |
| 1228 | 1212 | /* validate the graphics decoding */ |
| 1229 | 1213 | gfx_checks -= get_profile_ticks(); |
| 1230 | | error = validate_gfx(drivnum, config, &rgninfo) || error; |
| 1214 | error = validate_gfx(config, &rgninfo) || error; |
| 1231 | 1215 | gfx_checks += get_profile_ticks(); |
| 1232 | 1216 | |
| 1233 | 1217 | /* validate devices */ |
| 1234 | 1218 | device_checks -= get_profile_ticks(); |
| 1235 | | error = validate_devices(drivnum, config, portlist, &rgninfo) || error; |
| 1219 | error = validate_devices(config, portlist, &rgninfo) || error; |
| 1236 | 1220 | device_checks += get_profile_ticks(); |
| 1237 | 1221 | } |
| 1238 | 1222 | catch (emu_fatalerror &err) |
| 1239 | 1223 | { |
| 1240 | | global_free(config); |
| 1241 | | throw emu_fatalerror("Validating %s (%s): %s", driver->name, driver->source_file, err.string()); |
| 1224 | throw emu_fatalerror("Validating %s (%s): %s", driver.name, driver.source_file, err.string()); |
| 1242 | 1225 | } |
| 1243 | | |
| 1244 | | global_free(config); |
| 1245 | 1226 | } |
| 1246 | 1227 | |
| 1247 | 1228 | #if (REPORT_TIMES) |
src/emu/romload.c
| r9023 | r9024 | |
| 138 | 138 | ***************************************************************************/ |
| 139 | 139 | |
| 140 | 140 | /*------------------------------------------------- |
| 141 | | rom_source_is_gamedrv - return TRUE if the |
| 142 | | given rom_source refers to the game driver |
| 143 | | itself |
| 144 | | -------------------------------------------------*/ |
| 145 | | |
| 146 | | int rom_source_is_gamedrv(const game_driver *drv, const rom_source *source) |
| 147 | | { |
| 148 | | return ((const game_driver *)source == drv); |
| 149 | | } |
| 150 | | |
| 151 | | |
| 152 | | /*------------------------------------------------- |
| 153 | 141 | rom_first_source - return pointer to first ROM |
| 154 | 142 | source |
| 155 | 143 | -------------------------------------------------*/ |
| 156 | 144 | |
| 157 | | const rom_source *rom_first_source(const game_driver *drv, const machine_config *config) |
| 145 | const rom_source *rom_first_source(const machine_config &config) |
| 158 | 146 | { |
| 159 | | const device_config *devconfig; |
| 147 | /* look through devices */ |
| 148 | for (const device_config *devconfig = config.m_devicelist.first(); devconfig != NULL; devconfig = devconfig->next()) |
| 149 | if (devconfig->rom_region() != NULL) |
| 150 | return devconfig; |
| 160 | 151 | |
| 161 | | /* if the driver has a ROM pointer, that's what we want */ |
| 162 | | if (drv->rom != NULL) |
| 163 | | return (rom_source *)drv; |
| 164 | | |
| 165 | | /* otherwise, look through devices */ |
| 166 | | if (config != NULL) |
| 167 | | for (devconfig = config->m_devicelist.first(); devconfig != NULL; devconfig = devconfig->next()) |
| 168 | | { |
| 169 | | const rom_entry *devromp = devconfig->rom_region(); |
| 170 | | if (devromp != NULL) |
| 171 | | return (rom_source *)devconfig; |
| 172 | | } |
| 173 | 152 | return NULL; |
| 174 | 153 | } |
| 175 | 154 | |
| r9023 | r9024 | |
| 179 | 158 | source |
| 180 | 159 | -------------------------------------------------*/ |
| 181 | 160 | |
| 182 | | const rom_source *rom_next_source(const game_driver *drv, const machine_config *config, const rom_source *previous) |
| 161 | const rom_source *rom_next_source(const rom_source &previous) |
| 183 | 162 | { |
| 184 | | const device_config *devconfig; |
| 185 | | |
| 186 | | /* if the previous was the driver, we want the first device */ |
| 187 | | if (rom_source_is_gamedrv(drv, previous)) |
| 188 | | devconfig = (config != NULL) ? config->m_devicelist.first() : NULL; |
| 189 | | else |
| 190 | | devconfig = ((const device_config *)previous)->next(); |
| 191 | | |
| 192 | 163 | /* look for further devices with ROM definitions */ |
| 193 | | for ( ; devconfig != NULL; devconfig = devconfig->next()) |
| 194 | | { |
| 195 | | const rom_entry *devromp = devconfig->rom_region(); |
| 196 | | if (devromp != NULL) |
| 164 | for (const device_config *devconfig = previous.next(); devconfig != NULL; devconfig = devconfig->next()) |
| 165 | if (devconfig->rom_region() != NULL) |
| 197 | 166 | return (rom_source *)devconfig; |
| 198 | | } |
| 167 | |
| 199 | 168 | return NULL; |
| 200 | 169 | } |
| 201 | 170 | |
| r9023 | r9024 | |
| 205 | 174 | region |
| 206 | 175 | -------------------------------------------------*/ |
| 207 | 176 | |
| 208 | | const rom_entry *rom_first_region(const game_driver *drv, const rom_source *source) |
| 177 | const rom_entry *rom_first_region(const rom_source &source) |
| 209 | 178 | { |
| 210 | | const rom_entry *romp; |
| 211 | | |
| 212 | | if (source == NULL || rom_source_is_gamedrv(drv, source)) |
| 213 | | romp = drv->rom; |
| 214 | | else |
| 215 | | romp = ((const device_config *)source)->rom_region(); |
| 216 | | |
| 179 | const rom_entry *romp = source.rom_region(); |
| 217 | 180 | return (romp != NULL && !ROMENTRY_ISEND(romp)) ? romp : NULL; |
| 218 | 181 | } |
| 219 | 182 | |
| r9023 | r9024 | |
| 267 | 230 | |
| 268 | 231 | astring &rom_region_name(astring &result, const game_driver *drv, const rom_source *source, const rom_entry *romp) |
| 269 | 232 | { |
| 270 | | if (rom_source_is_gamedrv(drv, source)) |
| 271 | | result.cpy(ROMREGION_GETTAG(romp)); |
| 272 | | else |
| 273 | | { |
| 274 | | const device_config *devconfig = (const device_config *)source; |
| 275 | | result.printf("%s:%s", devconfig->tag(), ROMREGION_GETTAG(romp)); |
| 276 | | } |
| 277 | | return result; |
| 233 | return source->subtag(result, ROMREGION_GETTAG(romp)); |
| 278 | 234 | } |
| 279 | 235 | |
| 280 | 236 | |
| r9023 | r9024 | |
| 342 | 298 | |
| 343 | 299 | romdata->system_bios = 0; |
| 344 | 300 | |
| 345 | | /* first determine the default BIOS name */ |
| 346 | | for (rom = romdata->machine->gamedrv->rom; !ROMENTRY_ISEND(rom); rom++) |
| 347 | | if (ROMENTRY_ISDEFAULT_BIOS(rom)) |
| 348 | | defaultname = ROM_GETNAME(rom); |
| 301 | for (const rom_source *source = rom_first_source(*romdata->machine->config); source != NULL; source = rom_next_source(*source)) |
| 302 | { |
| 303 | /* first determine the default BIOS name */ |
| 304 | for (rom = source->rom_region(); !ROMENTRY_ISEND(rom); rom++) |
| 305 | if (ROMENTRY_ISDEFAULT_BIOS(rom)) |
| 306 | defaultname = ROM_GETNAME(rom); |
| 349 | 307 | |
| 350 | | /* look for a BIOS with a matching name */ |
| 351 | | for (rom = romdata->machine->gamedrv->rom; !ROMENTRY_ISEND(rom); rom++) |
| 352 | | if (ROMENTRY_ISSYSTEM_BIOS(rom)) |
| 353 | | { |
| 354 | | const char *biosname = ROM_GETNAME(rom); |
| 355 | | int bios_flags = ROM_GETBIOSFLAGS(rom); |
| 356 | | char bios_number[20]; |
| 308 | /* look for a BIOS with a matching name */ |
| 309 | for (rom = source->rom_region(); !ROMENTRY_ISEND(rom); rom++) |
| 310 | if (ROMENTRY_ISSYSTEM_BIOS(rom)) |
| 311 | { |
| 312 | const char *biosname = ROM_GETNAME(rom); |
| 313 | int bios_flags = ROM_GETBIOSFLAGS(rom); |
| 314 | char bios_number[20]; |
| 357 | 315 | |
| 358 | | /* Allow '-bios n' to still be used */ |
| 359 | | sprintf(bios_number, "%d", bios_flags - 1); |
| 360 | | if (strcmp(bios_number, specbios) == 0 || strcmp(biosname, specbios) == 0) |
| 361 | | romdata->system_bios = bios_flags; |
| 362 | | if (defaultname != NULL && strcmp(biosname, defaultname) == 0) |
| 363 | | default_no = bios_flags; |
| 364 | | bios_count++; |
| 365 | | } |
| 316 | /* Allow '-bios n' to still be used */ |
| 317 | sprintf(bios_number, "%d", bios_flags - 1); |
| 318 | if (strcmp(bios_number, specbios) == 0 || strcmp(biosname, specbios) == 0) |
| 319 | romdata->system_bios = bios_flags; |
| 320 | if (defaultname != NULL && strcmp(biosname, defaultname) == 0) |
| 321 | default_no = bios_flags; |
| 322 | bios_count++; |
| 323 | } |
| 366 | 324 | |
| 367 | | /* if none found, use the default */ |
| 368 | | if (romdata->system_bios == 0 && bios_count > 0) |
| 369 | | { |
| 370 | | /* if we got neither an empty string nor 'default' then warn the user */ |
| 371 | | if (specbios[0] != 0 && strcmp(specbios, "default") != 0 && romdata != NULL) |
| 325 | /* if none found, use the default */ |
| 326 | if (romdata->system_bios == 0 && bios_count > 0) |
| 372 | 327 | { |
| 373 | | romdata->errorstring.catprintf("%s: invalid bios\n", specbios); |
| 374 | | romdata->warnings++; |
| 328 | /* if we got neither an empty string nor 'default' then warn the user */ |
| 329 | if (specbios[0] != 0 && strcmp(specbios, "default") != 0 && romdata != NULL) |
| 330 | { |
| 331 | romdata->errorstring.catprintf("%s: invalid bios\n", specbios); |
| 332 | romdata->warnings++; |
| 333 | } |
| 334 | |
| 335 | /* set to default */ |
| 336 | romdata->system_bios = default_no; |
| 375 | 337 | } |
| 376 | 338 | |
| 377 | | /* set to default */ |
| 378 | | romdata->system_bios = default_no; |
| 339 | LOG(("Using System BIOS: %d\n", romdata->system_bios)); |
| 379 | 340 | } |
| 380 | | |
| 381 | | LOG(("Using System BIOS: %d\n", romdata->system_bios)); |
| 382 | 341 | } |
| 383 | 342 | |
| 384 | 343 | |
| r9023 | r9024 | |
| 397 | 356 | romdata->romstotalsize = 0; |
| 398 | 357 | |
| 399 | 358 | /* loop over regions, then over files */ |
| 400 | | for (source = rom_first_source(romdata->machine->gamedrv, romdata->machine->config); source != NULL; source = rom_next_source(romdata->machine->gamedrv, romdata->machine->config, source)) |
| 401 | | for (region = rom_first_region(romdata->machine->gamedrv, source); region != NULL; region = rom_next_region(region)) |
| 359 | for (source = rom_first_source(*romdata->machine->config); source != NULL; source = rom_next_source(*source)) |
| 360 | for (region = rom_first_region(*source); region != NULL; region = rom_next_region(region)) |
| 402 | 361 | for (rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom)) |
| 403 | 362 | if (ROM_GETBIOSFLAGS(rom) == 0 || ROM_GETBIOSFLAGS(rom) == romdata->system_bios) |
| 404 | 363 | { |
| r9023 | r9024 | |
| 1045 | 1004 | /* otherwise, look at our parents for a CHD with an identical checksum */ |
| 1046 | 1005 | /* and try to open that */ |
| 1047 | 1006 | for (drv = gamedrv; drv != NULL; drv = driver_get_clone(drv)) |
| 1048 | | for (source = rom_first_source(drv, NULL); source != NULL; source = rom_next_source(drv, NULL, source)) |
| 1049 | | for (region = rom_first_region(drv, source); region != NULL; region = rom_next_region(region)) |
| 1007 | { |
| 1008 | machine_config config(*drv); |
| 1009 | for (source = rom_first_source(config); source != NULL; source = rom_next_source(*source)) |
| 1010 | for (region = rom_first_region(*source); region != NULL; region = rom_next_region(region)) |
| 1050 | 1011 | if (ROMREGION_ISDISKDATA(region)) |
| 1051 | 1012 | for (rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom)) |
| 1052 | 1013 | |
| r9023 | r9024 | |
| 1081 | 1042 | *image_file = NULL; |
| 1082 | 1043 | } |
| 1083 | 1044 | } |
| 1045 | } |
| 1084 | 1046 | |
| 1085 | 1047 | return err; |
| 1086 | 1048 | } |
| r9023 | r9024 | |
| 1344 | 1306 | const rom_entry *region; |
| 1345 | 1307 | |
| 1346 | 1308 | /* loop until we hit the end */ |
| 1347 | | for (source = rom_first_source(romdata->machine->gamedrv, romdata->machine->config); source != NULL; source = rom_next_source(romdata->machine->gamedrv, romdata->machine->config, source)) |
| 1348 | | for (region = rom_first_region(romdata->machine->gamedrv, source); region != NULL; region = rom_next_region(region)) |
| 1309 | for (source = rom_first_source(*romdata->machine->config); source != NULL; source = rom_next_source(*source)) |
| 1310 | for (region = rom_first_region(*source); region != NULL; region = rom_next_region(region)) |
| 1349 | 1311 | { |
| 1350 | 1312 | UINT32 regionlength = ROMREGION_GETLENGTH(region); |
| 1351 | 1313 | UINT32 regionflags = ROMREGION_GETFLAGS(region); |
| r9023 | r9024 | |
| 1388 | 1350 | } |
| 1389 | 1351 | |
| 1390 | 1352 | /* now go back and post-process all the regions */ |
| 1391 | | for (source = rom_first_source(romdata->machine->gamedrv, romdata->machine->config); source != NULL; source = rom_next_source(romdata->machine->gamedrv, romdata->machine->config, source)) |
| 1392 | | for (region = rom_first_region(romdata->machine->gamedrv, source); region != NULL; region = rom_next_region(region)) |
| 1353 | for (source = rom_first_source(*romdata->machine->config); source != NULL; source = rom_next_source(*source)) |
| 1354 | for (region = rom_first_region(*source); region != NULL; region = rom_next_region(region)) |
| 1393 | 1355 | region_post_process(romdata, ROMREGION_GETTAG(region)); |
| 1394 | 1356 | } |
| 1395 | 1357 | |
src/emu/info.c
| r9023 | r9024 | |
| 39 | 39 | const game_driver *drv; |
| 40 | 40 | machine_config mconfig; |
| 41 | 41 | |
| 42 | | parent_info(const game_driver *drv) : mconfig(drv->machine_config) |
| 42 | parent_info(const game_driver *drv) : mconfig(*drv) |
| 43 | 43 | { |
| 44 | 44 | this->drv = drv; |
| 45 | 45 | } |
| r9023 | r9024 | |
| 458 | 458 | |
| 459 | 459 | for (parent = 0; parent < parents; ++parent) |
| 460 | 460 | { |
| 461 | | const game_driver *clone_of = pinfoarray[parent]->drv; |
| 462 | 461 | const machine_config *pconfig = &pinfoarray[parent]->mconfig; |
| 463 | 462 | const rom_source *psource; |
| 464 | 463 | const rom_entry *pregion, *prom; |
| 465 | 464 | |
| 466 | 465 | /* scan the clone_of ROM for a matching ROM entry */ |
| 467 | | for (psource = rom_first_source(clone_of, pconfig); psource != NULL; psource = rom_next_source(clone_of, pconfig, psource)) |
| 468 | | for (pregion = rom_first_region(clone_of, psource); pregion != NULL; pregion = rom_next_region(pregion)) |
| 466 | for (psource = rom_first_source(*pconfig); psource != NULL; psource = rom_next_source(*psource)) |
| 467 | for (pregion = rom_first_region(*psource); pregion != NULL; pregion = rom_next_region(pregion)) |
| 469 | 468 | for (prom = rom_first_file(pregion); prom != NULL; prom = rom_next_file(prom)) |
| 470 | 469 | if (hash_data_is_equal(ROM_GETHASHDATA(rom), ROM_GETHASHDATA(prom), 0)) |
| 471 | 470 | { |
| r9023 | r9024 | |
| 484 | 483 | the XML output |
| 485 | 484 | -------------------------------------------------*/ |
| 486 | 485 | |
| 487 | | static void print_game_rom(FILE *out, const game_driver *game, const machine_config *config) |
| 486 | static void print_game_rom(FILE *out, const game_driver *game, const machine_config &config) |
| 488 | 487 | { |
| 489 | 488 | const game_driver *clone_of = driver_get_clone(game); |
| 490 | 489 | int rom_type; |
| r9023 | r9024 | |
| 504 | 503 | const rom_entry *region; |
| 505 | 504 | |
| 506 | 505 | /* iterate over ROM sources: first the game, then any devices */ |
| 507 | | for (source = rom_first_source(game, config); source != NULL; source = rom_next_source(game, config, source)) |
| 508 | | for (region = rom_first_region(game, source); region != NULL; region = rom_next_region(region)) |
| 506 | for (source = rom_first_source(config); source != NULL; source = rom_next_source(*source)) |
| 507 | for (region = rom_first_region(*source); region != NULL; region = rom_next_region(region)) |
| 509 | 508 | { |
| 510 | 509 | int is_disk = ROMREGION_ISDISKDATA(region); |
| 511 | 510 | const rom_entry *rom; |
| r9023 | r9024 | |
| 611 | 610 | attribute, if appropriate |
| 612 | 611 | -------------------------------------------------*/ |
| 613 | 612 | |
| 614 | | static void print_game_sampleof(FILE *out, const game_driver *game, const machine_config *config) |
| 613 | static void print_game_sampleof(FILE *out, const game_driver *game, const machine_config &config) |
| 615 | 614 | { |
| 616 | 615 | const device_config_sound_interface *sound = NULL; |
| 617 | 616 | |
| 618 | | for (bool gotone = config->m_devicelist.first(sound); gotone; gotone = sound->next(sound)) |
| 617 | for (bool gotone = config.m_devicelist.first(sound); gotone; gotone = sound->next(sound)) |
| 619 | 618 | if (sound->devconfig().type() == SAMPLES) |
| 620 | 619 | { |
| 621 | 620 | const char *const *samplenames = ((const samples_interface *)sound->devconfig().static_config())->samplenames; |
| r9023 | r9024 | |
| 642 | 641 | samples referenced by a game_driver |
| 643 | 642 | -------------------------------------------------*/ |
| 644 | 643 | |
| 645 | | static void print_game_sample(FILE *out, const game_driver *game, const machine_config *config) |
| 644 | static void print_game_sample(FILE *out, const game_driver *game, const machine_config &config) |
| 646 | 645 | { |
| 647 | 646 | const device_config_sound_interface *sound = NULL; |
| 648 | 647 | |
| 649 | 648 | /* iterate over sound chips looking for samples */ |
| 650 | | for (bool gotone = config->m_devicelist.first(sound); gotone; gotone = sound->next(sound)) |
| 649 | for (bool gotone = config.m_devicelist.first(sound); gotone; gotone = sound->next(sound)) |
| 651 | 650 | if (sound->devconfig().type() == SAMPLES) |
| 652 | 651 | { |
| 653 | 652 | const char *const *samplenames = ((const samples_interface *)sound->devconfig().static_config())->samplenames; |
| r9023 | r9024 | |
| 685 | 684 | sound chips used by a game |
| 686 | 685 | -------------------------------------------------*/ |
| 687 | 686 | |
| 688 | | static void print_game_chips(FILE *out, const game_driver *game, const machine_config *config) |
| 687 | static void print_game_chips(FILE *out, const game_driver *game, const machine_config &config) |
| 689 | 688 | { |
| 690 | 689 | /* iterate over CPUs */ |
| 691 | 690 | const device_config_execute_interface *exec = NULL; |
| 692 | | for (bool gotone = config->m_devicelist.first(exec); gotone; gotone = exec->next(exec)) |
| 691 | for (bool gotone = config.m_devicelist.first(exec); gotone; gotone = exec->next(exec)) |
| 693 | 692 | { |
| 694 | 693 | fprintf(out, "\t\t<chip"); |
| 695 | 694 | fprintf(out, " type=\"cpu\""); |
| r9023 | r9024 | |
| 701 | 700 | |
| 702 | 701 | /* iterate over sound chips */ |
| 703 | 702 | const device_config_sound_interface *sound = NULL; |
| 704 | | for (bool gotone = config->m_devicelist.first(sound); gotone; gotone = sound->next(sound)) |
| 703 | for (bool gotone = config.m_devicelist.first(sound); gotone; gotone = sound->next(sound)) |
| 705 | 704 | { |
| 706 | 705 | fprintf(out, "\t\t<chip"); |
| 707 | 706 | fprintf(out, " type=\"audio\""); |
| r9023 | r9024 | |
| 719 | 718 | displays |
| 720 | 719 | -------------------------------------------------*/ |
| 721 | 720 | |
| 722 | | static void print_game_display(FILE *out, const game_driver *game, const machine_config *config) |
| 721 | static void print_game_display(FILE *out, const game_driver *game, const machine_config &config) |
| 723 | 722 | { |
| 724 | 723 | const screen_device_config *devconfig; |
| 725 | 724 | |
| 726 | 725 | /* iterate over screens */ |
| 727 | | for (devconfig = screen_first(*config); devconfig != NULL; devconfig = screen_next(devconfig)) |
| 726 | for (devconfig = screen_first(config); devconfig != NULL; devconfig = screen_next(devconfig)) |
| 728 | 727 | { |
| 729 | 728 | fprintf(out, "\t\t<display"); |
| 730 | 729 | |
| r9023 | r9024 | |
| 803 | 802 | displays |
| 804 | 803 | -------------------------------------------------*/ |
| 805 | 804 | |
| 806 | | static void print_game_sound(FILE *out, const game_driver *game, const machine_config *config) |
| 805 | static void print_game_sound(FILE *out, const game_driver *game, const machine_config &config) |
| 807 | 806 | { |
| 808 | | int speakers = speaker_output_count(config); |
| 807 | int speakers = speaker_output_count(&config); |
| 809 | 808 | |
| 810 | 809 | /* if we have no sound, zero out the speaker count */ |
| 811 | 810 | const device_config_sound_interface *sound = NULL; |
| 812 | | if (!config->m_devicelist.first(sound)) |
| 811 | if (!config.m_devicelist.first(sound)) |
| 813 | 812 | speakers = 0; |
| 814 | 813 | |
| 815 | 814 | fprintf(out, "\t\t<sound channels=\"%d\"/>\n", speakers); |
| r9023 | r9024 | |
| 820 | 819 | print_game_driver - print driver status |
| 821 | 820 | -------------------------------------------------*/ |
| 822 | 821 | |
| 823 | | static void print_game_driver(FILE *out, const game_driver *game, const machine_config *config) |
| 822 | static void print_game_driver(FILE *out, const game_driver *game, const machine_config &config) |
| 824 | 823 | { |
| 825 | 824 | fprintf(out, "\t\t<driver"); |
| 826 | 825 | |
| r9023 | r9024 | |
| 874 | 873 | else |
| 875 | 874 | fprintf(out, " savestate=\"unsupported\""); |
| 876 | 875 | |
| 877 | | fprintf(out, " palettesize=\"%d\"", config->m_total_colors); |
| 876 | fprintf(out, " palettesize=\"%d\"", config.m_total_colors); |
| 878 | 877 | |
| 879 | 878 | fprintf(out, "/>\n"); |
| 880 | 879 | } |
| r9023 | r9024 | |
| 918 | 917 | image devices |
| 919 | 918 | -------------------------------------------------*/ |
| 920 | 919 | |
| 921 | | static void print_game_images(FILE *out, const game_driver *game, const machine_config *config) |
| 920 | static void print_game_images(FILE *out, const game_driver *game, const machine_config &config) |
| 922 | 921 | { |
| 923 | 922 | const device_config_image_interface *dev = NULL; |
| 924 | 923 | const char *name; |
| 925 | 924 | const char *shortname; |
| 926 | 925 | |
| 927 | | for (bool gotone = config->m_devicelist.first(dev); gotone; gotone = dev->next(dev)) |
| 926 | for (bool gotone = config.m_devicelist.first(dev); gotone; gotone = dev->next(dev)) |
| 928 | 927 | { |
| 929 | 928 | /* print out device type */ |
| 930 | 929 | fprintf(out, "\t\t<device type=\"%s\"", xml_normalize_string(dev->image_type_name())); |
| r9023 | r9024 | |
| 971 | 970 | for all known software lists for this system |
| 972 | 971 | -------------------------------------------------*/ |
| 973 | 972 | |
| 974 | | static void print_game_software_list(FILE *out, const game_driver *game, const machine_config *config) |
| 973 | static void print_game_software_list(FILE *out, const game_driver *game, const machine_config &config) |
| 975 | 974 | { |
| 976 | | for (const device_config *dev = config->m_devicelist.first(SOFTWARE_LIST); dev != NULL; dev = dev->typenext()) |
| 975 | for (const device_config *dev = config.m_devicelist.first(SOFTWARE_LIST); dev != NULL; dev = dev->typenext()) |
| 977 | 976 | { |
| 978 | 977 | software_list_config *swlist = (software_list_config *)downcast<const legacy_device_config_base *>(dev)->inline_config(); |
| 979 | 978 | |
| r9023 | r9024 | |
| 996 | 995 | static void print_game_info(FILE *out, const game_driver *game) |
| 997 | 996 | { |
| 998 | 997 | const game_driver *clone_of; |
| 999 | | machine_config *config; |
| 998 | machine_config config(*game); |
| 1000 | 999 | ioport_list portlist; |
| 1001 | 1000 | const char *start; |
| 1002 | 1001 | |
| r9023 | r9024 | |
| 1005 | 1004 | return; |
| 1006 | 1005 | |
| 1007 | 1006 | /* start tracking resources and allocate the machine and input configs */ |
| 1008 | | config = global_alloc(machine_config(game->machine_config)); |
| 1009 | 1007 | input_port_list_init(portlist, game->ipt, NULL, 0, FALSE); |
| 1010 | 1008 | |
| 1011 | 1009 | /* print the header and the game name */ |
| r9023 | r9024 | |
| 1070 | 1068 | |
| 1071 | 1069 | /* close the topmost tag */ |
| 1072 | 1070 | fprintf(out, "\t</" XML_TOP ">\n"); |
| 1073 | | |
| 1074 | | global_free(config); |
| 1075 | 1071 | } |
| 1076 | 1072 | |
| 1077 | 1073 | |