summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/validity.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/emu/validity.c')
-rw-r--r--src/emu/validity.c616
1 files changed, 142 insertions, 474 deletions
diff --git a/src/emu/validity.c b/src/emu/validity.c
index b450b8fb00a..598fcc506f2 100644
--- a/src/emu/validity.c
+++ b/src/emu/validity.c
@@ -21,7 +21,6 @@
***************************************************************************/
#define REPORT_TIMES (0)
-#define DETECT_OVERLAPPING_MEMORY (0)
@@ -87,12 +86,12 @@ INLINE const char *input_port_string_from_index(UINT32 index)
meets the general requirements
-------------------------------------------------*/
-INLINE int validate_tag(const game_driver *driver, const char *object, const char *tag)
+bool validate_tag(const game_driver *driver, const char *object, const char *tag)
{
const char *validchars = "abcdefghijklmnopqrstuvwxyz0123456789_.:";
const char *begin = strrchr(tag, ':');
const char *p;
- int error = FALSE;
+ bool error = false;
/* some common names that are now deprecated */
if (strcmp(tag, "main") == 0 ||
@@ -102,7 +101,7 @@ INLINE int validate_tag(const game_driver *driver, const char *object, const cha
strcmp(tag, "right") == 0)
{
mame_printf_error("%s: %s has invalid generic tag '%s'\n", driver->source_file, driver->name, tag);
- error = TRUE;
+ error = true;
}
for (p = tag; *p != 0; p++)
@@ -110,19 +109,19 @@ INLINE int validate_tag(const game_driver *driver, const char *object, const cha
if (*p != tolower((UINT8)*p))
{
mame_printf_error("%s: %s has %s with tag '%s' containing upper-case characters\n", driver->source_file, driver->name, object, tag);
- error = TRUE;
+ error = true;
break;
}
if (*p == ' ')
{
mame_printf_error("%s: %s has %s with tag '%s' containing spaces\n", driver->source_file, driver->name, object, tag);
- error = TRUE;
+ error = true;
break;
}
if (strchr(validchars, *p) == NULL)
{
mame_printf_error("%s: %s has %s with tag '%s' containing invalid character '%c'\n", driver->source_file, driver->name, object, tag, *p);
- error = TRUE;
+ error = true;
break;
}
}
@@ -135,20 +134,20 @@ INLINE int validate_tag(const game_driver *driver, const char *object, const cha
if (strlen(begin) == 0)
{
mame_printf_error("%s: %s has %s with 0-length tag\n", driver->source_file, driver->name, object);
- error = TRUE;
+ error = true;
}
if (strlen(begin) < MIN_TAG_LENGTH)
{
mame_printf_error("%s: %s has %s with tag '%s' < %d characters\n", driver->source_file, driver->name, object, tag, MIN_TAG_LENGTH);
- error = TRUE;
+ error = true;
}
if (strlen(begin) > MAX_TAG_LENGTH)
{
mame_printf_error("%s: %s has %s with tag '%s' > %d characters\n", driver->source_file, driver->name, object, tag, MAX_TAG_LENGTH);
- error = TRUE;
+ error = true;
}
- return error;
+ return !error;
}
@@ -162,7 +161,7 @@ INLINE int validate_tag(const game_driver *driver, const char *object, const cha
behaviors
-------------------------------------------------*/
-static int validate_inlines(void)
+static bool validate_inlines(void)
{
#undef rand
volatile UINT64 testu64a = rand() ^ (rand() << 15) ^ ((UINT64)rand() << 30) ^ ((UINT64)rand() << 45);
@@ -180,7 +179,7 @@ static int validate_inlines(void)
UINT64 resultu64, expectedu64;
INT32 remainder, expremainder;
UINT32 uremainder, expuremainder, bigu32 = 0xffffffff;
- int error = FALSE;
+ bool error = false;
/* use only non-zero, positive numbers */
if (testu64a == 0) testu64a++;
@@ -200,32 +199,32 @@ static int validate_inlines(void)
resulti64 = mul_32x32(testi32a, testi32b);
expectedi64 = (INT64)testi32a * (INT64)testi32b;
if (resulti64 != expectedi64)
- { mame_printf_error("Error testing mul_32x32 (%08X x %08X) = %08X%08X (expected %08X%08X)\n", testi32a, testi32b, (UINT32)(resulti64 >> 32), (UINT32)resulti64, (UINT32)(expectedi64 >> 32), (UINT32)expectedi64); error = TRUE; }
+ { mame_printf_error("Error testing mul_32x32 (%08X x %08X) = %08X%08X (expected %08X%08X)\n", testi32a, testi32b, (UINT32)(resulti64 >> 32), (UINT32)resulti64, (UINT32)(expectedi64 >> 32), (UINT32)expectedi64); error = true; }
resultu64 = mulu_32x32(testu32a, testu32b);
expectedu64 = (UINT64)testu32a * (UINT64)testu32b;
if (resultu64 != expectedu64)
- { mame_printf_error("Error testing mulu_32x32 (%08X x %08X) = %08X%08X (expected %08X%08X)\n", testu32a, testu32b, (UINT32)(resultu64 >> 32), (UINT32)resultu64, (UINT32)(expectedu64 >> 32), (UINT32)expectedu64); error = TRUE; }
+ { mame_printf_error("Error testing mulu_32x32 (%08X x %08X) = %08X%08X (expected %08X%08X)\n", testu32a, testu32b, (UINT32)(resultu64 >> 32), (UINT32)resultu64, (UINT32)(expectedu64 >> 32), (UINT32)expectedu64); error = true; }
resulti32 = mul_32x32_hi(testi32a, testi32b);
expectedi32 = ((INT64)testi32a * (INT64)testi32b) >> 32;
if (resulti32 != expectedi32)
- { mame_printf_error("Error testing mul_32x32_hi (%08X x %08X) = %08X (expected %08X)\n", testi32a, testi32b, resulti32, expectedi32); error = TRUE; }
+ { mame_printf_error("Error testing mul_32x32_hi (%08X x %08X) = %08X (expected %08X)\n", testi32a, testi32b, resulti32, expectedi32); error = true; }
resultu32 = mulu_32x32_hi(testu32a, testu32b);
expectedu32 = ((INT64)testu32a * (INT64)testu32b) >> 32;
if (resultu32 != expectedu32)
- { mame_printf_error("Error testing mulu_32x32_hi (%08X x %08X) = %08X (expected %08X)\n", testu32a, testu32b, resultu32, expectedu32); error = TRUE; }
+ { mame_printf_error("Error testing mulu_32x32_hi (%08X x %08X) = %08X (expected %08X)\n", testu32a, testu32b, resultu32, expectedu32); error = true; }
resulti32 = mul_32x32_shift(testi32a, testi32b, 7);
expectedi32 = ((INT64)testi32a * (INT64)testi32b) >> 7;
if (resulti32 != expectedi32)
- { mame_printf_error("Error testing mul_32x32_shift (%08X x %08X) >> 7 = %08X (expected %08X)\n", testi32a, testi32b, resulti32, expectedi32); error = TRUE; }
+ { mame_printf_error("Error testing mul_32x32_shift (%08X x %08X) >> 7 = %08X (expected %08X)\n", testi32a, testi32b, resulti32, expectedi32); error = true; }
resultu32 = mulu_32x32_shift(testu32a, testu32b, 7);
expectedu32 = ((INT64)testu32a * (INT64)testu32b) >> 7;
if (resultu32 != expectedu32)
- { mame_printf_error("Error testing mulu_32x32_shift (%08X x %08X) >> 7 = %08X (expected %08X)\n", testu32a, testu32b, resultu32, expectedu32); error = TRUE; }
+ { mame_printf_error("Error testing mulu_32x32_shift (%08X x %08X) >> 7 = %08X (expected %08X)\n", testu32a, testu32b, resultu32, expectedu32); error = true; }
while ((INT64)testi32a * (INT64)0x7fffffff < testi64a)
testi64a /= 2;
@@ -235,34 +234,34 @@ static int validate_inlines(void)
resulti32 = div_64x32(testi64a, testi32a);
expectedi32 = testi64a / (INT64)testi32a;
if (resulti32 != expectedi32)
- { mame_printf_error("Error testing div_64x32 (%08X%08X / %08X) = %08X (expected %08X)\n", (UINT32)(testi64a >> 32), (UINT32)testi64a, testi32a, resulti32, expectedi32); error = TRUE; }
+ { mame_printf_error("Error testing div_64x32 (%08X%08X / %08X) = %08X (expected %08X)\n", (UINT32)(testi64a >> 32), (UINT32)testi64a, testi32a, resulti32, expectedi32); error = true; }
resultu32 = divu_64x32(testu64a, testu32a);
expectedu32 = testu64a / (UINT64)testu32a;
if (resultu32 != expectedu32)
- { mame_printf_error("Error testing divu_64x32 (%08X%08X / %08X) = %08X (expected %08X)\n", (UINT32)(testu64a >> 32), (UINT32)testu64a, testu32a, resultu32, expectedu32); error = TRUE; }
+ { mame_printf_error("Error testing divu_64x32 (%08X%08X / %08X) = %08X (expected %08X)\n", (UINT32)(testu64a >> 32), (UINT32)testu64a, testu32a, resultu32, expectedu32); error = true; }
resulti32 = div_64x32_rem(testi64a, testi32a, &remainder);
expectedi32 = testi64a / (INT64)testi32a;
expremainder = testi64a % (INT64)testi32a;
if (resulti32 != expectedi32 || remainder != expremainder)
- { mame_printf_error("Error testing div_64x32_rem (%08X%08X / %08X) = %08X,%08X (expected %08X,%08X)\n", (UINT32)(testi64a >> 32), (UINT32)testi64a, testi32a, resulti32, remainder, expectedi32, expremainder); error = TRUE; }
+ { mame_printf_error("Error testing div_64x32_rem (%08X%08X / %08X) = %08X,%08X (expected %08X,%08X)\n", (UINT32)(testi64a >> 32), (UINT32)testi64a, testi32a, resulti32, remainder, expectedi32, expremainder); error = true; }
resultu32 = divu_64x32_rem(testu64a, testu32a, &uremainder);
expectedu32 = testu64a / (UINT64)testu32a;
expuremainder = testu64a % (UINT64)testu32a;
if (resultu32 != expectedu32 || uremainder != expuremainder)
- { mame_printf_error("Error testing divu_64x32_rem (%08X%08X / %08X) = %08X,%08X (expected %08X,%08X)\n", (UINT32)(testu64a >> 32), (UINT32)testu64a, testu32a, resultu32, uremainder, expectedu32, expuremainder); error = TRUE; }
+ { mame_printf_error("Error testing divu_64x32_rem (%08X%08X / %08X) = %08X,%08X (expected %08X,%08X)\n", (UINT32)(testu64a >> 32), (UINT32)testu64a, testu32a, resultu32, uremainder, expectedu32, expuremainder); error = true; }
resulti32 = mod_64x32(testi64a, testi32a);
expectedi32 = testi64a % (INT64)testi32a;
if (resulti32 != expectedi32)
- { mame_printf_error("Error testing mod_64x32 (%08X%08X / %08X) = %08X (expected %08X)\n", (UINT32)(testi64a >> 32), (UINT32)testi64a, testi32a, resulti32, expectedi32); error = TRUE; }
+ { mame_printf_error("Error testing mod_64x32 (%08X%08X / %08X) = %08X (expected %08X)\n", (UINT32)(testi64a >> 32), (UINT32)testi64a, testi32a, resulti32, expectedi32); error = true; }
resultu32 = modu_64x32(testu64a, testu32a);
expectedu32 = testu64a % (UINT64)testu32a;
if (resultu32 != expectedu32)
- { mame_printf_error("Error testing modu_64x32 (%08X%08X / %08X) = %08X (expected %08X)\n", (UINT32)(testu64a >> 32), (UINT32)testu64a, testu32a, resultu32, expectedu32); error = TRUE; }
+ { mame_printf_error("Error testing modu_64x32 (%08X%08X / %08X) = %08X (expected %08X)\n", (UINT32)(testu64a >> 32), (UINT32)testu64a, testu32a, resultu32, expectedu32); error = true; }
while ((INT64)testi32a * (INT64)0x7fffffff < ((INT32)testi64a << 3))
testi64a /= 2;
@@ -272,39 +271,39 @@ static int validate_inlines(void)
resulti32 = div_32x32_shift((INT32)testi64a, testi32a, 3);
expectedi32 = ((INT64)(INT32)testi64a << 3) / (INT64)testi32a;
if (resulti32 != expectedi32)
- { mame_printf_error("Error testing div_32x32_shift (%08X << 3) / %08X = %08X (expected %08X)\n", (INT32)testi64a, testi32a, resulti32, expectedi32); error = TRUE; }
+ { mame_printf_error("Error testing div_32x32_shift (%08X << 3) / %08X = %08X (expected %08X)\n", (INT32)testi64a, testi32a, resulti32, expectedi32); error = true; }
resultu32 = divu_32x32_shift((UINT32)testu64a, testu32a, 3);
expectedu32 = ((UINT64)(UINT32)testu64a << 3) / (UINT64)testu32a;
if (resultu32 != expectedu32)
- { mame_printf_error("Error testing divu_32x32_shift (%08X << 3) / %08X = %08X (expected %08X)\n", (UINT32)testu64a, testu32a, resultu32, expectedu32); error = TRUE; }
+ { mame_printf_error("Error testing divu_32x32_shift (%08X << 3) / %08X = %08X (expected %08X)\n", (UINT32)testu64a, testu32a, resultu32, expectedu32); error = true; }
if (fabs(recip_approx(100.0) - 0.01) > 0.0001)
- { mame_printf_error("Error testing recip_approx\n"); error = TRUE; }
+ { mame_printf_error("Error testing recip_approx\n"); error = true; }
testi32a = (testi32a & 0x0000ffff) | 0x400000;
if (count_leading_zeros(testi32a) != 9)
- { mame_printf_error("Error testing count_leading_zeros\n"); error = TRUE; }
+ { mame_printf_error("Error testing count_leading_zeros\n"); error = true; }
testi32a = (testi32a | 0xffff0000) & ~0x400000;
if (count_leading_ones(testi32a) != 9)
- { mame_printf_error("Error testing count_leading_ones\n"); error = TRUE; }
+ { mame_printf_error("Error testing count_leading_ones\n"); error = true; }
testi32b = testi32a;
if (compare_exchange32(&testi32a, testi32b, 1000) != testi32b || testi32a != 1000)
- { mame_printf_error("Error testing compare_exchange32\n"); error = TRUE; }
+ { mame_printf_error("Error testing compare_exchange32\n"); error = true; }
#ifdef PTR64
testi64b = testi64a;
if (compare_exchange64(&testi64a, testi64b, 1000) != testi64b || testi64a != 1000)
- { mame_printf_error("Error testing compare_exchange64\n"); error = TRUE; }
+ { mame_printf_error("Error testing compare_exchange64\n"); error = true; }
#endif
if (atomic_exchange32(&testi32a, testi32b) != 1000)
- { mame_printf_error("Error testing atomic_exchange32\n"); error = TRUE; }
+ { mame_printf_error("Error testing atomic_exchange32\n"); error = true; }
if (atomic_add32(&testi32a, 45) != testi32b + 45)
- { mame_printf_error("Error testing atomic_add32\n"); error = TRUE; }
+ { mame_printf_error("Error testing atomic_add32\n"); error = true; }
if (atomic_increment32(&testi32a) != testi32b + 46)
- { mame_printf_error("Error testing atomic_increment32\n"); error = TRUE; }
+ { mame_printf_error("Error testing atomic_increment32\n"); error = true; }
if (atomic_decrement32(&testi32a) != testi32b + 45)
- { mame_printf_error("Error testing atomic_decrement32\n"); error = TRUE; }
+ { mame_printf_error("Error testing atomic_decrement32\n"); error = true; }
return error;
}
@@ -315,13 +314,13 @@ static int validate_inlines(void)
information
-------------------------------------------------*/
-static int validate_driver(int drivnum, const machine_config *config, game_driver_map &names, game_driver_map &descriptions)
+static bool validate_driver(int drivnum, const machine_config *config, game_driver_map &names, game_driver_map &descriptions)
{
const game_driver *driver = drivers[drivnum];
const game_driver *clone_of;
const char *compatible_with;
const game_driver *other_drv;
- int error = FALSE, is_clone;
+ bool error = FALSE, is_clone;
const char *s;
enum { NAME_LEN_PARENT = 8, NAME_LEN_CLONE = 16 };
@@ -331,7 +330,7 @@ static int validate_driver(int drivnum, const machine_config *config, game_drive
{
const game_driver *match = names.find(driver->name);
mame_printf_error("%s: %s is a duplicate name (%s, %s)\n", driver->source_file, driver->name, match->source_file, match->name);
- error = TRUE;
+ error = true;
}
/* check for duplicate descriptions */
@@ -339,35 +338,35 @@ static int validate_driver(int drivnum, const machine_config *config, game_drive
{
const game_driver *match = descriptions.find(driver->description);
mame_printf_error("%s: %s is a duplicate description (%s, %s)\n", driver->source_file, driver->description, match->source_file, match->description);
- error = TRUE;
+ error = true;
}
/* determine the clone */
- is_clone = strcmp(driver->parent, "0");
+ is_clone = (strcmp(driver->parent, "0") != 0);
clone_of = driver_get_clone(driver);
if (clone_of && (clone_of->flags & GAME_IS_BIOS_ROOT))
- is_clone = 0;
+ is_clone = false;
/* if we have at least 100 drivers, validate the clone */
/* (100 is arbitrary, but tries to avoid tiny.mak dependencies) */
if (driver_list_get_count(drivers) > 100 && !clone_of && is_clone)
{
mame_printf_error("%s: %s is a non-existant clone\n", driver->source_file, driver->parent);
- error = TRUE;
+ error = true;
}
/* look for recursive cloning */
if (clone_of == driver)
{
mame_printf_error("%s: %s is set as a clone of itself\n", driver->source_file, driver->name);
- error = TRUE;
+ error = true;
}
/* look for clones that are too deep */
if (clone_of != NULL && (clone_of = driver_get_clone(clone_of)) != NULL && (clone_of->flags & GAME_IS_BIOS_ROOT) == 0)
{
mame_printf_error("%s: %s is a clone of a clone\n", driver->source_file, driver->name);
- error = TRUE;
+ error = true;
}
/* make sure the driver name is 8 chars or less */
@@ -375,7 +374,7 @@ static int validate_driver(int drivnum, const machine_config *config, game_drive
{
mame_printf_error("%s: %s %s driver name must be %d characters or less\n", driver->source_file, driver->name,
is_clone ? "clone" : "parent", is_clone ? NAME_LEN_CLONE : NAME_LEN_PARENT);
- error = TRUE;
+ error = true;
}
/* make sure the year is only digits, '?' or '+' */
@@ -383,7 +382,7 @@ static int validate_driver(int drivnum, const machine_config *config, game_drive
if (!isdigit((UINT8)*s) && *s != '?' && *s != '+')
{
mame_printf_error("%s: %s has an invalid year '%s'\n", driver->source_file, driver->name, driver->year);
- error = TRUE;
+ error = true;
break;
}
@@ -396,14 +395,14 @@ static int validate_driver(int drivnum, const machine_config *config, game_drive
if ((compatible_with != NULL) && (driver_get_name(driver->compatible_with) == NULL))
{
mame_printf_error("%s: is compatible with %s, which is not in drivers[]\n", driver->name, driver->compatible_with);
- error = TRUE;
+ error = true;
}
/* check for clone_of and compatible_with being specified at the same time */
if ((driver_get_clone(driver) != NULL) && (compatible_with != NULL))
{
mame_printf_error("%s: both compatible_with and clone_of are specified\n", driver->name);
- error = TRUE;
+ error = true;
}
/* find any recursive dependencies on the current driver */
@@ -412,16 +411,17 @@ static int validate_driver(int drivnum, const machine_config *config, game_drive
if (driver == other_drv)
{
mame_printf_error("%s: recursive compatibility\n", driver->name);
- error = TRUE;
+ error = true;
break;
}
}
/* make sure sound-less drivers are flagged */
- if ((driver->flags & GAME_IS_BIOS_ROOT) == 0 && sound_first(config) == NULL && (driver->flags & GAME_NO_SOUND) == 0 && (driver->flags & GAME_NO_SOUND_HW) == 0)
+ const device_config_sound_interface *sound;
+ if ((driver->flags & GAME_IS_BIOS_ROOT) == 0 && !config->devicelist.first(sound) && (driver->flags & GAME_NO_SOUND) == 0 && (driver->flags & GAME_NO_SOUND_HW) == 0)
{
mame_printf_error("%s: %s missing GAME_NO_SOUND flag\n", driver->source_file, driver->name);
- error = TRUE;
+ error = true;
}
return error;
@@ -432,7 +432,7 @@ static int validate_driver(int drivnum, const machine_config *config, game_drive
validate_roms - validate ROM definitions
-------------------------------------------------*/
-static int validate_roms(int drivnum, const machine_config *config, region_array *rgninfo, game_driver_map &roms)
+static bool validate_roms(int drivnum, const machine_config *config, region_array *rgninfo, game_driver_map &roms)
{
const game_driver *driver = drivers[drivnum];
int bios_flags = 0, last_bios = 0;
@@ -440,7 +440,7 @@ static int validate_roms(int drivnum, const machine_config *config, region_array
const char *last_name = "???";
region_entry *currgn = NULL;
int items_since_region = 1;
- int error = FALSE;
+ bool error = false;
/* check for duplicate ROM entries */
/*
@@ -452,7 +452,7 @@ static int validate_roms(int drivnum, const machine_config *config, region_array
{
const game_driver *match = roms.find(romaddr);
mame_printf_error("%s: %s uses the same ROM set as (%s, %s)\n", driver->source_file, driver->description, match->source_file, match->name);
- error = TRUE;
+ error = true;
}
}
*/
@@ -478,14 +478,14 @@ static int validate_roms(int drivnum, const machine_config *config, region_array
if (regiontag == NULL)
{
mame_printf_error("%s: %s has NULL ROM_REGION tag\n", driver->source_file, driver->name);
- error = TRUE;
+ error = true;
}
/* load by name entries must be 8 characters or less */
else if (ROMREGION_ISLOADBYNAME(romp) && strlen(regiontag) > 8)
{
mame_printf_error("%s: %s has load-by-name region '%s' with name >8 characters\n", driver->source_file, driver->name, regiontag);
- error = TRUE;
+ error = true;
}
/* find any empty entry, checking for duplicates */
@@ -511,14 +511,15 @@ static int validate_roms(int drivnum, const machine_config *config, region_array
if (fulltag.cmp(rgninfo->entries[rgnnum].tag) == 0)
{
mame_printf_error("%s: %s has duplicate ROM_REGION tag '%s'\n", driver->source_file, driver->name, fulltag.cstr());
- error = TRUE;
+ error = true;
break;
}
}
}
/* validate the region tag */
- error |= validate_tag(driver, "region", regiontag);
+ if (!validate_tag(driver, "region", regiontag))
+ error = true;
}
/* If this is a system bios, make sure it is using the next available bios number */
@@ -529,7 +530,7 @@ static int validate_roms(int drivnum, const machine_config *config, region_array
{
const char *name = ROM_GETNAME(romp);
mame_printf_error("%s: %s has non-sequential bios %s\n", driver->source_file, driver->name, name);
- error = TRUE;
+ error = true;
}
last_bios = bios_flags;
}
@@ -550,7 +551,7 @@ static int validate_roms(int drivnum, const machine_config *config, region_array
if (tolower((UINT8)*s) != *s)
{
mame_printf_error("%s: %s has upper case ROM name %s\n", driver->source_file, driver->name, last_name);
- error = TRUE;
+ error = true;
break;
}
@@ -559,7 +560,7 @@ static int validate_roms(int drivnum, const machine_config *config, region_array
if (!hash_verify_string(hash))
{
mame_printf_error("%s: rom '%s' has an invalid hash string '%s'\n", driver->name, last_name, hash);
- error = TRUE;
+ error = true;
}
}
@@ -571,7 +572,7 @@ static int validate_roms(int drivnum, const machine_config *config, region_array
if (ROM_GETOFFSET(romp) + ROM_GETLENGTH(romp) > currgn->length)
{
mame_printf_error("%s: %s has ROM %s extending past the defined memory region\n", driver->source_file, driver->name, last_name);
- error = TRUE;
+ error = true;
}
}
}
@@ -586,142 +587,25 @@ static int validate_roms(int drivnum, const machine_config *config, region_array
/*-------------------------------------------------
- validate_cpu - validate CPUs and memory maps
--------------------------------------------------*/
-
-static int validate_cpu(int drivnum, const machine_config *config)
-{
- const game_driver *driver = drivers[drivnum];
- cpu_validity_check_func cpu_validity_check;
- const device_config *devconfig;
- int error = FALSE;
-
- /* loop over all the CPUs */
- for (devconfig = cpu_first(config); devconfig != NULL; devconfig = cpu_next(devconfig))
- {
- const cpu_config *cpuconfig = (const cpu_config *)devconfig->inline_config;
-
- /* check the CPU for incompleteness */
- if (devconfig->get_config_fct(CPUINFO_FCT_RESET) == NULL ||
- devconfig->get_config_fct(CPUINFO_FCT_EXECUTE) == NULL)
- {
- mame_printf_error("%s: %s uses an incomplete CPU\n", driver->source_file, driver->name);
- error = TRUE;
- continue;
- }
-
- /* check for CPU-specific validity check */
- cpu_validity_check = (cpu_validity_check_func) devconfig->get_config_fct(CPUINFO_FCT_VALIDITY_CHECK);
- if (cpu_validity_check != NULL && (*cpu_validity_check)(driver, devconfig->static_config))
- error = TRUE;
-
- /* validate the interrupts */
- if (cpuconfig->vblank_interrupt != NULL)
- {
- if (video_screen_count(config) == 0)
- {
- mame_printf_error("%s: %s cpu '%s' has a VBLANK interrupt, but the driver is screenless !\n", driver->source_file, driver->name, devconfig->tag());
- error = TRUE;
- }
- else if (cpuconfig->vblank_interrupt_screen != NULL && cpuconfig->vblank_interrupts_per_frame != 0)
- {
- mame_printf_error("%s: %s cpu '%s' has a new VBLANK interrupt handler with >1 interrupts!\n", driver->source_file, driver->name, devconfig->tag());
- error = TRUE;
- }
- else if (cpuconfig->vblank_interrupt_screen != NULL && config->devicelist.find(cpuconfig->vblank_interrupt_screen) == NULL)
- {
- mame_printf_error("%s: %s cpu '%s' VBLANK interrupt with a non-existant screen tag (%s)!\n", driver->source_file, driver->name, devconfig->tag(), cpuconfig->vblank_interrupt_screen);
- error = TRUE;
- }
- else if (cpuconfig->vblank_interrupt_screen == NULL && cpuconfig->vblank_interrupts_per_frame == 0)
- {
- mame_printf_error("%s: %s cpu '%s' has a VBLANK interrupt handler with 0 interrupts!\n", driver->source_file, driver->name, devconfig->tag());
- error = TRUE;
- }
- }
- else if (cpuconfig->vblank_interrupts_per_frame != 0)
- {
- 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, devconfig->tag());
- error = TRUE;
- }
-
- if (cpuconfig->timed_interrupt != NULL && cpuconfig->timed_interrupt_period == 0)
- {
- mame_printf_error("%s: %s cpu '%s' has a timer interrupt handler with 0 period!\n", driver->source_file, driver->name, devconfig->tag());
- error = TRUE;
- }
- else if (cpuconfig->timed_interrupt == NULL && cpuconfig->timed_interrupt_period != 0)
- {
- 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, devconfig->tag());
- error = TRUE;
- }
- }
-
- return error;
-}
-
-
-/*-------------------------------------------------
validate_display - validate display
configurations
-------------------------------------------------*/
-static int validate_display(int drivnum, const machine_config *config)
+static bool validate_display(int drivnum, const machine_config *config)
{
const game_driver *driver = drivers[drivnum];
- const device_config *devconfig;
- int palette_modes = FALSE;
- int error = FALSE;
-
- /* loop over screens */
- for (devconfig = video_screen_first(config); devconfig != NULL; devconfig = video_screen_next(devconfig))
- {
- const screen_config *scrconfig = (const screen_config *)devconfig->inline_config;
-
- /* sanity check dimensions */
- if ((scrconfig->width <= 0) || (scrconfig->height <= 0))
- {
- mame_printf_error("%s: %s screen '%s' has invalid display dimensions\n", driver->source_file, driver->name, devconfig->tag());
- error = TRUE;
- }
-
- /* sanity check display area */
- if (scrconfig->type != SCREEN_TYPE_VECTOR)
- {
- if ((scrconfig->visarea.max_x < scrconfig->visarea.min_x) ||
- (scrconfig->visarea.max_y < scrconfig->visarea.min_y) ||
- (scrconfig->visarea.max_x >= scrconfig->width) ||
- (scrconfig->visarea.max_y >= scrconfig->height))
- {
- mame_printf_error("%s: %s screen '%s' has an invalid display area\n", driver->source_file, driver->name, devconfig->tag());
- error = TRUE;
- }
-
- /* sanity check screen formats */
- if (scrconfig->format != BITMAP_FORMAT_INDEXED16 &&
- scrconfig->format != BITMAP_FORMAT_RGB15 &&
- scrconfig->format != BITMAP_FORMAT_RGB32)
- {
- mame_printf_error("%s: %s screen '%s' has unsupported format\n", driver->source_file, driver->name, devconfig->tag());
- error = TRUE;
- }
- if (scrconfig->format == BITMAP_FORMAT_INDEXED16)
- palette_modes = TRUE;
- }
-
- /* check for zero frame rate */
- if (scrconfig->refresh == 0)
- {
- mame_printf_error("%s: %s screen '%s' has a zero refresh rate\n", driver->source_file, driver->name, devconfig->tag());
- error = TRUE;
- }
- }
+ bool palette_modes = false;
+ bool error = false;
+
+ for (const screen_device_config *scrconfig = screen_first(*config); scrconfig != NULL; scrconfig = screen_next(scrconfig))
+ if (scrconfig->format() == BITMAP_FORMAT_INDEXED16)
+ palette_modes = true;
/* check for empty palette */
if (palette_modes && config->total_colors == 0)
{
mame_printf_error("%s: %s has zero palette entries\n", driver->source_file, driver->name);
- error = TRUE;
+ error = true;
}
return error;
@@ -733,15 +617,15 @@ static int validate_display(int drivnum, const machine_config *config)
configuration
-------------------------------------------------*/
-static int validate_gfx(int drivnum, const machine_config *config, region_array *rgninfo)
+static bool validate_gfx(int drivnum, const machine_config *config, region_array *rgninfo)
{
const game_driver *driver = drivers[drivnum];
- int error = FALSE;
+ bool error = false;
int gfxnum;
/* bail if no gfx */
if (!config->gfxdecodeinfo)
- return FALSE;
+ return false;
/* iterate over graphics decoding entries */
for (gfxnum = 0; gfxnum < MAX_GFX_ELEMENTS && config->gfxdecodeinfo[gfxnum].gfxlayout != NULL; gfxnum++)
@@ -769,7 +653,7 @@ static int validate_gfx(int drivnum, const machine_config *config, region_array
if (rgninfo->entries[rgnnum].tag == NULL)
{
mame_printf_error("%s: %s has gfx[%d] referencing non-existent region '%s'\n", driver->source_file, driver->name, gfxnum, region);
- error = TRUE;
+ error = true;
break;
}
@@ -800,7 +684,7 @@ static int validate_gfx(int drivnum, const machine_config *config, region_array
if ((start + len) / 8 > avail)
{
mame_printf_error("%s: %s has gfx[%d] extending past allocated memory of region '%s'\n", driver->source_file, driver->name, gfxnum, region);
- error = TRUE;
+ error = true;
}
}
break;
@@ -813,13 +697,13 @@ static int validate_gfx(int drivnum, const machine_config *config, region_array
if (total != RGN_FRAC(1,1))
{
mame_printf_error("%s: %s has gfx[%d] with unsupported layout total\n", driver->source_file, driver->name, gfxnum);
- error = TRUE;
+ error = true;
}
if (xscale != 1 || yscale != 1)
{
mame_printf_error("%s: %s has gfx[%d] with unsupported xscale/yscale\n", driver->source_file, driver->name, gfxnum);
- error = TRUE;
+ error = true;
}
}
else
@@ -827,13 +711,13 @@ static int validate_gfx(int drivnum, const machine_config *config, region_array
if (planes > MAX_GFX_PLANES)
{
mame_printf_error("%s: %s has gfx[%d] with invalid planes\n", driver->source_file, driver->name, gfxnum);
- error = TRUE;
+ error = true;
}
if (xscale * width > MAX_ABS_GFX_SIZE || yscale * height > MAX_ABS_GFX_SIZE)
{
mame_printf_error("%s: %s has gfx[%d] with invalid xscale/yscale\n", driver->source_file, driver->name, gfxnum);
- error = TRUE;
+ error = true;
}
}
}
@@ -848,14 +732,14 @@ static int validate_gfx(int drivnum, const machine_config *config, region_array
strings
-------------------------------------------------*/
-static int get_defstr_index(int_map &defstr_map, const char *name, const game_driver *driver, int *error)
+static int get_defstr_index(int_map &defstr_map, const char *name, const game_driver *driver, bool *error)
{
/* check for strings that should be DEF_STR */
int strindex = defstr_map.find(name);
if (strindex != 0 && name != input_port_string_from_index(strindex) && error != NULL)
{
mame_printf_error("%s: %s must use DEF_STR( %s )\n", driver->source_file, driver->name, name);
- *error = TRUE;
+ *error = true;
}
return strindex;
@@ -867,7 +751,7 @@ static int get_defstr_index(int_map &defstr_map, const char *name, const game_dr
analog input field
-------------------------------------------------*/
-static void validate_analog_input_field(const input_field_config *field, const game_driver *driver, int *error)
+static void validate_analog_input_field(const input_field_config *field, const game_driver *driver, bool *error)
{
INT32 analog_max = field->max;
INT32 analog_min = field->min;
@@ -883,7 +767,7 @@ static void validate_analog_input_field(const input_field_config *field, const g
if (((field->mask >> shift) + 1) < field->max)
{
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);
- *error = TRUE;
+ *error = true;
}
}
else
@@ -892,7 +776,7 @@ static void validate_analog_input_field(const input_field_config *field, const g
if (field->flags & ANALOG_FLAG_WRAPS)
{
mame_printf_error("%s: %s only positional analog ports use PORT_WRAPS\n", driver->source_file, driver->name);
- *error = TRUE;
+ *error = true;
}
}
@@ -900,14 +784,14 @@ static void validate_analog_input_field(const input_field_config *field, const g
if (field->sensitivity == 0)
{
mame_printf_error("%s: %s has an analog port with zero sensitivity\n", driver->source_file, driver->name);
- *error = TRUE;
+ *error = true;
}
/* check that the default falls in the bitmask range */
if (field->defvalue & ~field->mask)
{
mame_printf_error("%s: %s has an analog port with a default value out of the bitmask range\n", driver->source_file, driver->name);
- *error = TRUE;
+ *error = true;
}
/* tests for absolute devices */
@@ -927,7 +811,7 @@ static void validate_analog_input_field(const input_field_config *field, const g
if (default_value < analog_min || default_value > analog_max)
{
mame_printf_error("%s: %s has an analog port with a default value out PORT_MINMAX range\n", driver->source_file, driver->name);
- *error = TRUE;
+ *error = true;
}
/* check that the MINMAX falls in the bitmask range */
@@ -935,14 +819,14 @@ static void validate_analog_input_field(const input_field_config *field, const g
if (field->min & ~field->mask || analog_max & ~field->mask)
{
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);
- *error = TRUE;
+ *error = true;
}
/* absolute analog ports do not use PORT_RESET */
if (field->flags & ANALOG_FLAG_RESET)
{
mame_printf_error("%s: %s - absolute analog ports do not use PORT_RESET\n", driver->source_file, driver->name);
- *error = TRUE;
+ *error = true;
}
}
@@ -956,7 +840,7 @@ static void validate_analog_input_field(const input_field_config *field, const g
if (field->min != 0 || field->max != field->mask)
{
mame_printf_error("%s: %s - relative ports do not use PORT_MINMAX\n", driver->source_file, driver->name);
- *error = TRUE;
+ *error = true;
}
/* relative devices do not use a default value */
@@ -964,7 +848,7 @@ static void validate_analog_input_field(const input_field_config *field, const g
if (field->defvalue != 0)
{
mame_printf_error("%s: %s - relative ports do not use a default value other then 0\n", driver->source_file, driver->name);
- *error = TRUE;
+ *error = true;
}
}
}
@@ -976,7 +860,7 @@ static void validate_analog_input_field(const input_field_config *field, const g
setting
-------------------------------------------------*/
-static void validate_dip_settings(const input_field_config *field, const game_driver *driver, int_map &defstr_map, int *error)
+static void validate_dip_settings(const input_field_config *field, const game_driver *driver, int_map &defstr_map, bool *error)
{
const char *demo_sounds = input_port_string_from_index(INPUT_STRING_Demo_Sounds);
const char *flipscreen = input_port_string_from_index(INPUT_STRING_Flip_Screen);
@@ -997,21 +881,21 @@ static void validate_dip_settings(const input_field_config *field, const game_dr
if (field->name == demo_sounds && strindex == INPUT_STRING_On && field->defvalue != setting->value)
{
mame_printf_error("%s: %s Demo Sounds must default to On\n", driver->source_file, driver->name);
- *error = TRUE;
+ *error = true;
}
/* check for bad demo sounds options */
if (field->name == demo_sounds && (strindex == INPUT_STRING_Yes || strindex == INPUT_STRING_No))
{
mame_printf_error("%s: %s has wrong Demo Sounds option %s (must be Off/On)\n", driver->source_file, driver->name, setting->name);
- *error = TRUE;
+ *error = true;
}
/* check for bad flip screen options */
if (field->name == flipscreen && (strindex == INPUT_STRING_Yes || strindex == INPUT_STRING_No))
{
mame_printf_error("%s: %s has wrong Flip Screen option %s (must be Off/On)\n", driver->source_file, driver->name, setting->name);
- *error = TRUE;
+ *error = true;
}
/* if we have a neighbor, compare ourselves to him */
@@ -1023,21 +907,21 @@ static void validate_dip_settings(const input_field_config *field, const game_dr
if (strindex == INPUT_STRING_On && next_strindex == INPUT_STRING_Off)
{
mame_printf_error("%s: %s has inverted Off/On dipswitch order\n", driver->source_file, driver->name);
- *error = TRUE;
+ *error = true;
}
/* check for inverted yes/no dispswitch order */
else if (strindex == INPUT_STRING_Yes && next_strindex == INPUT_STRING_No)
{
mame_printf_error("%s: %s has inverted No/Yes dipswitch order\n", driver->source_file, driver->name);
- *error = TRUE;
+ *error = true;
}
/* check for inverted upright/cocktail dispswitch order */
else if (strindex == INPUT_STRING_Cocktail && next_strindex == INPUT_STRING_Upright)
{
mame_printf_error("%s: %s has inverted Upright/Cocktail dipswitch order\n", driver->source_file, driver->name);
- *error = TRUE;
+ *error = true;
}
/* check for proper coin ordering */
@@ -1045,7 +929,7 @@ static void validate_dip_settings(const input_field_config *field, const game_dr
strindex >= next_strindex && memcmp(&setting->condition, &setting->next->condition, sizeof(setting->condition)) == 0)
{
mame_printf_error("%s: %s has unsorted coinage %s > %s\n", driver->source_file, driver->name, setting->name, setting->next->name);
- coin_error = *error = TRUE;
+ coin_error = *error = true;
}
}
}
@@ -1067,7 +951,7 @@ static void validate_dip_settings(const input_field_config *field, const game_dr
validate_inputs - validate input configuration
-------------------------------------------------*/
-static int validate_inputs(int drivnum, const machine_config *config, int_map &defstr_map, ioport_list &portlist)
+static bool validate_inputs(int drivnum, const machine_config *config, int_map &defstr_map, ioport_list &portlist)
{
const input_port_config *scanport;
const input_port_config *port;
@@ -1075,7 +959,7 @@ static int validate_inputs(int drivnum, const machine_config *config, int_map &d
const game_driver *driver = drivers[drivnum];
int empty_string_found = FALSE;
char errorbuf[1024];
- int error = FALSE;
+ bool error = false;
/* skip if no ports */
if (driver->ipt == NULL)
@@ -1086,21 +970,21 @@ static int validate_inputs(int drivnum, const machine_config *config, int_map &d
if (errorbuf[0] != 0)
{
mame_printf_error("%s: %s has input port errors:\n%s\n", driver->source_file, driver->name, errorbuf);
- error = TRUE;
+ error = true;
}
/* check for duplicate tags */
- for (port = portlist.first(); port != NULL; port = port->next)
+ for (port = portlist.first(); port != NULL; port = port->next())
if (port->tag != NULL)
- for (scanport = port->next; scanport != NULL; scanport = scanport->next)
+ for (scanport = port->next(); scanport != NULL; scanport = scanport->next())
if (scanport->tag != NULL && strcmp(port->tag, scanport->tag) == 0)
{
mame_printf_error("%s: %s has a duplicate input port tag '%s'\n", driver->source_file, driver->name, port->tag);
- error = TRUE;
+ error = true;
}
/* iterate over the results */
- for (port = portlist.first(); port != NULL; port = port->next)
+ for (port = portlist.first(); port != NULL; port = port->next())
for (field = port->fieldlist; field != NULL; field = field->next)
{
const input_setting_config *setting;
@@ -1117,7 +1001,7 @@ static int validate_inputs(int drivnum, const machine_config *config, int_map &d
if (field->name == NULL)
{
mame_printf_error("%s: %s has a DIP switch name or setting with no name\n", driver->source_file, driver->name);
- error = TRUE;
+ error = true;
}
/* verify the settings list */
@@ -1128,7 +1012,7 @@ static int validate_inputs(int drivnum, const machine_config *config, int_map &d
if (field->type == IPT_INVALID)
{
mame_printf_error("%s: %s has an input port with an invalid type (0); use IPT_OTHER instead\n", driver->source_file, driver->name);
- error = TRUE;
+ error = true;
}
/* verify names */
@@ -1138,21 +1022,21 @@ static int validate_inputs(int drivnum, const machine_config *config, int_map &d
if (field->name[0] == 0 && !empty_string_found)
{
mame_printf_error("%s: %s has an input with an empty string\n", driver->source_file, driver->name);
- empty_string_found = error = TRUE;
+ empty_string_found = error = true;
}
/* check for trailing spaces */
if (field->name[0] != 0 && field->name[strlen(field->name) - 1] == ' ')
{
mame_printf_error("%s: %s input '%s' has trailing spaces\n", driver->source_file, driver->name, field->name);
- error = TRUE;
+ error = true;
}
/* check for invalid UTF-8 */
if (!utf8_is_valid_string(field->name))
{
mame_printf_error("%s: %s input '%s' has invalid characters\n", driver->source_file, driver->name, field->name);
- error = TRUE;
+ error = true;
}
/* look up the string and print an error if default strings are not used */
@@ -1163,7 +1047,7 @@ static int validate_inputs(int drivnum, const machine_config *config, int_map &d
if (field->condition.tag != NULL)
{
/* find a matching port */
- for (scanport = portlist.first(); scanport != NULL; scanport = scanport->next)
+ for (scanport = portlist.first(); scanport != NULL; scanport = scanport->next())
if (scanport->tag != NULL && strcmp(field->condition.tag, scanport->tag) == 0)
break;
@@ -1171,7 +1055,7 @@ static int validate_inputs(int drivnum, const machine_config *config, int_map &d
if (scanport == NULL)
{
mame_printf_error("%s: %s has a condition referencing non-existent input port tag '%s'\n", driver->source_file, driver->name, field->condition.tag);
- error = TRUE;
+ error = true;
}
}
@@ -1180,7 +1064,7 @@ static int validate_inputs(int drivnum, const machine_config *config, int_map &d
if (setting->condition.tag != NULL)
{
/* find a matching port */
- for (scanport = portlist.first(); scanport != NULL; scanport = scanport->next)
+ for (scanport = portlist.first(); scanport != NULL; scanport = scanport->next())
if (scanport->tag != NULL && strcmp(setting->condition.tag, scanport->tag) == 0)
break;
@@ -1188,7 +1072,7 @@ static int validate_inputs(int drivnum, const machine_config *config, int_map &d
if (scanport == NULL)
{
mame_printf_error("%s: %s has a condition referencing non-existent input port tag '%s'\n", driver->source_file, driver->name, setting->condition.tag);
- error = TRUE;
+ error = true;
}
}
}
@@ -1201,236 +1085,33 @@ static int validate_inputs(int drivnum, const machine_config *config, int_map &d
/*-------------------------------------------------
- validate_sound - validate sound and
- speaker configuration
--------------------------------------------------*/
-
-static int validate_sound(int drivnum, const machine_config *config)
-{
- const device_config *curspeak, *checkspeak, *cursound, *checksound;
- const game_driver *driver = drivers[drivnum];
- int error = FALSE;
-
- /* make sure the speaker layout makes sense */
- for (curspeak = speaker_output_first(config); curspeak != NULL; curspeak = speaker_output_next(curspeak))
- {
- /* check for duplicate tags */
- for (checkspeak = speaker_output_first(config); checkspeak != NULL; checkspeak = speaker_output_next(checkspeak))
- if (checkspeak != curspeak && strcmp(checkspeak->tag(), curspeak->tag()) == 0)
- {
- mame_printf_error("%s: %s has multiple speakers tagged as '%s'\n", driver->source_file, driver->name, checkspeak->tag());
- error = TRUE;
- }
-
- /* make sure there are no sound chips with the same tag */
- for (checksound = sound_first(config); checksound != NULL; checksound = sound_next(checksound))
- if (strcmp(curspeak->tag(), checksound->tag()) == 0)
- {
- mame_printf_error("%s: %s has both a speaker and a sound chip tagged as '%s'\n", driver->source_file, driver->name, curspeak->tag());
- error = TRUE;
- }
- }
-
- /* make sure the sounds are wired to the speakers correctly */
- for (cursound = sound_first(config); cursound != NULL; cursound = sound_next(cursound))
- {
- const sound_config *curconfig = (const sound_config *)cursound->inline_config;
- const sound_route *route;
-
- /* loop over all the routes */
- for (route = curconfig->routelist; route != NULL; route = route->next)
- {
- /* find a speaker with the requested tag */
- for (checkspeak = speaker_output_first(config); checkspeak != NULL; checkspeak = speaker_output_next(checkspeak))
- if (strcmp(route->target, checkspeak->tag()) == 0)
- break;
-
- /* if we didn't find one, look for another sound chip with the tag */
- if (checkspeak == NULL)
- {
- for (checksound = sound_first(config); checksound != NULL; checksound = sound_next(checksound))
- if (checksound != cursound && strcmp(route->target, checksound->tag()) == 0)
- break;
-
- /* if we didn't find one, it's an error */
- if (checksound == NULL)
- {
- mame_printf_error("%s: %s attempting to route sound to non-existant speaker '%s'\n", driver->source_file, driver->name, route->target);
- error = TRUE;
- }
- }
- }
- }
-
- return error;
-}
-
-
-/*-------------------------------------------------
validate_devices - run per-device validity
checks
-------------------------------------------------*/
-static int validate_devices(int drivnum, const machine_config *config, const ioport_list &portlist, region_array *rgninfo)
+static bool validate_devices(int drivnum, const machine_config *config, const ioport_list &portlist, region_array *rgninfo)
{
- int error = FALSE;
+ bool error = false;
const game_driver *driver = drivers[drivnum];
- for (const device_config *devconfig = config->devicelist.first(); devconfig != NULL; devconfig = devconfig->next)
+ for (const device_config *devconfig = config->devicelist.first(); devconfig != NULL; devconfig = devconfig->next())
{
- device_validity_check_func validity_check = (device_validity_check_func) devconfig->get_config_fct(DEVINFO_FCT_VALIDITY_CHECK);
- int detected_overlap = DETECT_OVERLAPPING_MEMORY ? FALSE : TRUE;
- const device_config *scanconfig;
- int spacenum;
-
/* validate the device tag */
- error |= validate_tag(driver, devconfig->get_config_string(DEVINFO_STR_NAME), devconfig->tag());
+ if (!validate_tag(driver, devconfig->name(), devconfig->tag()))
+ error = true;
/* look for duplicates */
- for (scanconfig = config->devicelist.first(); scanconfig != devconfig; scanconfig = scanconfig->next)
+ for (const device_config *scanconfig = config->devicelist.first(); scanconfig != devconfig; scanconfig = scanconfig->next())
if (strcmp(scanconfig->tag(), devconfig->tag()) == 0)
{
mame_printf_warning("%s: %s has multiple devices with the tag '%s'\n", driver->source_file, driver->name, devconfig->tag());
break;
}
- /* call the device-specific validity check */
- if (validity_check != NULL && (*validity_check)(driver, devconfig))
- error = TRUE;
-
- /* loop over all address spaces */
- for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++)
- {
-#define SPACE_SHIFT(a) ((addr_shift < 0) ? ((a) << -addr_shift) : ((a) >> addr_shift))
-#define SPACE_SHIFT_END(a) ((addr_shift < 0) ? (((a) << -addr_shift) | ((1 << -addr_shift) - 1)) : ((a) >> addr_shift))
- int databus_width = devconfig->databus_width(spacenum);
- int addr_shift = devconfig->addrbus_shift(spacenum);
- int alignunit = databus_width/8;
- address_map_entry *entry;
- address_map *map;
-
- /* construct the maps */
- map = address_map_alloc(devconfig, driver, spacenum, NULL);
-
- /* if this is an empty map, just skip it */
- if (map->entrylist == NULL)
- {
- address_map_free(map);
- continue;
- }
-
- /* validate the global map parameters */
- if (map->spacenum != spacenum)
- {
- mame_printf_error("%s: %s device '%s' space %d has address space %d handlers!\n", driver->source_file, driver->name, devconfig->tag(), spacenum, map->spacenum);
- error = TRUE;
- }
- if (map->databits != databus_width)
- {
- mame_printf_error("%s: %s device '%s' uses wrong memory handlers for %s space! (width = %d, memory = %08x)\n", driver->source_file, driver->name, devconfig->tag(), address_space_names[spacenum], databus_width, map->databits);
- error = TRUE;
- }
-
- /* loop over entries and look for errors */
- for (entry = map->entrylist; entry != NULL; entry = entry->next)
- {
- UINT32 bytestart = SPACE_SHIFT(entry->addrstart);
- UINT32 byteend = SPACE_SHIFT_END(entry->addrend);
-
- /* look for overlapping entries */
- if (!detected_overlap)
- {
- address_map_entry *scan;
- for (scan = map->entrylist; scan != entry; scan = scan->next)
- if (entry->addrstart <= scan->addrend && entry->addrend >= scan->addrstart &&
- ((entry->read.type != AMH_NONE && scan->read.type != AMH_NONE) ||
- (entry->write.type != AMH_NONE && scan->write.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, devconfig->tag(), address_space_names[spacenum], entry->addrstart, entry->addrend, entry->read.type, entry->write.type, scan->addrstart, scan->addrend, scan->read.type, scan->write.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, address_space_names[spacenum], entry->addrstart, entry->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, address_space_names[spacenum], entry->addrstart, entry->addrend, alignunit);
- error = TRUE;
- }
-
- /* if this is a program space, auto-assign implicit ROM entries */
- if (entry->read.type == AMH_ROM && entry->region == NULL)
- {
- entry->region = devconfig->tag();
- entry->rgnoffs = entry->addrstart;
- }
-
- /* if this entry references a memory region, validate it */
- if (entry->region != NULL && entry->share == 0)
- {
- int rgnnum;
-
- /* loop over entries in the class */
- for (rgnnum = 0; rgnnum < ARRAY_LENGTH(rgninfo->entries); rgnnum++)
- {
- /* stop if we hit an empty */
- if (rgninfo->entries[rgnnum].tag == NULL)
- {
- 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, devconfig->tag(), address_space_names[spacenum], entry->addrstart, entry->addrend, entry->region);
- error = TRUE;
- break;
- }
+ /* check for device-specific validity check */
+ if (devconfig->validity_check(*driver))
+ error = true;
- /* if we hit a match, check against the length */
- if (rgninfo->entries[rgnnum].tag.cmp(entry->region) == 0)
- {
- offs_t length = rgninfo->entries[rgnnum].length;
- if (entry->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, devconfig->tag(), address_space_names[spacenum], entry->addrstart, entry->addrend, entry->region, length);
- error = TRUE;
- }
- break;
- }
- }
- }
-
- /* make sure all devices exist */
- if ((entry->read.type == AMH_DEVICE_HANDLER && entry->read.tag != NULL && config->devicelist.find(entry->read.tag) == NULL) ||
- (entry->write.type == AMH_DEVICE_HANDLER && entry->write.tag != NULL && config->devicelist.find(entry->write.tag) == NULL))
- {
- mame_printf_error("%s: %s device '%s' %s space memory map entry references nonexistant device '%s'\n", driver->source_file, driver->name, devconfig->tag(), address_space_names[spacenum], entry->write.tag);
- error = TRUE;
- }
-
- /* make sure ports exist */
- if ((entry->read.type == AMH_PORT && entry->read.tag != NULL && portlist.find(entry->read.tag) == NULL) ||
- (entry->write.type == AMH_PORT && entry->write.tag != NULL && portlist.find(entry->write.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, devconfig->tag(), address_space_names[spacenum], entry->read.tag);
- error = TRUE;
- }
-
- /* validate bank and share tags */
- if (entry->read.type == AMH_BANK)
- error |= validate_tag(driver, "bank", entry->read.tag);
- if (entry->write.type == AMH_BANK)
- error |= validate_tag(driver, "bank", entry->write.tag);
- if (entry->share != NULL)
- error |= validate_tag(driver, "share", entry->share);
- }
-
- /* release the address map */
- address_map_free(map);
- }
}
return error;
}
@@ -1440,21 +1121,19 @@ static int validate_devices(int drivnum, const machine_config *config, const iop
mame_validitychecks - master validity checker
-------------------------------------------------*/
-int mame_validitychecks(const game_driver *curdriver)
+bool mame_validitychecks(const game_driver *curdriver)
{
osd_ticks_t prep = 0;
osd_ticks_t expansion = 0;
osd_ticks_t driver_checks = 0;
osd_ticks_t rom_checks = 0;
- osd_ticks_t cpu_checks = 0;
osd_ticks_t gfx_checks = 0;
osd_ticks_t display_checks = 0;
osd_ticks_t input_checks = 0;
- osd_ticks_t sound_checks = 0;
osd_ticks_t device_checks = 0;
int drivnum, strnum;
- int error = FALSE;
+ bool error = false;
UINT16 lsbtest;
UINT8 a, b;
@@ -1466,27 +1145,27 @@ int mame_validitychecks(const game_driver *curdriver)
/* basic system checks */
a = 0xff;
b = a + 1;
- if (b > a) { mame_printf_error("UINT8 must be 8 bits\n"); error = TRUE; }
-
- if (sizeof(INT8) != 1) { mame_printf_error("INT8 must be 8 bits\n"); error = TRUE; }
- if (sizeof(UINT8) != 1) { mame_printf_error("UINT8 must be 8 bits\n"); error = TRUE; }
- if (sizeof(INT16) != 2) { mame_printf_error("INT16 must be 16 bits\n"); error = TRUE; }
- if (sizeof(UINT16) != 2) { mame_printf_error("UINT16 must be 16 bits\n"); error = TRUE; }
- if (sizeof(INT32) != 4) { mame_printf_error("INT32 must be 32 bits\n"); error = TRUE; }
- if (sizeof(UINT32) != 4) { mame_printf_error("UINT32 must be 32 bits\n"); error = TRUE; }
- if (sizeof(INT64) != 8) { mame_printf_error("INT64 must be 64 bits\n"); error = TRUE; }
- if (sizeof(UINT64) != 8) { mame_printf_error("UINT64 must be 64 bits\n"); error = TRUE; }
+ if (b > a) { mame_printf_error("UINT8 must be 8 bits\n"); error = true; }
+
+ if (sizeof(INT8) != 1) { mame_printf_error("INT8 must be 8 bits\n"); error = true; }
+ if (sizeof(UINT8) != 1) { mame_printf_error("UINT8 must be 8 bits\n"); error = true; }
+ if (sizeof(INT16) != 2) { mame_printf_error("INT16 must be 16 bits\n"); error = true; }
+ if (sizeof(UINT16) != 2) { mame_printf_error("UINT16 must be 16 bits\n"); error = true; }
+ if (sizeof(INT32) != 4) { mame_printf_error("INT32 must be 32 bits\n"); error = true; }
+ if (sizeof(UINT32) != 4) { mame_printf_error("UINT32 must be 32 bits\n"); error = true; }
+ if (sizeof(INT64) != 8) { mame_printf_error("INT64 must be 64 bits\n"); error = true; }
+ if (sizeof(UINT64) != 8) { mame_printf_error("UINT64 must be 64 bits\n"); error = true; }
#ifdef PTR64
- if (sizeof(void *) != 8) { mame_printf_error("PTR64 flag enabled, but was compiled for 32-bit target\n"); error = TRUE; }
+ if (sizeof(void *) != 8) { mame_printf_error("PTR64 flag enabled, but was compiled for 32-bit target\n"); error = true; }
#else
- if (sizeof(void *) != 4) { mame_printf_error("PTR64 flag not enabled, but was compiled for 64-bit target\n"); error = TRUE; }
+ if (sizeof(void *) != 4) { mame_printf_error("PTR64 flag not enabled, but was compiled for 64-bit target\n"); error = true; }
#endif
lsbtest = 0;
*(UINT8 *)&lsbtest = 0xff;
#ifdef LSB_FIRST
- if (lsbtest == 0xff00) { mame_printf_error("LSB_FIRST specified, but running on a big-endian machine\n"); error = TRUE; }
+ if (lsbtest == 0xff00) { mame_printf_error("LSB_FIRST specified, but running on a big-endian machine\n"); error = true; }
#else
- if (lsbtest == 0x00ff) { mame_printf_error("LSB_FIRST not specified, but running on a little-endian machine\n"); error = TRUE; }
+ if (lsbtest == 0x00ff) { mame_printf_error("LSB_FIRST not specified, but running on a little-endian machine\n"); error = true; }
#endif
/* validate inline function behavior */
@@ -1536,11 +1215,6 @@ int mame_validitychecks(const game_driver *curdriver)
error = validate_inputs(drivnum, config, defstr, portlist) || error;
input_checks += get_profile_ticks();
- /* validate the CPU information */
- cpu_checks -= get_profile_ticks();
- error = validate_cpu(drivnum, config) || error;
- cpu_checks += get_profile_ticks();
-
/* validate the display */
display_checks -= get_profile_ticks();
error = validate_display(drivnum, config) || error;
@@ -1551,11 +1225,6 @@ int mame_validitychecks(const game_driver *curdriver)
error = validate_gfx(drivnum, config, &rgninfo) || error;
gfx_checks += get_profile_ticks();
- /* validate sounds and speakers */
- sound_checks -= get_profile_ticks();
- error = validate_sound(drivnum, config) || error;
- sound_checks += get_profile_ticks();
-
/* validate devices */
device_checks -= get_profile_ticks();
error = validate_devices(drivnum, config, portlist, &rgninfo) || error;
@@ -1573,7 +1242,6 @@ int mame_validitychecks(const game_driver *curdriver)
mame_printf_info("Display: %8dm\n", (int)(display_checks / 1000000));
mame_printf_info("Graphics: %8dm\n", (int)(gfx_checks / 1000000));
mame_printf_info("Input: %8dm\n", (int)(input_checks / 1000000));
- mame_printf_info("Sound: %8dm\n", (int)(sound_checks / 1000000));
#endif
return error;