Added new module tagmap which is a simple hashed string map.

Updated device and input port lists to use the tagmap for
tag searches. Also removed the whole "quark" thing from the
validity checker in favor of using the tagmaps.
This commit is contained in:
Aaron Giles 2009-11-23 04:55:26 +00:00
parent 41be698d6e
commit 9072c7f911
45 changed files with 477 additions and 519 deletions

View File

@ -226,10 +226,10 @@ enum
***************************************************************************/
/* device iteration helpers */
#define cpu_count(config) device_list_items((config)->devicelist, CPU)
#define cpu_first(config) device_list_first((config)->devicelist, CPU)
#define cpu_count(config) device_list_items(&(config)->devicelist, CPU)
#define cpu_first(config) device_list_first(&(config)->devicelist, CPU)
#define cpu_next(previous) ((previous)->typenext)
#define cpu_get_index(cpu) device_list_index((cpu)->machine->config->devicelist, CPU, (cpu)->tag)
#define cpu_get_index(cpu) device_list_index(&(cpu)->machine->config->devicelist, CPU, (cpu)->tag)
/* IRQ callback to be called by CPU cores when an IRQ is actually taken */

View File

@ -220,7 +220,7 @@ void crosshair_init(running_machine *machine)
global.auto_time = CROSSHAIR_VISIBILITY_AUTOTIME_DEFAULT;
/* determine who needs crosshairs */
for (port = machine->portconfig; port != NULL; port = port->next)
for (port = machine->portlist.head; port != NULL; port = port->next)
for (field = port->fieldlist; field != NULL; field = field->next)
if (field->crossaxis != CROSSHAIR_AXIS_NONE)
{

View File

@ -542,7 +542,7 @@ int debug_command_parameter_cpu(running_machine *machine, const char *param, con
}
/* if we got a valid one, return */
*result = device_list_find_by_index(machine->config->devicelist, CPU, cpunum);
*result = device_list_find_by_index(&machine->config->devicelist, CPU, cpunum);
if (*result != NULL)
return TRUE;
@ -2512,7 +2512,7 @@ static void execute_snap(running_machine *machine, int ref, int params, const ch
int scrnum = (params > 1) ? atoi(param[1]) : 0;
astring *fname;
const device_config *screen = device_list_find_by_index(machine->config->devicelist, VIDEO_SCREEN, scrnum);
const device_config *screen = device_list_find_by_index(&machine->config->devicelist, VIDEO_SCREEN, scrnum);
if ((screen == NULL) || !render_is_live_screen(screen))
{

View File

@ -2399,7 +2399,7 @@ static const memory_subview_item *memory_view_enumerate_subviews(running_machine
int itemnum;
/* first add all the device's address spaces */
for (device = machine->config->devicelist; device != NULL; device = device->next)
for (device = machine->config->devicelist.head; device != NULL; device = device->next)
for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++)
{
const address_space *space = memory_find_address_space(device, spacenum);

View File

@ -42,7 +42,7 @@ void devcb_resolve_read_line(devcb_resolved_read_line *resolved, const devcb_rea
/* input port handlers */
if (config->type == DEVCB_TYPE_INPUT)
{
resolved->target = input_port_by_tag(device->machine->portconfig, config->tag);
resolved->target = input_port_by_tag(&device->machine->portlist, config->tag);
if (resolved->target == NULL)
fatalerror("devcb_resolve_read_line: unable to find input port '%s' (requested by %s '%s')", config->tag, device_get_name(device), device->tag);
resolved->read = trampoline_read_port_to_read_line;
@ -216,7 +216,7 @@ void devcb_resolve_read8(devcb_resolved_read8 *resolved, const devcb_read8 *conf
/* input port handlers */
if (config->type == DEVCB_TYPE_INPUT)
{
resolved->target = input_port_by_tag(device->machine->portconfig, config->tag);
resolved->target = input_port_by_tag(&device->machine->portlist, config->tag);
if (resolved->target == NULL)
fatalerror("devcb_resolve_read8: unable to find input port '%s' (requested by %s '%s')", config->tag, device_get_name(device), device->tag);
resolved->read = trampoline_read_port_to_read8;

View File

@ -87,31 +87,79 @@ INLINE int device_matches_type(const device_config *device, device_type type)
DEVICE CONFIGURATION
***************************************************************************/
/*-------------------------------------------------
device_list_init - initialize a device list
structure, optionally allocating a map for it
-------------------------------------------------*/
void device_list_init(device_list *devlist, int allocmap)
{
/* initialize fields */
devlist->head = NULL;
devlist->map = NULL;
if (allocmap)
{
devlist->map = tagmap_alloc();
if (devlist->map == NULL)
fatalerror("Out of memory for device list map");
}
}
/*-------------------------------------------------
device_list_deinit - free memory attached to
a device list and clear out the structure
-------------------------------------------------*/
void device_list_deinit(device_list *devlist)
{
/* release all devices */
while (devlist->head != NULL)
device_list_remove(devlist, devlist->head->tag);
/* release the map memory */
if (devlist->map != NULL)
tagmap_free(devlist->map);
}
/*-------------------------------------------------
device_list_add - add a new device to the
end of a device list
-------------------------------------------------*/
device_config *device_list_add(device_config **listheadptr, const device_config *owner, device_type type, const char *tag, UINT32 clock)
device_config *device_list_add(device_list *devlist, const device_config *owner, device_type type, const char *tag, UINT32 clock)
{
device_config **devptr, **tempdevptr;
device_config *device, *tempdevice;
tagmap_error tmerr;
UINT32 configlen;
assert(listheadptr != NULL);
assert(devlist != NULL);
assert(devlist->map != NULL);
assert(type != NULL);
assert(tag != NULL);
/* find the end of the list, and ensure no duplicates along the way */
for (devptr = listheadptr; *devptr != NULL; devptr = &(*devptr)->next)
if (strcmp(tag, (*devptr)->tag) == 0)
fatalerror("Attempted to add duplicate device: type=%s tag=%s\n", device_get_name(*devptr), tag);
/* find the end of the list */
for (devptr = &devlist->head; *devptr != NULL; devptr = &(*devptr)->next) ;
/* get the size of the inline config */
configlen = (UINT32)devtype_get_info_int(type, DEVINFO_INT_INLINE_CONFIG_BYTES);
/* allocate a new device */
device = (device_config *)alloc_array_or_die(UINT8, sizeof(*device) + strlen(tag) + configlen);
/* add to the map */
tmerr = tagmap_add_unique_hash(devlist->map, tag, device);
if (tmerr == TMERR_DUPLICATE)
{
device_config *match = tagmap_find_hash_only(devlist->map, tag);
assert(match != NULL);
if (strcmp(tag, match->tag) == 0)
fatalerror("Attempted to add duplicate device: type=%s tag=%s\n", device_get_name(*devptr), tag);
else
fatalerror("Two devices have tags which hash to the same value: '%s' and '%s'\n", tag, match->tag);
}
/* populate device relationships */
device->next = NULL;
@ -154,12 +202,12 @@ device_config *device_list_add(device_config **listheadptr, const device_config
/* fetch function pointers to the core functions */
/* before adding us to the global list, add us to the end of the type list */
tempdevice = (device_config *)device_list_first(*listheadptr, type);
tempdevice = (device_config *)device_list_first(devlist, type);
for (tempdevptr = &tempdevice; *tempdevptr != NULL; tempdevptr = &(*tempdevptr)->typenext) ;
*tempdevptr = device;
/* and to the end of the class list */
tempdevice = (device_config *)device_list_class_first(*listheadptr, device->devclass);
tempdevice = (device_config *)device_list_class_first(devlist, device->devclass);
for (tempdevptr = &tempdevice; *tempdevptr != NULL; tempdevptr = &(*tempdevptr)->classnext) ;
*tempdevptr = device;
@ -174,16 +222,16 @@ device_config *device_list_add(device_config **listheadptr, const device_config
device list
-------------------------------------------------*/
void device_list_remove(device_config **listheadptr, const char *tag)
void device_list_remove(device_list *devlist, const char *tag)
{
device_config **devptr, **tempdevptr;
device_config *device, *tempdevice;
assert(listheadptr != NULL);
assert(devlist != NULL);
assert(tag != NULL);
/* find the device in the list */
for (devptr = listheadptr; *devptr != NULL; devptr = &(*devptr)->next)
for (devptr = &devlist->head; *devptr != NULL; devptr = &(*devptr)->next)
if (strcmp(tag, (*devptr)->tag) == 0)
break;
device = *devptr;
@ -191,13 +239,13 @@ void device_list_remove(device_config **listheadptr, const char *tag)
fatalerror("Attempted to remove non-existant device: tag=%s\n", tag);
/* before removing us from the global list, remove us from the type list */
tempdevice = (device_config *)device_list_first(*listheadptr, device->type);
tempdevice = (device_config *)device_list_first(devlist, device->type);
for (tempdevptr = &tempdevice; *tempdevptr != device; tempdevptr = &(*tempdevptr)->typenext) ;
assert(*tempdevptr == device);
*tempdevptr = device->typenext;
/* and from the class list */
tempdevice = (device_config *)device_list_class_first(*listheadptr, device->devclass);
tempdevice = (device_config *)device_list_class_first(devlist, device->devclass);
for (tempdevptr = &tempdevice; *tempdevptr != device; tempdevptr = &(*tempdevptr)->classnext) ;
assert(*tempdevptr == device);
*tempdevptr = device->classnext;
@ -205,6 +253,10 @@ void device_list_remove(device_config **listheadptr, const char *tag)
/* remove the device from the list */
*devptr = device->next;
/* and from the map */
if (devlist->map != NULL)
tagmap_remove(devlist->map, device->tag);
/* free the device object */
free(device);
}
@ -281,7 +333,7 @@ const device_contract *device_get_contract(const device_config *device, const ch
is allowed
-------------------------------------------------*/
int device_list_items(const device_config *listhead, device_type type)
int device_list_items(const device_list *devlist, device_type type)
{
const device_config *curdev;
int count = 0;
@ -289,14 +341,14 @@ int device_list_items(const device_config *listhead, device_type type)
/* locate all devices */
if (type == DEVICE_TYPE_WILDCARD)
{
for (curdev = listhead; curdev != NULL; curdev = curdev->next)
for (curdev = devlist->head; curdev != NULL; curdev = curdev->next)
count++;
}
/* locate all devices of a given type */
else
{
for (curdev = listhead; curdev != NULL && curdev->type != type; curdev = curdev->next) ;
for (curdev = devlist->head; curdev != NULL && curdev->type != type; curdev = curdev->next) ;
for ( ; curdev != NULL; curdev = curdev->typenext)
count++;
}
@ -311,16 +363,16 @@ int device_list_items(const device_config *listhead, device_type type)
DEVICE_TYPE_WILDCARD is allowed
-------------------------------------------------*/
const device_config *device_list_first(const device_config *listhead, device_type type)
const device_config *device_list_first(const device_list *devlist, device_type type)
{
const device_config *curdev;
/* first of any device type */
if (type == DEVICE_TYPE_WILDCARD)
return listhead;
return devlist->head;
/* first of a given type */
for (curdev = listhead; curdev != NULL && curdev->type != type; curdev = curdev->next) ;
for (curdev = devlist->head; curdev != NULL && curdev->type != type; curdev = curdev->next) ;
return curdev;
}
@ -339,19 +391,18 @@ const device_config *device_list_next(const device_config *prevdevice, device_ty
/*-------------------------------------------------
device_list_find_by_tag - retrieve a device
configuration based on a type and tag;
DEVICE_TYPE_WILDCARD is allowed
device_list_find_by_tag_slow - retrieve a
device configuration based on a tag
-------------------------------------------------*/
const device_config *device_list_find_by_tag(const device_config *listhead, const char *tag)
const device_config *device_list_find_by_tag_slow(const device_list *devlist, const char *tag)
{
const device_config *curdev;
assert(tag != NULL);
/* locate among all devices */
for (curdev = listhead; curdev != NULL; curdev = curdev->next)
for (curdev = devlist->head; curdev != NULL; curdev = curdev->next)
if (strcmp(tag, curdev->tag) == 0)
return curdev;
@ -374,7 +425,7 @@ const device_config *device_find_child_by_tag(const device_config *owner, const
assert(tag != NULL);
tempstring = astring_alloc();
child = device_list_find_by_tag(owner->machine->config->devicelist, device_build_tag(tempstring, owner, tag));
child = device_list_find_by_tag(&owner->machine->config->devicelist, device_build_tag(tempstring, owner, tag));
astring_free(tempstring);
return child;
@ -387,7 +438,7 @@ const device_config *device_find_child_by_tag(const device_config *owner, const
DEVICE_TYPE_WILDCARD is allowed
-------------------------------------------------*/
int device_list_index(const device_config *listhead, device_type type, const char *tag)
int device_list_index(const device_list *devlist, device_type type, const char *tag)
{
const device_config *curdev;
int index = 0;
@ -397,7 +448,7 @@ int device_list_index(const device_config *listhead, device_type type, const cha
/* locate among all devices */
if (type == DEVICE_TYPE_WILDCARD)
{
for (curdev = listhead; curdev != NULL; curdev = curdev->next)
for (curdev = devlist->head; curdev != NULL; curdev = curdev->next)
{
if (strcmp(tag, curdev->tag) == 0)
return index;
@ -408,7 +459,7 @@ int device_list_index(const device_config *listhead, device_type type, const cha
/* locate among all devices of a given type */
else
{
for (curdev = listhead; curdev != NULL && curdev->type != type; curdev = curdev->next) ;
for (curdev = devlist->head; curdev != NULL && curdev->type != type; curdev = curdev->next) ;
for ( ; curdev != NULL; curdev = curdev->typenext)
{
if (strcmp(tag, curdev->tag) == 0)
@ -426,14 +477,14 @@ int device_list_index(const device_config *listhead, device_type type, const cha
configuration based on a type and index
-------------------------------------------------*/
const device_config *device_list_find_by_index(const device_config *listhead, device_type type, int index)
const device_config *device_list_find_by_index(const device_list *devlist, device_type type, int index)
{
const device_config *curdev;
/* locate among all devices */
if (type == DEVICE_TYPE_WILDCARD)
{
for (curdev = listhead; curdev != NULL; curdev = curdev->next)
for (curdev = devlist->head; curdev != NULL; curdev = curdev->next)
if (index-- == 0)
return curdev;
}
@ -441,7 +492,7 @@ const device_config *device_list_find_by_index(const device_config *listhead, de
/* locate among all devices of a given type */
else
{
for (curdev = listhead; curdev != NULL && curdev->type != type; curdev = curdev->next) ;
for (curdev = devlist->head; curdev != NULL && curdev->type != type; curdev = curdev->next) ;
for ( ; curdev != NULL; curdev = curdev->typenext)
if (index-- == 0)
return curdev;
@ -462,13 +513,13 @@ const device_config *device_list_find_by_index(const device_config *listhead, de
items of a given class
-------------------------------------------------*/
int device_list_class_items(const device_config *listhead, device_class devclass)
int device_list_class_items(const device_list *devlist, device_class devclass)
{
const device_config *curdev;
int count = 0;
/* locate all devices of a given class */
for (curdev = listhead; curdev != NULL && curdev->devclass != devclass; curdev = curdev->next) ;
for (curdev = devlist->head; curdev != NULL && curdev->devclass != devclass; curdev = curdev->next) ;
for ( ; curdev != NULL; curdev = curdev->classnext)
count++;
@ -481,12 +532,12 @@ int device_list_class_items(const device_config *listhead, device_class devclass
device in the list of a given class
-------------------------------------------------*/
const device_config *device_list_class_first(const device_config *listhead, device_class devclass)
const device_config *device_list_class_first(const device_list *devlist, device_class devclass)
{
const device_config *curdev;
/* first of a given class */
for (curdev = listhead; curdev != NULL && curdev->devclass != devclass; curdev = curdev->next) ;
for (curdev = devlist->head; curdev != NULL && curdev->devclass != devclass; curdev = curdev->next) ;
return curdev;
}
@ -508,7 +559,7 @@ const device_config *device_list_class_next(const device_config *prevdevice, dev
device based on its class and tag
-------------------------------------------------*/
int device_list_class_index(const device_config *listhead, device_class devclass, const char *tag)
int device_list_class_index(const device_list *devlist, device_class devclass, const char *tag)
{
const device_config *curdev;
int index = 0;
@ -516,7 +567,7 @@ int device_list_class_index(const device_config *listhead, device_class devclass
assert(tag != NULL);
/* locate among all devices of a given class */
for (curdev = listhead; curdev != NULL && curdev->devclass != devclass; curdev = curdev->next) ;
for (curdev = devlist->head; curdev != NULL && curdev->devclass != devclass; curdev = curdev->next) ;
for ( ; curdev != NULL; curdev = curdev->classnext)
{
if (strcmp(tag, curdev->tag) == 0)
@ -534,12 +585,12 @@ int device_list_class_index(const device_config *listhead, device_class devclass
index
-------------------------------------------------*/
const device_config *device_list_class_find_by_index(const device_config *listhead, device_class devclass, int index)
const device_config *device_list_class_find_by_index(const device_list *devlist, device_class devclass, int index)
{
const device_config *curdev;
/* locate among all devices of a given class */
for (curdev = listhead; curdev != NULL && curdev->devclass != devclass; curdev = curdev->next) ;
for (curdev = devlist->head; curdev != NULL && curdev->devclass != devclass; curdev = curdev->next) ;
for ( ; curdev != NULL; curdev = curdev->classnext)
if (index-- == 0)
return curdev;
@ -566,7 +617,7 @@ void device_list_attach_machine(running_machine *machine)
assert(machine != NULL);
/* iterate over devices and assign the machine to them */
for (device = (device_config *)machine->config->devicelist; device != NULL; device = device->next)
for (device = (device_config *)machine->config->devicelist.head; device != NULL; device = device->next)
device->machine = machine;
}
@ -589,7 +640,7 @@ void device_list_start(running_machine *machine)
add_exit_callback(machine, device_list_stop);
/* iterate over devices and allocate memory for them */
for (device = (device_config *)machine->config->devicelist; device != NULL; device = device->next)
for (device = (device_config *)machine->config->devicelist.head; device != NULL; device = device->next)
{
int spacenum;
@ -622,7 +673,7 @@ void device_list_start(running_machine *machine)
int prevstarted = numstarted;
/* iterate over devices and start them */
for (device = (device_config *)machine->config->devicelist; device != NULL; device = device->next)
for (device = (device_config *)machine->config->devicelist.head; device != NULL; device = device->next)
{
device_start_func start = (device_start_func)device_get_info_fct(device, DEVINFO_FCT_START);
assert(start != NULL);
@ -675,7 +726,7 @@ static void device_list_stop(running_machine *machine)
assert(machine != NULL);
/* iterate over devices and stop them */
for (device = (device_config *)machine->config->devicelist; device != NULL; device = device->next)
for (device = (device_config *)machine->config->devicelist.head; device != NULL; device = device->next)
{
device_stop_func stop = (device_stop_func)device_get_info_fct(device, DEVINFO_FCT_STOP);
@ -712,7 +763,7 @@ static void device_list_reset(running_machine *machine)
assert(machine != NULL);
/* iterate over devices and stop them */
for (device = (device_config *)machine->config->devicelist; device != NULL; device = device->next)
for (device = (device_config *)machine->config->devicelist.head; device != NULL; device = device->next)
device_reset(device);
}

View File

@ -17,6 +17,7 @@
#include "mamecore.h"
#include "romload.h"
#include "memory.h"
#include "tagmap.h"
/***************************************************************************
@ -182,7 +183,7 @@ enum
/* shorthand for accessing devices by machine/type/tag */
#define devtag_get_device(mach,tag) device_list_find_by_tag((mach)->config->devicelist, tag)
#define devtag_get_device(mach,tag) device_list_find_by_tag(&(mach)->config->devicelist, tag)
#define devtag_reset(mach,tag) device_reset(devtag_get_device(mach, tag))
#define devtag_get_address_space(mach,tag,space)
@ -328,6 +329,15 @@ struct _device_config
};
/* an object that contains a list of devices */
typedef struct _device_list device_list;
struct _device_list
{
device_config * head; /* head of the list */
tagmap * map; /* map for fast lookups */
};
/***************************************************************************
FUNCTION PROTOTYPES
@ -336,11 +346,17 @@ struct _device_config
/* ----- device configuration ----- */
/* initialize a device list structure, optionally allocating a map for it */
void device_list_init(device_list *devlist, int allocmap);
/* free memory attached to a device list and clear out the structure */
void device_list_deinit(device_list *devlist);
/* add a new device to the end of a device list */
device_config *device_list_add(device_config **listheadptr, const device_config *owner, device_type type, const char *tag, UINT32 clock);
device_config *device_list_add(device_list *devlist, const device_config *owner, device_type type, const char *tag, UINT32 clock);
/* remove a device from a device list */
void device_list_remove(device_config **listheadptr, const char *tag);
void device_list_remove(device_list *devlist, const char *tag);
/* build a tag that combines the device's name and the given tag */
const char *device_build_tag(astring *dest, const device_config *device, const char *tag);
@ -356,44 +372,44 @@ const device_contract *device_get_contract(const device_config *device, const ch
/* ----- type-based device access ----- */
/* return the number of items of a given type; DEVICE_TYPE_WILDCARD is allowed */
int device_list_items(const device_config *listhead, device_type type);
int device_list_items(const device_list *devlist, device_type type);
/* return the first device in the list of a given type; DEVICE_TYPE_WILDCARD is allowed */
const device_config *device_list_first(const device_config *listhead, device_type type);
const device_config *device_list_first(const device_list *devlist, device_type type);
/* return the next device in the list of a given type; DEVICE_TYPE_WILDCARD is allowed */
const device_config *device_list_next(const device_config *prevdevice, device_type type);
/* retrieve a device configuration based on a tag */
const device_config *device_list_find_by_tag(const device_config *listhead, const char *tag);
/* retrieve a device configuration based on a tag via linear search */
const device_config *device_list_find_by_tag_slow(const device_list *devlist, const char *tag);
/* retrieve a child device configuration based on a tag */
const device_config *device_find_child_by_tag(const device_config *owner, const char *tag);
/* return the index of a device based on its type and tag; DEVICE_TYPE_WILDCARD is allowed */
int device_list_index(const device_config *listhead, device_type type, const char *tag);
int device_list_index(const device_list *devlist, device_type type, const char *tag);
/* retrieve a device configuration based on a type and index; DEVICE_TYPE_WILDCARD is allowed */
const device_config *device_list_find_by_index(const device_config *listhead, device_type type, int index);
const device_config *device_list_find_by_index(const device_list *devlist, device_type type, int index);
/* ----- class-based device access ----- */
/* return the number of items of a given class */
int device_list_class_items(const device_config *listhead, device_class devclass);
int device_list_class_items(const device_list *devlist, device_class devclass);
/* return the first device in the list of a given class */
const device_config *device_list_class_first(const device_config *listhead, device_class devclass);
const device_config *device_list_class_first(const device_list *devlist, device_class devclass);
/* return the next device in the list of a given class */
const device_config *device_list_class_next(const device_config *prevdevice, device_class devclass);
/* return the index of a device based on its class and tag */
int device_list_class_index(const device_config *listhead, device_class devclass, const char *tag);
int device_list_class_index(const device_list *devlist, device_class devclass, const char *tag);
/* retrieve a device configuration based on a class and index */
const device_config *device_list_class_find_by_index(const device_config *listhead, device_class devclass, int index);
const device_config *device_list_class_find_by_index(const device_list *devlist, device_class devclass, int index);
@ -444,4 +460,26 @@ genf *devtype_get_info_fct(device_type type, UINT32 state);
const char *devtype_get_info_string(device_type type, UINT32 state);
/***************************************************************************
INLINE FUNCTIONS
***************************************************************************/
/*-------------------------------------------------
device_list_find_by_tag - retrieve a device
configuration based on a type and tag;
DEVICE_TYPE_WILDCARD is allowed
-------------------------------------------------*/
INLINE const device_config *device_list_find_by_tag(const device_list *devlist, const char *tag)
{
/* if we have a map, use it */
if (devlist->map != NULL)
return tagmap_find_hash_only(devlist->map, tag);
/* otherwise, go the slow route */
return device_list_find_by_tag_slow(devlist, tag);
}
#endif /* __DEVINTRF_H__ */

View File

@ -36,13 +36,13 @@
settings for a game
-------------------------------------------------*/
static void print_game_switches(FILE *out, const game_driver *game, const input_port_config *portlist)
static void print_game_switches(FILE *out, const game_driver *game, const input_port_list *portlist)
{
const input_port_config *port;
const input_field_config *field;
/* iterate looking for DIP switches */
for (port = portlist; port != NULL; port = port->next)
for (port = portlist->head; port != NULL; port = port->next)
for (field = port->fieldlist; field != NULL; field = field->next)
if (field->type == IPT_DIPSWITCH)
{
@ -70,13 +70,13 @@ static void print_game_switches(FILE *out, const game_driver *game, const input_
settings for a game
-------------------------------------------------*/
static void print_game_configs(FILE *out, const game_driver *game, const input_port_config *portlist)
static void print_game_configs(FILE *out, const game_driver *game, const input_port_list *portlist)
{
const input_port_config *port;
const input_field_config *field;
/* iterate looking for configurations */
for (port = portlist; port != NULL; port = port->next)
for (port = portlist->head; port != NULL; port = port->next)
for (field = port->fieldlist; field != NULL; field = field->next)
if (field->type == IPT_CONFIG)
{
@ -104,13 +104,13 @@ static void print_game_configs(FILE *out, const game_driver *game, const input_p
Adjusters for a game
-------------------------------------------------*/
static void print_game_adjusters(FILE *out, const game_driver *game, const input_port_config *portlist)
static void print_game_adjusters(FILE *out, const game_driver *game, const input_port_list *portlist)
{
const input_port_config *port;
const input_field_config *field;
/* iterate looking for Adjusters */
for (port = portlist; port != NULL; port = port->next)
for (port = portlist->head; port != NULL; port = port->next)
for (field = port->fieldlist; field != NULL; field = field->next)
if (field->type == IPT_ADJUSTER)
{
@ -124,7 +124,7 @@ static void print_game_adjusters(FILE *out, const game_driver *game, const input
input
-------------------------------------------------*/
static void print_game_input(FILE *out, const game_driver *game, const input_port_config *portlist)
static void print_game_input(FILE *out, const game_driver *game, const input_port_list *portlist)
{
/* fix me -- this needs to be cleaned up to match the core style */
@ -164,7 +164,7 @@ enum {cjoy, cdoublejoy, cAD_stick, cdial, ctrackball, cpaddle, clightgun, cpedal
control[i].reverse = 0;
}
for (port = portlist; port != NULL; port = port->next)
for (port = portlist->head; port != NULL; port = port->next)
for (field = port->fieldlist; field != NULL; field = field->next)
{
if (nplayer < field->player+1)
@ -821,8 +821,8 @@ static void print_game_driver(FILE *out, const game_driver *game, const machine_
static void print_game_info(FILE *out, const game_driver *game)
{
const input_port_config *portconfig;
const game_driver *clone_of;
input_port_list portlist;
machine_config *config;
const char *start;
@ -836,7 +836,7 @@ static void print_game_info(FILE *out, const game_driver *game)
/* temporary hook until MESS device transition is complete */
mess_devices_setup(NULL, config, game);
#endif /* MESS */
portconfig = input_port_config_alloc(game->ipt, NULL, 0);
input_port_list_init(&portlist, game->ipt, NULL, 0, FALSE);
/* print the header and the game name */
fprintf(out, "\t<" XML_TOP);
@ -886,13 +886,13 @@ static void print_game_info(FILE *out, const game_driver *game)
print_game_chips(out, game, config);
print_game_display(out, game, config);
print_game_sound(out, game, config);
print_game_input(out, game, portconfig);
print_game_switches(out, game, portconfig);
print_game_configs(out, game, portconfig);
print_game_input(out, game, &portlist);
print_game_switches(out, game, &portlist);
print_game_configs(out, game, &portlist);
#ifdef MESS
print_game_categories(out, game, portconfig);
print_game_categories(out, game, &portlist);
#endif /* MESS */
print_game_adjusters(out, game, portconfig);
print_game_adjusters(out, game, &portlist);
print_game_driver(out, game, config);
#ifdef MESS
print_game_device(out, game, config);
@ -902,7 +902,7 @@ static void print_game_info(FILE *out, const game_driver *game)
/* close the topmost tag */
fprintf(out, "\t</" XML_TOP ">\n");
input_port_config_free(portconfig);
input_port_list_deinit(&portlist);
machine_config_free(config);
}

View File

@ -200,9 +200,9 @@ struct _digital_joystick_state
typedef struct _device_field_info device_field_info;
struct _device_field_info
{
device_field_info * next; /* linked list of info for this port */
device_field_info * next; /* linked list of info for this port */
const input_field_config * field; /* pointer to the input field referenced */
const device_config * device; /* device */
const device_config * device; /* device */
UINT8 shift; /* shift to apply to the final result */
};
@ -225,8 +225,8 @@ struct _input_field_state
struct _input_port_state
{
analog_field_state * analoglist; /* pointer to list of analog port info */
device_field_info * readdevicelist; /* pointer to list of input device info */
device_field_info * writedevicelist; /* pointer to list of output device info */
device_field_info * readdevicelist; /* pointer to list of input device info */
device_field_info * writedevicelist; /* pointer to list of output device info */
input_port_value defvalue; /* combined default value across the port */
input_port_value digital; /* current value from all digital inputs */
input_port_value vblank; /* value of all IPT_VBLANK bits */
@ -250,7 +250,7 @@ struct _input_port_private
{
/* global state */
UINT8 safe_to_read; /* clear at start; set after state is loaded */
/* types */
input_type_state * typestatelist; /* list of live type states */
input_type_state * type_to_typestate[__ipt_max][MAX_PLAYERS]; /* map from type/player to type state */
@ -443,7 +443,7 @@ static INT32 apply_analog_settings(INT32 current, analog_field_state *analog);
/* initialization helpers */
static void init_port_types(running_machine *machine);
static void init_port_state(running_machine *machine);
static void init_autoselect_devices(const input_port_config *portlist, int type1, int type2, int type3, const char *option, const char *ananame);
static void init_autoselect_devices(const input_port_list *portlist, int type1, int type2, int type3, const char *option, const char *ananame);
static device_field_info *init_field_device_info(const input_field_config *field,const char *device_name);
static analog_field_state *init_field_analog_state(const input_field_config *field);
@ -455,7 +455,7 @@ static void frame_update_analog_field(running_machine *machine, analog_field_sta
static int frame_get_digital_field_state(const input_field_config *field, int mouse_down);
/* port configuration helpers */
static input_port_config *port_config_detokenize(input_port_config *listhead, const input_port_token *ipt, char *errorbuf, int errorbuflen);
static void port_config_detokenize(input_port_list *portlist, const input_port_token *ipt, char *errorbuf, int errorbuflen);
static input_port_config *port_config_alloc(const input_port_config **listhead);
static void port_config_free(const input_port_config **portptr);
static input_port_config *port_config_find(const input_port_config *listhead, const char *tag);
@ -548,26 +548,6 @@ INLINE INT32 apply_analog_min_max(const analog_field_state *analog, INT32 value)
}
/*-------------------------------------------------
get_port_index - return an index for the
given port tag
-------------------------------------------------*/
INLINE int get_port_index(const input_port_config *portlist, const char *tag)
{
const input_port_config *port;
int index = 0;
for (port = portlist; port != NULL; port = port->next)
{
if (port->tag != NULL && strcmp(tag, port->tag) == 0)
return index;
index++;
}
return -1;
}
/*-------------------------------------------------
get_port_tag - return a guaranteed tag for
a port
@ -580,7 +560,7 @@ INLINE const char *get_port_tag(const input_port_config *port, char *tempbuffer)
if (port->tag != NULL)
return port->tag;
for (curport = port->machine->portconfig; curport != NULL; curport = curport->next)
for (curport = port->machine->portlist.head; curport != NULL; curport = curport->next)
{
if (curport == port)
break;
@ -626,6 +606,12 @@ INLINE int condition_equal(const input_condition *cond1, const input_condition *
/***************************************************************************
CUSTOM DEVICE I/O
***************************************************************************/
/*-------------------------------------------------
custom_read_line_device - device handler
stub to process PORT_CUSTOM behavior
-------------------------------------------------*/
static READ_LINE_DEVICE_HANDLER( custom_read_line_device )
{
const device_field_info *device_field = (const device_field_info *) device;
@ -633,6 +619,12 @@ static READ_LINE_DEVICE_HANDLER( custom_read_line_device )
return (*device_field->field->custom)(device_field->field, device_field->field->custom_param);
}
/*-------------------------------------------------
changed_write_line_device - device handler
stub to process PORT_CHANGED behavior
-------------------------------------------------*/
static WRITE_LINE_DEVICE_HANDLER( changed_write_line_device )
{
const device_field_info *device_field = (const device_field_info *) device;
@ -675,7 +667,7 @@ time_t input_port_init(running_machine *machine, const input_port_token *tokens)
/* if we have a token list, proceed */
if (tokens != NULL)
{
machine->portconfig = input_port_config_alloc(tokens, errorbuf, sizeof(errorbuf));
input_port_list_init(&machine->portlist, tokens, errorbuf, sizeof(errorbuf), TRUE);
if (errorbuf[0] != 0)
mame_printf_error("Input port errors:\n%s", errorbuf);
init_port_state(machine);
@ -704,8 +696,7 @@ static void input_port_exit(running_machine *machine)
record_end(machine, NULL);
/* free our allocated config */
if (machine->portconfig != NULL)
input_port_config_free(machine->portconfig);
input_port_list_deinit(&machine->portlist);
}
@ -715,45 +706,67 @@ static void input_port_exit(running_machine *machine)
***************************************************************************/
/*-------------------------------------------------
input_port_config_alloc - allocate a list of
input ports from the given token list
input_port_list_init - initialize an input
port list structure and allocate ports
according to the given tokens
-------------------------------------------------*/
const input_port_config *input_port_config_alloc(const input_port_token *tokens, char *errorbuf, int errorbuflen)
void input_port_list_init(input_port_list *portlist, const input_port_token *tokens, char *errorbuf, int errorbuflen, int allocmap)
{
/* initialize fields */
portlist->head = NULL;
portlist->map = NULL;
if (allocmap)
{
portlist->map = tagmap_alloc();
if (portlist->map == NULL)
fatalerror("Out of memory for input port map");
}
/* no tokens, no list */
if (tokens == NULL)
return NULL;
return;
/* reset error buffer */
if (errorbuf != NULL)
*errorbuf = 0;
return port_config_detokenize(NULL, tokens, errorbuf, errorbuflen);
/* detokenize into the list */
port_config_detokenize(portlist, tokens, errorbuf, errorbuflen);
}
/*-------------------------------------------------
input_port_config_free - free memory
allocated from input_port_alloc
input_port_list_deinit - free memory attached
to an input port list and clear out the
structure
-------------------------------------------------*/
void input_port_config_free(const input_port_config *portlist)
void input_port_list_deinit(input_port_list *portlist)
{
/* iterate over all ports and free them */
while (portlist != NULL)
port_config_free(&portlist);
while (portlist->head != NULL)
port_config_free(&portlist->head);
/* free the map if present */
if (portlist->map != NULL)
tagmap_free(portlist->map);
portlist->map = NULL;
}
/*-------------------------------------------------
input_port_by_tag - return a pointer to the
port_config associated with the given port
tag
input_port_by_tag_slow - return a pointer to
the port_config associated with the given
port tag
-------------------------------------------------*/
const input_port_config *input_port_by_tag(const input_port_config *portlist, const char *tag)
const input_port_config *input_port_by_tag_slow(const input_port_list *portlist, const char *tag)
{
const input_port_config *port;
/* loop over ports until we hit the index or run out */
for (port = portlist; port != NULL; port = port->next)
for (port = portlist->head; port != NULL; port = port->next)
if (port->tag != NULL && strcmp(port->tag, tag) == 0)
return port;
@ -767,12 +780,12 @@ const input_port_config *input_port_by_tag(const input_port_config *portlist, co
index
-------------------------------------------------*/
const input_port_config *input_port_by_index(const input_port_config *portlist, int index)
const input_port_config *input_port_by_index(const input_port_list *portlist, int index)
{
const input_port_config *port;
/* loop over ports until we hit the index or run out */
for (port = portlist; port != NULL; port = port->next)
for (port = portlist->head; port != NULL; port = port->next)
if (index-- == 0)
return port;
@ -786,7 +799,7 @@ const input_port_config *input_port_by_index(const input_port_config *portlist,
mask on the tagged port
-------------------------------------------------*/
const input_field_config *input_field_by_tag_and_mask(const input_port_config *portlist, const char *tag, input_port_value mask)
const input_field_config *input_field_by_tag_and_mask(const input_port_list *portlist, const char *tag, input_port_value mask)
{
const input_port_config *port = input_port_by_tag(portlist, tag);
const input_field_config *field;
@ -1297,7 +1310,7 @@ input_port_value input_port_read_direct(const input_port_config *port)
input_port_value input_port_read(running_machine *machine, const char *tag)
{
const input_port_config *port = input_port_by_tag(machine->portconfig, tag);
const input_port_config *port = input_port_by_tag(&machine->portlist, tag);
if (port == NULL)
fatalerror("Unable to locate input port '%s'", tag);
return input_port_read_direct(port);
@ -1312,7 +1325,7 @@ input_port_value input_port_read(running_machine *machine, const char *tag)
input_port_value input_port_read_safe(running_machine *machine, const char *tag, UINT32 defvalue)
{
const input_port_config *port = input_port_by_tag(machine->portconfig, tag);
const input_port_config *port = input_port_by_tag(&machine->portlist, tag);
return (port == NULL) ? defvalue : input_port_read_direct(port);
}
@ -1330,7 +1343,7 @@ int input_port_get_crosshair_position(running_machine *machine, int player, floa
int gotx = FALSE, goty = FALSE;
/* read all the lightgun values */
for (port = machine->portconfig; port != NULL; port = port->next)
for (port = machine->portlist.head; port != NULL; port = port->next)
for (field = port->fieldlist; field != NULL; field = field->next)
if (field->player == player && field->crossaxis != CROSSHAIR_AXIS_NONE)
if (input_condition_true(machine, &field->condition))
@ -1399,7 +1412,7 @@ void input_port_update_defaults(running_machine *machine)
const input_port_config *port;
/* loop over all input ports */
for (port = machine->portconfig; port != NULL; port = port->next)
for (port = machine->portlist.head; port != NULL; port = port->next)
{
const input_field_config *field;
@ -1470,7 +1483,7 @@ void input_port_write_direct(const input_port_config *port, input_port_value dat
input_port_value oldval = (port->state->lastwrite & device_field->field->mask) >> device_field->shift;
input_port_value newval = (newvalue & device_field->field->mask) >> device_field->shift;
/* if the bits have changed, call the handler */
/* if the bits have changed, call the handler */
if (oldval != newval)
(*device_field->field->write_line_device)(device_field->device, newval);
}
@ -1479,6 +1492,7 @@ void input_port_write_direct(const input_port_config *port, input_port_value dat
port->state->lastwrite = newvalue;
}
/*-------------------------------------------------
input_port_write - write a value to a
port specified by tag
@ -1486,20 +1500,21 @@ void input_port_write_direct(const input_port_config *port, input_port_value dat
void input_port_write(running_machine *machine, const char *tag, input_port_value value, input_port_value mask)
{
const input_port_config *port = input_port_by_tag(machine->portconfig, tag);
const input_port_config *port = input_port_by_tag(&machine->portlist, tag);
if (port == NULL)
fatalerror("Unable to locate input port '%s'", tag);
input_port_write_direct(port, value, mask);
}
/*-------------------------------------------------
input_port_read_safe - write a value to
input_port_write_safe - write a value to
a port, ignore if the port does not exist
-------------------------------------------------*/
void input_port_write_safe(running_machine *machine, const char *tag, input_port_value value, input_port_value mask)
{
const input_port_config *port = input_port_by_tag(machine->portconfig, tag);
const input_port_config *port = input_port_by_tag(&machine->portlist, tag);
if (port != NULL)
input_port_write_direct(port, value, mask);
}
@ -1641,7 +1656,7 @@ static void init_port_state(running_machine *machine)
const input_port_config *port;
/* allocate live structures to mirror the configuration */
for (port = machine->portconfig; port != NULL; port = port->next)
for (port = machine->portlist.head; port != NULL; port = port->next)
{
analog_field_state **analogstatetail;
device_field_info **readdevicetail;
@ -1719,18 +1734,18 @@ static void init_port_state(running_machine *machine)
}
/* handle autoselection of devices */
init_autoselect_devices(machine->portconfig, IPT_PADDLE, IPT_PADDLE_V, 0, OPTION_PADDLE_DEVICE, "paddle");
init_autoselect_devices(machine->portconfig, IPT_AD_STICK_X, IPT_AD_STICK_Y, IPT_AD_STICK_Z, OPTION_ADSTICK_DEVICE, "analog joystick");
init_autoselect_devices(machine->portconfig, IPT_LIGHTGUN_X, IPT_LIGHTGUN_Y, 0, OPTION_LIGHTGUN_DEVICE, "lightgun");
init_autoselect_devices(machine->portconfig, IPT_PEDAL, IPT_PEDAL2, IPT_PEDAL3, OPTION_PEDAL_DEVICE, "pedal");
init_autoselect_devices(machine->portconfig, IPT_DIAL, IPT_DIAL_V, 0, OPTION_DIAL_DEVICE, "dial");
init_autoselect_devices(machine->portconfig, IPT_TRACKBALL_X, IPT_TRACKBALL_Y, 0, OPTION_TRACKBALL_DEVICE, "trackball");
init_autoselect_devices(machine->portconfig, IPT_POSITIONAL, IPT_POSITIONAL_V, 0, OPTION_POSITIONAL_DEVICE, "positional");
init_autoselect_devices(machine->portconfig, IPT_MOUSE_X, IPT_MOUSE_Y, 0, OPTION_MOUSE_DEVICE, "mouse");
init_autoselect_devices(&machine->portlist, IPT_PADDLE, IPT_PADDLE_V, 0, OPTION_PADDLE_DEVICE, "paddle");
init_autoselect_devices(&machine->portlist, IPT_AD_STICK_X, IPT_AD_STICK_Y, IPT_AD_STICK_Z, OPTION_ADSTICK_DEVICE, "analog joystick");
init_autoselect_devices(&machine->portlist, IPT_LIGHTGUN_X, IPT_LIGHTGUN_Y, 0, OPTION_LIGHTGUN_DEVICE, "lightgun");
init_autoselect_devices(&machine->portlist, IPT_PEDAL, IPT_PEDAL2, IPT_PEDAL3, OPTION_PEDAL_DEVICE, "pedal");
init_autoselect_devices(&machine->portlist, IPT_DIAL, IPT_DIAL_V, 0, OPTION_DIAL_DEVICE, "dial");
init_autoselect_devices(&machine->portlist, IPT_TRACKBALL_X, IPT_TRACKBALL_Y, 0, OPTION_TRACKBALL_DEVICE, "trackball");
init_autoselect_devices(&machine->portlist, IPT_POSITIONAL, IPT_POSITIONAL_V, 0, OPTION_POSITIONAL_DEVICE, "positional");
init_autoselect_devices(&machine->portlist, IPT_MOUSE_X, IPT_MOUSE_Y, 0, OPTION_MOUSE_DEVICE, "mouse");
/* look for 4-way joysticks and change the default map if we find any */
if (joystick_map_default[0] == 0 || strcmp(joystick_map_default, "auto") == 0)
for (port = machine->portconfig; port != NULL; port = port->next)
for (port = machine->portlist.head; port != NULL; port = port->next)
for (field = port->fieldlist; field != NULL; field = field->next)
if (field->state->joystick != NULL && field->way == 4)
{
@ -1746,7 +1761,7 @@ static void init_port_state(running_machine *machine)
in and the corresponding option
-------------------------------------------------*/
static void init_autoselect_devices(const input_port_config *portlist, int type1, int type2, int type3, const char *option, const char *ananame)
static void init_autoselect_devices(const input_port_list *portlist, int type1, int type2, int type3, const char *option, const char *ananame)
{
const char *stemp = options_get_string(mame_options(), option);
input_device_class autoenable = DEVICE_CLASS_KEYBOARD;
@ -1783,8 +1798,8 @@ static void init_autoselect_devices(const input_port_config *portlist, int type1
mame_printf_error("Invalid %s value %s; reverting to keyboard\n", option, stemp);
/* only scan the list if we haven't already enabled this class of control */
if (portlist != NULL && !input_device_class_enabled(portlist->machine, autoenable))
for (port = portlist; port != NULL; port = port->next)
if (portlist->head != NULL && !input_device_class_enabled(portlist->head->machine, autoenable))
for (port = portlist->head; port != NULL; port = port->next)
for (field = port->fieldlist; field != NULL; field = field->next)
/* if this port type is in use, apply the autoselect criteria */
@ -1793,7 +1808,7 @@ static void init_autoselect_devices(const input_port_config *portlist, int type1
(type3 != 0 && field->type == type3))
{
mame_printf_verbose("Input: Autoenabling %s due to presence of a %s\n", autostring, ananame);
input_device_class_enable(portlist->machine, autoenable, TRUE);
input_device_class_enable(port->machine, autoenable, TRUE);
break;
}
}
@ -2056,11 +2071,11 @@ profiler_mark_start(PROFILER_INPUT);
const char *tag = NULL;
input_port_value mask;
if (render_target_map_point_input(mouse_target, mouse_target_x, mouse_target_y, &tag, &mask, NULL, NULL))
mouse_field = input_field_by_tag_and_mask(machine->portconfig, tag, mask);
mouse_field = input_field_by_tag_and_mask(&machine->portlist, tag, mask);
}
/* loop over all input ports */
for (port = machine->portconfig; port != NULL; port = port->next)
for (port = machine->portlist.head; port != NULL; port = port->next)
{
const input_field_config *field;
device_field_info *device_field;
@ -2110,7 +2125,7 @@ profiler_mark_start(PROFILER_INPUT);
}
/* handle playback/record */
for (port = machine->portconfig; port != NULL; port = port->next)
for (port = machine->portlist.head; port != NULL; port = port->next)
{
playback_port(port);
record_port(port);
@ -2433,7 +2448,7 @@ static int frame_get_digital_field_state(const input_field_config *field, int mo
detokenize a series of input port tokens
-------------------------------------------------*/
static input_port_config *port_config_detokenize(input_port_config *listhead, const input_port_token *ipt, char *errorbuf, int errorbuflen)
static void port_config_detokenize(input_port_list *portlist, const input_port_token *ipt, char *errorbuf, int errorbuflen)
{
UINT32 entrytype = INPUT_TOKEN_INVALID;
input_setting_config *cursetting = NULL;
@ -2465,7 +2480,7 @@ static input_port_config *port_config_detokenize(input_port_config *listhead, co
field_config_insert(curfield, &maskbits, errorbuf, errorbuflen);
maskbits = 0;
listhead = port_config_detokenize(listhead, TOKEN_GET_PTR(ipt, tokenptr), errorbuf, errorbuflen);
port_config_detokenize(portlist, TOKEN_GET_PTR(ipt, tokenptr), errorbuf, errorbuflen);
curport = NULL;
curfield = NULL;
cursetting = NULL;
@ -2477,8 +2492,17 @@ static input_port_config *port_config_detokenize(input_port_config *listhead, co
field_config_insert(curfield, &maskbits, errorbuf, errorbuflen);
maskbits = 0;
curport = port_config_alloc((const input_port_config **)&listhead);
curport = port_config_alloc(&portlist->head);
curport->tag = TOKEN_GET_STRING(ipt);
if (portlist->map != NULL)
{
tagmap_error err = tagmap_add_unique_hash(portlist->map, curport->tag, curport);
if (err == TMERR_DUPLICATE)
{
const input_port_config *match = tagmap_find_hash_only(portlist->map, curport->tag);
error_buf_append(errorbuf, errorbuflen, "tag '%s' has same hash as tag '%s'; please change one of them", curport->tag, match->tag);
}
}
curfield = NULL;
cursetting = NULL;
break;
@ -2489,7 +2513,7 @@ static input_port_config *port_config_detokenize(input_port_config *listhead, co
field_config_insert(curfield, &maskbits, errorbuf, errorbuflen);
maskbits = 0;
curport = port_config_find(listhead, TOKEN_GET_STRING(ipt));
curport = port_config_find(portlist->head, TOKEN_GET_STRING(ipt));
curfield = NULL;
cursetting = NULL;
break;
@ -2501,7 +2525,10 @@ static input_port_config *port_config_detokenize(input_port_config *listhead, co
TOKEN_GET_UINT64_UNPACK2(ipt, mask, 32, defval, 32);
if (curport == NULL)
return (input_port_config *)error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_FIELD encountered with no active port (mask=%X defval=%X)\n", mask, defval);
{
error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_FIELD encountered with no active port (mask=%X defval=%X)\n", mask, defval);
return;
}
if (curfield != NULL)
field_config_insert(curfield, &maskbits, errorbuf, errorbuflen);
@ -3075,8 +3102,6 @@ static input_port_config *port_config_detokenize(input_port_config *listhead, co
/* insert any pending fields */
if (curfield != NULL)
field_config_insert(curfield, &maskbits, errorbuf, errorbuflen);
return listhead;
}
@ -3109,7 +3134,7 @@ static input_port_config *port_config_alloc(const input_port_config **listhead)
static void port_config_free(const input_port_config **portptr)
{
input_port_config *port = (input_port_config *)*portptr;
input_port_config *port = (input_port_config *)*portptr;
/* free any field configs first */
while (port->fieldlist != NULL)
@ -3673,7 +3698,7 @@ static int load_game_config(running_machine *machine, xml_data_node *portnode, i
defvalue = xml_get_attribute_int(portnode, "defvalue", 0);
/* find the port we want; if no tag, search them all */
for (port = machine->portconfig; port != NULL; port = port->next)
for (port = machine->portlist.head; port != NULL; port = port->next)
if (tag == NULL || strcmp(get_port_tag(port, tempbuffer), tag) == 0)
for (field = port->fieldlist; field != NULL; field = field->next)
@ -3836,7 +3861,7 @@ static void save_game_inputs(running_machine *machine, xml_data_node *parentnode
const input_port_config *port;
/* iterate over ports */
for (port = machine->portconfig; port != NULL; port = port->next)
for (port = machine->portlist.head; port != NULL; port = port->next)
for (field = port->fieldlist; field != NULL; field = field->next)
if (save_this_input_field_type(field->type))
{

View File

@ -21,6 +21,7 @@
#include "inputseq.h"
#include "tokenize.h"
#include "unicode.h"
#include "tagmap.h"
@ -703,6 +704,15 @@ struct _input_port_config
};
/* an object that contains a list of port configurations */
typedef struct _input_port_list input_port_list;
struct _input_port_list
{
const input_port_config * head; /* head of the list */
tagmap * map; /* map for fast lookups */
};
/* describes a fundamental input type, including default input sequences */
typedef struct _input_type_desc input_type_desc;
struct _input_type_desc
@ -1022,20 +1032,20 @@ time_t input_port_init(running_machine *machine, const input_port_token *tokens)
/* ----- port configurations ----- */
/* allocate a list of input ports from the given token list */
const input_port_config *input_port_config_alloc(const input_port_token *tokens, char *errorbuf, int errorbuflen);
/* initialize an input port list structure and allocate ports according to the given tokens */
void input_port_list_init(input_port_list *portlist, const input_port_token *tokens, char *errorbuf, int errorbuflen, int allocmap);
/* free memory allocated from input_port_alloc */
void input_port_config_free(const input_port_config *portlist);
/* free memory attached to an input port list and clear out the structure */
void input_port_list_deinit(input_port_list *portlist);
/* return the config that matches the given tag */
const input_port_config *input_port_by_tag(const input_port_config *portlist, const char *tag);
const input_port_config *input_port_by_tag_slow(const input_port_list *portlist, const char *tag);
/* return the config that matches the given tag */
const input_port_config *input_port_by_index(const input_port_config *portlist, int index);
const input_port_config *input_port_by_index(const input_port_list *portlist, int index);
/* return the field that matches the given tag and mask */
const input_field_config *input_field_by_tag_and_mask(const input_port_config *portlist, const char *tag, input_port_value mask);
const input_field_config *input_field_by_tag_and_mask(const input_port_list *portlist, const char *tag, input_port_value mask);
@ -1136,4 +1146,25 @@ int input_condition_true(running_machine *machine, const input_condition *condit
const char *input_port_string_from_token(const input_port_token token);
/***************************************************************************
INLINE FUNCTIONS
***************************************************************************/
/*-------------------------------------------------
input_port_by_tag - return the config that
matches the given tag
-------------------------------------------------*/
INLINE const input_port_config *input_port_by_tag(const input_port_list *portlist, const char *tag)
{
/* use the map if we have it */
if (portlist->map != NULL)
return tagmap_find_hash_only(portlist->map, tag);
/* otherwise, do it the slow way */
return input_port_by_tag_slow(portlist, tag);
}
#endif /* __INPTPORT_H__ */

View File

@ -435,7 +435,7 @@ static DEVICE_START( riot6532 )
/* set static values */
riot->device = device;
riot->intf = (riot6532_interface *)device->static_config;
riot->index = device_list_index(device->machine->config->devicelist, RIOT6532, device->tag);
riot->index = device_list_index(&device->machine->config->devicelist, RIOT6532, device->tag);
/* configure the ports */
devcb_resolve_read8(&riot->port[0].in_func, &riot->intf->in_a_func, device);

View File

@ -299,7 +299,7 @@ void nvram_load(running_machine *machine)
}
/* find all devices with NVRAM handlers, and read from them next */
for (device = machine->config->devicelist; device != NULL; device = device->next)
for (device = machine->config->devicelist.head; device != NULL; device = device->next)
{
device_nvram_func nvram = (device_nvram_func)device_get_info_fct(device, DEVINFO_FCT_NVRAM);
if (nvram != NULL)
@ -332,7 +332,7 @@ void nvram_save(running_machine *machine)
}
/* find all devices with NVRAM handlers, and write them next */
for (device = machine->config->devicelist; device != NULL; device = device->next)
for (device = machine->config->devicelist.head; device != NULL; device = device->next)
{
device_nvram_func nvram = (device_nvram_func)device_get_info_fct(device, DEVINFO_FCT_NVRAM);
if (nvram != NULL)

View File

@ -1120,7 +1120,7 @@ static void configuration_save(running_machine *machine, int config_type, xml_da
return;
/* iterate over disc devices */
for (device = device_list_first(machine->config->devicelist, LASERDISC); device != NULL; device = device_list_next(device, LASERDISC))
for (device = device_list_first(&machine->config->devicelist, LASERDISC); device != NULL; device = device_list_next(device, LASERDISC))
{
laserdisc_config *origconfig = (laserdisc_config *)device->inline_config;
laserdisc_state *ld = get_safe_token(device);
@ -1210,7 +1210,7 @@ void laserdisc_overlay_enable(const device_config *device, int enable)
VIDEO_UPDATE( laserdisc )
{
const device_config *laserdisc = device_list_first(screen->machine->config->devicelist, LASERDISC);
const device_config *laserdisc = device_list_first(&screen->machine->config->devicelist, LASERDISC);
if (laserdisc != NULL)
{
const rectangle *visarea = video_screen_get_visible_area(screen);

View File

@ -148,7 +148,7 @@ struct _running_machine
{
/* configuration data */
const machine_config * config; /* points to the constructed machine_config */
const input_port_config *portconfig; /* points to a list of input port configurations */
input_port_list portlist; /* points to a list of input port configurations */
/* CPU information */
const device_config * firstcpu; /* first CPU (allows for quick iteration via typenext) */

View File

@ -36,9 +36,9 @@ static void machine_config_detokenize(machine_config *config, const machine_conf
the given configuration
-------------------------------------------------*/
INLINE void remove_device(device_config **listheadptr, const char *tag)
INLINE void remove_device(device_list *list, const char *tag)
{
device_config *device = (device_config *)device_list_find_by_tag(*listheadptr, tag);
device_config *device = (device_config *)device_list_find_by_tag(list, tag);
device_custom_config_func custom;
assert(device != NULL);
@ -49,7 +49,7 @@ INLINE void remove_device(device_config **listheadptr, const char *tag)
(*custom)(device, MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_FREE, NULL);
/* remove the device from the list */
device_list_remove(listheadptr, tag);
device_list_remove(list, tag);
}
@ -70,9 +70,13 @@ machine_config *machine_config_alloc(const machine_config_token *tokens)
/* allocate a new configuration object */
config = alloc_clear_or_die(machine_config);
/* initialize the device list */
device_list_init(&config->devicelist, TRUE);
/* parse tokens into the config */
machine_config_detokenize(config, tokens, NULL, 0);
return config;
}
@ -85,8 +89,9 @@ machine_config *machine_config_alloc(const machine_config_token *tokens)
void machine_config_free(machine_config *config)
{
/* release the device list */
while (config->devicelist != NULL)
remove_device(&config->devicelist, config->devicelist->tag);
while (config->devicelist.head != NULL)
remove_device(&config->devicelist, config->devicelist.head->tag);
device_list_deinit(&config->devicelist);
/* release the configuration itself */
free(config);
@ -144,7 +149,7 @@ static void machine_config_detokenize(machine_config *config, const machine_conf
case MCONFIG_TOKEN_DEVICE_MODIFY:
tag = TOKEN_GET_STRING(tokens);
device = (device_config *)device_list_find_by_tag(config->devicelist, device_build_tag(tempstring, owner, tag));
device = (device_config *)device_list_find_by_tag(&config->devicelist, device_build_tag(tempstring, owner, tag));
if (device == NULL)
fatalerror("Unable to find device: tag=%s\n", astring_c(tempstring));
break;
@ -322,7 +327,7 @@ static void machine_config_detokenize(machine_config *config, const machine_conf
/* if we are the outermost level, process any device-specific machine configurations */
if (depth == 0)
for (device = config->devicelist; device != NULL; device = device->next)
for (device = config->devicelist.head; device != NULL; device = device->next)
{
tokens = (const machine_config_token *)device_get_info_ptr(device, DEVINFO_PTR_MACHINE_CONFIG);
if (tokens != NULL)

View File

@ -143,7 +143,7 @@ struct _machine_config
sound_start_func sound_start; /* one-time sound start callback */
sound_reset_func sound_reset; /* sound reset callback */
device_config * devicelist; /* list head for devices */
device_list devicelist; /* list head for devices */
};

View File

@ -1360,7 +1360,7 @@ UINT64 *_memory_install_device_handler64(const address_space *space, const devic
void memory_install_read_port_handler(const address_space *space, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, const char *tag)
{
const input_port_config *port = input_port_by_tag(space->machine->portconfig, tag);
const input_port_config *port = input_port_by_tag(&space->machine->portlist, tag);
address_space *spacerw = (address_space *)space;
genf *handler = NULL;
@ -1377,7 +1377,6 @@ void memory_install_read_port_handler(const address_space *space, offs_t addrsta
}
/*-------------------------------------------------
memory_install_write_port_handler - install a
new 8-bit input port handler into the given
@ -1386,7 +1385,7 @@ void memory_install_read_port_handler(const address_space *space, offs_t addrsta
void memory_install_write_port_handler(const address_space *space, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, const char *tag)
{
const input_port_config *port = input_port_by_tag(space->machine->portconfig, tag);
const input_port_config *port = input_port_by_tag(&space->machine->portlist, tag);
address_space *spacerw = (address_space *)space;
genf *handler = NULL;
@ -1551,7 +1550,7 @@ static void memory_init_spaces(running_machine *machine)
memset(memdata->wptable, STATIC_WATCHPOINT, 1 << LEVEL1_BITS);
/* loop over devices */
for (device = machine->config->devicelist; device != NULL; device = device->next)
for (device = machine->config->devicelist.head; device != NULL; device = device->next)
for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++)
if (device_get_addrbus_width(device, spacenum) > 0)
{
@ -1760,7 +1759,7 @@ static void memory_init_populate(running_machine *machine)
/* if we have a read port tag, look it up */
if (entry->read_porttag != NULL)
{
const input_port_config *port = input_port_by_tag(machine->portconfig, entry->read_porttag);
const input_port_config *port = input_port_by_tag(&machine->portlist, entry->read_porttag);
int bits = (entry->read_bits == 0) ? space->dbits : entry->read_bits;
genf *handler = NULL;
@ -1779,7 +1778,7 @@ static void memory_init_populate(running_machine *machine)
/* if we have a write port tag, look it up */
if (entry->write_porttag != NULL)
{
const input_port_config *port = input_port_by_tag(machine->portconfig, entry->write_porttag);
const input_port_config *port = input_port_by_tag(&machine->portlist, entry->write_porttag);
int bits = (entry->write_bits == 0) ? space->dbits : entry->write_bits;
genf *handler = NULL;
@ -1802,7 +1801,7 @@ static void memory_init_populate(running_machine *machine)
void *object = space;
if (entry->read_devtag != NULL)
{
object = (void *)device_list_find_by_tag(machine->config->devicelist, entry->read_devtag);
object = (void *)device_list_find_by_tag(&machine->config->devicelist, entry->read_devtag);
if (object == NULL)
fatalerror("Unidentified object in memory map: tag=%s\n", entry->read_devtag);
}
@ -1816,7 +1815,7 @@ static void memory_init_populate(running_machine *machine)
void *object = space;
if (entry->write_devtag != NULL)
{
object = (void *)device_list_find_by_tag(machine->config->devicelist, entry->write_devtag);
object = (void *)device_list_find_by_tag(&machine->config->devicelist, entry->write_devtag);
if (object == NULL)
fatalerror("Unidentified object in memory map: tag=%s\n", entry->write_devtag);
}

View File

@ -186,7 +186,7 @@ astring *_profiler_get_text(running_machine *machine, astring *string)
/* and then the text */
if (curtype >= PROFILER_CPU_FIRST && curtype <= PROFILER_CPU_MAX)
astring_catprintf(string, "CPU '%s'", device_list_find_by_index(machine->config->devicelist, CPU, curtype - PROFILER_CPU_FIRST)->tag);
astring_catprintf(string, "CPU '%s'", device_list_find_by_index(&machine->config->devicelist, CPU, curtype - PROFILER_CPU_FIRST)->tag);
else
for (nameindex = 0; nameindex < ARRAY_LENGTH(names); nameindex++)
if (names[nameindex].type == curtype)

View File

@ -960,10 +960,9 @@ int render_is_live_screen(const device_config *screen)
assert(screen != NULL);
assert(screen->machine != NULL);
assert(screen->machine->config != NULL);
assert(screen->machine->config->devicelist != NULL);
assert(screen->tag != NULL);
screen_index = device_list_index(screen->machine->config->devicelist, VIDEO_SCREEN, screen->tag);
screen_index = device_list_index(&screen->machine->config->devicelist, VIDEO_SCREEN, screen->tag);
assert(screen_index != -1);
@ -1466,7 +1465,7 @@ void render_target_get_minimum_size(render_target *target, INT32 *minwidth, INT3
for (item = target->curview->itemlist[layer]; item != NULL; item = item->next)
if (item->element == NULL)
{
const device_config *screen = device_list_find_by_index(target->machine->config->devicelist, VIDEO_SCREEN, item->index);
const device_config *screen = device_list_find_by_index(&target->machine->config->devicelist, VIDEO_SCREEN, item->index);
const screen_config *scrconfig = (const screen_config *)screen->inline_config;
const rectangle vectorvis = { 0, 639, 0, 479 };
const rectangle *visarea = NULL;
@ -1598,7 +1597,7 @@ const render_primitive_list *render_target_get_primitives(render_target *target)
state = output_get_value(item->output_name);
else if (item->input_tag[0] != 0)
{
const input_field_config *field = input_field_by_tag_and_mask(target->machine->portconfig, item->input_tag, item->input_mask);
const input_field_config *field = input_field_by_tag_and_mask(&target->machine->portlist, item->input_tag, item->input_mask);
if (field != NULL)
state = ((input_port_read_safe(target->machine, item->input_tag, 0) ^ field->defvalue) & item->input_mask) ? 1 : 0;
}

View File

@ -1339,7 +1339,7 @@ static int get_variable_value(const machine_config *config, const char *string,
/* screen 0 parameters */
for (device = video_screen_first(config); device != NULL; device = video_screen_next(device))
{
int scrnum = device_list_index(config->devicelist, VIDEO_SCREEN, device->tag);
int scrnum = device_list_index(&config->devicelist, VIDEO_SCREEN, device->tag);
const screen_config *scrconfig = (const screen_config *)device->inline_config;
/* native X aspect factor */

View File

@ -165,7 +165,7 @@ const rom_source *rom_first_source(const game_driver *drv, const machine_config
/* otherwise, look through devices */
if (config != NULL)
for (device = config->devicelist; device != NULL; device = device->next)
for (device = config->devicelist.head; device != NULL; device = device->next)
{
const rom_entry *devromp = (const rom_entry *)device_get_info_ptr(device, DEVINFO_PTR_ROM_REGION);
if (devromp != NULL)
@ -186,7 +186,7 @@ const rom_source *rom_next_source(const game_driver *drv, const machine_config *
/* if the previous was the driver, we want the first device */
if (rom_source_is_gamedrv(drv, previous))
device = (config != NULL) ? config->devicelist : NULL;
device = (config != NULL) ? config->devicelist.head : NULL;
else
device = ((const device_config *)previous)->next;

View File

@ -32,14 +32,14 @@
/* these functions are macros primarily due to include file ordering */
/* plus, they are very simple */
#define sound_count(config) device_list_items((config)->devicelist, SOUND)
#define sound_first(config) device_list_first((config)->devicelist, SOUND)
#define sound_count(config) device_list_items(&(config)->devicelist, SOUND)
#define sound_first(config) device_list_first(&(config)->devicelist, SOUND)
#define sound_next(previous) ((previous)->typenext)
/* these functions are macros primarily due to include file ordering */
/* plus, they are very simple */
#define speaker_output_count(config) device_list_items((config)->devicelist, SPEAKER_OUTPUT)
#define speaker_output_first(config) device_list_first((config)->devicelist, SPEAKER_OUTPUT)
#define speaker_output_count(config) device_list_items(&(config)->devicelist, SPEAKER_OUTPUT)
#define speaker_output_first(config) device_list_first(&(config)->devicelist, SPEAKER_OUTPUT)
#define speaker_output_next(previous) ((previous)->typenext)

View File

@ -176,12 +176,12 @@ static DISCRETE_RESET(dss_adjustment)
if (node->custom)
{
context->port = input_port_by_tag(node->info->device->machine->portconfig, (const char *)node->custom);
context->port = input_port_by_tag(&node->info->device->machine->portlist, (const char *)node->custom);
if (context->port == NULL)
fatalerror("DISCRETE_ADJUSTMENT_TAG - NODE_%d has invalid tag", NODE_BLOCKINDEX(node));
}
else
context->port = input_port_by_index(node->info->device->machine->portconfig, DSS_ADJUSTMENT__PORT);
context->port = input_port_by_index(&node->info->device->machine->portlist, DSS_ADJUSTMENT__PORT);
context->lastpval = 0x7fffffff;
context->pmin = DSS_ADJUSTMENT__PMIN;

View File

@ -1208,7 +1208,7 @@ static void dma_scsp(const address_space *space, struct _SCSP *SCSP)
/*Job done,request a dma end irq*/
if(scsp_regs[0x1e/2] & 0x10)
cpu_set_input_line(device_list_find_by_index(space->machine->config->devicelist, CPU, 2),dma_transfer_end,HOLD_LINE);
cpu_set_input_line(device_list_find_by_index(&space->machine->config->devicelist, CPU, 2),dma_transfer_end,HOLD_LINE);
}
#ifdef UNUSED_FUNCTION

View File

@ -1448,7 +1448,7 @@ static slider_state *slider_init(running_machine *machine)
}
/* add analog adjusters */
for (port = machine->portconfig; port != NULL; port = port->next)
for (port = machine->portlist.head; port != NULL; port = port->next)
for (field = port->fieldlist; field != NULL; field = field->next)
if (field->type == IPT_ADJUSTER)
{
@ -1513,7 +1513,7 @@ static slider_state *slider_init(running_machine *machine)
tailptr = &(*tailptr)->next;
}
for (device = device_list_first(machine->config->devicelist, LASERDISC); device != NULL; device = device_list_next(device, LASERDISC))
for (device = device_list_first(&machine->config->devicelist, LASERDISC); device != NULL; device = device_list_next(device, LASERDISC))
{
const laserdisc_config *config = (const laserdisc_config *)device->inline_config;
if (config->overupdate != NULL)
@ -1556,7 +1556,7 @@ static slider_state *slider_init(running_machine *machine)
#ifdef MAME_DEBUG
/* add crosshair adjusters */
for (port = machine->portconfig; port != NULL; port = port->next)
for (port = machine->portlist.head; port != NULL; port = port->next)
for (field = port->fieldlist; field != NULL; field = field->next)
if (field->crossaxis != CROSSHAIR_AXIS_NONE && field->player == 0)
{
@ -1973,7 +1973,7 @@ static char *slider_get_screen_desc(const device_config *screen)
static char *slider_get_laserdisc_desc(const device_config *laserdisc)
{
int ldcount = device_list_items(laserdisc->machine->config->devicelist, LASERDISC);
int ldcount = device_list_items(&laserdisc->machine->config->devicelist, LASERDISC);
static char descbuf[256];
if (ldcount > 1)

View File

@ -1460,7 +1460,7 @@ static void menu_main_populate(running_machine *machine, ui_menu *menu, void *st
int has_dips = FALSE;
/* scan the input port array to see what options we need to enable */
for (port = machine->portconfig; port != NULL; port = port->next)
for (port = machine->portlist.head; port != NULL; port = port->next)
for (field = port->fieldlist; field != NULL; field = field->next)
{
if (field->type == IPT_DIPSWITCH)
@ -1661,7 +1661,7 @@ static void menu_input_specific_populate(running_machine *machine, ui_menu *menu
suborder[SEQ_TYPE_INCREMENT] = 2;
/* iterate over the input ports and add menu items */
for (port = machine->portconfig; port != NULL; port = port->next)
for (port = machine->portlist.head; port != NULL; port = port->next)
for (field = port->fieldlist; field != NULL; field = field->next)
{
const char *name = input_field_name(field);
@ -2020,7 +2020,7 @@ static void menu_settings_populate(running_machine *machine, ui_menu *menu, sett
diplist_tailptr = &menustate->diplist;
/* loop over input ports and set up the current values */
for (port = machine->portconfig; port != NULL; port = port->next)
for (port = machine->portlist.head; port != NULL; port = port->next)
for (field = port->fieldlist; field != NULL; field = field->next)
if (field->type == type && input_condition_true(machine, &field->condition))
{
@ -2273,7 +2273,7 @@ static void menu_analog_populate(running_machine *machine, ui_menu *menu)
const input_port_config *port;
/* loop over input ports and add the items */
for (port = machine->portconfig; port != NULL; port = port->next)
for (port = machine->portlist.head; port != NULL; port = port->next)
for (field = port->fieldlist; field != NULL; field = field->next)
if (input_type_is_analog(field->type))
{

View File

@ -40,14 +40,6 @@ UINT8 your_ptr64_flag_is_wrong[(int)(5 - sizeof(void *))];
/***************************************************************************
CONSTANTS
***************************************************************************/
#define QUARK_HASH_SIZE 389
/***************************************************************************
TYPE DEFINITIONS
***************************************************************************/
@ -67,35 +59,6 @@ struct _region_info
};
typedef struct _quark_entry quark_entry;
struct _quark_entry
{
UINT32 crc;
struct _quark_entry *next;
};
typedef struct _quark_table quark_table;
struct _quark_table
{
UINT32 entries;
UINT32 hashsize;
quark_entry *entry;
quark_entry **hash;
};
typedef struct _quark_tables quark_tables;
struct _quark_tables
{
quark_table *source;
quark_table *name;
quark_table *description;
quark_table *roms;
quark_table *defstr;
};
/***************************************************************************
INLINE FUNCTIONS
@ -114,42 +77,6 @@ INLINE const char *input_port_string_from_index(UINT32 index)
}
/*-------------------------------------------------
quark_string_crc - compute the CRC of a string
-------------------------------------------------*/
INLINE UINT32 quark_string_crc(const char *string)
{
return crc32(0, (UINT8 *)string, (UINT32)strlen(string));
}
/*-------------------------------------------------
quark_add - add a quark to the table and
connect it to the hash tables
-------------------------------------------------*/
INLINE void quark_add(quark_table *table, int index, UINT32 crc)
{
quark_entry *entry = &table->entry[index];
int hash = crc % table->hashsize;
entry->crc = crc;
entry->next = table->hash[hash];
table->hash[hash] = entry;
}
/*-------------------------------------------------
quark_table_get_first - return a pointer to the
first hash entry connected to a CRC
-------------------------------------------------*/
INLINE quark_entry *quark_table_get_first(quark_table *table, UINT32 crc)
{
return table->hash[crc % table->hashsize];
}
/*-------------------------------------------------
validate_tag - ensure that the given tag
meets the general requirements
@ -221,110 +148,6 @@ INLINE int validate_tag(const game_driver *driver, const char *object, const cha
/***************************************************************************
QUARK TABLES
***************************************************************************/
/*-------------------------------------------------
quark_table_alloc - allocate an array of
quark entries and a hash table
-------------------------------------------------*/
static quark_table *quark_table_alloc(UINT32 entries, UINT32 hashsize)
{
quark_table *table;
UINT32 total_bytes;
/* determine how many total bytes we need */
total_bytes = sizeof(*table) + entries * sizeof(table->entry[0]) + hashsize * sizeof(table->hash[0]);
table = (quark_table *)alloc_array_or_die(UINT8, total_bytes);
/* fill in the details */
table->entries = entries;
table->hashsize = hashsize;
/* compute the pointers */
table->entry = (quark_entry *)((UINT8 *)table + sizeof(*table));
table->hash = (quark_entry **)((UINT8 *)table->entry + entries * sizeof(table->entry[0]));
/* reset the hash table */
memset(table->hash, 0, hashsize * sizeof(table->hash[0]));
return table;
}
/*-------------------------------------------------
quark_tables_create - build "quarks" for fast
string operations
-------------------------------------------------*/
static void quark_tables_create(quark_tables *tables)
{
int drivnum = driver_list_get_count(drivers), strnum;
/* allocate memory for the quark tables */
tables->source = quark_table_alloc(drivnum, QUARK_HASH_SIZE);
tables->name = quark_table_alloc(drivnum, QUARK_HASH_SIZE);
tables->description = quark_table_alloc(drivnum, QUARK_HASH_SIZE);
tables->roms = quark_table_alloc(drivnum, QUARK_HASH_SIZE);
/* build the quarks and the hash tables */
for (drivnum = 0; drivers[drivnum]; drivnum++)
{
const game_driver *driver = drivers[drivnum];
/* fill in the quark with hashes of the strings */
quark_add(tables->source, drivnum, quark_string_crc(driver->source_file));
quark_add(tables->name, drivnum, quark_string_crc(driver->name));
quark_add(tables->description, drivnum, quark_string_crc(driver->description));
/* only track actual driver ROM entries */
if (driver->rom && (driver->flags & GAME_NO_STANDALONE) == 0)
quark_add(tables->roms, drivnum, (FPTR)driver->rom);
}
/* allocate memory for a quark table of strings */
tables->defstr = quark_table_alloc(INPUT_STRING_COUNT, 97);
/* add all the default strings */
for (strnum = 1; strnum < INPUT_STRING_COUNT; strnum++)
{
const char *string = input_port_string_from_index(strnum);
if (string != NULL)
quark_add(tables->defstr, strnum, quark_string_crc(string));
}
}
/*-------------------------------------------------
quark_tables_free - free allocated tables
-------------------------------------------------*/
static void quark_tables_free(quark_tables *tables)
{
if (tables->source != NULL)
free(tables->source);
tables->source = NULL;
if (tables->name != NULL)
free(tables->name);
tables->name = NULL;
if (tables->description != NULL)
free(tables->description);
tables->description = NULL;
if (tables->roms != NULL)
free(tables->roms);
tables->roms = NULL;
if (tables->defstr != NULL)
free(tables->defstr);
tables->defstr = NULL;
}
/***************************************************************************
VALIDATION FUNCTIONS
***************************************************************************/
@ -487,22 +310,31 @@ static int validate_inlines(void)
information
-------------------------------------------------*/
static int validate_driver(int drivnum, const machine_config *config, const quark_tables *tables)
static int validate_driver(int drivnum, const machine_config *config, tagmap *names, tagmap *descriptions)
{
const game_driver *driver = drivers[drivnum];
quark_table *name_table = tables->name;
quark_table *description_table = tables->description;
#ifndef MESS
quark_table *roms_table = tables->roms;
#endif /* MESS */
const game_driver *clone_of;
quark_entry *entry;
int error = FALSE, is_clone;
const char *s;
UINT32 crc;
enum { NAME_LEN_PARENT = 8, NAME_LEN_CLONE = 16 };
/* check for duplicate names */
if (tagmap_add(names, driver->name, (void *)driver) == TMERR_DUPLICATE)
{
const game_driver *match = tagmap_find(names, 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;
}
/* check for duplicate descriptions */
if (tagmap_add(descriptions, driver->description, (void *)driver) == TMERR_DUPLICATE)
{
const game_driver *match = tagmap_find(descriptions, 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;
}
/* determine the clone */
is_clone = strcmp(driver->parent, "0");
clone_of = driver_get_clone(driver);
@ -557,50 +389,6 @@ static int validate_driver(int drivnum, const machine_config *config, const quar
}
#endif
/* find duplicate driver names */
crc = quark_string_crc(driver->name);
for (entry = quark_table_get_first(name_table, crc); entry; entry = entry->next)
if (entry->crc == crc && entry != &name_table->entry[drivnum])
{
const game_driver *match = drivers[entry - name_table->entry];
if (!strcmp(match->name, 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;
}
}
/* find duplicate descriptions */
crc = quark_string_crc(driver->description);
for (entry = quark_table_get_first(description_table, crc); entry; entry = entry->next)
if (entry->crc == crc && entry != &description_table->entry[drivnum])
{
const game_driver *match = drivers[entry - description_table->entry];
if (!strcmp(match->description, driver->description))
{
mame_printf_error("%s: %s is a duplicate description (%s, %s)\n", driver->source_file, driver->description, match->source_file, match->name);
error = TRUE;
}
}
/* find shared ROM entries */
#ifndef MESS
if (driver->rom && (driver->flags & GAME_IS_BIOS_ROOT) == 0)
{
crc = (FPTR)driver->rom;
for (entry = quark_table_get_first(roms_table, crc); entry; entry = entry->next)
if (entry->crc == crc && entry != &roms_table->entry[drivnum])
{
const game_driver *match = drivers[entry - roms_table->entry];
if (match->rom == driver->rom)
{
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;
}
}
}
#endif /* MESS */
return error;
}
@ -609,7 +397,7 @@ static int validate_driver(int drivnum, const machine_config *config, const quar
validate_roms - validate ROM definitions
-------------------------------------------------*/
static int validate_roms(int drivnum, const machine_config *config, region_info *rgninfo)
static int validate_roms(int drivnum, const machine_config *config, region_info *rgninfo, tagmap *roms)
{
const game_driver *driver = drivers[drivnum];
int bios_flags = 0, last_bios = 0;
@ -620,6 +408,21 @@ static int validate_roms(int drivnum, const machine_config *config, region_info
const rom_source *source;
int error = FALSE;
#ifndef MESS
/* check for duplicate ROM entries */
if (driver->rom != NULL && (driver->flags & GAME_NO_STANDALONE) == 0)
{
char romaddr[20];
sprintf(romaddr, "%p", driver->rom);
if (tagmap_add(roms, romaddr, (void *)driver) == TMERR_DUPLICATE)
{
const game_driver *match = tagmap_find(roms, 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;
}
}
#endif
/* iterate, starting with the driver's ROMs and continuing with device ROMs */
for (source = rom_first_source(driver, config); source != NULL; source = rom_next_source(driver, config, source))
{
@ -794,7 +597,7 @@ static int validate_cpu(int drivnum, const machine_config *config)
mame_printf_error("%s: %s cpu '%s' has a new VBLANK interrupt handler with >1 interrupts!\n", driver->source_file, driver->name, device->tag);
error = TRUE;
}
else if (cpuconfig->vblank_interrupt_screen != NULL && device_list_find_by_tag(config->devicelist, cpuconfig->vblank_interrupt_screen) == NULL)
else if (cpuconfig->vblank_interrupt_screen != NULL && device_list_find_by_tag(&config->devicelist, 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, device->tag, cpuconfig->vblank_interrupt_screen);
error = TRUE;
@ -1014,21 +817,11 @@ static int validate_gfx(int drivnum, const machine_config *config, region_info *
strings
-------------------------------------------------*/
static int get_defstr_index(quark_table *defstr_table, const char *name, const game_driver *driver, int *error)
static int get_defstr_index(tagmap *defstr_map, const char *name, const game_driver *driver, int *error)
{
UINT32 crc = quark_string_crc(name);
quark_entry *entry;
int strindex = 0;
/* scan the quark table of input port strings */
for (entry = quark_table_get_first(defstr_table, crc); entry != NULL; entry = entry->next)
if (entry->crc == crc && strcmp(name, input_port_string_from_index(entry - defstr_table->entry)) == 0)
{
strindex = entry - defstr_table->entry;
break;
}
/* check for strings that should be DEF_STR */
void *result = tagmap_find(defstr_map, name);
FPTR strindex = (FPTR)result;
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);
@ -1153,7 +946,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, quark_table *defstr_table, int *error)
static void validate_dip_settings(const input_field_config *field, const game_driver *driver, tagmap *defstr_map, int *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);
@ -1164,7 +957,7 @@ static void validate_dip_settings(const input_field_config *field, const game_dr
/* iterate through the settings */
for (setting = field->settinglist; setting != NULL; setting = setting->next)
{
int strindex = get_defstr_index(defstr_table, setting->name, driver, error);
int strindex = get_defstr_index(defstr_map, setting->name, driver, error);
/* note any coinage strings */
if (strindex >= INPUT_STRING_9C_1C && strindex <= INPUT_STRING_1C_9C)
@ -1194,7 +987,7 @@ static void validate_dip_settings(const input_field_config *field, const game_dr
/* if we have a neighbor, compare ourselves to him */
if (setting->next != NULL)
{
int next_strindex = get_defstr_index(defstr_table, setting->next->name, driver, error);
int next_strindex = get_defstr_index(defstr_map, setting->next->name, driver, error);
/* check for inverted off/on dispswitch order */
if (strindex == INPUT_STRING_On && next_strindex == INPUT_STRING_Off)
@ -1244,7 +1037,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, quark_table *defstr_table, const input_port_config **portlistptr)
static int validate_inputs(int drivnum, const machine_config *config, tagmap *defstr_map, input_port_list *portlist)
{
const input_port_config *scanport;
const input_port_config *port;
@ -1259,15 +1052,15 @@ static int validate_inputs(int drivnum, const machine_config *config, quark_tabl
return FALSE;
/* allocate the input ports */
*portlistptr = input_port_config_alloc(driver->ipt, errorbuf, sizeof(errorbuf));
input_port_list_init(portlist, driver->ipt, errorbuf, sizeof(errorbuf), FALSE);
if (errorbuf[0] != 0)
{
mame_printf_error("%s: %s has input port errors:\n%s\n", driver->source_file, driver->name, errorbuf);
error = TRUE;
}
/* check for duplicate tags */
for (port = *portlistptr; port != NULL; port = port->next)
for (port = portlist->head; port != NULL; port = port->next)
if (port->tag != NULL)
for (scanport = port->next; scanport != NULL; scanport = scanport->next)
if (scanport->tag != NULL && strcmp(port->tag, scanport->tag) == 0)
@ -1277,7 +1070,7 @@ static int validate_inputs(int drivnum, const machine_config *config, quark_tabl
}
/* iterate over the results */
for (port = *portlistptr; port != NULL; port = port->next)
for (port = portlist->head; port != NULL; port = port->next)
for (field = port->fieldlist; field != NULL; field = field->next)
{
const input_setting_config *setting;
@ -1298,7 +1091,7 @@ static int validate_inputs(int drivnum, const machine_config *config, quark_tabl
}
/* verify the settings list */
validate_dip_settings(field, driver, defstr_table, &error);
validate_dip_settings(field, driver, defstr_map, &error);
}
/* look for invalid (0) types which should be mapped to IPT_OTHER */
@ -1333,14 +1126,14 @@ static int validate_inputs(int drivnum, const machine_config *config, quark_tabl
}
/* look up the string and print an error if default strings are not used */
/*strindex = */get_defstr_index(defstr_table, field->name, driver, &error);
/*strindex = */get_defstr_index(defstr_map, field->name, driver, &error);
}
/* verify conditions on the field */
if (field->condition.tag != NULL)
{
/* find a matching port */
for (scanport = *portlistptr; scanport != NULL; scanport = scanport->next)
for (scanport = portlist->head; scanport != NULL; scanport = scanport->next)
if (scanport->tag != NULL && strcmp(field->condition.tag, scanport->tag) == 0)
break;
@ -1357,7 +1150,7 @@ static int validate_inputs(int drivnum, const machine_config *config, quark_tabl
if (setting->condition.tag != NULL)
{
/* find a matching port */
for (scanport = *portlistptr; scanport != NULL; scanport = scanport->next)
for (scanport = portlist->head; scanport != NULL; scanport = scanport->next)
if (scanport->tag != NULL && strcmp(setting->condition.tag, scanport->tag) == 0)
break;
@ -1371,7 +1164,7 @@ static int validate_inputs(int drivnum, const machine_config *config, quark_tabl
}
#ifdef MESS
if (mess_validate_input_ports(drivnum, config, *portlistptr))
if (mess_validate_input_ports(drivnum, config, portlist))
error = TRUE;
#endif /* MESS */
@ -1451,13 +1244,13 @@ static int validate_sound(int drivnum, const machine_config *config)
checks
-------------------------------------------------*/
static int validate_devices(int drivnum, const machine_config *config, const input_port_config *portlist, region_info *rgninfo)
static int validate_devices(int drivnum, const machine_config *config, const input_port_list *portlist, region_info *rgninfo)
{
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))
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);
const device_config *scandevice;
@ -1467,7 +1260,7 @@ static int validate_devices(int drivnum, const machine_config *config, const inp
error |= validate_tag(driver, device_get_info_string(device, DEVINFO_STR_NAME), device->tag);
/* look for duplicates */
for (scandevice = device_list_first(config->devicelist, DEVICE_TYPE_WILDCARD); scandevice != device; scandevice = device_list_next(scandevice, DEVICE_TYPE_WILDCARD))
for (scandevice = device_list_first(&config->devicelist, DEVICE_TYPE_WILDCARD); scandevice != device; scandevice = device_list_next(scandevice, DEVICE_TYPE_WILDCARD))
if (strcmp(scandevice->tag, device->tag) == 0)
{
mame_printf_warning("%s: %s has multiple devices with the tag '%s'\n", driver->source_file, driver->name, device->tag);
@ -1569,12 +1362,12 @@ static int validate_devices(int drivnum, const machine_config *config, const inp
}
/* make sure all devices exist */
if (entry->read_devtag != NULL && device_list_find_by_tag(config->devicelist, entry->read_devtag) == NULL)
if (entry->read_devtag != NULL && device_list_find_by_tag(&config->devicelist, entry->read_devtag) == NULL)
{
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);
error = TRUE;
}
if (entry->write_devtag != NULL && device_list_find_by_tag(config->devicelist, entry->write_devtag) == NULL)
if (entry->write_devtag != NULL && device_list_find_by_tag(&config->devicelist, entry->write_devtag) == NULL)
{
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);
error = TRUE;
@ -1609,7 +1402,6 @@ static int validate_devices(int drivnum, const machine_config *config, const inp
int mame_validitychecks(const game_driver *curdriver)
{
quark_tables tables;
osd_ticks_t prep = 0;
osd_ticks_t expansion = 0;
osd_ticks_t driver_checks = 0;
@ -1624,10 +1416,19 @@ int mame_validitychecks(const game_driver *curdriver)
osd_ticks_t mess_checks = 0;
#endif
int drivnum;
int drivnum, strnum;
int error = FALSE;
UINT16 lsbtest;
UINT8 a, b;
tagmap *names = tagmap_alloc();
tagmap *descriptions = tagmap_alloc();
tagmap *roms = tagmap_alloc();
tagmap *defstr = tagmap_alloc();
/* check for memory */
if (descriptions == NULL || names == NULL || roms == NULL || defstr == NULL)
fatalerror("Out of memory for string maps!");
/* basic system checks */
a = 0xff;
@ -1662,16 +1463,21 @@ int mame_validitychecks(const game_driver *curdriver)
begin_resource_tracking();
get_profile_ticks();
/* prepare by pre-scanning all the drivers and adding their info to hash tables */
/* pre-populate the defstr tagmap with all the default strings */
prep -= get_profile_ticks();
quark_tables_create(&tables);
for (strnum = 1; strnum < INPUT_STRING_COUNT; strnum++)
{
const char *string = input_port_string_from_index(strnum);
if (string != NULL)
tagmap_add(defstr, string, (void *)strnum);
}
prep += get_profile_ticks();
/* iterate over all drivers */
for (drivnum = 0; drivers[drivnum]; drivnum++)
{
const game_driver *driver = drivers[drivnum];
const input_port_config *portlist = NULL;
input_port_list portlist;
machine_config *config;
region_info rgninfo;
int rgnnum;
@ -1688,17 +1494,17 @@ int mame_validitychecks(const game_driver *curdriver)
/* validate the driver entry */
driver_checks -= get_profile_ticks();
error = validate_driver(drivnum, config, &tables) || error;
error = validate_driver(drivnum, config, names, descriptions) || error;
driver_checks += get_profile_ticks();
/* validate the ROM information */
rom_checks -= get_profile_ticks();
error = validate_roms(drivnum, config, &rgninfo) || error;
error = validate_roms(drivnum, config, &rgninfo, roms) || error;
rom_checks += get_profile_ticks();
/* validate input ports */
input_checks -= get_profile_ticks();
error = validate_inputs(drivnum, config, tables.defstr, &portlist) || error;
error = validate_inputs(drivnum, config, defstr, &portlist) || error;
input_checks += get_profile_ticks();
/* validate the CPU information */
@ -1723,14 +1529,13 @@ int mame_validitychecks(const game_driver *curdriver)
/* validate devices */
device_checks -= get_profile_ticks();
error = validate_devices(drivnum, config, portlist, &rgninfo) || error;
error = validate_devices(drivnum, config, &portlist, &rgninfo) || error;
device_checks += get_profile_ticks();
for (rgnnum = 0; rgnnum < ARRAY_LENGTH(rgninfo.entries); rgnnum++)
if (rgninfo.entries[rgnnum].tag != NULL)
astring_free(rgninfo.entries[rgnnum].tag);
if (portlist != NULL)
input_port_config_free(portlist);
input_port_list_deinit(&portlist);
machine_config_free(config);
}
@ -1758,7 +1563,11 @@ int mame_validitychecks(const game_driver *curdriver)
end_resource_tracking();
exit_resource_tracking();
quark_tables_free(&tables);
tagmap_free(defstr);
tagmap_free(roms);
tagmap_free(descriptions);
tagmap_free(names);
return error;
}

View File

@ -2224,7 +2224,7 @@ static void create_snapshot_bitmap(const device_config *screen)
/* select the appropriate view in our dummy target */
if (global.snap_native && screen != NULL)
{
view_index = device_list_index(screen->machine->config->devicelist, VIDEO_SCREEN, screen->tag);
view_index = device_list_index(&screen->machine->config->devicelist, VIDEO_SCREEN, screen->tag);
assert(view_index != -1);
render_target_set_view(global.snap_target, view_index);
}

View File

@ -45,8 +45,8 @@ enum
/* these functions are macros primarily due to include file ordering */
/* plus, they are very simple */
#define video_screen_count(config) device_list_items((config)->devicelist, VIDEO_SCREEN)
#define video_screen_first(config) device_list_first((config)->devicelist, VIDEO_SCREEN)
#define video_screen_count(config) device_list_items(&(config)->devicelist, VIDEO_SCREEN)
#define video_screen_first(config) device_list_first(&(config)->devicelist, VIDEO_SCREEN)
#define video_screen_next(previous) device_list_next((previous), VIDEO_SCREEN)
#define video_screen_get_format(screen) (((screen_config *)(screen)->inline_config)->format)

View File

@ -4539,7 +4539,7 @@ static DEVICE_START( voodoo )
}
/* set the type, and initialize the chip mask */
v->index = device_list_index(device->machine->config->devicelist, device->type, device->tag);
v->index = device_list_index(&device->machine->config->devicelist, device->type, device->tag);
v->screen = devtag_get_device(device->machine, config->screen);
assert_always(v->screen != NULL, "Unable to find screen attached to voodoo");
v->cpu = cputag_get_cpu(device->machine, config->cputag);

View File

@ -227,7 +227,7 @@ static void process_commands(const device_config *laserdisc)
static TIMER_CALLBACK( vsync_update )
{
const device_config *laserdisc = device_list_first(machine->config->devicelist, LASERDISC);
const device_config *laserdisc = device_list_first(&machine->config->devicelist, LASERDISC);
int vblank_scanline;
attotime target;
@ -250,7 +250,7 @@ static MACHINE_START( ldplayer )
static TIMER_CALLBACK( autoplay )
{
const device_config *laserdisc = device_list_first(machine->config->devicelist, LASERDISC);
const device_config *laserdisc = device_list_first(&machine->config->devicelist, LASERDISC);
/* start playing */
(*execute_command)(laserdisc, CMD_PLAY);
@ -323,7 +323,7 @@ static TIMER_CALLBACK( pr8210_bit_callback )
static MACHINE_START( pr8210 )
{
const device_config *laserdisc = device_list_first(machine->config->devicelist, LASERDISC);
const device_config *laserdisc = device_list_first(&machine->config->devicelist, LASERDISC);
MACHINE_START_CALL(ldplayer);
pr8210_bit_timer = timer_alloc(machine, pr8210_bit_callback, (void *)laserdisc);
}

View File

@ -43,6 +43,7 @@ UTILOBJS = \
$(LIBOBJ)/util/png.o \
$(LIBOBJ)/util/pool.o \
$(LIBOBJ)/util/sha1.o \
$(LIBOBJ)/util/tagmap.o \
$(LIBOBJ)/util/unicode.o \
$(LIBOBJ)/util/unzip.o \
$(LIBOBJ)/util/vbiparse.o \

View File

@ -471,7 +471,7 @@ static VIDEO_UPDATE(firebeat)
{
int chip;
if (screen == device_list_find_by_index(screen->machine->config->devicelist, VIDEO_SCREEN, 0))
if (screen == device_list_find_by_index(&screen->machine->config->devicelist, VIDEO_SCREEN, 0))
chip = 0;
else
chip = 1;
@ -600,7 +600,7 @@ static void GCU_w(running_machine *machine, int chip, UINT32 offset, UINT32 data
COMBINE_DATA( &gcu[chip].visible_area );
if (ACCESSING_BITS_0_15)
{
const device_config *screen = device_list_find_by_index(machine->config->devicelist, VIDEO_SCREEN, chip);
const device_config *screen = device_list_find_by_index(&machine->config->devicelist, VIDEO_SCREEN, chip);
if (screen != NULL)
{

View File

@ -2485,7 +2485,7 @@ static DRIVER_INIT( gmgalax )
memory_configure_bank(machine, 1, 0, 2, memory_region(machine, "maincpu") + 0x10000, 0x4000);
/* callback when the game select is toggled */
gmgalax_game_changed(machine->portconfig->fieldlist, NULL, 0, 0);
gmgalax_game_changed(machine->portlist.head->fieldlist, NULL, 0, 0);
state_save_register_global(machine, gmgalax_selected_game);
}

View File

@ -270,7 +270,7 @@ static MACHINE_START( gottlieb )
state_save_register_global_array(machine, track);
/* see if we have a laserdisc */
laserdisc = device_list_first(machine->config->devicelist, LASERDISC);
laserdisc = device_list_first(&machine->config->devicelist, LASERDISC);
if (laserdisc != NULL)
{
/* attach to the I/O ports */

View File

@ -1407,7 +1407,7 @@ static WRITE8_HANDLER( s12_mcu_settings_w )
static READ8_HANDLER( s12_mcu_gun_h_r )
{
const input_port_config *port = input_port_by_tag(space->machine->portconfig, "LIGHT0_X");
const input_port_config *port = input_port_by_tag(&space->machine->portlist, "LIGHT0_X");
if( port != NULL )
{
int rv = input_port_read_direct( port ) << 6;
@ -1426,7 +1426,7 @@ static READ8_HANDLER( s12_mcu_gun_h_r )
static READ8_HANDLER( s12_mcu_gun_v_r )
{
const input_port_config *port = input_port_by_tag(space->machine->portconfig, "LIGHT0_Y");
const input_port_config *port = input_port_by_tag(&space->machine->portlist, "LIGHT0_Y");
if( port != NULL )
{
int rv = input_port_read_direct( port ) << 6;

View File

@ -164,7 +164,7 @@ static void via_irq(const device_config *device, int state)
static input_port_value input_port_read_indexed(running_machine *machine, int portnum)
{
const input_port_config *port = input_port_by_index(machine->portconfig, portnum);
const input_port_config *port = input_port_by_index(&machine->portlist, portnum);
return input_port_read_direct(port);
}

View File

@ -346,7 +346,7 @@ void atari_machine_start(running_machine *machine)
/* GTIA */
memset(&gtia_intf, 0, sizeof(gtia_intf));
if (input_port_by_tag(machine->portconfig, "console") != NULL)
if (input_port_by_tag(&machine->portlist, "console") != NULL)
gtia_intf.console_read = console_read;
if (devtag_get_device(machine, "dac") != NULL)
gtia_intf.console_write = console_write;

View File

@ -469,7 +469,7 @@ static void K033906_w(const address_space *space, int chip, int reg, UINT32 data
case 0x10: // initEnable
{
const device_config *device = device_list_find_by_index(space->machine->config->devicelist, VOODOO_GRAPHICS, chip);
const device_config *device = device_list_find_by_index(&space->machine->config->devicelist, VOODOO_GRAPHICS, chip);
voodoo_set_init_enable(device, data);
break;
}

View File

@ -1035,7 +1035,7 @@ static DEVICE_START( naomibd )
}
/* set the type */
v->index = device_list_index(device->machine->config->devicelist, device->type, device->tag);
v->index = device_list_index(&device->machine->config->devicelist, device->type, device->tag);
v->type = config->type;
/* initialize some registers */

View File

@ -342,7 +342,7 @@ void at_keyboard_init(running_machine *machine, AT_KEYBOARD_TYPE type)
{
char buf[40];
sprintf(buf, "pc_keyboard_%d", i);
keyboard.ports[i] = input_port_by_tag(machine->portconfig, buf);
keyboard.ports[i] = input_port_by_tag(&machine->portlist, buf);
}
#ifdef MESS

View File

@ -69,11 +69,11 @@ static WRITE8_DEVICE_HANDLER( joust2_pia_3_cb1_w );
*
*************************************/
static READ8_DEVICE_HANDLER( input_port_0_device_r ) { return input_port_read_direct(input_port_by_index(device->machine->portconfig, 0)); }
static READ8_DEVICE_HANDLER( input_port_1_device_r ) { return input_port_read_direct(input_port_by_index(device->machine->portconfig, 1)); }
static READ8_DEVICE_HANDLER( input_port_2_device_r ) { return input_port_read_direct(input_port_by_index(device->machine->portconfig, 2)); }
static READ8_DEVICE_HANDLER( input_port_3_device_r ) { return input_port_read_direct(input_port_by_index(device->machine->portconfig, 3)); }
static READ8_DEVICE_HANDLER( input_port_4_device_r ) { return input_port_read_direct(input_port_by_index(device->machine->portconfig, 4)); }
static READ8_DEVICE_HANDLER( input_port_0_device_r ) { return input_port_read_direct(input_port_by_index(&device->machine->portlist, 0)); }
static READ8_DEVICE_HANDLER( input_port_1_device_r ) { return input_port_read_direct(input_port_by_index(&device->machine->portlist, 1)); }
static READ8_DEVICE_HANDLER( input_port_2_device_r ) { return input_port_read_direct(input_port_by_index(&device->machine->portlist, 2)); }
static READ8_DEVICE_HANDLER( input_port_3_device_r ) { return input_port_read_direct(input_port_by_index(&device->machine->portlist, 3)); }
static READ8_DEVICE_HANDLER( input_port_4_device_r ) { return input_port_read_direct(input_port_by_index(&device->machine->portlist, 4)); }
/*************************************
*

View File

@ -896,7 +896,7 @@ static void check_palette(running_machine *machine)
const input_port_config *port;
int newset;
port = input_port_by_tag(machine->portconfig, "VIDHW");
port = input_port_by_tag(&machine->portlist, "VIDHW");
if (port != NULL)
{
newset = input_port_read_direct(port);

View File

@ -84,7 +84,7 @@ WRITE8_HANDLER( gottlieb_video_control_w )
WRITE8_HANDLER( gottlieb_laserdisc_video_control_w )
{
const device_config *laserdisc = device_list_first(space->machine->config->devicelist, LASERDISC);
const device_config *laserdisc = device_list_first(&space->machine->config->devicelist, LASERDISC);
/* bit 0 works like the other games */
gottlieb_video_control_w(space, offset, data & 0x01);

View File

@ -2234,7 +2234,7 @@ void TC0100SCN_vh_start(running_machine *machine, int chips,int gfxnum,int x_off
int xd,yd;
TC0100SCN_dblwidth[i]=0;
screen = device_list_find_by_index(machine->config->devicelist, VIDEO_SCREEN, i);
screen = device_list_find_by_index(&machine->config->devicelist, VIDEO_SCREEN, i);
if (screen == NULL)
screen = machine->primary_screen;