Added support for inline device configuration.

This commit is contained in:
Aaron Giles 2008-02-20 06:06:13 +00:00
parent 8c4a6a2d2a
commit 99675196a8
4 changed files with 17 additions and 8 deletions

View File

@ -82,15 +82,20 @@ device_config *device_list_add(device_config **listheadptr, device_type type, co
if (type == (*devptr)->type && strcmp(tag, (*devptr)->tag) == 0)
fatalerror("Attempted to add duplicate device: type=%s tag=%s\n", devtype_name(type), tag);
/* get the size of the inline config */
info.i = 0;
(*type)(NULL, NULL, DEVINFO_INT_INLINE_CONFIG_BYTES, &info);
/* allocate a new device */
device = malloc_or_die(sizeof(*device) + strlen(tag));
device = malloc_or_die(sizeof(*device) + strlen(tag) + info.i);
/* populate all fields */
device->next = NULL;
device->type = type;
device->flags = 0;
device->clock = 0;
device->config = NULL;
device->static_config = NULL;
device->inline_config = (info.i == 0) ? NULL : (device->tag + strlen(tag) + 1);
device->token = NULL;
strcpy(device->tag, tag);
@ -217,7 +222,7 @@ void device_list_start(running_machine *machine)
assert(config->start != NULL);
/* call the start function */
config->token = (*config->start)(machine, config->clock, config->flags, config->config);
config->token = (*config->start)(machine, config->clock, config->flags, config->static_config, config->inline_config);
assert(config->token != NULL);
/* fatal error if this fails */

View File

@ -27,6 +27,8 @@ enum
/* --- the following bits of info are returned as 64-bit signed integers --- */
DEVINFO_INT_FIRST = 0x00000,
DEVINFO_INT_INLINE_CONFIG_BYTES = DEVINFO_INT_FIRST,/* R/O: bytes of inline configuration */
DEVINFO_INT_DEVICE_SPECIFIC = 0x08000, /* R/W: device-specific values start here */
DEVINFO_INT_LAST = 0x0ffff,
@ -77,7 +79,7 @@ typedef union _deviceinfo deviceinfo;
/* device interface function types */
typedef void (*device_get_info_func)(running_machine *machine, void *token, UINT32 state, deviceinfo *info);
typedef void (*device_set_info_func)(running_machine *machine, void *token, UINT32 state, const deviceinfo *info);
typedef void *(*device_start_func)(running_machine *machine, UINT32 clock, UINT32 flags, const void *config);
typedef void *(*device_start_func)(running_machine *machine, UINT32 clock, UINT32 flags, const void *static_config, const void *inline_config);
typedef void (*device_stop_func)(running_machine *machine, void *token);
typedef void (*device_reset_func)(running_machine *machine, void *token);
@ -109,11 +111,12 @@ struct _device_config
device_type type; /* device type */
UINT32 flags; /* device flags */
UINT32 clock; /* device clock */
const void * config; /* static device configuration */
device_set_info_func set_info; /* quick pointer to set_info callback */
device_start_func start; /* quick pointer to start callback */
device_stop_func stop; /* quick pointer to stop callback */
device_reset_func reset; /* quick pointer to reset callback */
const void * static_config; /* static device configuration */
void * inline_config; /* inline device configuration */
void * token; /* token if device is live */
char tag[1]; /* tag for this instance */
};

View File

@ -385,7 +385,7 @@ struct _machine_config
device->flags = (_flags); \
#define MDRV_DEVICE_CONFIG(_config) \
device->config = &(_config); \
device->static_config = &(_config); \

View File

@ -445,9 +445,9 @@ void mc6845_update(mc6845_t *mc6845, mame_bitmap *bitmap, const rectangle *clipr
/* device interface */
static void *mc6845_start(running_machine *machine, UINT32 clock, UINT32 flags, const void *config)
static void *mc6845_start(running_machine *machine, UINT32 clock, UINT32 flags, const void *static_config, const void *inline_config)
{
return mc6845_config(config);
return mc6845_config(static_config);
}
@ -465,6 +465,7 @@ void mc6845_get_info(running_machine *machine, void *token, UINT32 state, device
switch (state)
{
/* --- the following bits of info are returned as 64-bit signed integers --- */
case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break;
/* --- the following bits of info are returned as pointers to data or functions --- */
case DEVINFO_FCT_SET_INFO: info->set_info = mc6845_set_info; break;