270
269
const game_driver *driver = drivers[drivnum];
272
271
/* fill in the quark with hashes of the strings */
273
quark_add(source_table, drivnum, quark_string_crc(driver->source_file));
274
quark_add(name_table, drivnum, quark_string_crc(driver->name));
275
quark_add(description_table, drivnum, quark_string_crc(driver->description));
272
quark_add(tables->source, drivnum, quark_string_crc(driver->source_file));
273
quark_add(tables->name, drivnum, quark_string_crc(driver->name));
274
quark_add(tables->description, drivnum, quark_string_crc(driver->description));
277
276
/* only track actual driver ROM entries */
278
277
if (driver->rom && (driver->flags & GAME_NO_STANDALONE) == 0)
279
quark_add(roms_table, drivnum, (FPTR)driver->rom);
278
quark_add(tables->roms, drivnum, (FPTR)driver->rom);
282
281
/* allocate memory for a quark table of strings */
283
defstr_table = quark_table_alloc(INPUT_STRING_COUNT, 97);
282
tables->defstr = quark_table_alloc(INPUT_STRING_COUNT, 97);
285
284
/* add all the default strings */
286
285
for (strnum = 1; strnum < INPUT_STRING_COUNT; strnum++)
288
287
const char *string = input_port_string_from_index(strnum);
289
288
if (string != NULL)
290
quark_add(defstr_table, strnum, quark_string_crc(string));
289
quark_add(tables->defstr, strnum, quark_string_crc(string));
771
776
if (cpu_validity_check != NULL && (*cpu_validity_check)(driver, device->static_config))
774
/* loop over all address spaces */
775
for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++)
777
#define SPACE_SHIFT(a) ((addr_shift < 0) ? ((a) << -addr_shift) : ((a) >> addr_shift))
778
#define SPACE_SHIFT_END(a) ((addr_shift < 0) ? (((a) << -addr_shift) | ((1 << -addr_shift) - 1)) : ((a) >> addr_shift))
779
int databus_width = cpu_get_databus_width(device, spacenum);
780
int addr_shift = cpu_get_addrbus_shift(device, spacenum);
781
int alignunit = databus_width/8;
782
address_map_entry *entry;
785
/* construct the maps */
786
map = address_map_alloc(device, driver, spacenum);
788
/* if this is an empty map, just skip it */
789
if (map->entrylist == NULL)
791
address_map_free(map);
795
/* validate the global map parameters */
796
if (map->spacenum != spacenum)
798
mame_printf_error("%s: %s CPU '%s' space %d has address space %d handlers!\n", driver->source_file, driver->name, device->tag, spacenum, map->spacenum);
801
if (map->databits != databus_width)
803
mame_printf_error("%s: %s cpu '%s' uses wrong memory handlers for %s space! (width = %d, memory = %08x)\n", driver->source_file, driver->name, device->tag, address_space_names[spacenum], databus_width, map->databits);
807
/* loop over entries and look for errors */
808
for (entry = map->entrylist; entry != NULL; entry = entry->next)
810
UINT32 bytestart = SPACE_SHIFT(entry->addrstart);
811
UINT32 byteend = SPACE_SHIFT_END(entry->addrend);
813
/* look for inverted start/end pairs */
814
if (byteend < bytestart)
816
mame_printf_error("%s: %s wrong %s memory read handler start = %08x > end = %08x\n", driver->source_file, driver->name, address_space_names[spacenum], entry->addrstart, entry->addrend);
820
/* look for misaligned entries */
821
if ((bytestart & (alignunit - 1)) != 0 || (byteend & (alignunit - 1)) != (alignunit - 1))
823
mame_printf_error("%s: %s wrong %s memory read handler start = %08x, end = %08x ALIGN = %d\n", driver->source_file, driver->name, address_space_names[spacenum], entry->addrstart, entry->addrend, alignunit);
827
/* if this is a program space, auto-assign implicit ROM entries */
828
if ((FPTR)entry->read.generic == STATIC_ROM && entry->region == NULL)
830
entry->region = device->tag;
831
entry->rgnoffs = entry->addrstart;
834
/* if this entry references a memory region, validate it */
835
if (entry->region != NULL && entry->share == 0)
839
/* loop over entries in the class */
840
for (rgnnum = 0; rgnnum < ARRAY_LENGTH(rgninfo->entries); rgnnum++)
842
/* stop if we hit an empty */
843
if (rgninfo->entries[rgnnum].tag == NULL)
845
mame_printf_error("%s: %s CPU '%s' %s space memory map entry %X-%X references non-existant region '%s'\n", driver->source_file, driver->name, device->tag, address_space_names[spacenum], entry->addrstart, entry->addrend, entry->region);
850
/* if we hit a match, check against the length */
851
if (astring_cmpc(rgninfo->entries[rgnnum].tag, entry->region) == 0)
853
offs_t length = rgninfo->entries[rgnnum].length;
854
if (entry->rgnoffs + (byteend - bytestart + 1) > length)
856
mame_printf_error("%s: %s CPU '%s' %s space memory map entry %X-%X extends beyond region '%s' size (%X)\n", driver->source_file, driver->name, device->tag, address_space_names[spacenum], entry->addrstart, entry->addrend, entry->region, length);
864
/* make sure all devices exist */
865
if (entry->read_devtag != NULL && device_list_find_by_tag(config->devicelist, entry->read_devtag) == NULL)
867
mame_printf_error("%s: %s CPU '%s' %s space memory map entry references nonexistant device '%s'\n", driver->source_file, driver->name, device->tag, address_space_names[spacenum], entry->read_devtag);
870
if (entry->write_devtag != NULL && device_list_find_by_tag(config->devicelist, entry->write_devtag) == NULL)
872
mame_printf_error("%s: %s CPU '%s' %s space memory map entry references nonexistant device '%s'\n", driver->source_file, driver->name, device->tag, address_space_names[spacenum], entry->write_devtag);
876
/* make sure ports exist */
877
if (entry->read_porttag != NULL && input_port_by_tag(portlist, entry->read_porttag) == NULL)
879
mame_printf_error("%s: %s CPU '%s' %s space memory map entry references nonexistant port tag '%s'\n", driver->source_file, driver->name, device->tag, address_space_names[spacenum], entry->read_porttag);
884
/* release the address map */
885
address_map_free(map);
887
/* validate the interrupts */
888
if (cpuconfig->vblank_interrupt != NULL)
890
if (video_screen_count(config) == 0)
892
mame_printf_error("%s: %s cpu '%s' has a VBLANK interrupt, but the driver is screenless !\n", driver->source_file, driver->name, device->tag);
895
else if (cpuconfig->vblank_interrupt_screen != NULL && cpuconfig->vblank_interrupts_per_frame != 0)
897
mame_printf_error("%s: %s cpu '%s' has a new VBLANK interrupt handler with >1 interrupts!\n", driver->source_file, driver->name, device->tag);
900
else if (cpuconfig->vblank_interrupt_screen != NULL && device_list_find_by_tag(config->devicelist, cpuconfig->vblank_interrupt_screen) == NULL)
902
mame_printf_error("%s: %s cpu '%s' VBLANK interrupt with a non-existant screen tag (%s)!\n", driver->source_file, driver->name, device->tag, cpuconfig->vblank_interrupt_screen);
905
else if (cpuconfig->vblank_interrupt_screen == NULL && cpuconfig->vblank_interrupts_per_frame == 0)
907
mame_printf_error("%s: %s cpu '%s' has a VBLANK interrupt handler with 0 interrupts!\n", driver->source_file, driver->name, device->tag);
911
else if (cpuconfig->vblank_interrupts_per_frame != 0)
913
mame_printf_error("%s: %s cpu '%s' has no VBLANK interrupt handler but a non-0 interrupt count is given!\n", driver->source_file, driver->name, device->tag);
917
if (cpuconfig->timed_interrupt != NULL && cpuconfig->timed_interrupt_period == 0)
919
mame_printf_error("%s: %s cpu '%s' has a timer interrupt handler with 0 period!\n", driver->source_file, driver->name, device->tag);
922
else if (cpuconfig->timed_interrupt == NULL && cpuconfig->timed_interrupt_period != 0)
924
mame_printf_error("%s: %s cpu '%s' has a no timer interrupt handler but has a non-0 period given!\n", driver->source_file, driver->name, device->tag);
779
/* validate the interrupts */
780
if (cpuconfig->vblank_interrupt != NULL)
782
if (video_screen_count(config) == 0)
784
mame_printf_error("%s: %s cpu '%s' has a VBLANK interrupt, but the driver is screenless !\n", driver->source_file, driver->name, device->tag);
787
else if (cpuconfig->vblank_interrupt_screen != NULL && cpuconfig->vblank_interrupts_per_frame != 0)
789
mame_printf_error("%s: %s cpu '%s' has a new VBLANK interrupt handler with >1 interrupts!\n", driver->source_file, driver->name, device->tag);
792
else if (cpuconfig->vblank_interrupt_screen != NULL && device_list_find_by_tag(config->devicelist, cpuconfig->vblank_interrupt_screen) == NULL)
794
mame_printf_error("%s: %s cpu '%s' VBLANK interrupt with a non-existant screen tag (%s)!\n", driver->source_file, driver->name, device->tag, cpuconfig->vblank_interrupt_screen);
797
else if (cpuconfig->vblank_interrupt_screen == NULL && cpuconfig->vblank_interrupts_per_frame == 0)
799
mame_printf_error("%s: %s cpu '%s' has a VBLANK interrupt handler with 0 interrupts!\n", driver->source_file, driver->name, device->tag);
803
else if (cpuconfig->vblank_interrupts_per_frame != 0)
805
mame_printf_error("%s: %s cpu '%s' has no VBLANK interrupt handler but a non-0 interrupt count is given!\n", driver->source_file, driver->name, device->tag);
809
if (cpuconfig->timed_interrupt != NULL && cpuconfig->timed_interrupt_period == 0)
811
mame_printf_error("%s: %s cpu '%s' has a timer interrupt handler with 0 period!\n", driver->source_file, driver->name, device->tag);
814
else if (cpuconfig->timed_interrupt == NULL && cpuconfig->timed_interrupt_period != 0)
816
mame_printf_error("%s: %s cpu '%s' has a no timer interrupt handler but has a non-0 period given!\n", driver->source_file, driver->name, device->tag);
1580
1472
/* call the device-specific validity check */
1581
1473
if (validity_check != NULL && (*validity_check)(driver, device))
1476
/* loop over all address spaces */
1477
for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++)
1479
#define SPACE_SHIFT(a) ((addr_shift < 0) ? ((a) << -addr_shift) : ((a) >> addr_shift))
1480
#define SPACE_SHIFT_END(a) ((addr_shift < 0) ? (((a) << -addr_shift) | ((1 << -addr_shift) - 1)) : ((a) >> addr_shift))
1481
int databus_width = device_get_databus_width(device, spacenum);
1482
int addr_shift = device_get_addrbus_shift(device, spacenum);
1483
int alignunit = databus_width/8;
1484
address_map_entry *entry;
1487
/* construct the maps */
1488
map = address_map_alloc(device, driver, spacenum);
1490
/* if this is an empty map, just skip it */
1491
if (map->entrylist == NULL)
1493
address_map_free(map);
1497
/* validate the global map parameters */
1498
if (map->spacenum != spacenum)
1500
mame_printf_error("%s: %s device '%s' space %d has address space %d handlers!\n", driver->source_file, driver->name, device->tag, spacenum, map->spacenum);
1503
if (map->databits != databus_width)
1505
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, address_space_names[spacenum], databus_width, map->databits);
1509
/* loop over entries and look for errors */
1510
for (entry = map->entrylist; entry != NULL; entry = entry->next)
1512
UINT32 bytestart = SPACE_SHIFT(entry->addrstart);
1513
UINT32 byteend = SPACE_SHIFT_END(entry->addrend);
1515
/* look for inverted start/end pairs */
1516
if (byteend < bytestart)
1518
mame_printf_error("%s: %s wrong %s memory read handler start = %08x > end = %08x\n", driver->source_file, driver->name, address_space_names[spacenum], entry->addrstart, entry->addrend);
1522
/* look for misaligned entries */
1523
if ((bytestart & (alignunit - 1)) != 0 || (byteend & (alignunit - 1)) != (alignunit - 1))
1525
mame_printf_error("%s: %s wrong %s memory read handler start = %08x, end = %08x ALIGN = %d\n", driver->source_file, driver->name, address_space_names[spacenum], entry->addrstart, entry->addrend, alignunit);
1529
/* if this is a program space, auto-assign implicit ROM entries */
1530
if ((FPTR)entry->read.generic == STATIC_ROM && entry->region == NULL)
1532
entry->region = device->tag;
1533
entry->rgnoffs = entry->addrstart;
1536
/* if this entry references a memory region, validate it */
1537
if (entry->region != NULL && entry->share == 0)
1541
/* loop over entries in the class */
1542
for (rgnnum = 0; rgnnum < ARRAY_LENGTH(rgninfo->entries); rgnnum++)
1544
/* stop if we hit an empty */
1545
if (rgninfo->entries[rgnnum].tag == NULL)
1547
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, address_space_names[spacenum], entry->addrstart, entry->addrend, entry->region);
1552
/* if we hit a match, check against the length */
1553
if (astring_cmpc(rgninfo->entries[rgnnum].tag, entry->region) == 0)
1555
offs_t length = rgninfo->entries[rgnnum].length;
1556
if (entry->rgnoffs + (byteend - bytestart + 1) > length)
1558
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, address_space_names[spacenum], entry->addrstart, entry->addrend, entry->region, length);
1566
/* make sure all devices exist */
1567
if (entry->read_devtag != NULL && device_list_find_by_tag(config->devicelist, entry->read_devtag) == NULL)
1569
mame_printf_error("%s: %s device '%s' %s space memory map entry references nonexistant device '%s'\n", driver->source_file, driver->name, device->tag, address_space_names[spacenum], entry->read_devtag);
1572
if (entry->write_devtag != NULL && device_list_find_by_tag(config->devicelist, entry->write_devtag) == NULL)
1574
mame_printf_error("%s: %s device '%s' %s space memory map entry references nonexistant device '%s'\n", driver->source_file, driver->name, device->tag, address_space_names[spacenum], entry->write_devtag);
1578
/* make sure ports exist */
1579
if (entry->read_porttag != NULL && input_port_by_tag(portlist, entry->read_porttag) == NULL)
1581
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, address_space_names[spacenum], entry->read_porttag);
1586
/* release the address map */
1587
address_map_free(map);
1663
1670
memset(&rgninfo, 0, sizeof(rgninfo));
1665
1672
/* expand the machine driver */
1666
expansion -= osd_profiling_ticks();
1673
expansion -= get_profile_ticks();
1667
1674
config = machine_config_alloc(driver->machine_config);
1668
expansion += osd_profiling_ticks();
1675
expansion += get_profile_ticks();
1670
1677
/* validate the driver entry */
1671
driver_checks -= osd_profiling_ticks();
1672
error = validate_driver(drivnum, config) || error;
1673
driver_checks += osd_profiling_ticks();
1678
driver_checks -= get_profile_ticks();
1679
error = validate_driver(drivnum, config, &tables) || error;
1680
driver_checks += get_profile_ticks();
1675
1682
/* validate the ROM information */
1676
rom_checks -= osd_profiling_ticks();
1683
rom_checks -= get_profile_ticks();
1677
1684
error = validate_roms(drivnum, config, &rgninfo) || error;
1678
rom_checks += osd_profiling_ticks();
1685
rom_checks += get_profile_ticks();
1680
1687
/* validate input ports */
1681
input_checks -= osd_profiling_ticks();
1682
error = validate_inputs(drivnum, config, &portlist) || error;
1683
input_checks += osd_profiling_ticks();
1688
input_checks -= get_profile_ticks();
1689
error = validate_inputs(drivnum, config, tables.defstr, &portlist) || error;
1690
input_checks += get_profile_ticks();
1685
1692
/* validate the CPU information */
1686
cpu_checks -= osd_profiling_ticks();
1687
error = validate_cpu(drivnum, config, portlist, &rgninfo) || error;
1688
cpu_checks += osd_profiling_ticks();
1693
cpu_checks -= get_profile_ticks();
1694
error = validate_cpu(drivnum, config) || error;
1695
cpu_checks += get_profile_ticks();
1690
1697
/* validate the display */
1691
display_checks -= osd_profiling_ticks();
1698
display_checks -= get_profile_ticks();
1692
1699
error = validate_display(drivnum, config) || error;
1693
display_checks += osd_profiling_ticks();
1700
display_checks += get_profile_ticks();
1695
1702
/* validate the graphics decoding */
1696
gfx_checks -= osd_profiling_ticks();
1703
gfx_checks -= get_profile_ticks();
1697
1704
error = validate_gfx(drivnum, config, &rgninfo) || error;
1698
gfx_checks += osd_profiling_ticks();
1705
gfx_checks += get_profile_ticks();
1700
1707
/* validate sounds and speakers */
1701
sound_checks -= osd_profiling_ticks();
1708
sound_checks -= get_profile_ticks();
1702
1709
error = validate_sound(drivnum, config) || error;
1703
sound_checks += osd_profiling_ticks();
1710
sound_checks += get_profile_ticks();
1705
1712
/* validate devices */
1706
device_checks -= osd_profiling_ticks();
1707
error = validate_devices(drivnum, config) || error;
1708
device_checks += osd_profiling_ticks();
1713
device_checks -= get_profile_ticks();
1714
error = validate_devices(drivnum, config, portlist, &rgninfo) || error;
1715
device_checks += get_profile_ticks();
1710
1717
for (rgnnum = 0; rgnnum < ARRAY_LENGTH(rgninfo.entries); rgnnum++)
1711
1718
if (rgninfo.entries[rgnnum].tag != NULL)