diff options
| author | 2010-01-17 09:26:29 +0000 | |
|---|---|---|
| committer | 2010-01-17 09:26:29 +0000 | |
| commit | d061ced59276808138b8a62ca99c6530d0b179bf (patch) | |
| tree | e08630dd72dce81f385643006b35aa9a802e657b /src | |
| parent | 14e2b9acf31db5fbc78a1ece0548130e4d7bed24 (diff) | |
Created new template class tagged_list which manages a simple list
along with a tagmap. Changed memory regions, input ports, and devices
to use this class. For devices, converted typenext and classnext
fields into methods which dynamically search for the next item.
Changed a number of macros to use the features of the class, removing
the need for a bunch of helper functions.
Diffstat (limited to 'src')
43 files changed, 443 insertions, 800 deletions
diff --git a/src/emu/clifront.c b/src/emu/clifront.c index a5cb042197a..c86b39010b1 100644 --- a/src/emu/clifront.c +++ b/src/emu/clifront.c @@ -659,7 +659,7 @@ int cli_info_listdevices(core_options *options, const char *gamename) printf("Driver %s (%s):\n", drivers[drvindex]->name, drivers[drvindex]->description); /* iterate through devices */ - for (device = config->devicelist.head; device != NULL; device = device->next) + for (device = config->devicelist.first(); device != NULL; device = device->next) { switch (device->devclass) { diff --git a/src/emu/cpuintrf.h b/src/emu/cpuintrf.h index f82346c0c63..2609c2dfb04 100644 --- a/src/emu/cpuintrf.h +++ b/src/emu/cpuintrf.h @@ -225,10 +225,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_next(previous) ((previous)->typenext) -#define cpu_get_index(cpu) device_list_index(&(cpu)->machine->config->devicelist, CPU, (cpu)->tag) +#define cpu_count(config) (config)->devicelist.count(CPU) +#define cpu_first(config) (config)->devicelist.first(CPU) +#define cpu_next(previous) (previous)->typenext() +#define cpu_get_index(cpu) (cpu)->machine->config->devicelist.index(CPU, (cpu)->tag) /* IRQ callback to be called by CPU cores when an IRQ is actually taken */ diff --git a/src/emu/crsshair.c b/src/emu/crsshair.c index 64c32df8c92..e53384b0884 100644 --- a/src/emu/crsshair.c +++ b/src/emu/crsshair.c @@ -222,7 +222,7 @@ void crosshair_init(running_machine *machine) global.auto_time = CROSSHAIR_VISIBILITY_AUTOTIME_DEFAULT; /* determine who needs crosshairs */ - for (port = machine->portlist.head; port != NULL; port = port->next) + for (port = machine->portlist.first(); port != NULL; port = port->next) for (field = port->fieldlist; field != NULL; field = field->next) if (field->crossaxis != CROSSHAIR_AXIS_NONE) { diff --git a/src/emu/debug/debugcmd.c b/src/emu/debug/debugcmd.c index b7835084ca8..4381dbbdf14 100644 --- a/src/emu/debug/debugcmd.c +++ b/src/emu/debug/debugcmd.c @@ -543,7 +543,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 = machine->config->devicelist.find(CPU, cpunum); if (*result != NULL) return TRUE; @@ -2504,7 +2504,7 @@ static void execute_snap(running_machine *machine, int ref, int params, const ch const char *filename = param[0]; int scrnum = (params > 1) ? atoi(param[1]) : 0; - const device_config *screen = device_list_find_by_index(&machine->config->devicelist, VIDEO_SCREEN, scrnum); + const device_config *screen = machine->config->devicelist.find(VIDEO_SCREEN, scrnum); if ((screen == NULL) || !render_is_live_screen(screen)) { diff --git a/src/emu/debug/debugcpu.c b/src/emu/debug/debugcpu.c index 2a0d8269557..fb55784702f 100644 --- a/src/emu/debug/debugcpu.c +++ b/src/emu/debug/debugcpu.c @@ -2442,7 +2442,7 @@ static const device_config *expression_get_device(running_machine *machine, cons { const device_config *device; - for (device = machine->config->devicelist.head; device != NULL; device = device->next) + for (device = machine->config->devicelist.first(); device != NULL; device = device->next) if (mame_stricmp(device->tag, tag) == 0) return device; diff --git a/src/emu/debug/debugvw.c b/src/emu/debug/debugvw.c index 40f40d0ee5b..57bf541bdfc 100644 --- a/src/emu/debug/debugvw.c +++ b/src/emu/debug/debugvw.c @@ -2372,7 +2372,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.head; device != NULL; device = device->next) + for (device = machine->config->devicelist.first(); device != NULL; device = device->next) for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) { const address_space *space = device->space(spacenum); diff --git a/src/emu/devintrf.c b/src/emu/devintrf.c index 1855795f5ea..6d0c89bdea5 100644 --- a/src/emu/devintrf.c +++ b/src/emu/devintrf.c @@ -121,31 +121,6 @@ const device_config *device_config::subdevice(const char *_tag) const ***************************************************************************/ /*------------------------------------------------- - 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; -} - - -/*------------------------------------------------- - 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); -} - - -/*------------------------------------------------- device_list_add - add a new device to the end of a device list -------------------------------------------------*/ @@ -153,8 +128,6 @@ void device_list_deinit(device_list *devlist) device_config::device_config(const device_config *_owner, device_type _type, const char *_tag, UINT32 _clock) : next(NULL), owner(const_cast<device_config *>(_owner)), - typenext(NULL), - classnext(NULL), tag(_tag), type(_type), devclass(static_cast<device_class>(devtype_get_info_int(_type, DEVINFO_INT_CLASS))), @@ -185,97 +158,12 @@ device_config::device_config(const device_config *_owner, device_type _type, con device_config::~device_config() { - global_free(inline_config); -} - - -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; - - assert(devlist != NULL); - assert(type != NULL); - assert(tag != NULL); - - /* find the end of the list */ - for (devptr = &devlist->head; *devptr != NULL; devptr = &(*devptr)->next) ; - - /* allocate a new device */ - device = global_alloc(device_config(owner, type, tag, clock)); - - /* add to the map */ - tmerr = devlist->map.add_unique_hash(tag, device, FALSE); - if (tmerr == TMERR_DUPLICATE) - { - const device_config *match = devlist->map.find_hash_only(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.cstr()); - } - - /* 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(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(devlist, device->devclass); - for (tempdevptr = &tempdevice; *tempdevptr != NULL; tempdevptr = &(*tempdevptr)->classnext) ; - *tempdevptr = device; - - /* link us to the end of the master list and return */ - *devptr = device; - return device; -} - - -/*------------------------------------------------- - device_list_remove - remove a device from a - device list --------------------------------------------------*/ - -void device_list_remove(device_list *devlist, const char *tag) -{ - device_config **devptr, **tempdevptr; - device_config *device, *tempdevice; - - assert(devlist != NULL); - assert(tag != NULL); - - /* find the device in the list */ - for (devptr = &devlist->head; *devptr != NULL; devptr = &(*devptr)->next) - if (strcmp(tag, (*devptr)->tag) == 0) - break; - device = *devptr; - if (device == NULL) - 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(devlist, device->type); - for (tempdevptr = &tempdevice; *tempdevptr != device; tempdevptr = &(*tempdevptr)->typenext) ; - assert(*tempdevptr == device); - *tempdevptr = device->typenext; + /* call the custom config free function first */ + device_custom_config_func custom = reinterpret_cast<device_custom_config_func>(devtype_get_info_fct(type, DEVINFO_FCT_CUSTOM_CONFIG)); + if (custom != NULL) + (*custom)(this, MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_FREE, NULL); - /* and from the class list */ - tempdevice = (device_config *)device_list_class_first(devlist, device->devclass); - for (tempdevptr = &tempdevice; *tempdevptr != device; tempdevptr = &(*tempdevptr)->classnext) ; - assert(*tempdevptr == device); - *tempdevptr = device->classnext; - - /* remove the device from the list */ - *devptr = device->next; - - /* and from the map */ - devlist->map.remove(device->tag); - - /* free the device object */ - global_free(device); + global_free(inline_config); } @@ -337,274 +225,117 @@ const device_contract *device_get_contract(const device_config *device, const ch TYPE-BASED DEVICE ACCESS ***************************************************************************/ -/*------------------------------------------------- - device_list_items - return the number of - items of a given type; DEVICE_TYPE_WILDCARD - is allowed --------------------------------------------------*/ - -int device_list_items(const device_list *devlist, device_type type) -{ - const device_config *curdev; - int count = 0; - - /* locate all devices */ - if (type == DEVICE_TYPE_WILDCARD) - { - for (curdev = devlist->head; curdev != NULL; curdev = curdev->next) - count++; - } - - /* locate all devices of a given type */ - else - { - for (curdev = devlist->head; curdev != NULL && curdev->type != type; curdev = curdev->next) ; - for ( ; curdev != NULL; curdev = curdev->typenext) - count++; - } - - return count; -} - - -/*------------------------------------------------- - device_list_first - return the first device - in the list of a given type; - DEVICE_TYPE_WILDCARD is allowed --------------------------------------------------*/ - -const device_config *device_list_first(const device_list *devlist, device_type type) +device_config *device_list::first(device_type type) const { - const device_config *curdev; - - /* first of any device type */ - if (type == DEVICE_TYPE_WILDCARD) - return devlist->head; - /* first of a given type */ - for (curdev = devlist->head; curdev != NULL && curdev->type != type; curdev = curdev->next) ; - return curdev; -} - - -/*------------------------------------------------- - device_list_next - 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) -{ - assert(prevdevice != NULL); - return (type == DEVICE_TYPE_WILDCARD) ? prevdevice->next : prevdevice->typenext; -} - - -/*------------------------------------------------- - device_list_find_by_tag_slow - retrieve a - device configuration based on a 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 = devlist->head; curdev != NULL; curdev = curdev->next) - if (strcmp(tag, curdev->tag) == 0) + for (device_config *curdev = super::first(); curdev != NULL; curdev = curdev->next) + if (curdev->type == type) return curdev; - - /* fail */ return NULL; } -/*------------------------------------------------- - device_find_child_by_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) +int device_list::count(device_type type) const { - const device_config *child; - - assert(owner != NULL); - assert(tag != NULL); - - astring tempstring; - child = device_list_find_by_tag(&owner->machine->config->devicelist, device_build_tag(tempstring, owner, tag)); + int num = 0; - return child; + for (const device_config *curdev = first(type); curdev != NULL; curdev = curdev->typenext()) + num++; + + return num; } -/*------------------------------------------------- - device_list_index - return the index of a - device based on its type and tag; - DEVICE_TYPE_WILDCARD is allowed --------------------------------------------------*/ - -int device_list_index(const device_list *devlist, device_type type, const char *tag) +int device_list::index(device_type type, device_config *object) const { - const device_config *curdev; - int index = 0; - - assert(tag != NULL); - - /* locate among all devices */ - if (type == DEVICE_TYPE_WILDCARD) - { - for (curdev = devlist->head; curdev != NULL; curdev = curdev->next) - { - if (strcmp(tag, curdev->tag) == 0) - return index; - index++; - } - } - - /* locate among all devices of a given type */ - else - { - for (curdev = devlist->head; curdev != NULL && curdev->type != type; curdev = curdev->next) ; - for ( ; curdev != NULL; curdev = curdev->typenext) - { - if (strcmp(tag, curdev->tag) == 0) - return index; - index++; - } - } - + int num = 0; + for (device_config *cur = first(type); cur != NULL; cur = cur->typenext()) + if (cur == object) + return num; + else + num++; return -1; } -/*------------------------------------------------- - device_list_find_by_index - retrieve a device - configuration based on a type and index --------------------------------------------------*/ - -const device_config *device_list_find_by_index(const device_list *devlist, device_type type, int index) +int device_list::index(device_type type, const char *tag) const { - const device_config *curdev; - - /* locate among all devices */ - if (type == DEVICE_TYPE_WILDCARD) - { - for (curdev = devlist->head; curdev != NULL; curdev = curdev->next) - if (index-- == 0) - return curdev; - } - - /* locate among all devices of a given type */ - else - { - for (curdev = devlist->head; curdev != NULL && curdev->type != type; curdev = curdev->next) ; - for ( ; curdev != NULL; curdev = curdev->typenext) - if (index-- == 0) - return curdev; - } + device_config *object = find(tag); + return (object != NULL && object->type == type) ? index(type, object) : -1; +} + - /* fail */ +device_config *device_list::find(device_type type, int index) const +{ + for (device_config *cur = first(type); cur != NULL; cur = cur->typenext()) + if (index-- == 0) + return cur; return NULL; } - -/*************************************************************************** - CLASS-BASED DEVICE ACCESS -***************************************************************************/ - -/*------------------------------------------------- - device_list_class_items - return the number of - items of a given class --------------------------------------------------*/ - -int device_list_class_items(const device_list *devlist, device_class devclass) +device_config *device_list::first(device_class devclass) const { - const device_config *curdev; - int count = 0; - - /* locate all devices of a given class */ - for (curdev = devlist->head; curdev != NULL && curdev->devclass != devclass; curdev = curdev->next) ; - for ( ; curdev != NULL; curdev = curdev->classnext) - count++; - - return count; + /* first of a given devclass */ + for (device_config *curdev = super::first(); curdev != NULL; curdev = curdev->next) + if (curdev->devclass == devclass) + return curdev; + return NULL; } -/*------------------------------------------------- - device_list_class_first - return the first - device in the list of a given class --------------------------------------------------*/ - -const device_config *device_list_class_first(const device_list *devlist, device_class devclass) +int device_list::count(device_class devclass) const { - const device_config *curdev; + int num = 0; - /* first of a given class */ - for (curdev = devlist->head; curdev != NULL && curdev->devclass != devclass; curdev = curdev->next) ; - return curdev; + for (const device_config *curdev = first(devclass); curdev != NULL; curdev = curdev->classnext()) + num++; + + return num; } -/*------------------------------------------------- - device_list_class_next - 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) +int device_list::index(device_class devclass, device_config *object) const { - assert(prevdevice != NULL); - return prevdevice->classnext; + int num = 0; + for (device_config *cur = first(devclass); cur != NULL; cur = cur->classnext()) + if (cur == object) + return num; + else + num++; + return -1; } -/*------------------------------------------------- - device_list_class_index - return the index of a - device based on its class and tag --------------------------------------------------*/ - -int device_list_class_index(const device_list *devlist, device_class devclass, const char *tag) +int device_list::index(device_class devclass, const char *tag) const { - const device_config *curdev; - int index = 0; - - assert(tag != NULL); - - /* locate among all devices of a given class */ - for (curdev = devlist->head; curdev != NULL && curdev->devclass != devclass; curdev = curdev->next) ; - for ( ; curdev != NULL; curdev = curdev->classnext) - { - if (strcmp(tag, curdev->tag) == 0) - return index; - index++; - } + device_config *object = find(tag); + return (object != NULL && object->devclass == devclass) ? index(devclass, object) : -1; +} + - return -1; +device_config *device_list::find(device_class devclass, int index) const +{ + for (device_config *cur = first(devclass); cur != NULL; cur = cur->classnext()) + if (index-- == 0) + return cur; + return NULL; } + /*------------------------------------------------- - device_list_class_find_by_index - retrieve a - device configuration based on a class and - index + device_find_child_by_tag - retrieve a child + device configuration based on a tag -------------------------------------------------*/ -const device_config *device_list_class_find_by_index(const device_list *devlist, device_class devclass, int index) +const device_config *device_find_child_by_tag(const device_config *owner, const char *tag) { - const device_config *curdev; - - /* locate among all devices of a given class */ - for (curdev = devlist->head; curdev != NULL && curdev->devclass != devclass; curdev = curdev->next) ; - for ( ; curdev != NULL; curdev = curdev->classnext) - if (index-- == 0) - return curdev; + assert(owner != NULL); + assert(tag != NULL); - /* fail */ - return NULL; + astring tempstring; + return owner->machine->config->devicelist.find(device_build_tag(tempstring, owner, tag)); } @@ -625,7 +356,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.head; device != NULL; device = device->next) + for (device = machine->config->devicelist.first(); device != NULL; device = device->next) device->machine = machine; } @@ -648,7 +379,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.head; device != NULL; device = device->next) + for (device = machine->config->devicelist.first(); device != NULL; device = device->next) { int spacenum; @@ -680,7 +411,7 @@ void device_list_start(running_machine *machine) int prevstarted = numstarted; /* iterate over devices and start them */ - for (device = (device_config *)machine->config->devicelist.head; device != NULL; device = device->next) + for (device = machine->config->devicelist.first(); device != NULL; device = device->next) { device_start_func start = (device_start_func)device_get_info_fct(device, DEVINFO_FCT_START); assert(start != NULL); @@ -733,7 +464,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.head; device != NULL; device = device->next) + for (device = machine->config->devicelist.first(); device != NULL; device = device->next) { device_stop_func stop = (device_stop_func)device_get_info_fct(device, DEVINFO_FCT_STOP); @@ -768,7 +499,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.head; device != NULL; device = device->next) + for (device = machine->config->devicelist.first(); device != NULL; device = device->next) device_reset(device); } diff --git a/src/emu/devintrf.h b/src/emu/devintrf.h index 72412a30d8f..972abfeb021 100644 --- a/src/emu/devintrf.h +++ b/src/emu/devintrf.h @@ -268,6 +268,34 @@ typedef const machine_config_token *(*device_custom_config_func)(const device_co typedef device_get_info_func device_type; +// template specializations +class device_list : public tagged_list<device_config> +{ + typedef tagged_list<device_config> super; + +public: + // pull the generic forms forward + using super::first; + using super::count; + using super::index; + using super::find; + + // provide type-specific overrides + device_config *first(device_type type) const; + int count(device_type type) const; + int index(device_type type, device_config *object) const; + int index(device_type type, const char *tag) const; + device_config *find(device_type type, int index) const; + + // provide class-specific overrides + device_config *first(device_class devclass) const; + int count(device_class devclass) const; + int index(device_class devclass, device_config *object) const; + int index(device_class devclass, const char *tag) const; + device_config *find(device_class devclass, int index) const; +}; + + /* the actual deviceinfo union */ union deviceinfo { @@ -310,7 +338,7 @@ class region_info; class device_config { DISABLE_COPYING(device_config); - + public: // private eventually const address_space * addrspace[ADDRESS_SPACES]; /* auto-discovered address spaces */ @@ -323,12 +351,26 @@ public: const region_info *subregion(const char *tag) const; const device_config *subdevice(const char *tag) const; + + device_config *typenext() const + { + for (device_config *cur = this->next; cur != NULL; cur = cur->next) + if (cur->type == type) + return cur; + return NULL; + } + + device_config *classnext() const + { + for (device_config *cur = this->next; cur != NULL; cur = cur->next) + if (cur->devclass == devclass) + return cur; + return NULL; + } /* device relationships (always valid) */ device_config * next; /* next device (of any type/class) */ device_config * owner; /* device that owns us, or NULL if nobody */ - device_config * typenext; /* next device of the same type */ - device_config * classnext; /* next device of the same class */ /* device properties (always valid) */ astring tag; /* tag for this instance */ @@ -353,14 +395,6 @@ public: }; -/* an object that contains a list of devices */ -struct device_list -{ - device_config * head; /* head of the list */ - tagmap_t<device_config *> map; /* map for fast lookups */ -}; - - /*************************************************************************** FUNCTION PROTOTYPES @@ -369,18 +403,6 @@ struct device_list /* ----- 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_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_list *devlist, const char *tag); - /* build a tag that combines the device's name and the given tag */ astring &device_build_tag(astring &dest, const device_config *device, const char *tag); @@ -394,46 +416,9 @@ 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_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_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 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_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_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_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_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_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_list *devlist, device_class devclass, int index); - /* ----- live device management ----- */ @@ -489,19 +474,6 @@ const char *devtype_get_info_string(device_type type, UINT32 state); ***************************************************************************/ /*------------------------------------------------- - 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 */ - return devlist->map.find_hash_only(tag); -} - - -/*------------------------------------------------- space - return an address space within a device -------------------------------------------------*/ diff --git a/src/emu/drawgfx.c b/src/emu/drawgfx.c index ab771666494..08909290778 100644 --- a/src/emu/drawgfx.c +++ b/src/emu/drawgfx.c @@ -92,8 +92,8 @@ void gfx_init(running_machine *machine) for (curgfx = 0; curgfx < MAX_GFX_ELEMENTS && gfxdecodeinfo[curgfx].gfxlayout != NULL; curgfx++) { const gfx_decode_entry *gfxdecode = &gfxdecodeinfo[curgfx]; - UINT32 region_length = 8 * memory_region_length(machine, gfxdecode->memory_region); - const UINT8 *region_base = memory_region(machine, gfxdecode->memory_region); + UINT32 region_length = (gfxdecode->memory_region != NULL) ? (8 * memory_region_length(machine, gfxdecode->memory_region)) : 0; + const UINT8 *region_base = (gfxdecode->memory_region != NULL) ? memory_region(machine, gfxdecode->memory_region) : NULL; UINT32 xscale = (gfxdecode->xscale == 0) ? 1 : gfxdecode->xscale; UINT32 yscale = (gfxdecode->yscale == 0) ? 1 : gfxdecode->yscale; UINT32 *extpoffs, extxoffs[MAX_ABS_GFX_SIZE], extyoffs[MAX_ABS_GFX_SIZE]; diff --git a/src/emu/emu.h b/src/emu/emu.h index 4f31420a6ee..9563db0ac6a 100644 --- a/src/emu/emu.h +++ b/src/emu/emu.h @@ -56,7 +56,6 @@ // commonly-referenecd utilities imported from lib/util #include "chd.h" #include "palette.h" -#include "tagmap.h" #include "unicode.h" // emulator-specific utilities diff --git a/src/emu/emucore.h b/src/emu/emucore.h index d299e56ca3d..f0917b83c1f 100644 --- a/src/emu/emucore.h +++ b/src/emu/emucore.h @@ -30,6 +30,7 @@ #include "corestr.h" #include "astring.h" #include "bitmap.h" +#include "tagmap.h" @@ -306,6 +307,114 @@ private: /*************************************************************************** + COMMON TEMPLATES +***************************************************************************/ + +template<class T> class tagged_list +{ + DISABLE_COPYING(tagged_list); + + T *head; + T **tailptr; + tagmap_t<T *> map; + +public: + tagged_list() : + head(NULL), + tailptr(&head) { } + + virtual ~tagged_list() + { + while (head != NULL) + remove(head); + } + + T *first() const { return head; } + + int count() const + { + int num = 0; + for (T *cur = head; cur != NULL; cur = cur->next) + num++; + return num; + } + + int index(T *object) const + { + int num = 0; + for (T *cur = head; cur != NULL; cur = cur->next) + if (cur == object) + return num; + else + num++; + return -1; + } + + int index(const char *tag) const + { + T *object = find(tag); + return (object != NULL) ? index(object) : -1; + } + + T *prepend(const char *tag, T *object, bool replace_if_duplicate = false) + { + if (map.add_unique_hash(tag, object, replace_if_duplicate) != TMERR_NONE) + throw emu_fatalerror("Error adding object named '%s'", tag); + object->next = head; + head = object; + if (tailptr == &head) + tailptr = &object->next; + return object; + } + + T *append(const char *tag, T *object, bool replace_if_duplicate = false) + { + if (map.add_unique_hash(tag, object, replace_if_duplicate) != TMERR_NONE) + throw emu_fatalerror("Error adding object named '%s'", tag); + *tailptr = object; + object->next = NULL; + tailptr = &object->next; + return object; + } + + void remove(T *object) + { + for (T **objectptr = &head; *objectptr != NULL; objectptr = &(*objectptr)->next) + if (*objectptr == object) + { + *objectptr = object->next; + if (tailptr == &object->next) + tailptr = objectptr; + map.remove(object); + global_free(object); + return; + } + } + + void remove(const char *tag) + { + T *object = find(tag); + if (object != NULL) + remove(object); + } + + T *find(const char *tag) const + { + return map.find_hash_only(tag); + } + + T *find(int index) const + { + for (T *cur = head; cur != NULL; cur = cur->next) + if (index-- == 0) + return cur; + return NULL; + } +}; + + + +/*************************************************************************** FUNCTION PROTOTYPES ***************************************************************************/ diff --git a/src/emu/info.c b/src/emu/info.c index 63ae4dc509a..e8dc38c5dd4 100644 --- a/src/emu/info.c +++ b/src/emu/info.c @@ -37,13 +37,13 @@ settings for a game -------------------------------------------------*/ -static void print_game_switches(FILE *out, const game_driver *game, const input_port_list *portlist) +static void print_game_switches(FILE *out, const game_driver *game, const ioport_list &portlist) { const input_port_config *port; const input_field_config *field; /* iterate looking for DIP switches */ - for (port = portlist->head; port != NULL; port = port->next) + for (port = portlist.first(); port != NULL; port = port->next) for (field = port->fieldlist; field != NULL; field = field->next) if (field->type == IPT_DIPSWITCH) { @@ -75,13 +75,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_list *portlist) +static void print_game_configs(FILE *out, const game_driver *game, const ioport_list &portlist) { const input_port_config *port; const input_field_config *field; /* iterate looking for configurations */ - for (port = portlist->head; port != NULL; port = port->next) + for (port = portlist.first(); port != NULL; port = port->next) for (field = port->fieldlist; field != NULL; field = field->next) if (field->type == IPT_CONFIG) { @@ -113,13 +113,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_list *portlist) +static void print_game_adjusters(FILE *out, const game_driver *game, const ioport_list &portlist) { const input_port_config *port; const input_field_config *field; /* iterate looking for Adjusters */ - for (port = portlist->head; port != NULL; port = port->next) + for (port = portlist.first(); port != NULL; port = port->next) for (field = port->fieldlist; field != NULL; field = field->next) if (field->type == IPT_ADJUSTER) { @@ -133,7 +133,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_list *portlist) +static void print_game_input(FILE *out, const game_driver *game, const ioport_list &portlist) { /* fix me -- this needs to be cleaned up to match the core style */ @@ -173,7 +173,7 @@ enum {cjoy, cdoublejoy, cAD_stick, cdial, ctrackball, cpaddle, clightgun, cpedal control[i].reverse = 0; } - for (port = portlist->head; port != NULL; port = port->next) + for (port = portlist.first(); port != NULL; port = port->next) for (field = port->fieldlist; field != NULL; field = field->next) { if (nplayer < field->player+1) @@ -827,8 +827,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 game_driver *clone_of; - input_port_list portlist; machine_config *config; + ioport_list portlist; const char *start; /* no action if not a game */ @@ -837,7 +837,7 @@ static void print_game_info(FILE *out, const game_driver *game) /* start tracking resources and allocate the machine and input configs */ config = machine_config_alloc(game->machine_config); - input_port_list_init(&portlist, game->ipt, NULL, 0, FALSE); + input_port_list_init(portlist, game->ipt, NULL, 0, FALSE); /* print the header and the game name */ fprintf(out, "\t<" XML_TOP); @@ -887,13 +887,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, &portlist); - print_game_switches(out, game, &portlist); - print_game_configs(out, game, &portlist); + 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, &portlist); + print_game_categories(out, game, portlist); #endif /* MESS */ - print_game_adjusters(out, game, &portlist); + print_game_adjusters(out, game, portlist); print_game_driver(out, game, config); #ifdef MESS print_game_device(out, game, config); @@ -903,7 +903,6 @@ static void print_game_info(FILE *out, const game_driver *game) /* close the topmost tag */ fprintf(out, "\t</" XML_TOP ">\n"); - input_port_list_deinit(&portlist); machine_config_free(config); } diff --git a/src/emu/inptport.c b/src/emu/inptport.c index df67e2e2c36..2a4ce6c0512 100644 --- a/src/emu/inptport.c +++ b/src/emu/inptport.c @@ -442,7 +442,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_list *portlist, int type1, int type2, int type3, const char *option, const char *ananame); +static void init_autoselect_devices(const ioport_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); @@ -454,10 +454,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 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); +static void port_config_detokenize(ioport_list &portlist, const input_port_token *ipt, char *errorbuf, int errorbuflen); static input_field_config *field_config_alloc(input_port_config *port, int type, input_port_value defvalue, input_port_value maskbits); static void field_config_insert(input_field_config *field, input_port_value *disallowedbits, char *errorbuf, int errorbuflen); static void field_config_free(input_field_config **fieldptr); @@ -559,7 +556,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->portlist.head; curport != NULL; curport = curport->next) + for (curport = port->machine->portlist.first(); curport != NULL; curport = curport->next) { if (curport == port) break; @@ -662,7 +659,7 @@ time_t input_port_init(running_machine *machine, const input_port_token *tokens) /* if we have a token list, proceed */ if (tokens != NULL) { - input_port_list_init(&machine->portlist, tokens, errorbuf, sizeof(errorbuf), TRUE); + 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); @@ -689,9 +686,6 @@ static void input_port_exit(running_machine *machine) /* close any playback or recording files */ playback_end(machine, NULL); record_end(machine, NULL); - - /* free our allocated config */ - input_port_list_deinit(&machine->portlist); } @@ -706,11 +700,8 @@ static void input_port_exit(running_machine *machine) 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) +void input_port_list_init(ioport_list &portlist, const input_port_token *tokens, char *errorbuf, int errorbuflen, int allocmap) { - /* initialize fields */ - portlist->head = NULL; - /* no tokens, no list */ if (tokens == NULL) return; @@ -725,52 +716,18 @@ void input_port_list_init(input_port_list *portlist, const input_port_token *tok /*------------------------------------------------- - input_port_list_deinit - free memory attached - to an input port list and clear out the - structure --------------------------------------------------*/ - -void input_port_list_deinit(input_port_list *portlist) -{ - /* iterate over all ports and free them */ - while (portlist->head != NULL) - port_config_free(&portlist->head); -} - - -/*------------------------------------------------- - 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_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->head; port != NULL; port = port->next) - if (port->tag != NULL && strcmp(port->tag, tag) == 0) - return port; - - return NULL; -} - - -/*------------------------------------------------- input_field_by_tag_and_mask - return a pointer to the first field that intersects the given mask on the tagged port -------------------------------------------------*/ -const input_field_config *input_field_by_tag_and_mask(const input_port_list *portlist, const char *tag, input_port_value mask) +const input_field_config *input_field_by_tag_and_mask(const ioport_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; + const input_port_config *port = portlist.find(tag); /* if we got the port, look for the field */ if (port != NULL) - for (field = port->fieldlist; field != NULL; field = field->next) + for (const input_field_config *field = port->fieldlist; field != NULL; field = field->next) if ((field->mask & mask) != 0) return field; @@ -1308,7 +1265,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->portlist.head; port != NULL; port = port->next) + for (port = machine->portlist.first(); 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)) @@ -1377,7 +1334,7 @@ void input_port_update_defaults(running_machine *machine) const input_port_config *port; /* loop over all input ports */ - for (port = machine->portlist.head; port != NULL; port = port->next) + for (port = machine->portlist.first(); port != NULL; port = port->next) { const input_field_config *field; @@ -1620,7 +1577,7 @@ static void init_port_state(running_machine *machine) const input_port_config *port; /* allocate live structures to mirror the configuration */ - for (port = machine->portlist.head; port != NULL; port = port->next) + for (port = machine->portlist.first(); port != NULL; port = port->next) { analog_field_state **analogstatetail; device_field_info **readdevicetail; @@ -1698,18 +1655,18 @@ static void init_port_state(running_machine *machine) } /* handle autoselection of devices */ - 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"); + 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->portlist.head; port != NULL; port = port->next) + for (port = machine->portlist.first(); port != NULL; port = port->next) for (field = port->fieldlist; field != NULL; field = field->next) if (field->state->joystick != NULL && field->way == 4) { @@ -1725,7 +1682,7 @@ static void init_port_state(running_machine *machine) in and the corresponding option -------------------------------------------------*/ -static void init_autoselect_devices(const input_port_list *portlist, int type1, int type2, int type3, const char *option, const char *ananame) +static void init_autoselect_devices(const ioport_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; @@ -1762,8 +1719,8 @@ static void init_autoselect_devices(const input_port_list *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->head != NULL && !input_device_class_enabled(portlist->head->machine, autoenable)) - for (port = portlist->head; port != NULL; port = port->next) + if (portlist.first() != NULL && !input_device_class_enabled(portlist.first()->machine, autoenable)) + for (port = portlist.first(); 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 */ @@ -2036,11 +1993,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->portlist, tag, mask); + mouse_field = input_field_by_tag_and_mask(machine->portlist, tag, mask); } /* loop over all input ports */ - for (port = machine->portlist.head; port != NULL; port = port->next) + for (port = machine->portlist.first(); port != NULL; port = port->next) { const input_field_config *field; device_field_info *device_field; @@ -2410,14 +2367,13 @@ static int frame_get_digital_field_state(const input_field_config *field, int mo detokenize a series of input port tokens -------------------------------------------------*/ -static void port_config_detokenize(input_port_list *portlist, const input_port_token *ipt, char *errorbuf, int errorbuflen) +static void port_config_detokenize(ioport_list &portlist, const input_port_token *ipt, char *errorbuf, int errorbuflen) { UINT32 entrytype = INPUT_TOKEN_INVALID; input_setting_config *cursetting = NULL; input_field_config *curfield = NULL; input_port_config *curport = NULL; input_port_value maskbits = 0; - tagmap_error err; UINT16 category; /* (MESS-specific) category */ /* loop over tokens until we hit the end */ @@ -2426,6 +2382,7 @@ static void port_config_detokenize(input_port_list *portlist, const input_port_t UINT32 mask, defval, type, val; input_port_token temptoken; input_condition condition; + const char *string; int hasdiploc; int index; @@ -2455,14 +2412,8 @@ static void port_config_detokenize(input_port_list *portlist, const input_port_t field_config_insert(curfield, &maskbits, errorbuf, errorbuflen); maskbits = 0; - curport = port_config_alloc(&portlist->head); - curport->tag = TOKEN_GET_STRING(ipt); - err = portlist->map.add_unique_hash(curport->tag, curport, FALSE); - if (err == TMERR_DUPLICATE) - { - const input_port_config *match = portlist->map.find_hash_only(curport->tag); - error_buf_append(errorbuf, errorbuflen, "tag '%s' has same hash as tag '%s'; please change one of them", curport->tag, match->tag); - } + string = TOKEN_GET_STRING(ipt); + curport = portlist.append(string, global_alloc(input_port_config(string))); curfield = NULL; cursetting = NULL; break; @@ -2473,7 +2424,7 @@ static void port_config_detokenize(input_port_list *portlist, const input_port_t field_config_insert(curfield, &maskbits, errorbuf, errorbuflen); maskbits = 0; - curport = port_config_find(portlist->head, TOKEN_GET_STRING(ipt)); + curport = portlist.find(TOKEN_GET_STRING(ipt)); curfield = NULL; cursetting = NULL; break; @@ -3066,66 +3017,32 @@ static void port_config_detokenize(input_port_list *portlist, const input_port_t /*------------------------------------------------- - port_config_alloc - allocate a new input - port config and append to the end of the - given list + input_port_config - constructor for an + I/O port configuration object -------------------------------------------------*/ -static input_port_config *port_config_alloc(const input_port_config **listhead) +input_port_config::input_port_config(const char *_tag) + : next(NULL), + tag(_tag), + fieldlist(NULL), + state(NULL), + machine(NULL) { - const input_port_config * const *tailptr; - input_port_config *config; - - /* allocate memory */ - config = global_alloc_clear(input_port_config); - - /* add it to the tail */ - for (tailptr = listhead; *tailptr != NULL; tailptr = &(*tailptr)->next) ; - *(input_port_config **)tailptr = config; - - return config; } /*------------------------------------------------- - port_config_free - free an allocated input - port configuration + ~input_port_config - destructor for an + I/O port configuration object -------------------------------------------------*/ -static void port_config_free(const input_port_config **portptr) +input_port_config::~input_port_config() { - input_port_config *port = (input_port_config *)*portptr; - - /* free any field configs first */ - while (port->fieldlist != NULL) - field_config_free((input_field_config **)&port->fieldlist); - - /* remove ourself from the list */ - *portptr = port->next; - - /* free ourself */ - global_free(port); + while (fieldlist != NULL) + field_config_free((input_field_config **)&fieldlist); } -/*------------------------------------------------- - port_config_find - locate an existing port - configuration by tag --------------------------------------------------*/ - -static input_port_config *port_config_find(const input_port_config *listhead, const char *tag) -{ - const input_port_config *scanport; - - /* scan for a matching tag and return the matching port */ - for (scanport = listhead; scanport != NULL; scanport = scanport->next) - if (scanport->tag != NULL && strcmp(scanport->tag, tag) == 0) - return (input_port_config *)scanport; - - /* failure is fatal */ - fatalerror("port_config_find failed to find a matching port '%s'", tag); -} - /*------------------------------------------------- field_config_alloc - allocate a new input @@ -3658,7 +3575,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->portlist.head; port != NULL; port = port->next) + for (port = machine->portlist.first(); 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) @@ -3820,7 +3737,7 @@ static void save_game_inputs(running_machine *machine, xml_data_node *parentnode const input_port_config *port; /* iterate over ports */ - for (port = machine->portlist.head; port != NULL; port = port->next) + for (port = machine->portlist.first(); port != NULL; port = port->next) for (field = port->fieldlist; field != NULL; field = field->next) if (save_this_input_field_type(field->type)) { diff --git a/src/emu/inptport.h b/src/emu/inptport.h index f0bde41bc26..8d54666aea4 100644 --- a/src/emu/inptport.h +++ b/src/emu/inptport.h @@ -562,10 +562,14 @@ typedef struct _input_field_state input_field_state; /* forward declarations */ -typedef struct _input_port_config input_port_config; +class input_port_config; typedef struct _input_field_config input_field_config; +/* template specializations */ +typedef tagged_list<input_port_config> ioport_list; + + /* custom input port callback function */ typedef UINT32 (*input_field_custom_func)(const input_field_config *field, void *param); @@ -689,9 +693,15 @@ struct _input_field_user_settings /* a single input port configuration */ -struct _input_port_config +class input_port_config { - const input_port_config * next; /* pointer to next port */ + DISABLE_COPYING(input_port_config); + +public: + input_port_config(const char *tag); + ~input_port_config(); + + input_port_config * next; /* pointer to next port */ const char * tag; /* pointer to this port's tag */ const input_field_config * fieldlist; /* list of input_field_configs */ @@ -701,15 +711,6 @@ 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_t<const input_port_config *> map; /* map for fast lookups */ -}; - - /* describes a fundamental input type, including default input sequences */ class input_type_desc { @@ -1030,16 +1031,10 @@ time_t input_port_init(running_machine *machine, const input_port_token *tokens) /* ----- port configurations ----- */ /* 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 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_slow(const input_port_list *portlist, const char *tag); +void input_port_list_init(ioport_list &portlist, const input_port_token *tokens, char *errorbuf, int errorbuflen, int allocmap); /* return the field that matches the given tag and 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_field_config *input_field_by_tag_and_mask(const ioport_list &portlist, const char *tag, input_port_value mask); @@ -1140,21 +1135,4 @@ 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 */ - return portlist->map.find_hash_only(tag); -} - - #endif /* __INPTPORT_H__ */ diff --git a/src/emu/machine/6532riot.c b/src/emu/machine/6532riot.c index ad1c99146e3..a91764b8625 100644 --- a/src/emu/machine/6532riot.c +++ b/src/emu/machine/6532riot.c @@ -434,7 +434,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->machine->config->devicelist.index(RIOT6532, device->tag); /* configure the ports */ devcb_resolve_read8(&riot->port[0].in_func, &riot->intf->in_a_func, device); diff --git a/src/emu/machine/generic.c b/src/emu/machine/generic.c index 62cc0206f04..730bd8cbaca 100644 --- a/src/emu/machine/generic.c +++ b/src/emu/machine/generic.c @@ -338,7 +338,7 @@ void nvram_load(running_machine *machine) } /* find all devices with NVRAM handlers, and read from them next */ - for (device = machine->config->devicelist.head; device != NULL; device = device->next) + for (device = machine->config->devicelist.first(); device != NULL; device = device->next) { device_nvram_func nvram = (device_nvram_func)device_get_info_fct(device, DEVINFO_FCT_NVRAM); if (nvram != NULL) @@ -371,7 +371,7 @@ void nvram_save(running_machine *machine) } /* find all devices with NVRAM handlers, and write them next */ - for (device = machine->config->devicelist.head; device != NULL; device = device->next) + for (device = machine->config->devicelist.first(); device != NULL; device = device->next) { device_nvram_func nvram = (device_nvram_func)device_get_info_fct(device, DEVINFO_FCT_NVRAM); if (nvram != NULL) diff --git a/src/emu/machine/ldcore.c b/src/emu/machine/ldcore.c index cbd2c090210..4377e8ddb71 100644 --- a/src/emu/machine/ldcore.c +++ b/src/emu/machine/ldcore.c @@ -1126,7 +1126,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 = machine->config->devicelist.first(LASERDISC); device != NULL; device = device->typenext()) { laserdisc_config *origconfig = (laserdisc_config *)device->inline_config; laserdisc_state *ld = get_safe_token(device); @@ -1216,7 +1216,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 = screen->machine->config->devicelist.first(LASERDISC); if (laserdisc != NULL) { const rectangle *visarea = video_screen_get_visible_area(screen); diff --git a/src/emu/mame.c b/src/emu/mame.c index f812d21cf62..7c7799db36e 100644 --- a/src/emu/mame.c +++ b/src/emu/mame.c @@ -137,10 +137,6 @@ struct _mame_private void (*saveload_schedule_callback)(running_machine *); attotime saveload_schedule_time; - /* list of memory regions, and a map for lookups */ - region_info * regionlist; - tagmap_t<region_info *> regionmap; - /* random number seed */ UINT32 rand_seed; @@ -769,31 +765,15 @@ region_info::~region_info() region -------------------------------------------------*/ -UINT8 *memory_region_alloc(running_machine *machine, const char *name, UINT32 length, UINT32 flags) +region_info *memory_region_alloc(running_machine *machine, const char *name, UINT32 length, UINT32 flags) { - mame_private *mame = machine->mame_data; - region_info **infoptr, *info; - tagmap_error tagerr; - /* make sure we don't have a region of the same name; also find the end of the list */ - for (infoptr = &mame->regionlist; *infoptr != NULL; infoptr = &(*infoptr)->next) - if ((*infoptr)->name.cmp(name) == 0) - fatalerror("memory_region_alloc called with duplicate region name \"%s\"\n", name); + region_info *info = machine->regionlist.find(name); + if (info != NULL) + fatalerror("memory_region_alloc called with duplicate region name \"%s\"\n", name); /* allocate the region */ - info = auto_alloc(machine, region_info(machine, name, length, flags)); - - /* attempt to put is in the hash table */ - tagerr = mame->regionmap.add_unique_hash(name, info, FALSE); - if (tagerr == TMERR_DUPLICATE) - { - region_info *match = mame->regionmap.find_hash_only(name); - fatalerror("Memory region '%s' has same hash as tag '%s'; please change one of them", name, match->name.cstr()); - } - - /* hook us into the list */ - *infoptr = info; - return info->base.u8; + return machine->regionlist.append(name, global_alloc(region_info(machine, name, length, flags))); } @@ -804,41 +784,7 @@ UINT8 *memory_region_alloc(running_machine *machine, const char *name, UINT32 le void memory_region_free(running_machine *machine, const char *name) { - mame_private *mame = machine->mame_data; - region_info **infoptr; - - /* find the region */ - for (infoptr = &mame->regionlist; *infoptr != NULL; infoptr = &(*infoptr)->next) - if ((*infoptr)->name.cmp(name) == 0) - { - region_info *info = *infoptr; - - /* remove us from the list and the map */ - *infoptr = info->next; - mame->regionmap.remove(info->name); - - /* free the region */ - auto_free(machine, info); - break; - } -} - - -/*------------------------------------------------- - memory_region_info - return a pointer to the - information struct for a given memory region --------------------------------------------------*/ - -region_info *memory_region_info(running_machine *machine, const char *name) -{ - mame_private *mame = machine->mame_data; - - /* NULL tag always fails */ - if (name == NULL) - return NULL; - - /* look up the region and return the base */ - return mame->regionmap.find_hash_only(name); + machine->regionlist.remove(name); } @@ -886,7 +832,7 @@ UINT32 memory_region_flags(running_machine *machine, const char *name) const char *memory_region_next(running_machine *machine, const char *name) { if (name == NULL) - return (machine->mame_data->regionlist != NULL) ? machine->mame_data->regionlist->name : NULL; + return (machine->regionlist.first() != NULL) ? machine->regionlist.first()->name.cstr() : NULL; const region_info *region = machine->region(name); return (region != NULL && region->next != NULL) ? region->next->name.cstr() : NULL; } @@ -1348,7 +1294,6 @@ running_machine::running_machine(const game_driver *driver) { try { - memset(&portlist, 0, sizeof(portlist)); memset(gfx, 0, sizeof(gfx)); memset(&generic, 0, sizeof(generic)); diff --git a/src/emu/mame.h b/src/emu/mame.h index 2d984d0e68d..6a6c78672a2 100644 --- a/src/emu/mame.h +++ b/src/emu/mame.h @@ -151,6 +151,10 @@ typedef struct _generic_video_private generic_video_private; typedef struct _generic_audio_private generic_audio_private; +// template specializations +typedef tagged_list<region_info> region_list; + + /* output channel callback */ typedef void (*output_callback_func)(void *param, const char *format, va_list argptr); @@ -220,10 +224,11 @@ public: inline const region_info *region(const char *tag); resource_pool respool; /* pool of resources for this machine */ + region_list regionlist; /* list of memory regions */ /* configuration data */ const machine_config * config; /* points to the constructed machine_config */ - input_port_list portlist; /* points to a list of input port configurations */ + ioport_list portlist; /* points to a list of input port configurations */ /* CPU information */ const device_config * firstcpu; /* first CPU (allows for quick iteration via typenext) */ @@ -391,14 +396,11 @@ int mame_is_paused(running_machine *machine); /* ----- memory region management ----- */ /* allocate a new memory region */ -UINT8 *memory_region_alloc(running_machine *machine, const char *name, UINT32 length, UINT32 flags); +region_info *memory_region_alloc(running_machine *machine, const char *name, UINT32 length, UINT32 flags); /* free an allocated memory region */ void memory_region_free(running_machine *machine, const char *name); -/* return a pointer to the information struct for a given memory region */ -region_info *memory_region_info(running_machine *machine, const char *name); - /* return a pointer to a specified memory region */ UINT8 *memory_region(running_machine *machine, const char *name); @@ -474,17 +476,17 @@ void mame_get_current_datetime(running_machine *machine, mame_system_time *systi inline const device_config *running_machine::device(const char *tag) { - return device_list_find_by_tag(&config->devicelist, tag); + return config->devicelist.find(tag); } inline const input_port_config *running_machine::port(const char *tag) { - return input_port_by_tag(&portlist, tag); + return portlist.find(tag); } inline const region_info *running_machine::region(const char *tag) { - return memory_region_info(this, tag); + return regionlist.find(tag); } diff --git a/src/emu/mconfig.c b/src/emu/mconfig.c index 32e48dbd221..9d158b74378 100644 --- a/src/emu/mconfig.c +++ b/src/emu/mconfig.c @@ -31,33 +31,6 @@ static void machine_config_detokenize(machine_config *config, const machine_conf ***************************************************************************/ /*------------------------------------------------- - remove_device - remove the head device from - the given configuration --------------------------------------------------*/ - -INLINE void remove_device(device_list *list, const char *tag) -{ - device_config *device = (device_config *)device_list_find_by_tag(list, tag); - device_custom_config_func custom; - - assert(device != NULL); - - /* call the custom config free function first */ - custom = (device_custom_config_func)devtype_get_info_fct(device->type, DEVINFO_FCT_CUSTOM_CONFIG); - if (custom != NULL) - (*custom)(device, MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_FREE, NULL); - - /* remove the device from the list */ - device_list_remove(list, tag); -} - - - -/*************************************************************************** - MACHINE CONFIGURATIONS -***************************************************************************/ - -/*------------------------------------------------- machine_config_alloc - allocate a new machine configuration and populate it using the supplied constructor @@ -70,9 +43,6 @@ machine_config *machine_config_alloc(const machine_config_token *tokens) /* allocate a new configuration object */ config = global_alloc_clear(machine_config); - /* initialize the device list */ - device_list_init(&config->devicelist, TRUE); - /* parse tokens into the config */ machine_config_detokenize(config, tokens, NULL, 0); @@ -87,11 +57,6 @@ machine_config *machine_config_alloc(const machine_config_token *tokens) void machine_config_free(machine_config *config) { - /* release the device list */ - while (config->devicelist.head != NULL) - remove_device(&config->devicelist, config->devicelist.head->tag); - device_list_deinit(&config->devicelist); - /* release the configuration itself */ global_free(config); } @@ -136,19 +101,19 @@ static void machine_config_detokenize(machine_config *config, const machine_conf TOKEN_UNGET_UINT32(tokens); TOKEN_GET_UINT64_UNPACK2(tokens, entrytype, 8, clock, 32); devtype = TOKEN_GET_PTR(tokens, devtype); - tag = TOKEN_GET_STRING(tokens); - device = device_list_add(&config->devicelist, owner, devtype, device_build_tag(tempstring, owner, tag), clock); + tag = device_build_tag(tempstring, owner, TOKEN_GET_STRING(tokens)); + device = config->devicelist.append(tag, global_alloc(device_config(owner, devtype, tag, clock))); break; case MCONFIG_TOKEN_DEVICE_REMOVE: tag = TOKEN_GET_STRING(tokens); - remove_device(&config->devicelist, device_build_tag(tempstring, owner, tag)); + config->devicelist.remove(device_build_tag(tempstring, owner, tag)); device = NULL; break; 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 = config->devicelist.find(device_build_tag(tempstring, owner, tag)); if (device == NULL) fatalerror("Unable to find device: tag=%s\n", tempstring.cstr()); break; @@ -326,7 +291,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.head; device != NULL; device = device->next) + for (device = config->devicelist.first(); device != NULL; device = device->next) { tokens = (const machine_config_token *)device_get_info_ptr(device, DEVINFO_PTR_MACHINE_CONFIG); if (tokens != NULL) diff --git a/src/emu/memory.c b/src/emu/memory.c index 34a7a6b92f2..31341deef2b 100644 --- a/src/emu/memory.c +++ b/src/emu/memory.c @@ -1711,7 +1711,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.head; device != NULL; device = device->next) + for (device = machine->config->devicelist.first(); device != NULL; device = device->next) for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) if (device_get_addrbus_width(device, spacenum) > 0) { diff --git a/src/emu/profiler.c b/src/emu/profiler.c index 33f1e30f25c..0a28f4b83b4 100644 --- a/src/emu/profiler.c +++ b/src/emu/profiler.c @@ -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) - string.catprintf("CPU '%s'", device_list_find_by_index(&machine->config->devicelist, CPU, curtype - PROFILER_CPU_FIRST)->tag.cstr()); + string.catprintf("CPU '%s'", machine->config->devicelist.find(CPU, curtype - PROFILER_CPU_FIRST)->tag.cstr()); else for (nameindex = 0; nameindex < ARRAY_LENGTH(names); nameindex++) if (names[nameindex].type == curtype) diff --git a/src/emu/render.c b/src/emu/render.c index 0e03a915347..eb3d1b74653 100644 --- a/src/emu/render.c +++ b/src/emu/render.c @@ -963,7 +963,7 @@ int render_is_live_screen(const device_config *screen) assert(screen->machine->config != NULL); assert(screen->tag != NULL); - screen_index = device_list_index(&screen->machine->config->devicelist, VIDEO_SCREEN, screen->tag); + screen_index = screen->machine->config->devicelist.index(VIDEO_SCREEN, screen->tag); assert(screen_index != -1); @@ -1466,7 +1466,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 = target->machine->config->devicelist.find(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 +1598,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->portlist, 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; } diff --git a/src/emu/rendlay.c b/src/emu/rendlay.c index 1bbf8ca92f5..ea2b3cb701a 100644 --- a/src/emu/rendlay.c +++ b/src/emu/rendlay.c @@ -1342,7 +1342,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 = config->devicelist.index(VIDEO_SCREEN, device->tag); const screen_config *scrconfig = (const screen_config *)device->inline_config; /* native X aspect factor */ diff --git a/src/emu/romload.c b/src/emu/romload.c index 4bdd4e47227..1fcdf5285b7 100644 --- a/src/emu/romload.c +++ b/src/emu/romload.c @@ -64,8 +64,7 @@ struct _romload_private open_chd * chd_list; /* disks */ open_chd ** chd_list_tailptr; - UINT8 * regionbase; /* base of current region */ - UINT32 regionlength; /* length of current region */ + region_info * region; /* info about current region */ astring errorstring; /* error string */ }; @@ -165,7 +164,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.head; device != NULL; device = device->next) + for (device = config->devicelist.first(); 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 +185,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.head : NULL; + device = (config != NULL) ? config->devicelist.first() : NULL; else device = ((const device_config *)previous)->next; @@ -731,7 +730,7 @@ static int read_rom_data(rom_load_data *romdata, const rom_entry *romp) int skip = ROM_GETSKIPCOUNT(romp); int reversed = ROM_ISREVERSED(romp); int numgroups = (numbytes + groupsize - 1) / groupsize; - UINT8 *base = romdata->regionbase + ROM_GETOFFSET(romp); + UINT8 *base = romdata->region->base.u8 + ROM_GETOFFSET(romp); UINT32 tempbufsize; UINT8 *tempbuf; int i; @@ -743,7 +742,7 @@ static int read_rom_data(rom_load_data *romdata, const rom_entry *romp) fatalerror("Error in RomModule definition: %s length not an even multiple of group size\n", ROM_GETNAME(romp)); /* make sure we only fill within the region space */ - if (ROM_GETOFFSET(romp) + numgroups * groupsize + (numgroups - 1) * skip > romdata->regionlength) + if (ROM_GETOFFSET(romp) + numgroups * groupsize + (numgroups - 1) * skip > romdata->region->length) fatalerror("Error in RomModule definition: %s out of memory region space\n", ROM_GETNAME(romp)); /* make sure the length was valid */ @@ -845,10 +844,10 @@ static int read_rom_data(rom_load_data *romdata, const rom_entry *romp) static void fill_rom_data(rom_load_data *romdata, const rom_entry *romp) { UINT32 numbytes = ROM_GETLENGTH(romp); - UINT8 *base = romdata->regionbase + ROM_GETOFFSET(romp); + UINT8 *base = romdata->region->base.u8 + ROM_GETOFFSET(romp); /* make sure we fill within the region space */ - if (ROM_GETOFFSET(romp) + numbytes > romdata->regionlength) + if (ROM_GETOFFSET(romp) + numbytes > romdata->region->length) fatalerror("Error in RomModule definition: FILL out of memory region space\n"); /* make sure the length was valid */ @@ -866,14 +865,14 @@ static void fill_rom_data(rom_load_data *romdata, const rom_entry *romp) static void copy_rom_data(rom_load_data *romdata, const rom_entry *romp) { - UINT8 *base = romdata->regionbase + ROM_GETOFFSET(romp); + UINT8 *base = romdata->region->base.u8 + ROM_GETOFFSET(romp); const char *srcrgntag = ROM_GETNAME(romp); UINT32 numbytes = ROM_GETLENGTH(romp); UINT32 srcoffs = (FPTR)ROM_GETHASHDATA(romp); /* srcoffset in place of hashdata */ UINT8 *srcbase; /* make sure we copy within the region space */ - if (ROM_GETOFFSET(romp) + numbytes > romdata->regionlength) + if (ROM_GETOFFSET(romp) + numbytes > romdata->region->length) fatalerror("Error in RomModule definition: COPY out of target memory region space\n"); /* make sure the length was valid */ @@ -1286,22 +1285,21 @@ static void process_region_list(rom_load_data *romdata) regionflags = normalize_flags_for_device(romdata->machine, regionflags, regiontag); /* remember the base and length */ - romdata->regionbase = memory_region_alloc(romdata->machine, regiontag, regionlength, regionflags); - romdata->regionlength = regionlength; - LOG(("Allocated %X bytes @ %p\n", romdata->regionlength, romdata->regionbase)); + romdata->region = memory_region_alloc(romdata->machine, regiontag, regionlength, regionflags); + LOG(("Allocated %X bytes @ %p\n", romdata->region->length, romdata->region->base.v)); /* clear the region if it's requested */ if (ROMREGION_ISERASE(region)) - memset(romdata->regionbase, ROMREGION_GETERASEVAL(region), romdata->regionlength); + memset(romdata->region->base.v, ROMREGION_GETERASEVAL(region), romdata->region->length); /* or if it's sufficiently small (<= 4MB) */ - else if (romdata->regionlength <= 0x400000) - memset(romdata->regionbase, 0, romdata->regionlength); + else if (romdata->region->length <= 0x400000) + memset(romdata->region->base.v, 0, romdata->region->length); #ifdef MAME_DEBUG /* if we're debugging, fill region with random data to catch errors */ else - fill_random(romdata->machine, romdata->regionbase, romdata->regionlength); + fill_random(romdata->machine, romdata->region->base.u8, romdata->region->length); #endif /* now process the entries in the region */ diff --git a/src/emu/sound.h b/src/emu/sound.h index 4dcbc0b47c4..fab44615717 100644 --- a/src/emu/sound.h +++ b/src/emu/sound.h @@ -34,15 +34,15 @@ /* 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_next(previous) ((previous)->typenext) +#define sound_count(config) (config)->devicelist.count(SOUND) +#define sound_first(config) (config)->devicelist.first(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_next(previous) ((previous)->typenext) +#define speaker_output_count(config) (config)->devicelist.count(SPEAKER_OUTPUT) +#define speaker_output_first(config) (config)->devicelist.first(SPEAKER_OUTPUT) +#define speaker_output_next(previous) (previous)->typenext() diff --git a/src/emu/sound/disc_inp.c b/src/emu/sound/disc_inp.c index 5ae665afc1f..f02a6c80bf8 100644 --- a/src/emu/sound/disc_inp.c +++ b/src/emu/sound/disc_inp.c @@ -174,7 +174,7 @@ static DISCRETE_RESET(dss_adjustment) double min, max; - context->port = input_port_by_tag(&node->info->device->machine->portlist, (const char *)node->custom); + context->port = node->info->device->machine->portlist.find((const char *)node->custom); if (context->port == NULL) fatalerror("DISCRETE_ADJUSTMENT - NODE_%d has invalid tag", NODE_BLOCKINDEX(node)); diff --git a/src/emu/sound/scsp.c b/src/emu/sound/scsp.c index 25102d483ea..d57cb365fff 100644 --- a/src/emu/sound/scsp.c +++ b/src/emu/sound/scsp.c @@ -1206,7 +1206,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(space->machine->config->devicelist.find(CPU, 2),dma_transfer_end,HOLD_LINE); } #ifdef UNUSED_FUNCTION diff --git a/src/emu/ui.c b/src/emu/ui.c index d0a835d964b..9a630a4d55b 100644 --- a/src/emu/ui.c +++ b/src/emu/ui.c @@ -978,7 +978,7 @@ astring &game_info_astring(running_machine *machine, astring &string) /* count how many identical CPUs we have */ count = 1; - for (scandevice = device->typenext; scandevice != NULL; scandevice = scandevice->typenext) + for (scandevice = device->typenext(); scandevice != NULL; scandevice = scandevice->typenext()) { if (cpu_get_type(device) != cpu_get_type(scandevice) || device->clock != scandevice->clock) break; @@ -1007,7 +1007,7 @@ astring &game_info_astring(running_machine *machine, astring &string) /* count how many identical sound chips we have */ count = 1; - for (scandevice = device->typenext; scandevice != NULL; scandevice = scandevice->typenext) + for (scandevice = device->typenext(); scandevice != NULL; scandevice = scandevice->typenext()) { if (sound_get_type(device) != sound_get_type(scandevice) || device->clock != scandevice->clock) break; @@ -1442,7 +1442,7 @@ static slider_state *slider_init(running_machine *machine) } /* add analog adjusters */ - for (port = machine->portlist.head; port != NULL; port = port->next) + for (port = machine->portlist.first(); port != NULL; port = port->next) for (field = port->fieldlist; field != NULL; field = field->next) if (field->type == IPT_ADJUSTER) { @@ -1507,7 +1507,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 = machine->config->devicelist.first(LASERDISC); device != NULL; device = device->typenext()) { const laserdisc_config *config = (const laserdisc_config *)device->inline_config; if (config->overupdate != NULL) @@ -1550,7 +1550,7 @@ static slider_state *slider_init(running_machine *machine) #ifdef MAME_DEBUG /* add crosshair adjusters */ - for (port = machine->portlist.head; port != NULL; port = port->next) + for (port = machine->portlist.first(); port != NULL; port = port->next) for (field = port->fieldlist; field != NULL; field = field->next) if (field->crossaxis != CROSSHAIR_AXIS_NONE && field->player == 0) { @@ -1966,7 +1966,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 = laserdisc->machine->config->devicelist.count(LASERDISC); static char descbuf[256]; if (ldcount > 1) diff --git a/src/emu/uimenu.c b/src/emu/uimenu.c index 7ab40c1dce8..5134680c4fc 100644 --- a/src/emu/uimenu.c +++ b/src/emu/uimenu.c @@ -1466,7 +1466,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->portlist.head; port != NULL; port = port->next) + for (port = machine->portlist.first(); port != NULL; port = port->next) for (field = port->fieldlist; field != NULL; field = field->next) { if (field->type == IPT_DIPSWITCH) @@ -1666,7 +1666,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->portlist.head; port != NULL; port = port->next) + for (port = machine->portlist.first(); 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->portlist.head; port != NULL; port = port->next) + for (port = machine->portlist.first(); 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) astring text; /* loop over input ports and add the items */ - for (port = machine->portlist.head; port != NULL; port = port->next) + for (port = machine->portlist.first(); port != NULL; port = port->next) for (field = port->fieldlist; field != NULL; field = field->next) if (input_type_is_analog(field->type)) { diff --git a/src/emu/validity.c b/src/emu/validity.c index 867f8b43a73..b8da081f52b 100644 --- a/src/emu/validity.c +++ b/src/emu/validity.c @@ -599,7 +599,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.cstr()); 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 && config->devicelist.find(cpuconfig->vblank_interrupt_screen) == NULL) { mame_printf_error("%s: %s cpu '%s' VBLANK interrupt with a non-existant screen tag (%s)!\n", driver->source_file, driver->name, device->tag.cstr(), cpuconfig->vblank_interrupt_screen); error = TRUE; @@ -1038,7 +1038,7 @@ static void validate_dip_settings(const input_field_config *field, const game_dr validate_inputs - validate input configuration -------------------------------------------------*/ -static int validate_inputs(int drivnum, const machine_config *config, int_map &defstr_map, input_port_list *portlist) +static int validate_inputs(int drivnum, const machine_config *config, int_map &defstr_map, ioport_list &portlist) { const input_port_config *scanport; const input_port_config *port; @@ -1061,7 +1061,7 @@ static int validate_inputs(int drivnum, const machine_config *config, int_map &d } /* check for duplicate tags */ - for (port = portlist->head; port != NULL; port = port->next) + for (port = portlist.first(); port != NULL; port = port->next) if (port->tag != NULL) for (scanport = port->next; scanport != NULL; scanport = scanport->next) if (scanport->tag != NULL && strcmp(port->tag, scanport->tag) == 0) @@ -1071,7 +1071,7 @@ static int validate_inputs(int drivnum, const machine_config *config, int_map &d } /* iterate over the results */ - for (port = portlist->head; port != NULL; port = port->next) + for (port = portlist.first(); port != NULL; port = port->next) for (field = port->fieldlist; field != NULL; field = field->next) { const input_setting_config *setting; @@ -1134,7 +1134,7 @@ static int validate_inputs(int drivnum, const machine_config *config, int_map &d if (field->condition.tag != NULL) { /* find a matching port */ - for (scanport = portlist->head; scanport != NULL; scanport = scanport->next) + for (scanport = portlist.first(); scanport != NULL; scanport = scanport->next) if (scanport->tag != NULL && strcmp(field->condition.tag, scanport->tag) == 0) break; @@ -1151,7 +1151,7 @@ static int validate_inputs(int drivnum, const machine_config *config, int_map &d if (setting->condition.tag != NULL) { /* find a matching port */ - for (scanport = portlist->head; scanport != NULL; scanport = scanport->next) + for (scanport = portlist.first(); scanport != NULL; scanport = scanport->next) if (scanport->tag != NULL && strcmp(setting->condition.tag, scanport->tag) == 0) break; @@ -1245,13 +1245,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_list *portlist, region_array *rgninfo) +static int validate_devices(int drivnum, const machine_config *config, const ioport_list &portlist, region_array *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 = config->devicelist.first(); device != NULL; device = device->next) { device_validity_check_func validity_check = (device_validity_check_func) device_get_info_fct(device, DEVINFO_FCT_VALIDITY_CHECK); int detected_overlap = DETECT_OVERLAPPING_MEMORY ? FALSE : TRUE; @@ -1262,7 +1262,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 = config->devicelist.first(); scandevice != device; scandevice = scandevice->next) 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.cstr()); @@ -1379,16 +1379,16 @@ static int validate_devices(int drivnum, const machine_config *config, const inp } /* make sure all devices exist */ - if ((entry->read.type == AMH_DEVICE_HANDLER && entry->read.tag != NULL && device_list_find_by_tag(&config->devicelist, entry->read.tag) == NULL) || - (entry->write.type == AMH_DEVICE_HANDLER && entry->write.tag != NULL && device_list_find_by_tag(&config->devicelist, entry->write.tag) == NULL)) + if ((entry->read.type == AMH_DEVICE_HANDLER && entry->read.tag != NULL && config->devicelist.find(entry->read.tag) == NULL) || + (entry->write.type == AMH_DEVICE_HANDLER && entry->write.tag != NULL && config->devicelist.find(entry->write.tag) == NULL)) { mame_printf_error("%s: %s device '%s' %s space memory map entry references nonexistant device '%s'\n", driver->source_file, driver->name, device->tag.cstr(), address_space_names[spacenum], entry->write.tag); error = TRUE; } /* make sure ports exist */ - if ((entry->read.type == AMH_PORT && entry->read.tag != NULL && input_port_by_tag(portlist, entry->read.tag) == NULL) || - (entry->write.type == AMH_PORT && entry->write.tag != NULL && input_port_by_tag(portlist, entry->write.tag) == NULL)) + if ((entry->read.type == AMH_PORT && entry->read.tag != NULL && portlist.find(entry->read.tag) == NULL) || + (entry->write.type == AMH_PORT && entry->write.tag != NULL && portlist.find(entry->write.tag) == NULL)) { mame_printf_error("%s: %s device '%s' %s space memory map entry references nonexistant port tag '%s'\n", driver->source_file, driver->name, device->tag.cstr(), address_space_names[spacenum], entry->read.tag); error = TRUE; @@ -1498,7 +1498,7 @@ int mame_validitychecks(const game_driver *curdriver) for (drivnum = 0; drivers[drivnum]; drivnum++) { const game_driver *driver = drivers[drivnum]; - input_port_list portlist; + ioport_list portlist; machine_config *config; region_array rgninfo; @@ -1523,7 +1523,7 @@ int mame_validitychecks(const game_driver *curdriver) /* validate input ports */ input_checks -= get_profile_ticks(); - error = validate_inputs(drivnum, config, defstr, &portlist) || error; + error = validate_inputs(drivnum, config, defstr, portlist) || error; input_checks += get_profile_ticks(); /* validate the CPU information */ @@ -1548,10 +1548,9 @@ 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(); - input_port_list_deinit(&portlist); machine_config_free(config); } diff --git a/src/emu/video.c b/src/emu/video.c index 90c396ec354..2adf3d0ed6b 100644 --- a/src/emu/video.c +++ b/src/emu/video.c @@ -2074,7 +2074,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.cstr()); + view_index = screen->machine->config->devicelist.index(VIDEO_SCREEN, screen->tag.cstr()); assert(view_index != -1); render_target_set_view(global.snap_target, view_index); } diff --git a/src/emu/video.h b/src/emu/video.h index ed27983d160..9c2a8dd8ed0 100644 --- a/src/emu/video.h +++ b/src/emu/video.h @@ -44,9 +44,9 @@ 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_next(previous) device_list_next((previous), VIDEO_SCREEN) +#define video_screen_count(config) (config)->devicelist.count(VIDEO_SCREEN) +#define video_screen_first(config) (config)->devicelist.first(VIDEO_SCREEN) +#define video_screen_next(previous) (previous)->typenext() #define video_screen_get_format(screen) (((screen_config *)(screen)->inline_config)->format) diff --git a/src/emu/video/voodoo.c b/src/emu/video/voodoo.c index 220a9b58fdd..64ad5299459 100644 --- a/src/emu/video/voodoo.c +++ b/src/emu/video/voodoo.c @@ -4538,7 +4538,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->machine->config->devicelist.index(device->type, device->tag); v->screen = device->machine->device(config->screen); assert_always(v->screen != NULL, "Unable to find screen attached to voodoo"); v->cpu = device->machine->device(config->cputag); diff --git a/src/ldplayer/ldplayer.c b/src/ldplayer/ldplayer.c index 2706b10adeb..2bc21c22b92 100644 --- a/src/ldplayer/ldplayer.c +++ b/src/ldplayer/ldplayer.c @@ -226,7 +226,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 = machine->config->devicelist.first(LASERDISC); int vblank_scanline; attotime target; @@ -249,7 +249,7 @@ static MACHINE_START( ldplayer ) static TIMER_CALLBACK( autoplay ) { - const device_config *laserdisc = device_list_first(&machine->config->devicelist, LASERDISC); + const device_config *laserdisc = machine->config->devicelist.first(LASERDISC); /* start playing */ (*execute_command)(laserdisc, CMD_PLAY); @@ -322,7 +322,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 = machine->config->devicelist.first(LASERDISC); MACHINE_START_CALL(ldplayer); pr8210_bit_timer = timer_alloc(machine, pr8210_bit_callback, (void *)laserdisc); } diff --git a/src/lib/util/tagmap.c b/src/lib/util/tagmap.c index b3e0a711dec..3c0db36d72e 100644 --- a/src/lib/util/tagmap.c +++ b/src/lib/util/tagmap.c @@ -127,7 +127,7 @@ tagmap_error tagmap_add_unique_hash(tagmap *map, const char *tag, void *object, /*------------------------------------------------- - tagmap_remove - remove an object from a + tagmap_remove - remove an entr from a tagmap -------------------------------------------------*/ @@ -147,6 +147,31 @@ void tagmap_remove(tagmap *map, const char *tag) } +/*------------------------------------------------- + tagmap_remove_object - remove an entry from a + tagmap by object pointer +-------------------------------------------------*/ + +void tagmap_remove_object(tagmap *map, void *object) +{ + UINT32 hashindex; + + for (hashindex = 0; hashindex < ARRAY_LENGTH(map->table); hashindex++) + { + tagmap_entry **entryptr; + + for (entryptr = &map->table[hashindex]; *entryptr != NULL; entryptr = &(*entryptr)->next) + if ((*entryptr)->object == object) + { + tagmap_entry *entry = *entryptr; + *entryptr = entry->next; + free(entry); + return; + } + } +} + + /*************************************************************************** LOCAL FUNCTIONS diff --git a/src/lib/util/tagmap.h b/src/lib/util/tagmap.h index b6e771f815c..2a22ad74222 100644 --- a/src/lib/util/tagmap.h +++ b/src/lib/util/tagmap.h @@ -116,6 +116,9 @@ tagmap_error tagmap_add_unique_hash(tagmap *map, const char *tag, void *object, /* remove an entry from a tagmap */ void tagmap_remove(tagmap *map, const char *tag); +/* remove an entry from a tagmap by object pointer */ +void tagmap_remove_object(tagmap *map, void *object); + /*************************************************************************** @@ -140,6 +143,7 @@ public: tagmap_error add(const char *tag, T object, bool replace_if_duplicate = false) { return tagmap_add(this, tag, (void *)object, replace_if_duplicate); } tagmap_error add_unique_hash(const char *tag, T object, bool replace_if_duplicate = false) { return tagmap_add_unique_hash(this, tag, (void *)object, replace_if_duplicate); } void remove(const char *tag) { tagmap_remove(this, tag); } + void remove(T object) { tagmap_remove_object(this, object); } T find(const char *tag) const { return reinterpret_cast<T>(tagmap_find(this, tag)); } T find(const char *tag, UINT32 hash) const { return reinterpret_cast<T>(tagmap_find_prehashed(this, tag, hash)); } diff --git a/src/mame/audio/namcoc7x.c b/src/mame/audio/namcoc7x.c index 7be79ae6d3c..09bc1ada53b 100644 --- a/src/mame/audio/namcoc7x.c +++ b/src/mame/audio/namcoc7x.c @@ -88,7 +88,7 @@ void namcoc7x_on_driver_init(running_machine *machine) memset(pROM, 0, 4); // install speedup cheat - for (cpu = devtag_get_device(machine, "maincpu"); cpu != NULL; cpu = cpu->typenext) + for (cpu = devtag_get_device(machine, "maincpu"); cpu != NULL; cpu = cpu->typenext()) if (cpu_get_type(cpu) == CPU_M37702) memory_install_readwrite16_handler(cpu_get_address_space(cpu, ADDRESS_SPACE_PROGRAM), 0x82, 0x83, 0, 0, speedup_r, speedup_w); } diff --git a/src/mame/drivers/firebeat.c b/src/mame/drivers/firebeat.c index 903fe2f78b6..f54a1c7bbd2 100644 --- a/src/mame/drivers/firebeat.c +++ b/src/mame/drivers/firebeat.c @@ -470,7 +470,7 @@ static VIDEO_UPDATE(firebeat) { int chip; - if (screen == device_list_find_by_index(&screen->machine->config->devicelist, VIDEO_SCREEN, 0)) + if (screen == screen->machine->config->devicelist.find(VIDEO_SCREEN, 0)) chip = 0; else chip = 1; @@ -599,7 +599,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 = machine->config->devicelist.find(VIDEO_SCREEN, chip); if (screen != NULL) { diff --git a/src/mame/drivers/galaxian.c b/src/mame/drivers/galaxian.c index 8b9d67d9ddd..099a5a61419 100644 --- a/src/mame/drivers/galaxian.c +++ b/src/mame/drivers/galaxian.c @@ -2484,7 +2484,7 @@ static DRIVER_INIT( gmgalax ) memory_configure_bank(machine, "bank1", 0, 2, memory_region(machine, "maincpu") + 0x10000, 0x4000); /* callback when the game select is toggled */ - gmgalax_game_changed(machine->portlist.head->fieldlist, NULL, 0, 0); + gmgalax_game_changed(machine->portlist.first()->fieldlist, NULL, 0, 0); state_save_register_global(machine, gmgalax_selected_game); } diff --git a/src/mame/drivers/gottlieb.c b/src/mame/drivers/gottlieb.c index 51505253479..d63d8cb2f70 100644 --- a/src/mame/drivers/gottlieb.c +++ b/src/mame/drivers/gottlieb.c @@ -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 = machine->config->devicelist.first(LASERDISC); if (laserdisc != NULL) { /* attach to the I/O ports */ diff --git a/src/mame/machine/naomibd.c b/src/mame/machine/naomibd.c index 01193d5a46d..a81bfe4d361 100644 --- a/src/mame/machine/naomibd.c +++ b/src/mame/machine/naomibd.c @@ -1034,7 +1034,7 @@ static DEVICE_START( naomibd ) } /* set the type */ - v->index = device_list_index(&device->machine->config->devicelist, device->type, device->tag); + v->index = device->machine->config->devicelist.index(device->type, device->tag); v->type = config->type; /* initialize some registers */ diff --git a/src/mame/video/gottlieb.c b/src/mame/video/gottlieb.c index 39997a434a0..1b7eb432ddf 100644 --- a/src/mame/video/gottlieb.c +++ b/src/mame/video/gottlieb.c @@ -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 = space->machine->config->devicelist.first(LASERDISC); /* bit 0 works like the other games */ gottlieb_video_control_w(space, offset, data & 0x01); |
