mirror of
https://github.com/holub/mame
synced 2025-04-24 01:11:11 +03:00
Adding per-device and per-CPU validity checks
This commit is contained in:
parent
ea680e40b2
commit
697181c8cd
@ -20,6 +20,7 @@
|
||||
|
||||
*/
|
||||
|
||||
#include "driver.h"
|
||||
#include "cpuintrf.h"
|
||||
#include "debugger.h"
|
||||
#include "cop400.h"
|
||||
@ -389,6 +390,23 @@ static void cop410_set_context (void *src)
|
||||
R = *(COP410_Regs*)src;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* Validity check
|
||||
**************************************************************************/
|
||||
static int cop410_validity_check(const game_driver *driver, const void *config)
|
||||
{
|
||||
int error = FALSE;
|
||||
const cop400_interface *intf = (const cop400_interface *) config;
|
||||
|
||||
if ((intf == NULL) || (intf->cki <= 0))
|
||||
{
|
||||
mame_printf_error("%s: %s has an invalid CPU configuration\n", driver->source_file, driver->name);
|
||||
error = TRUE;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* Generic set_info
|
||||
**************************************************************************/
|
||||
@ -471,6 +489,7 @@ void cop410_get_info(UINT32 state, cpuinfo *info)
|
||||
case CPUINFO_PTR_BURN: info->burn = NULL; break;
|
||||
case CPUINFO_PTR_DISASSEMBLE: info->disassemble = cop410_dasm; break;
|
||||
case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &cop410_ICount; break;
|
||||
case CPUINFO_PTR_VALIDITY_CHECK: info->validity_check = cop410_validity_check; break;
|
||||
|
||||
/* case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM:
|
||||
info->internal_map8 = address_map_cop410_internal_rom; break;*/
|
||||
|
@ -133,6 +133,7 @@ enum
|
||||
CPUINFO_PTR_INTERNAL_MEMORY_MAP, /* R/O: const addrmap_token *map */
|
||||
CPUINFO_PTR_INTERNAL_MEMORY_MAP_LAST = CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACES - 1,
|
||||
CPUINFO_PTR_DEBUG_REGISTER_LIST, /* R/O: int *list: list of registers for the debugger */
|
||||
CPUINFO_PTR_VALIDITY_CHECK, /* R/O: int (*validity_check)(const void *config) */
|
||||
|
||||
CPUINFO_PTR_CPU_SPECIFIC = 0x18000, /* R/W: CPU-specific values start here */
|
||||
|
||||
@ -229,6 +230,7 @@ typedef int (*cpu_read_func)(int space, UINT32 offset, int size, UINT64 *value);
|
||||
typedef int (*cpu_write_func)(int space, UINT32 offset, int size, UINT64 value);
|
||||
typedef int (*cpu_readop_func)(UINT32 offset, int size, UINT64 *value);
|
||||
typedef void (*cpu_setup_commands_func)(void);
|
||||
typedef int (*cpu_validity_check_func)(const game_driver *driver, const void *config);
|
||||
|
||||
|
||||
/* cpuinfo union used to pass data to/from the get_info/set_info functions */
|
||||
@ -258,6 +260,7 @@ union _cpuinfo
|
||||
const addrmap16_token * internal_map16; /* CPUINFO_PTR_INTERNAL_MEMORY_MAP */
|
||||
const addrmap32_token * internal_map32; /* CPUINFO_PTR_INTERNAL_MEMORY_MAP */
|
||||
const addrmap64_token * internal_map64; /* CPUINFO_PTR_INTERNAL_MEMORY_MAP */
|
||||
cpu_validity_check_func validity_check; /* CPUINFO_PTR_VALIDITY_CHECK */
|
||||
};
|
||||
|
||||
|
||||
|
@ -68,6 +68,7 @@ enum
|
||||
DEVINFO_FCT_START, /* R/O: device_start_func */
|
||||
DEVINFO_FCT_STOP, /* R/O: device_stop_func */
|
||||
DEVINFO_FCT_RESET, /* R/O: device_reset_func */
|
||||
DEVINFO_FCT_VALIDITY_CHECK, /* R/O: device_validity_check_func */
|
||||
|
||||
DEVINFO_FCT_DEVICE_SPECIFIC = 0x28000, /* R/W: device-specific values start here */
|
||||
|
||||
@ -113,6 +114,10 @@ enum
|
||||
#define DEVICE_RESET(name) void DEVICE_RESET_NAME(name)(const device_config *device)
|
||||
#define DEVICE_RESET_CALL(name) DEVICE_RESET_NAME(name)(device)
|
||||
|
||||
#define DEVICE_VALIDITY_CHECK_NAME(name) device_validity_check_##name
|
||||
#define DEVICE_VALIDITY_CHECK(name) int DEVICE_VALIDITY_CHECK_NAME(name)(const game_driver *driver, const device_config *device)
|
||||
#define DEVICE_VALIDITY_CHECK_CALL(name) DEVICE_VALIDITY_CHECK(name)(driver, device)
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
@ -130,6 +135,7 @@ typedef void (*device_set_info_func)(const device_config *device, UINT32 state,
|
||||
typedef void (*device_start_func)(const device_config *device);
|
||||
typedef void (*device_stop_func)(const device_config *device);
|
||||
typedef void (*device_reset_func)(const device_config *device);
|
||||
typedef int (*device_validity_check_func)(const game_driver *driver, const device_config *device);
|
||||
|
||||
|
||||
/* a device_type is simply a pointer to its get_info function */
|
||||
@ -148,6 +154,7 @@ union _deviceinfo
|
||||
device_start_func start; /* DEVINFO_FCT_START */
|
||||
device_stop_func stop; /* DEVINFO_FCT_STOP */
|
||||
device_reset_func reset; /* DEVINFO_FCT_RESET */
|
||||
device_validity_check_func validity_check; /* DEVINFO_FCT_VALIDITY_CHECK */
|
||||
};
|
||||
|
||||
|
||||
|
@ -621,6 +621,7 @@ static int validate_cpu(int drivnum, const machine_config *config, const UINT32
|
||||
const game_driver *driver = drivers[drivnum];
|
||||
int error = FALSE;
|
||||
int cpunum;
|
||||
cpu_validity_check_func cpu_validity_check;
|
||||
|
||||
/* loop over all the CPUs */
|
||||
for (cpunum = 0; cpunum < MAX_CPU; cpunum++)
|
||||
@ -652,6 +653,14 @@ static int validate_cpu(int drivnum, const machine_config *config, const UINT32
|
||||
continue;
|
||||
}
|
||||
|
||||
/* check for CPU-specific validity check */
|
||||
cpu_validity_check = (cpu_validity_check_func) cputype_get_info_fct(cpu->type, CPUINFO_PTR_VALIDITY_CHECK);
|
||||
if (cpu_validity_check != NULL)
|
||||
{
|
||||
if ((*cpu_validity_check)(driver, config->cpu[cpunum].reset_param))
|
||||
error = TRUE;
|
||||
}
|
||||
|
||||
/* loop over all address spaces */
|
||||
for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++)
|
||||
{
|
||||
@ -1380,6 +1389,30 @@ static int validate_sound(int drivnum, const machine_config *config)
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
validate_devices - run per-device validity
|
||||
checks
|
||||
-------------------------------------------------*/
|
||||
|
||||
static int validate_devices(int drivnum, const machine_config *config)
|
||||
{
|
||||
int error = FALSE;
|
||||
const game_driver *driver = drivers[drivnum];
|
||||
const device_config *device;
|
||||
|
||||
for (device = device_list_first(config->devicelist, DEVICE_TYPE_WILDCARD); device != NULL; device = device_list_next(device, DEVICE_TYPE_WILDCARD))
|
||||
{
|
||||
device_validity_check_func validity_check = (device_validity_check_func) device_get_info_fct(device, DEVINFO_FCT_VALIDITY_CHECK);
|
||||
if (validity_check != NULL)
|
||||
{
|
||||
if ((*validity_check)(driver, device))
|
||||
error = TRUE;
|
||||
}
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
mame_validitychecks - master validity checker
|
||||
-------------------------------------------------*/
|
||||
@ -1395,6 +1428,7 @@ int mame_validitychecks(const game_driver *curdriver)
|
||||
osd_ticks_t display_checks = 0;
|
||||
osd_ticks_t input_checks = 0;
|
||||
osd_ticks_t sound_checks = 0;
|
||||
osd_ticks_t device_checks = 0;
|
||||
#ifdef MESS
|
||||
osd_ticks_t mess_checks = 0;
|
||||
#endif
|
||||
@ -1500,6 +1534,11 @@ int mame_validitychecks(const game_driver *curdriver)
|
||||
error = validate_sound(drivnum, config) || error;
|
||||
sound_checks += osd_profiling_ticks();
|
||||
|
||||
/* validate devices */
|
||||
device_checks -= osd_profiling_ticks();
|
||||
error = validate_devices(drivnum, config) || error;
|
||||
device_checks += osd_profiling_ticks();
|
||||
|
||||
machine_config_free(config);
|
||||
}
|
||||
|
||||
|
@ -804,6 +804,29 @@ static DEVICE_RESET( mc6845 )
|
||||
mc6845->light_pen_latched = FALSE;
|
||||
}
|
||||
|
||||
static DEVICE_VALIDITY_CHECK( mc6845 )
|
||||
{
|
||||
int error = FALSE;
|
||||
const mc6845_interface *intf = (const mc6845_interface *) device->static_config;
|
||||
|
||||
if (intf != NULL)
|
||||
{
|
||||
if (intf->clock <= 0)
|
||||
{
|
||||
mame_printf_error("%s: %s has an mc6845 with an invalid clock\n", driver->source_file, driver->name);
|
||||
error = TRUE;
|
||||
}
|
||||
|
||||
if (intf->hpixels_per_column <= 0)
|
||||
{
|
||||
mame_printf_error("%s: %s has an mc6845 with an invalid hpixels_per_column\n", driver->source_file, driver->name);
|
||||
error = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
static DEVICE_SET_INFO( mc6845 )
|
||||
{
|
||||
@ -828,6 +851,7 @@ DEVICE_GET_INFO( mc6845 )
|
||||
case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(mc6845); break;
|
||||
case DEVINFO_FCT_STOP: /* Nothing */ break;
|
||||
case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(mc6845); break;
|
||||
case DEVINFO_FCT_VALIDITY_CHECK: info->validity_check = DEVICE_VALIDITY_CHECK_NAME(mc6845); break;
|
||||
|
||||
/* --- the following bits of info are returned as NULL-terminated strings --- */
|
||||
case DEVINFO_STR_NAME: info->s = "Motorola 6845"; break;
|
||||
|
Loading…
Reference in New Issue
Block a user