diff options
| author | 2010-01-19 15:08:18 +0000 | |
|---|---|---|
| committer | 2010-01-19 15:08:18 +0000 | |
| commit | 409add88bbd2fa97f9b3c063884f37abc56ebcee (patch) | |
| tree | fbdd9175ae1079cfeb4da3237fd034664f278c4b /src | |
| parent | 576dfd4d9d0a1d9d5b15ba06c0a3d8c6a52d5b03 (diff) | |
Convrted the rest of devintrf to classes and moved management
functions into methods of those classes. The most wide-ranging
change was converting device_reset() to device->reset(). Apart
from that it was mostly internal shuffling in the core.
Diffstat (limited to 'src')
45 files changed, 465 insertions, 563 deletions
diff --git a/src/emu/cpu/z80/z80daisy.c b/src/emu/cpu/z80/z80daisy.c index 915be1dac71..06cab99dd04 100644 --- a/src/emu/cpu/z80/z80daisy.c +++ b/src/emu/cpu/z80/z80daisy.c @@ -31,7 +31,7 @@ z80_daisy_state *z80daisy_init(running_device *cpudevice, const z80_daisy_chain { *tailptr = auto_alloc(cpudevice->machine, z80_daisy_state); (*tailptr)->next = NULL; - (*tailptr)->device = cpudevice->machine->device(device_inherit_tag(tempstring, cpudevice->tag, daisy->devname)); + (*tailptr)->device = cpudevice->machine->device(cpudevice->siblingtag(tempstring, daisy->devname)); if ((*tailptr)->device == NULL) fatalerror("Unable to locate device '%s'", daisy->devname); (*tailptr)->irq_state = (z80_daisy_irq_state)(*tailptr)->device->get_config_fct(DEVINFO_FCT_IRQ_STATE); @@ -48,7 +48,7 @@ void z80daisy_reset(z80_daisy_state *daisy) { /* loop over all devices and call their reset function */ for ( ; daisy != NULL; daisy = daisy->next) - device_reset(daisy->device); + daisy->device->reset(); } diff --git a/src/emu/cpuexec.c b/src/emu/cpuexec.c index 9c5021010ab..330c494d2f2 100644 --- a/src/emu/cpuexec.c +++ b/src/emu/cpuexec.c @@ -1501,7 +1501,7 @@ static TIMER_CALLBACK( empty_event_queue ) /* if we're clearing the line that was previously asserted, or if we're just */ /* pulsing the line, reset the CPU */ if ((state == CLEAR_LINE && cpu_is_suspended(device, SUSPEND_REASON_RESET)) || state == PULSE_LINE) - device_reset(device); + device->reset(); /* if we're clearing the line, make sure the CPU is not halted */ cpu_resume(device, SUSPEND_REASON_RESET); diff --git a/src/emu/devintrf.c b/src/emu/devintrf.c index 3000c30f341..e6f3445fdb8 100644 --- a/src/emu/devintrf.c +++ b/src/emu/devintrf.c @@ -20,17 +20,6 @@ #define TEMP_STRING_POOL_ENTRIES 16 #define MAX_STRING_LENGTH 256 -// ->started states -// -// Only 0 and 1 are externally visible in practice, making it a -// boolean //for external users - -enum { - DEVICE_STOPPED = 0, - DEVICE_STARTED = 1, - DEVICE_STARTING = 2, - DEVICE_DELAYED = 3 -}; /*************************************************************************** @@ -43,16 +32,6 @@ static int temp_string_pool_index; /*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ - -static void device_list_stop(running_machine *machine); -static void device_list_reset(running_machine *machine); -static void set_default_string(UINT32 state, char *buffer); - - - -/*************************************************************************** INLINE FUNCTIONS ***************************************************************************/ @@ -69,49 +48,111 @@ static char *get_temp_string_buffer(void) } + + +/*************************************************************************** + LIVE DEVICE MANAGEMENT +***************************************************************************/ + /*------------------------------------------------- - device_matches_type - does a device match - the provided type, taking wildcards into - effect? + device_list - device list constructor -------------------------------------------------*/ -INLINE int device_matches_type(running_device *device, device_type type) +device_list::device_list() + : machine(NULL) { - return (type == DEVICE_TYPE_WILDCARD) ? TRUE : (device->type == type); } /*------------------------------------------------- - subregion - return a pointer to the region - info for a given region + import_config_list - import a list of device + configs and allocate new devices -------------------------------------------------*/ -const region_info *running_device::subregion(const char *_tag) const +void device_list::import_config_list(const device_config_list &list, running_machine &_machine) { - // safety first - if (this == NULL) - return NULL; + // remember the machine for later use + machine = &_machine; + + // append each device from the configuration list + for (const device_config *devconfig = list.first(); devconfig != NULL; devconfig = devconfig->next) + append(devconfig->tag, new running_device(_machine, *devconfig)); +} - // build a fully-qualified name - astring tempstring(tag, ":", _tag); - return machine->region(tempstring); + +/*------------------------------------------------- + start_all - start all the devices in the + list +-------------------------------------------------*/ + +void device_list::start_all() +{ + // add exit and reset callbacks + assert(machine != NULL); + add_reset_callback(machine, static_reset); + add_exit_callback(machine, static_stop); + + // iterate until we've started everything + int devcount = count(); + int numstarted = 0; + while (numstarted < devcount) + { + // iterate over devices and start them + int prevstarted = numstarted; + for (running_device *device = first(); device != NULL; device = device->next) + if (!device->started) + { + // attempt to start the device, catching any expected exceptions + try + { + device->start(); + numstarted++; + } + catch (device_missing_dependencies &) + { + } + } + + // if we didn't start anything new, we're in trouble + if (numstarted == prevstarted) + fatalerror("Circular dependency in device startup; unable to start %d/%d devices\n", devcount - numstarted, devcount); + } } /*------------------------------------------------- - subdevice - return a pointer to the given - device that is owned by us + stop_all - stop all devices in the list -------------------------------------------------*/ -running_device *running_device::subdevice(const char *_tag) const +void device_list::stop_all() { - // safety first - if (this == NULL) - return NULL; + // iterate over devices and stop them + for (running_device *device = first(); device != NULL; device = device->next) + device->stop(); +} - // build a fully-qualified name - astring tempstring(tag, ":", _tag); - return machine->device(tempstring); + +void device_list::static_stop(running_machine *machine) +{ + machine->devicelist.stop_all(); +} + + +/*------------------------------------------------- + reset_all - reset all devices in the list +-------------------------------------------------*/ + +void device_list::reset_all() +{ + /* iterate over devices and stop them */ + for (running_device *device = first(); device != NULL; device = device->next) + device->reset(); +} + + +void device_list::static_reset(running_machine *machine) +{ + machine->devicelist.reset_all(); } @@ -121,8 +162,8 @@ running_device *running_device::subdevice(const char *_tag) const ***************************************************************************/ /*------------------------------------------------- - device_list_add - add a new device to the - end of a device list + device_config - constructor for a new + device configuration -------------------------------------------------*/ device_config::device_config(const device_config *_owner, device_type _type, const char *_tag, UINT32 _clock) @@ -135,401 +176,321 @@ device_config::device_config(const device_config *_owner, device_type _type, con static_config(NULL), inline_config(NULL) { + // initialize remaining members memset(address_map, 0, sizeof(address_map)); - devclass = (device_class)get_config_int(DEVINFO_INT_CLASS); + // derive the clock from our owner if requested if ((clock & 0xff000000) == 0xff000000) { assert(owner != NULL); clock = owner->clock * ((clock >> 12) & 0xfff) / ((clock >> 0) & 0xfff); } - /* populate device configuration */ + // allocate a buffer for the inline configuration UINT32 configlen = (UINT32)get_config_int(DEVINFO_INT_INLINE_CONFIG_BYTES); inline_config = (configlen == 0) ? NULL : global_alloc_array_clear(UINT8, configlen); } +/*------------------------------------------------- + ~device_config - destructor +-------------------------------------------------*/ + device_config::~device_config() { - /* call the custom config free function first */ + // call the custom config free function first device_custom_config_func custom = reinterpret_cast<device_custom_config_func>(get_config_fct(DEVINFO_FCT_CUSTOM_CONFIG)); if (custom != NULL) (*custom)(this, MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_FREE, NULL); + // free the inline config global_free(inline_config); } -running_device::running_device(running_machine &_machine, const device_config &_config) - : _baseconfig(_config), - machine(&_machine), - next(NULL), - owner((_config.owner != NULL) ? _machine.devicelist.find(_config.owner->tag) : NULL), - tag(_config.tag), - type(_config.type), - devclass(_config.devclass), - clock(_config.clock), - started(DEVICE_STOPPED), - token(NULL), - tokenbytes(_config.get_config_int(DEVINFO_INT_TOKEN_BYTES)), - region(NULL), - execute(NULL), - get_runtime_info(NULL) -{ - /* get the size of the token data; we do it directly because we can't call device_get_config_* with no token */ - if (tokenbytes == 0) - throw emu_fatalerror("Device %s specifies a 0 token length!\n", tag.cstr()); - - /* allocate memory for the token */ - token = auto_alloc_array_clear(machine, UINT8, tokenbytes); - - /* fill in the remaining runtime fields */ - memset(addrspace, 0, sizeof(addrspace)); - - // get function pointers - execute = (device_execute_func)get_config_fct(DEVINFO_FCT_EXECUTE); - get_runtime_info = (device_get_runtime_info_func)get_config_fct(DEVINFO_FCT_GET_RUNTIME_INFO); -} - - -running_device::~running_device() -{ - auto_free(machine, token); -} - - -void running_device::set_address_space(int spacenum, const address_space *space) -{ - addrspace[spacenum] = space; -} - - /*------------------------------------------------- - device_build_tag - build a tag that combines - the device's name and the given tag + device_get_config_int - return an integer state + value from an allocated device -------------------------------------------------*/ -astring &device_build_tag(astring &dest, const device_config *devconfig, const char *tag) +INT64 device_config::get_config_int(UINT32 state) const { - if (devconfig != NULL) - dest.cpy(devconfig->tag).cat(":").cat(tag); - else - dest.cpy(tag); - return dest; -} - - -/*------------------------------------------------- - device_inherit_tag - build a tag with the same - device prefix as the source tag --------------------------------------------------*/ + assert(this != NULL); + assert(type != NULL); + assert(state >= DEVINFO_INT_FIRST && state <= DEVINFO_INT_LAST); -astring &device_inherit_tag(astring &dest, const char *sourcetag, const char *tag) -{ - const char *divider = strrchr(sourcetag, ':'); - if (divider != NULL) - dest.cpy(sourcetag, divider + 1 - sourcetag).cat(tag); - else - dest.cpy(tag); - return dest; + // retrieve the value + deviceinfo info; + info.i = 0; + (*type)(this, state, &info); + return info.i; } /*------------------------------------------------- - device_get_contract - find a given contract - on a device + device_get_config_ptr - return a pointer state + value from an allocated device -------------------------------------------------*/ -const device_contract *device_get_contract(running_device *device, const char *name) +void *device_config::get_config_ptr(UINT32 state) const { - const device_contract *contract = (const device_contract *)device->get_config_ptr(DEVINFO_PTR_CONTRACT_LIST); - - /* if no contracts, obviously we don't have it */ - if (contract == NULL) - return NULL; - - /* scan forward through the array looking for a match */ - for ( ; contract->name != NULL; contract++) - if (strcmp(name, contract->name) == 0) - return contract; + assert(this != NULL); + assert(type != NULL); + assert(state >= DEVINFO_PTR_FIRST && state <= DEVINFO_PTR_LAST); - return NULL; + // retrieve the value + deviceinfo info; + info.p = NULL; + (*type)(this, state, &info); + return info.p; } - -/*************************************************************************** - LIVE DEVICE MANAGEMENT -***************************************************************************/ - /*------------------------------------------------- - device_list_attach_machine - "attach" a - running_machine to its list of devices + device_get_config_fct - return a function + pointer state value from an allocated device -------------------------------------------------*/ -void device_list::import_config_list(const device_config_list &list, running_machine &machine) +genf *device_config::get_config_fct(UINT32 state) const { - for (const device_config *devconfig = list.first(); devconfig != NULL; devconfig = devconfig->next) - append(devconfig->tag, new running_device(machine, *devconfig)); + assert(this != NULL); + assert(type != NULL); + assert(state >= DEVINFO_FCT_FIRST && state <= DEVINFO_FCT_LAST); + + // retrieve the value + deviceinfo info; + info.f = 0; + (*type)(this, state, &info); + return info.f; } /*------------------------------------------------- - device_list_start - start the configured list - of devices for a machine + device_get_config_string - return a string value + from an allocated device -------------------------------------------------*/ -void device_list_start(running_machine *machine) +const char *device_config::get_config_string(UINT32 state) const { - running_device *device; - int numstarted = 0; - int devcount = machine->devicelist.count(); - - assert(machine != NULL); - - /* add an exit callback for cleanup */ - add_reset_callback(machine, device_list_reset); - add_exit_callback(machine, device_list_stop); + assert(this != NULL); + assert(type != NULL); + assert(state >= DEVINFO_STR_FIRST && state <= DEVINFO_STR_LAST); - /* iterate until we've started everything */ - while (numstarted < devcount) + // retrieve the value + deviceinfo info; + info.s = get_temp_string_buffer(); + (*type)(this, state, &info); + if (info.s[0] == 0) { - int prevstarted = numstarted; - - /* iterate over devices and start them */ - for (device = machine->devicelist.first(); device != NULL; device = device->next) + switch (state) { - device_start_func start = (device_start_func)device->get_config_fct(DEVINFO_FCT_START); - assert(start != NULL); - - if (!device->started) - { - device->region = machine->regionlist.find(device->baseconfig().tag); - - device->started = DEVICE_STARTING; - (*start)(device); - - /* if the start was delayed, move back to the stopped state, otherwise count it */ - if (device->started == DEVICE_DELAYED) - device->started = DEVICE_STOPPED; - else - { - device->started = DEVICE_STARTED; - numstarted++; - } - } + case DEVINFO_STR_NAME: strcpy(info.s, "Custom"); break; + case DEVINFO_STR_FAMILY: strcpy(info.s, "Custom"); break; + case DEVINFO_STR_VERSION: strcpy(info.s, "1.0"); break; + case DEVINFO_STR_SOURCE_FILE: strcpy(info.s, __FILE__); break; + case DEVINFO_STR_CREDITS: strcpy(info.s, "Copyright Nicola Salmoria and the MAME Team"); break; } - - /* if we didn't start anything new, we're in trouble */ - if (numstarted == prevstarted) - fatalerror("Circular dependency in device startup; unable to start %d/%d devices\n", devcount - numstarted, devcount); } + return info.s; } /*------------------------------------------------- - device_delay_init - delay the startup of a - given device for dependency reasons + subtag - create a tag for an object that is + owned by this device -------------------------------------------------*/ -void device_delay_init(running_device *device) +astring &device_config::subtag(astring &dest, const char *_tag) const { - if (device->started != DEVICE_STARTING && device->started != DEVICE_DELAYED) - fatalerror("Error: Calling device_delay_init on a device not in the process of starting."); - device->started = DEVICE_DELAYED; + return (this != NULL) ? dest.cpy(tag).cat(":").cat(_tag) : dest.cpy(_tag); } /*------------------------------------------------- - device_list_stop - stop the configured list - of devices for a machine + siblingtag - create a tag for an object that + a sibling to this device -------------------------------------------------*/ -static void device_list_stop(running_machine *machine) +astring &device_config::siblingtag(astring &dest, const char *_tag) const { - running_device *device; + return (this != NULL && owner != NULL) ? owner->subtag(dest, _tag) : dest.cpy(_tag); +} - assert(machine != NULL); - /* iterate over devices and stop them */ - for (device = machine->devicelist.first(); device != NULL; device = device->next) - { - device_stop_func stop = (device_stop_func)device->get_config_fct(DEVINFO_FCT_STOP); - assert(device->token != NULL); - assert(device->type != NULL); +/*************************************************************************** + LIVE DEVICE MANAGEMENT +***************************************************************************/ - /* if we have a stop function, call it */ - if (stop != NULL) - (*stop)(device); +/*------------------------------------------------- + running_device - constructor for a new + running device; initial state is derived + from the provided config +-------------------------------------------------*/ - /* free allocated memory for the token */ - auto_free(machine, device->token); +running_device::running_device(running_machine &_machine, const device_config &_config) + : _baseconfig(_config), + machine(&_machine), + next(NULL), + owner((_config.owner != NULL) ? _machine.devicelist.find(_config.owner->tag) : NULL), + tag(_config.tag), + type(_config.type), + devclass(_config.devclass), + clock(_config.clock), + started(false), + token(NULL), + tokenbytes(_config.get_config_int(DEVINFO_INT_TOKEN_BYTES)), + region(NULL), + execute(NULL), + get_runtime_info(NULL) +{ + memset(addrspace, 0, sizeof(addrspace)); - /* reset all runtime fields */ - device->token = NULL; - device->tokenbytes = 0; - device->machine = NULL; - device->region = NULL; - } + if (tokenbytes == 0) + throw emu_fatalerror("Device %s specifies a 0 token length!\n", tag.cstr()); + + // allocate memory for the token + token = auto_alloc_array_clear(machine, UINT8, tokenbytes); + + // get function pointers + execute = (device_execute_func)get_config_fct(DEVINFO_FCT_EXECUTE); + get_runtime_info = (device_get_runtime_info_func)get_config_fct(DEVINFO_FCT_GET_RUNTIME_INFO); } /*------------------------------------------------- - device_list_reset - reset the configured list - of devices for a machine + ~running_device - destructor for a + running_device -------------------------------------------------*/ -static void device_list_reset(running_machine *machine) +running_device::~running_device() { - running_device *device; - - assert(machine != NULL); - - /* iterate over devices and stop them */ - for (device = machine->devicelist.first(); device != NULL; device = device->next) - device_reset(device); + // release token memory + auto_free(machine, token); } /*------------------------------------------------- - device_reset - reset a device based on an - allocated device_config + subregion - return a pointer to the region + info for a given region -------------------------------------------------*/ -void device_reset(running_device *device) +const region_info *running_device::subregion(const char *_tag) const { - device_reset_func reset; - - assert(device != NULL); - assert(device->token != NULL); - assert(device->type != NULL); + // safety first + if (this == NULL) + return NULL; - /* if we have a reset function, call it */ - reset = (device_reset_func)device->get_config_fct(DEVINFO_FCT_RESET); - if (reset != NULL) - (*reset)(device); + // build a fully-qualified name + astring tempstring; + return machine->region(subtag(tempstring, _tag)); } /*------------------------------------------------- - device_set_clock - change the clock on a - device + subdevice - return a pointer to the given + device that is owned by us -------------------------------------------------*/ -void device_set_clock(running_device *device, UINT32 clock) +running_device *running_device::subdevice(const char *_tag) const { - device_config *devicerw = (device_config *)device; + // safety first + if (this == NULL) + return NULL; - /* not much for now */ - devicerw->clock = clock; + // build a fully-qualified name + astring tempstring; + return machine->device(subtag(tempstring, _tag)); } - -/*************************************************************************** - DEVICE INFORMATION GETTERS -***************************************************************************/ - /*------------------------------------------------- - device_get_config_int - return an integer state - value from an allocated device + set_address_space - connect an address space + to a device -------------------------------------------------*/ -INT64 device_config::get_config_int(UINT32 state) const +void running_device::set_address_space(int spacenum, const address_space *space) { - deviceinfo info; + addrspace[spacenum] = space; +} - assert(this != NULL); - assert(type != NULL); - assert(state >= DEVINFO_INT_FIRST && state <= DEVINFO_INT_LAST); - /* retrieve the value */ - info.i = 0; - (*type)(this, state, &info); - return info.i; +/*------------------------------------------------- + set_clock - set a device's clock +-------------------------------------------------*/ + +void running_device::set_clock(UINT32 _clock) +{ + clock = _clock; } /*------------------------------------------------- - device_get_config_ptr - return a pointer state - value from an allocated device + start - start a device -------------------------------------------------*/ -void *device_config::get_config_ptr(UINT32 state) const +void running_device::start() { - deviceinfo info; + // find our region + region = machine->regionlist.find(baseconfig().tag); - assert(this != NULL); - assert(type != NULL); - assert(state >= DEVINFO_PTR_FIRST && state <= DEVINFO_PTR_LAST); + // start functions are required + device_start_func start = (device_start_func)get_config_fct(DEVINFO_FCT_START); + assert(start != NULL); + (*start)(this); - /* retrieve the value */ - info.p = NULL; - (*type)(this, state, &info); - return info.p; + // if we didn't get any exceptions then we started ok + started = true; } /*------------------------------------------------- - device_get_config_fct - return a function - pointer state value from an allocated device + stop - stop a device -------------------------------------------------*/ -genf *device_config::get_config_fct(UINT32 state) const +void running_device::stop() { - deviceinfo info; - - assert(this != NULL); + assert(token != NULL); assert(type != NULL); - assert(state >= DEVINFO_FCT_FIRST && state <= DEVINFO_FCT_LAST); - /* retrieve the value */ - info.f = 0; - (*type)(this, state, &info); - return info.f; + // if we have a stop function, call it + device_stop_func stop = (device_stop_func)get_config_fct(DEVINFO_FCT_STOP); + if (stop != NULL) + (*stop)(this); } /*------------------------------------------------- - device_get_config_string - return a string value - from an allocated device + reset - reset a device -------------------------------------------------*/ -const char *device_config::get_config_string(UINT32 state) const +void running_device::reset() { - deviceinfo info; - assert(this != NULL); - assert(type != NULL); - assert(state >= DEVINFO_STR_FIRST && state <= DEVINFO_STR_LAST); + assert(this->token != NULL); + assert(this->type != NULL); - /* retrieve the value */ - info.s = get_temp_string_buffer(); - (*type)(this, state, &info); - if (info.s[0] == 0) - set_default_string(state, info.s); - return info.s; + // if we have a reset function, call it + device_reset_func reset = (device_reset_func)get_config_fct(DEVINFO_FCT_RESET); + if (reset != NULL) + (*reset)(this); } - /*------------------------------------------------- - device_get_runtime_int - return an integer state + get_runtime_int - return an integer state value from an allocated device -------------------------------------------------*/ INT64 running_device::get_runtime_int(UINT32 state) { - deviceinfo info; - assert(this != NULL); assert(get_runtime_info != NULL); assert(state >= DEVINFO_INT_FIRST && state <= DEVINFO_INT_LAST); - /* retrieve the value */ + // retrieve the value + deviceinfo info; info.i = 0; (*get_runtime_info)(this, state, &info); return info.i; @@ -537,19 +498,18 @@ INT64 running_device::get_runtime_int(UINT32 state) /*------------------------------------------------- - device_get_runtime_ptr - return a pointer state + get_runtime_ptr - return a pointer state value from an allocated device -------------------------------------------------*/ void *running_device::get_runtime_ptr(UINT32 state) { - deviceinfo info; - assert(this != NULL); assert(get_runtime_info != NULL); assert(state >= DEVINFO_PTR_FIRST && state <= DEVINFO_PTR_LAST); - /* retrieve the value */ + // retrieve the value + deviceinfo info; info.p = NULL; (*get_runtime_info)(this, state, &info); return info.p; @@ -557,45 +517,19 @@ void *running_device::get_runtime_ptr(UINT32 state) /*------------------------------------------------- - device_get_runtime_string - return a string value + get_runtime_string - return a string value from an allocated device -------------------------------------------------*/ const char *running_device::get_runtime_string(UINT32 state) { - deviceinfo info; - assert(this != NULL); assert(get_runtime_info != NULL); assert(state >= DEVINFO_STR_FIRST && state <= DEVINFO_STR_LAST); - /* retrieve the value */ + // retrieve the value + deviceinfo info; info.s = get_temp_string_buffer(); (*get_runtime_info)(this, state, &info); - if (info.s[0] == 0) - set_default_string(state, info.s); return info.s; } - - - -/*************************************************************************** - DEFAULT HANDLERS -***************************************************************************/ - -/*------------------------------------------------- - set_default_string - compute a default string - if none is provided --------------------------------------------------*/ - -static void set_default_string(UINT32 state, char *buffer) -{ - switch (state) - { - case DEVINFO_STR_NAME: strcpy(buffer, "Custom"); break; - case DEVINFO_STR_FAMILY: strcpy(buffer, "Custom"); break; - case DEVINFO_STR_VERSION: strcpy(buffer, "1.0"); break; - case DEVINFO_STR_SOURCE_FILE: strcpy(buffer, __FILE__); break; - case DEVINFO_STR_CREDITS: strcpy(buffer, "Copyright Nicola Salmoria and the MAME Team"); break; - } -} diff --git a/src/emu/devintrf.h b/src/emu/devintrf.h index b82590bccab..0402d15521a 100644 --- a/src/emu/devintrf.h +++ b/src/emu/devintrf.h @@ -24,115 +24,111 @@ CONSTANTS ***************************************************************************/ -/* forward references */ +// forward references struct rom_entry; union machine_config_token; -/* device classes */ +// device classes enum device_class { - DEVICE_CLASS_GENERAL = 0, /* default class for general devices */ - DEVICE_CLASS_PERIPHERAL, /* peripheral devices: PIAs, timers, etc. */ - DEVICE_CLASS_AUDIO, /* audio devices (not sound chips), including speakers */ - DEVICE_CLASS_VIDEO, /* video devices, including screens */ - DEVICE_CLASS_CPU_CHIP, /* CPU chips; only CPU cores should return this class */ - DEVICE_CLASS_SOUND_CHIP, /* sound chips; only sound cores should return this class */ - DEVICE_CLASS_TIMER, /* timer devices */ - DEVICE_CLASS_OTHER /* anything else (the list may expand in the future) */ + DEVICE_CLASS_GENERAL = 0, // default class for general devices + DEVICE_CLASS_PERIPHERAL, // peripheral devices: PIAs, timers, etc. + DEVICE_CLASS_AUDIO, // audio devices (not sound chips), including speakers + DEVICE_CLASS_VIDEO, // video devices, including screens + DEVICE_CLASS_CPU_CHIP, // CPU chips; only CPU cores should return this class + DEVICE_CLASS_SOUND_CHIP, // sound chips; only sound cores should return this class + DEVICE_CLASS_TIMER, // timer devices + DEVICE_CLASS_OTHER // anything else (the list may expand in the future) }; -/* useful in device_list functions for scanning through all devices */ -#define DEVICE_TYPE_WILDCARD NULL - - -/* state constants passed to the device_get_config_func */ +// state constants passed to the device_get_config_func enum { - /* --- the following bits of info are returned as 64-bit signed integers --- */ + // --- the following bits of info are returned as 64-bit signed integers --- DEVINFO_INT_FIRST = 0x00000, - DEVINFO_INT_TOKEN_BYTES = DEVINFO_INT_FIRST, /* R/O: bytes to allocate for the token */ - DEVINFO_INT_INLINE_CONFIG_BYTES, /* R/O: bytes to allocate for the inline configuration */ - DEVINFO_INT_CLASS, /* R/O: the device's class */ + DEVINFO_INT_TOKEN_BYTES = DEVINFO_INT_FIRST, // R/O: bytes to allocate for the token + DEVINFO_INT_INLINE_CONFIG_BYTES, // R/O: bytes to allocate for the inline configuration + DEVINFO_INT_CLASS, // R/O: the device's class - DEVINFO_INT_ENDIANNESS, /* R/O: either ENDIANNESS_BIG or ENDIANNESS_LITTLE */ - DEVINFO_INT_DATABUS_WIDTH, /* R/O: data bus size for each address space (8,16,32,64) */ + DEVINFO_INT_ENDIANNESS, // R/O: either ENDIANNESS_BIG or ENDIANNESS_LITTLE + DEVINFO_INT_DATABUS_WIDTH, // R/O: data bus size for each address space (8,16,32,64) DEVINFO_INT_DATABUS_WIDTH_0 = DEVINFO_INT_DATABUS_WIDTH + 0, DEVINFO_INT_DATABUS_WIDTH_1 = DEVINFO_INT_DATABUS_WIDTH + 1, DEVINFO_INT_DATABUS_WIDTH_2 = DEVINFO_INT_DATABUS_WIDTH + 2, DEVINFO_INT_DATABUS_WIDTH_3 = DEVINFO_INT_DATABUS_WIDTH + 3, DEVINFO_INT_DATABUS_WIDTH_LAST = DEVINFO_INT_DATABUS_WIDTH + ADDRESS_SPACES - 1, - DEVINFO_INT_ADDRBUS_WIDTH, /* R/O: address bus size for each address space (12-32) */ + DEVINFO_INT_ADDRBUS_WIDTH, // R/O: address bus size for each address space (12-32) DEVINFO_INT_ADDRBUS_WIDTH_0 = DEVINFO_INT_ADDRBUS_WIDTH + 0, DEVINFO_INT_ADDRBUS_WIDTH_1 = DEVINFO_INT_ADDRBUS_WIDTH + 1, DEVINFO_INT_ADDRBUS_WIDTH_2 = DEVINFO_INT_ADDRBUS_WIDTH + 2, DEVINFO_INT_ADDRBUS_WIDTH_3 = DEVINFO_INT_ADDRBUS_WIDTH + 3, DEVINFO_INT_ADDRBUS_WIDTH_LAST = DEVINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACES - 1, - DEVINFO_INT_ADDRBUS_SHIFT, /* R/O: shift applied to addresses each address space (+3 means >>3, -1 means <<1) */ + DEVINFO_INT_ADDRBUS_SHIFT, // R/O: shift applied to addresses each address space (+3 means >>3, -1 means <<1) DEVINFO_INT_ADDRBUS_SHIFT_0 = DEVINFO_INT_ADDRBUS_SHIFT + 0, DEVINFO_INT_ADDRBUS_SHIFT_1 = DEVINFO_INT_ADDRBUS_SHIFT + 1, DEVINFO_INT_ADDRBUS_SHIFT_2 = DEVINFO_INT_ADDRBUS_SHIFT + 2, DEVINFO_INT_ADDRBUS_SHIFT_3 = DEVINFO_INT_ADDRBUS_SHIFT + 3, DEVINFO_INT_ADDRBUS_SHIFT_LAST = DEVINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACES - 1, - DEVINFO_INT_CLASS_SPECIFIC = 0x04000, /* R/W: device-specific values start here */ - DEVINFO_INT_DEVICE_SPECIFIC = 0x08000, /* R/W: device-specific values start here */ + DEVINFO_INT_CLASS_SPECIFIC = 0x04000, // R/W: device-specific values start here + DEVINFO_INT_DEVICE_SPECIFIC = 0x08000, // R/W: device-specific values start here DEVINFO_INT_LAST = 0x0ffff, - /* --- the following bits of info are returned as pointers --- */ + // --- the following bits of info are returned as pointers --- DEVINFO_PTR_FIRST = 0x10000, - DEVINFO_PTR_ROM_REGION = DEVINFO_PTR_FIRST, /* R/O: pointer to device-specific ROM region */ - DEVINFO_PTR_MACHINE_CONFIG, /* R/O: pointer to device-specific machine config */ - DEVINFO_PTR_CONTRACT_LIST, /* R/O: pointer to list of supported device contracts */ + DEVINFO_PTR_ROM_REGION = DEVINFO_PTR_FIRST, // R/O: pointer to device-specific ROM region + DEVINFO_PTR_MACHINE_CONFIG, // R/O: pointer to device-specific machine config + DEVINFO_PTR_CONTRACT_LIST, // R/O: pointer to list of supported device contracts - DEVINFO_PTR_INTERNAL_MEMORY_MAP, /* R/O: const addrmap_token *map */ + DEVINFO_PTR_INTERNAL_MEMORY_MAP, // R/O: const addrmap_token *map DEVINFO_PTR_INTERNAL_MEMORY_MAP_0 = DEVINFO_PTR_INTERNAL_MEMORY_MAP + 0, DEVINFO_PTR_INTERNAL_MEMORY_MAP_1 = DEVINFO_PTR_INTERNAL_MEMORY_MAP + 1, DEVINFO_PTR_INTERNAL_MEMORY_MAP_2 = DEVINFO_PTR_INTERNAL_MEMORY_MAP + 2, DEVINFO_PTR_INTERNAL_MEMORY_MAP_3 = DEVINFO_PTR_INTERNAL_MEMORY_MAP + 3, DEVINFO_PTR_INTERNAL_MEMORY_MAP_LAST = DEVINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACES - 1, - DEVINFO_PTR_DEFAULT_MEMORY_MAP, /* R/O: const addrmap_token *map */ + DEVINFO_PTR_DEFAULT_MEMORY_MAP, // R/O: const addrmap_token *map DEVINFO_PTR_DEFAULT_MEMORY_MAP_0 = DEVINFO_PTR_DEFAULT_MEMORY_MAP + 0, DEVINFO_PTR_DEFAULT_MEMORY_MAP_1 = DEVINFO_PTR_DEFAULT_MEMORY_MAP + 1, DEVINFO_PTR_DEFAULT_MEMORY_MAP_2 = DEVINFO_PTR_DEFAULT_MEMORY_MAP + 2, DEVINFO_PTR_DEFAULT_MEMORY_MAP_3 = DEVINFO_PTR_DEFAULT_MEMORY_MAP + 3, DEVINFO_PTR_DEFAULT_MEMORY_MAP_LAST = DEVINFO_PTR_DEFAULT_MEMORY_MAP + ADDRESS_SPACES - 1, - DEVINFO_PTR_CLASS_SPECIFIC = 0x14000, /* R/W: device-specific values start here */ - DEVINFO_PTR_DEVICE_SPECIFIC = 0x18000, /* R/W: device-specific values start here */ + DEVINFO_PTR_CLASS_SPECIFIC = 0x14000, // R/W: device-specific values start here + DEVINFO_PTR_DEVICE_SPECIFIC = 0x18000, // R/W: device-specific values start here DEVINFO_PTR_LAST = 0x1ffff, - /* --- the following bits of info are returned as pointers to functions --- */ + // --- the following bits of info are returned as pointers to functions --- DEVINFO_FCT_FIRST = 0x20000, - DEVINFO_FCT_START = DEVINFO_FCT_FIRST, /* R/O: device_start_func */ - DEVINFO_FCT_STOP, /* R/O: device_stop_func */ - DEVINFO_FCT_RESET, /* R/O: device_reset_func */ - DEVINFO_FCT_EXECUTE, /* R/O: device_execute_func */ - DEVINFO_FCT_VALIDITY_CHECK, /* R/O: device_validity_check_func */ - DEVINFO_FCT_NVRAM, /* R/O: device_nvram_func */ - DEVINFO_FCT_CUSTOM_CONFIG, /* R/O: device_custom_config_func */ - DEVINFO_FCT_GET_RUNTIME_INFO, /* R/O: device_get_runtime_info_func */ - - DEVINFO_FCT_CLASS_SPECIFIC = 0x24000, /* R/W: device-specific values start here */ - DEVINFO_FCT_DEVICE_SPECIFIC = 0x28000, /* R/W: device-specific values start here */ + DEVINFO_FCT_START = DEVINFO_FCT_FIRST, // R/O: device_start_func + DEVINFO_FCT_STOP, // R/O: device_stop_func + DEVINFO_FCT_RESET, // R/O: device_reset_func + DEVINFO_FCT_EXECUTE, // R/O: device_execute_func + DEVINFO_FCT_VALIDITY_CHECK, // R/O: device_validity_check_func + DEVINFO_FCT_NVRAM, // R/O: device_nvram_func + DEVINFO_FCT_CUSTOM_CONFIG, // R/O: device_custom_config_func + DEVINFO_FCT_GET_RUNTIME_INFO, // R/O: device_get_runtime_info_func + + DEVINFO_FCT_CLASS_SPECIFIC = 0x24000, // R/W: device-specific values start here + DEVINFO_FCT_DEVICE_SPECIFIC = 0x28000, // R/W: device-specific values start here DEVINFO_FCT_LAST = 0x2ffff, - /* --- the following bits of info are returned as NULL-terminated strings --- */ + // --- the following bits of info are returned as NULL-terminated strings --- DEVINFO_STR_FIRST = 0x30000, - DEVINFO_STR_NAME = DEVINFO_STR_FIRST, /* R/O: name of the device */ - DEVINFO_STR_FAMILY, /* R/O: family of the device */ - DEVINFO_STR_VERSION, /* R/O: version of the device */ - DEVINFO_STR_SOURCE_FILE, /* R/O: file containing the device implementation */ - DEVINFO_STR_CREDITS, /* R/O: credits for the device implementation */ + DEVINFO_STR_NAME = DEVINFO_STR_FIRST, // R/O: name of the device + DEVINFO_STR_FAMILY, // R/O: family of the device + DEVINFO_STR_VERSION, // R/O: version of the device + DEVINFO_STR_SOURCE_FILE, // R/O: file containing the device implementation + DEVINFO_STR_CREDITS, // R/O: credits for the device implementation - DEVINFO_STR_CLASS_SPECIFIC = 0x34000, /* R/W: device-specific values start here */ - DEVINFO_STR_DEVICE_SPECIFIC = 0x38000, /* R/W: device-specific values start here */ + DEVINFO_STR_CLASS_SPECIFIC = 0x34000, // R/W: device-specific values start here + DEVINFO_STR_DEVICE_SPECIFIC = 0x38000, // R/W: device-specific values start here DEVINFO_STR_LAST = 0x3ffff }; @@ -180,25 +176,17 @@ enum #define DEVICE_NVRAM_CALL(name) DEVICE_NVRAM_NAME(name)(device, file, read_or_write) -/* device contract lists */ -#define DEVICE_CONTRACT_LIST_NAME(name) device_contract_list_##name - -#define DEVICE_CONTRACT_LIST_START(name) static const device_contract DEVICE_CONTRACT_LIST_NAME(name)[] = { -#define DEVICE_CONTRACT_ENTRY(type, var) { type, sizeof(var), &(var) }, -#define DEVICE_CONTRACT_LIST_END { NULL, 0, NULL } }; - - -/* macro for specifying a clock derived from an owning device */ +// macro for specifying a clock derived from an owning device #define DERIVED_CLOCK(num, den) (0xff000000 | ((num) << 12) | ((den) << 0)) -/* shorthand for accessing devices by machine/type/tag */ +// shorthand for accessing devices by machine/type/tag #define devtag_get_device(mach,tag) (mach)->device(tag) -#define devtag_reset(mach,tag) device_reset((mach)->device(tag)) +#define devtag_reset(mach,tag) (mach)->device(tag)->reset() -/* shorthand for getting standard data about devices */ +// shorthand for getting standard data about devices #define device_get_endianness(dev) (dev)->get_config_int(DEVINFO_INT_ENDIANNESS) #define device_get_databus_width(dev,space) (dev)->get_config_int(DEVINFO_INT_DATABUS_WIDTH + (space)) #define device_get_addrbus_width(dev,space) (dev)->get_config_int(DEVINFO_INT_ADDRBUS_WIDTH + (space)) @@ -215,22 +203,18 @@ enum TYPE DEFINITIONS ***************************************************************************/ -/* forward-declare these types */ +// forward-declare these types +class region_info; class device_config; class running_device; union deviceinfo; -/* a device contract */ -struct device_contract -{ - const char * name; /* name of this contract */ - UINT32 size; /* size of this contract in bytes */ - const void * contract; /* pointer to the contract struct itself */ -}; +// exception types +class device_missing_dependencies : public emu_exception { }; -/* device interface function types */ +// device interface function types typedef void (*device_get_config_func)(const device_config *device, UINT32 state, deviceinfo *info); typedef int (*device_validity_check_func)(const game_driver *driver, const device_config *device); typedef const machine_config_token *(*device_custom_config_func)(const device_config *device, UINT32 entrytype, const machine_config_token *tokens); @@ -243,11 +227,11 @@ typedef void (*device_nvram_func)(running_device *device, mame_file *file, int r typedef void (*device_get_runtime_info_func)(running_device *device, UINT32 state, deviceinfo *info); -/* a device_type is simply a pointer to its get_info function */ +// a device_type is simply a pointer to its get_info function typedef device_get_config_func device_type; -// template specializations +// tagged_device_list is a tagged_list with additional searching based on type or class template<class T> class tagged_device_list : public tagged_list<T> { typedef tagged_list<T> super; @@ -333,47 +317,59 @@ public: }; -// template specializations +// device_config_list manages a list of device_configs typedef tagged_device_list<device_config> device_config_list; + +// device_list manages a list of running_devices class device_list : public tagged_device_list<running_device> { + running_machine *machine; + + static void static_reset(running_machine *machine); + static void static_stop(running_machine *machine); + public: + device_list(); void import_config_list(const device_config_list &list, running_machine &machine); + + void start_all(); + void reset_all(); + void stop_all(); }; -/* the actual deviceinfo union */ + +// the actual deviceinfo union union deviceinfo { - INT64 i; /* generic integers */ - void * p; /* generic pointers */ - genf * f; /* generic function pointers */ - char * s; /* generic strings */ - - device_start_func start; /* DEVINFO_FCT_START */ - device_stop_func stop; /* DEVINFO_FCT_STOP */ - device_reset_func reset; /* DEVINFO_FCT_RESET */ - device_execute_func execute; /* DEVINFO_FCT_EXECUTE */ - device_validity_check_func validity_check; /* DEVINFO_FCT_VALIDITY_CHECK */ - device_custom_config_func custom_config; /* DEVINFO_FCT_CUSTOM_CONFIG */ - device_nvram_func nvram; /* DEVINFO_FCT_NVRAM */ - device_get_runtime_info_func get_runtime_info; /* DEVINFO_FCT_GET_RUNTIME_INFO */ - const rom_entry * romregion; /* DEVINFO_PTR_ROM_REGION */ - const machine_config_token *machine_config; /* DEVINFO_PTR_MACHINE_CONFIG */ - const device_contract * contract_list; /* DEVINFO_PTR_CONTRACT_LIST */ - const addrmap8_token * internal_map8; /* DEVINFO_PTR_INTERNAL_MEMORY_MAP */ - const addrmap16_token * internal_map16; /* DEVINFO_PTR_INTERNAL_MEMORY_MAP */ - const addrmap32_token * internal_map32; /* DEVINFO_PTR_INTERNAL_MEMORY_MAP */ - const addrmap64_token * internal_map64; /* DEVINFO_PTR_INTERNAL_MEMORY_MAP */ - const addrmap8_token * default_map8; /* DEVINFO_PTR_DEFAULT_MEMORY_MAP */ - const addrmap16_token * default_map16; /* DEVINFO_PTR_DEFAULT_MEMORY_MAP */ - const addrmap32_token * default_map32; /* DEVINFO_PTR_DEFAULT_MEMORY_MAP */ - const addrmap64_token * default_map64; /* DEVINFO_PTR_DEFAULT_MEMORY_MAP */ + INT64 i; // generic integers + void * p; // generic pointers + genf * f; // generic function pointers + char * s; // generic strings + + device_start_func start; // DEVINFO_FCT_START + device_stop_func stop; // DEVINFO_FCT_STOP + device_reset_func reset; // DEVINFO_FCT_RESET + device_execute_func execute; // DEVINFO_FCT_EXECUTE + device_validity_check_func validity_check; // DEVINFO_FCT_VALIDITY_CHECK + device_custom_config_func custom_config; // DEVINFO_FCT_CUSTOM_CONFIG + device_nvram_func nvram; // DEVINFO_FCT_NVRAM + device_get_runtime_info_func get_runtime_info; // DEVINFO_FCT_GET_RUNTIME_INFO + const rom_entry * romregion; // DEVINFO_PTR_ROM_REGION + const machine_config_token *machine_config; // DEVINFO_PTR_MACHINE_CONFIG + const addrmap8_token * internal_map8; // DEVINFO_PTR_INTERNAL_MEMORY_MAP + const addrmap16_token * internal_map16; // DEVINFO_PTR_INTERNAL_MEMORY_MAP + const addrmap32_token * internal_map32; // DEVINFO_PTR_INTERNAL_MEMORY_MAP + const addrmap64_token * internal_map64; // DEVINFO_PTR_INTERNAL_MEMORY_MAP + const addrmap8_token * default_map8; // DEVINFO_PTR_DEFAULT_MEMORY_MAP + const addrmap16_token * default_map16; // DEVINFO_PTR_DEFAULT_MEMORY_MAP + const addrmap32_token * default_map32; // DEVINFO_PTR_DEFAULT_MEMORY_MAP + const addrmap64_token * default_map64; // DEVINFO_PTR_DEFAULT_MEMORY_MAP }; -/* the configuration for a general device */ +// the configuration for a general device enum device_space { AS_PROGRAM = 0, @@ -381,8 +377,8 @@ enum device_space AS_IO = 2 }; -class region_info; +// device_config represents a device configuration that is attached to a machine_config class device_config { DISABLE_COPYING(device_config); @@ -411,23 +407,27 @@ public: genf *get_config_fct(UINT32 state) const; const char *get_config_string(UINT32 state) const; - /* device relationships */ - device_config * next; /* next device (of any type/class) */ - device_config * owner; /* device that owns us, or NULL if nobody */ + astring &subtag(astring &dest, const char *tag) const; + astring &siblingtag(astring &dest, const char *tag) const; + + // device relationships + device_config * next; // next device (of any type/class) + device_config * owner; // device that owns us, or NULL if nobody - /* device properties */ - astring tag; /* tag for this instance */ - device_type type; /* device type */ - device_class devclass; /* device class */ + // device properties + astring tag; // tag for this instance + device_type type; // device type + device_class devclass; // device class - /* device configuration */ - UINT32 clock; /* device clock */ - const addrmap_token * address_map[ADDRESS_SPACES]; /* address maps for each address space */ - const void * static_config; /* static device configuration */ - void * inline_config; /* inline device configuration */ + // device configuration + UINT32 clock; // device clock + const addrmap_token * address_map[ADDRESS_SPACES]; // address maps for each address space + const void * static_config; // static device configuration + void * inline_config; // inline device configuration }; +// running_device represents a device that is live and attached to a running_machine class running_device { DISABLE_COPYING(running_device); @@ -435,7 +435,7 @@ class running_device const device_config & _baseconfig; public: // private eventually - const address_space * addrspace[ADDRESS_SPACES]; /* auto-discovered address spaces */ + const address_space * addrspace[ADDRESS_SPACES]; // auto-discovered address spaces public: running_device(running_machine &machine, const device_config &config); @@ -446,6 +446,9 @@ public: inline const address_space *space(int index = 0) const; inline const address_space *space(device_space index) const; + astring &subtag(astring &dest, const char *tag) const { return _baseconfig.subtag(dest, tag); } + astring &siblingtag(astring &dest, const char *tag) const { return _baseconfig.siblingtag(dest, tag); } + const region_info *subregion(const char *tag) const; running_device *subdevice(const char *tag) const; @@ -462,6 +465,11 @@ public: for (cur = this->next; cur != NULL && cur->devclass != devclass; cur = cur->next) ; return cur; } + + void start(); + void reset(); + void stop(); + void set_clock(UINT32 clock); // get state from a device config INT64 get_config_int(UINT32 state) const { return _baseconfig.get_config_int(state); } @@ -475,68 +483,34 @@ public: void set_address_space(int spacenum, const address_space *space); - /* these fields are only valid once the device is attached to a machine */ - running_machine * machine; /* machine if device is live */ + // these fields are only valid once the device is attached to a machine + running_machine * machine; // machine if device is live - /* device relationships */ - running_device * next; /* next device (of any type/class) */ - running_device * owner; /* device that owns us, or NULL if nobody */ + // device relationships + running_device * next; // next device (of any type/class) + running_device * owner; // device that owns us, or NULL if nobody - /* device properties */ - astring tag; /* tag for this instance */ - device_type type; /* device type */ - device_class devclass; /* device class */ + // device properties + astring tag; // tag for this instance + device_type type; // device type + device_class devclass; // device class - /* device configuration */ - UINT32 clock; /* device clock */ + // device configuration + UINT32 clock; // device clock - /* these fields are only valid if the device is live */ - UINT8 started; /* TRUE if the start function has succeeded */ - void * token; /* token if device is live */ - UINT32 tokenbytes; /* size of the token data allocated */ - const region_info * region; /* our device-local region */ + // these fields are only valid if the device is live + bool started; // true if the start function has succeeded + void * token; // token if device is live + UINT32 tokenbytes; // size of the token data allocated + const region_info * region; // our device-local region - device_execute_func execute; /* quick pointer to execute callback */ + device_execute_func execute; // quick pointer to execute callback device_get_runtime_info_func get_runtime_info; }; /*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ - - -/* ----- device configuration ----- */ - -/* build a tag that combines the device's name and the given tag */ -astring &device_build_tag(astring &dest, const device_config *devconfig, const char *tag); - -/* build a tag with the same device prefix as the source tag*/ -astring &device_inherit_tag(astring &dest, const char *sourcetag, const char *tag); - -/* find a given contract on a device */ -const device_contract *device_get_contract(running_device *device, const char *name); - - - -/* ----- live device management ----- */ - -/* start the configured list of devices for a machine */ -void device_list_start(running_machine *machine); - -/* reset a device based on an allocated device_config */ -void device_reset(running_device *device); - -/* change the clock on a device */ -void device_set_clock(running_device *device, UINT32 clock); - -/* allow a device to ask for its initialization to be delayed */ -void device_delay_init(running_device *device); - - - -/*************************************************************************** INLINE FUNCTIONS ***************************************************************************/ diff --git a/src/emu/machine/6522via.c b/src/emu/machine/6522via.c index e11badef73a..891e2f6d305 100644 --- a/src/emu/machine/6522via.c +++ b/src/emu/machine/6522via.c @@ -262,7 +262,7 @@ static DEVICE_START( via6522 ) /* Default clock is from CPU1 */ if (device->clock == 0) - device_set_clock(device, device->machine->firstcpu->clock); + device->set_clock(device->machine->firstcpu->clock); /* save state register */ state_save_register_device_item(device, 0, v->in_a); diff --git a/src/emu/machine/6850acia.c b/src/emu/machine/6850acia.c index a75597e573c..8d737a0b66f 100644 --- a/src/emu/machine/6850acia.c +++ b/src/emu/machine/6850acia.c @@ -282,7 +282,7 @@ WRITE8_DEVICE_HANDLER( acia6850_ctrl_w ) if (divide == 3) { acia_p->reset = 1; - device_reset(device); + device->reset(); } else { diff --git a/src/emu/machine/idectrl.c b/src/emu/machine/idectrl.c index a40626316e6..b4a3a3582da 100644 --- a/src/emu/machine/idectrl.c +++ b/src/emu/machine/idectrl.c @@ -302,7 +302,7 @@ void ide_set_user_password(running_device *device, const UINT8 *password) static TIMER_CALLBACK( reset_callback ) { - device_reset((running_device *)ptr); + reinterpret_cast<running_device *>(ptr)->reset(); } diff --git a/src/emu/machine/ldcore.c b/src/emu/machine/ldcore.c index 5e7cc9f6e11..e50a1c31fe0 100644 --- a/src/emu/machine/ldcore.c +++ b/src/emu/machine/ldcore.c @@ -1485,10 +1485,7 @@ static DEVICE_START( laserdisc ) ld->screen = device->machine->device(config->screen); assert(ld->screen != NULL); if (!ld->screen->started) - { - device_delay_init(device); - return; - } + throw device_missing_dependencies(); /* save a copy of the device pointer */ ld->device = device; @@ -1614,7 +1611,7 @@ void laserdisc_set_type(running_device *device, int type) if (ld->core != NULL && ld->core->config.type != type) { ld->core->config.type = type; - device_reset(device); + device->reset(); } } diff --git a/src/emu/machine/smc91c9x.c b/src/emu/machine/smc91c9x.c index fb2f4326871..24b6b97bc96 100644 --- a/src/emu/machine/smc91c9x.c +++ b/src/emu/machine/smc91c9x.c @@ -425,7 +425,7 @@ WRITE16_DEVICE_HANDLER( smc91c9x_w ) case EREG_RCR: /* receive control register */ if (LOG_ETHERNET) { - if (data & 0x8000) device_reset(device); + if (data & 0x8000) device->reset(); if (data & 0x8000) logerror(" SOFT RST\n"); if (data & 0x4000) logerror(" FILT_CAR\n"); if (data & 0x0200) logerror(" STRIP CRC\n"); diff --git a/src/emu/mame.c b/src/emu/mame.c index 8b235704cf9..09b639898e6 100644 --- a/src/emu/mame.c +++ b/src/emu/mame.c @@ -1413,7 +1413,7 @@ static void init_machine(running_machine *machine) #endif /* MESS */ /* start up the devices */ - device_list_start(machine); + machine->devicelist.start_all(); /* call the game driver's init function */ /* this is where decryption is done and memory maps are altered */ diff --git a/src/emu/mconfig.c b/src/emu/mconfig.c index ed842db2eec..0de82ffb5f4 100644 --- a/src/emu/mconfig.c +++ b/src/emu/mconfig.c @@ -101,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 = device_build_tag(tempstring, owner, TOKEN_GET_STRING(tokens)); + tag = owner->subtag(tempstring, 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); - config->devicelist.remove(device_build_tag(tempstring, owner, tag)); + config->devicelist.remove(owner->subtag(tempstring, tag)); device = NULL; break; case MCONFIG_TOKEN_DEVICE_MODIFY: tag = TOKEN_GET_STRING(tokens); - device = config->devicelist.find(device_build_tag(tempstring, owner, tag)); + device = config->devicelist.find(owner->subtag(tempstring, tag)); if (device == NULL) fatalerror("Unable to find device: tag=%s\n", tempstring.cstr()); break; diff --git a/src/emu/memory.c b/src/emu/memory.c index f6221341374..fd695c5fbbd 100644 --- a/src/emu/memory.c +++ b/src/emu/memory.c @@ -398,7 +398,7 @@ static void memory_init_locate(running_machine *machine); static void memory_exit(running_machine *machine); /* address map helpers */ -static void map_detokenize(memory_private *memdata, address_map *map, const game_driver *driver, const char *devtag, const addrmap_token *tokens); +static void map_detokenize(memory_private *memdata, address_map *map, const game_driver *driver, const device_config *devconfig, const addrmap_token *tokens); /* memory mapping helpers */ static void space_map_range(address_space *space, read_or_write readorwrite, int handlerbits, int handlerunitmask, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, genf *handler, void *object, const char *handler_name); @@ -844,16 +844,16 @@ address_map *address_map_alloc(const device_config *devconfig, const game_driver /* append the internal device map (first so it takes priority) */ internal_map = (const addrmap_token *)devconfig->get_config_ptr(DEVINFO_PTR_INTERNAL_MEMORY_MAP + spacenum); if (internal_map != NULL) - map_detokenize((memory_private *)memdata, map, driver, devconfig->tag, internal_map); + map_detokenize((memory_private *)memdata, map, driver, devconfig, internal_map); /* construct the standard map */ if (devconfig->address_map[spacenum] != NULL) - map_detokenize((memory_private *)memdata, map, driver, devconfig->tag, devconfig->address_map[spacenum]); + map_detokenize((memory_private *)memdata, map, driver, devconfig, devconfig->address_map[spacenum]); /* append the default device map (last so it can be overridden) */ default_map = (const addrmap_token *)devconfig->get_config_ptr(DEVINFO_PTR_DEFAULT_MEMORY_MAP + spacenum); if (default_map != NULL) - map_detokenize((memory_private *)memdata, map, driver, devconfig->tag, default_map); + map_detokenize((memory_private *)memdata, map, driver, devconfig, default_map); return map; } @@ -2210,7 +2210,7 @@ static void memory_exit(running_machine *machine) fatalerror("%s: %s AM_RANGE(0x%x, 0x%x) setting %s already set!\n", driver->source_file, driver->name, entry->addrstart, entry->addrend, #field); \ } while (0) -static void map_detokenize(memory_private *memdata, address_map *map, const game_driver *driver, const char *devtag, const addrmap_token *tokens) +static void map_detokenize(memory_private *memdata, address_map *map, const game_driver *driver, const device_config *devconfig, const addrmap_token *tokens) { address_map_entry **firstentryptr; address_map_entry **entryptr; @@ -2252,7 +2252,7 @@ static void map_detokenize(memory_private *memdata, address_map *map, const game /* including */ case ADDRMAP_TOKEN_INCLUDE: - map_detokenize(memdata, map, driver, devtag, TOKEN_GET_PTR(tokens, tokenptr)); + map_detokenize(memdata, map, driver, devconfig, TOKEN_GET_PTR(tokens, tokenptr)); for (entryptr = &map->entrylist; *entryptr != NULL; entryptr = &(*entryptr)->next) ; entry = NULL; break; @@ -2307,7 +2307,7 @@ static void map_detokenize(memory_private *memdata, address_map *map, const game entry->read.name = TOKEN_GET_STRING(tokens); } if (entry->read.type == AMH_DEVICE_HANDLER || entry->read.type == AMH_PORT || entry->read.type == AMH_BANK) - entry->read.tag = device_inherit_tag(entry->read.derived_tag, devtag, TOKEN_GET_STRING(tokens)); + entry->read.tag = devconfig->siblingtag(entry->read.derived_tag, TOKEN_GET_STRING(tokens)); break; case ADDRMAP_TOKEN_WRITE: @@ -2321,7 +2321,7 @@ static void map_detokenize(memory_private *memdata, address_map *map, const game entry->write.name = TOKEN_GET_STRING(tokens); } if (entry->write.type == AMH_DEVICE_HANDLER || entry->write.type == AMH_PORT || entry->write.type == AMH_BANK) - entry->write.tag = device_inherit_tag(entry->write.derived_tag, devtag, TOKEN_GET_STRING(tokens)); + entry->write.tag = devconfig->siblingtag(entry->write.derived_tag, TOKEN_GET_STRING(tokens)); break; case ADDRMAP_TOKEN_READWRITE: @@ -2342,8 +2342,8 @@ static void map_detokenize(memory_private *memdata, address_map *map, const game if (entry->read.type == AMH_DEVICE_HANDLER || entry->read.type == AMH_PORT || entry->read.type == AMH_BANK) { const char *basetag = TOKEN_GET_STRING(tokens); - entry->read.tag = device_inherit_tag(entry->read.derived_tag, devtag, basetag); - entry->write.tag = device_inherit_tag(entry->write.derived_tag, devtag, basetag); + entry->read.tag = devconfig->siblingtag(entry->read.derived_tag, basetag); + entry->write.tag = devconfig->siblingtag(entry->write.derived_tag, basetag); } break; @@ -2351,7 +2351,7 @@ static void map_detokenize(memory_private *memdata, address_map *map, const game check_entry_field(region); TOKEN_UNGET_UINT32(tokens); TOKEN_GET_UINT64_UNPACK2(tokens, entrytype, 8, entry->rgnoffs, 32); - entry->region = device_inherit_tag(entry->region_string, devtag, TOKEN_GET_STRING(tokens)); + entry->region = devconfig->siblingtag(entry->region_string, TOKEN_GET_STRING(tokens)); break; case ADDRMAP_TOKEN_SHARE: diff --git a/src/emu/sound.c b/src/emu/sound.c index 9dbd97fd65b..38dec3829f4 100644 --- a/src/emu/sound.c +++ b/src/emu/sound.c @@ -533,7 +533,7 @@ static void sound_reset(running_machine *machine) /* reset all the sound chips */ for (sound = sound_first(machine); sound != NULL; sound = sound_next(sound)) - device_reset(sound); + sound->reset(); } diff --git a/src/emu/sound/tms5110.c b/src/emu/sound/tms5110.c index d64c0c43c78..2286ca993c4 100644 --- a/src/emu/sound/tms5110.c +++ b/src/emu/sound/tms5110.c @@ -722,7 +722,7 @@ void tms5110_PDC_set(tms5110_state *tms, int data) case TMS5110_CMD_RESET: perform_dummy_read(tms); - device_reset(tms->device); + tms->device->reset(); break; case TMS5110_CMD_READ_BIT: diff --git a/src/emu/sound/tms5220.c b/src/emu/sound/tms5220.c index f14459d111f..fb13dc212bc 100644 --- a/src/emu/sound/tms5220.c +++ b/src/emu/sound/tms5220.c @@ -937,7 +937,7 @@ static void process_command(tms5220_state *tms) if (tms->intf->read) (*tms->intf->read)(tms->device, 1); } - device_reset(tms->device); + tms->device->reset(); break; } } @@ -1349,7 +1349,7 @@ WRITE_LINE_DEVICE_HANDLER( tms5220_rsq_w ) if (new_val == 0) { if (tms->variant == variant_tms5220c) - device_reset(device); + device->reset(); else /* illegal */ LOG(("tms5220_rs_w: illegal\n")); @@ -1392,7 +1392,7 @@ WRITE_LINE_DEVICE_HANDLER( tms5220_wsq_w ) if (new_val == 0) { if (tms->variant == variant_tms5220c) - device_reset(device); + device->reset(); else /* illegal */ LOG(("tms5220_ws_w: illegal\n")); diff --git a/src/mame/audio/exidy.c b/src/mame/audio/exidy.c index 6e10674014a..c1d440ea0bd 100644 --- a/src/mame/audio/exidy.c +++ b/src/mame/audio/exidy.c @@ -781,7 +781,7 @@ static DEVICE_RESET( venture_sound ) devtag_reset(device->machine, "pia1"); /* 6532 */ - device_reset(riot); + riot->reset(); /* 8253 */ memset(sh8253_timer, 0, sizeof(sh8253_timer)); @@ -999,8 +999,8 @@ static DEVICE_RESET( victory_sound ) running_device *pia1 = devtag_get_device(device->machine, "pia1"); DEVICE_RESET_CALL(common_sh_reset); - device_reset(pia1); - device_reset(riot); + pia1->reset(); + riot->reset(); memset(sh8253_timer, 0, sizeof(sh8253_timer)); /* the flip-flop @ F4 is reset */ diff --git a/src/mame/audio/gottlieb.c b/src/mame/audio/gottlieb.c index 1f5df525e96..0b860c75b05 100644 --- a/src/mame/audio/gottlieb.c +++ b/src/mame/audio/gottlieb.c @@ -512,10 +512,7 @@ static WRITE8_HANDLER( speech_control_w ) /* bit 7 goes to the speech chip RESET pin */ if ((previous ^ data) & 0x80) - { - running_device *sp = devtag_get_device(space->machine, "spsnd"); - device_reset(sp); - } + space->machine->device("spsnd")->reset(); } diff --git a/src/mame/audio/taito_en.c b/src/mame/audio/taito_en.c index eb371ab852b..0f4694ba749 100644 --- a/src/mame/audio/taito_en.c +++ b/src/mame/audio/taito_en.c @@ -257,7 +257,7 @@ static SOUND_RESET( taito_f3_soundsystem_reset ) sound_ram[3]=ROM[0x80003]; /* reset CPU to catch any banking of startup vectors */ - device_reset(devtag_get_device(machine, "audiocpu")); + machine->device("audiocpu")->reset(); //cputag_set_input_line(machine, "audiocpu", INPUT_LINE_RESET, ASSERT_LINE); } diff --git a/src/mame/drivers/crystal.c b/src/mame/drivers/crystal.c index 1a69ef4d18a..00c8c1f0006 100644 --- a/src/mame/drivers/crystal.c +++ b/src/mame/drivers/crystal.c @@ -343,7 +343,7 @@ static WRITE32_HANDLER(PIO_w) UINT32 DAT = data & 0x10000000; if (!RST) - device_reset(ds1302); + ds1302->reset(); ds1302_dat_w(ds1302, 0, DAT ? 1 : 0); ds1302_clk_w(ds1302, 0, CLK ? 1 : 0); diff --git a/src/mame/drivers/cubeqst.c b/src/mame/drivers/cubeqst.c index 9c007ae7641..c9a6a1b02b8 100644 --- a/src/mame/drivers/cubeqst.c +++ b/src/mame/drivers/cubeqst.c @@ -273,7 +273,7 @@ static WRITE16_HANDLER( reset_w ) swap_linecpu_banks(space->machine); if (!BIT(data, 2)) - device_reset(laserdisc); + laserdisc->reset(); reset_latch = data & 0xff; } diff --git a/src/mame/drivers/dcheese.c b/src/mame/drivers/dcheese.c index a61c6f898cd..676ded1eb88 100644 --- a/src/mame/drivers/dcheese.c +++ b/src/mame/drivers/dcheese.c @@ -184,7 +184,7 @@ static WRITE8_HANDLER( sound_control_w ) /* bit 0x20 = LED */ /* bit 0x40 = BSMT2000 reset */ if ((diff & 0x40) && (data & 0x40)) - device_reset(state->bsmt); + state->bsmt->reset(); if (data != 0x40 && data != 0x60) logerror("%04X:sound_control_w = %02X\n", cpu_get_pc(space->cpu), data); } diff --git a/src/mame/drivers/flyball.c b/src/mame/drivers/flyball.c index 0178c722c9b..8a5e87daa18 100644 --- a/src/mame/drivers/flyball.c +++ b/src/mame/drivers/flyball.c @@ -382,7 +382,7 @@ static MACHINE_RESET( flyball ) for (i = 0; i < 0x1000; i++) state->rombase[i] = ROM[i ^ 0x1ff]; - device_reset(devtag_get_device(machine, "maincpu")); + machine->device("maincpu")->reset(); timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), NULL, 0, flyball_quarter_callback); diff --git a/src/mame/drivers/galivan.c b/src/mame/drivers/galivan.c index 3b6cc1f2b76..9926c4a6e3e 100644 --- a/src/mame/drivers/galivan.c +++ b/src/mame/drivers/galivan.c @@ -445,7 +445,7 @@ static MACHINE_RESET( galivan ) { galivan_state *state = (galivan_state *)machine->driver_data; - device_reset(devtag_get_device(machine, "maincpu")); + machine->device("maincpu")->reset(); // state->layers = 0x60; state->layers = 0; @@ -459,7 +459,7 @@ static MACHINE_RESET( ninjemak ) { galivan_state *state = (galivan_state *)machine->driver_data; - device_reset(devtag_get_device(machine, "maincpu")); + machine->device("maincpu")->reset(); state->scrollx[0] = state->scrollx[1] = 0; state->scrolly[0] = state->scrolly[1] = 0; diff --git a/src/mame/drivers/gameplan.c b/src/mame/drivers/gameplan.c index 115c2de1f09..b37ad1cd4f1 100644 --- a/src/mame/drivers/gameplan.c +++ b/src/mame/drivers/gameplan.c @@ -145,7 +145,7 @@ static WRITE8_DEVICE_HANDLER( audio_reset_w ) if (data == 0) { - device_reset(state->riot); + state->riot->reset(); cpuexec_boost_interleave(device->machine, attotime_zero, ATTOTIME_IN_USEC(10)); } } diff --git a/src/mame/drivers/gladiatr.c b/src/mame/drivers/gladiatr.c index ce302b39992..0a321035373 100644 --- a/src/mame/drivers/gladiatr.c +++ b/src/mame/drivers/gladiatr.c @@ -272,7 +272,7 @@ static MACHINE_RESET( gladiator ) { UINT8 *rom = memory_region(machine, "audiocpu") + 0x10000; memory_set_bankptr(machine, "bank2",rom); - device_reset(devtag_get_device(machine, "audiocpu")); + machine->device("audiocpu")->reset(); } } diff --git a/src/mame/drivers/itech8.c b/src/mame/drivers/itech8.c index 64aeac15611..7c8cdef7d8c 100644 --- a/src/mame/drivers/itech8.c +++ b/src/mame/drivers/itech8.c @@ -677,7 +677,7 @@ static MACHINE_RESET( itech8 ) if (main_cpu_type == CPU_M6809 || main_cpu_type == CPU_HD6309) { memory_set_bankptr(machine, "bank1", &memory_region(machine, "maincpu")[0x4000]); - device_reset(devtag_get_device(machine, "maincpu")); + machine->device("maincpu")->reset(); } /* reset the palette chip */ diff --git a/src/mame/drivers/lethal.c b/src/mame/drivers/lethal.c index 206e44a37c3..2461e259897 100644 --- a/src/mame/drivers/lethal.c +++ b/src/mame/drivers/lethal.c @@ -609,7 +609,7 @@ static MACHINE_RESET( lethalen ) memory_set_bankptr(machine, "bank2", &prgrom[0x48000]); /* force reset again to read proper reset vector */ - device_reset(devtag_get_device(machine, "maincpu")); + machine->device("maincpu")->reset(); for (i = 0; i < 4; i++) state->layer_colorbase[i] = 0; diff --git a/src/mame/drivers/magicard.c b/src/mame/drivers/magicard.c index 67c88cefad8..2f6fcdddf4d 100644 --- a/src/mame/drivers/magicard.c +++ b/src/mame/drivers/magicard.c @@ -606,7 +606,7 @@ static MACHINE_RESET( magicard ) UINT16 *src = (UINT16*)memory_region( machine, "maincpu" ); UINT16 *dst = magicram; memcpy (dst, src, 0x80000); - device_reset(devtag_get_device(machine, "maincpu")); + machine->device("maincpu")->reset(); } diff --git a/src/mame/drivers/mediagx.c b/src/mame/drivers/mediagx.c index 80b37659071..0fe2b0e8c8b 100644 --- a/src/mame/drivers/mediagx.c +++ b/src/mame/drivers/mediagx.c @@ -976,7 +976,7 @@ static MACHINE_RESET(mediagx) cpu_set_irq_callback(devtag_get_device(machine, "maincpu"), irq_callback); memcpy(bios_ram, rom, 0x40000); - device_reset(devtag_get_device(machine, "maincpu")); + machine->device("maincpu")->reset(); timer_device_adjust_oneshot(devtag_get_device(machine, "sound_timer"), ATTOTIME_IN_MSEC(10), 0); diff --git a/src/mame/drivers/midvunit.c b/src/mame/drivers/midvunit.c index bfa346eda17..16f5c2caa3c 100644 --- a/src/mame/drivers/midvunit.c +++ b/src/mame/drivers/midvunit.c @@ -74,7 +74,7 @@ static MACHINE_RESET( midvunit ) dcs_reset_w(0); memcpy(ram_base, memory_region(machine, "user1"), 0x20000*4); - device_reset(devtag_get_device(machine, "maincpu")); + machine->device("maincpu")->reset(); timer[0] = devtag_get_device(machine, "timer0"); timer[1] = devtag_get_device(machine, "timer1"); @@ -87,7 +87,7 @@ static MACHINE_RESET( midvplus ) dcs_reset_w(0); memcpy(ram_base, memory_region(machine, "user1"), 0x20000*4); - device_reset(devtag_get_device(machine, "maincpu")); + machine->device("maincpu")->reset(); timer[0] = devtag_get_device(machine, "timer0"); timer[1] = devtag_get_device(machine, "timer1"); diff --git a/src/mame/drivers/midzeus.c b/src/mame/drivers/midzeus.c index c83b3cdf1a5..06c9c8aaf3b 100644 --- a/src/mame/drivers/midzeus.c +++ b/src/mame/drivers/midzeus.c @@ -94,7 +94,7 @@ static MACHINE_RESET( midzeus ) { memcpy(ram_base, memory_region(machine, "user1"), 0x40000*4); *ram_base <<= 1; - device_reset(devtag_get_device(machine, "maincpu")); + machine->device("maincpu")->reset(); cmos_protected = TRUE; } diff --git a/src/mame/drivers/model2.c b/src/mame/drivers/model2.c index 4a5612c6571..c46f8cd51f5 100644 --- a/src/mame/drivers/model2.c +++ b/src/mame/drivers/model2.c @@ -353,7 +353,7 @@ static MACHINE_RESET(model2_scsp) // copy the 68k vector table into RAM memcpy(model2_soundram, memory_region(machine, "audiocpu") + 0x80000, 16); - device_reset(devtag_get_device(machine, "audiocpu")); + machine->device("audiocpu")->reset(); } static MACHINE_RESET(model2) diff --git a/src/mame/drivers/model3.c b/src/mame/drivers/model3.c index 76891ef16ab..d38c59e1348 100644 --- a/src/mame/drivers/model3.c +++ b/src/mame/drivers/model3.c @@ -1240,7 +1240,7 @@ static void model3_init(running_machine *machine, int step) // copy the 68k vector table into RAM memcpy(model3_soundram, memory_region(machine, "audiocpu")+0x80000, 16); - device_reset(devtag_get_device(machine, "audiocpu")); + machine->device("audiocpu")->reset(); model3_machine_init(step); // step 1.5 model3_tap_reset(); diff --git a/src/mame/drivers/mpu4.c b/src/mame/drivers/mpu4.c index 9154c0eef41..1162e56947c 100644 --- a/src/mame/drivers/mpu4.c +++ b/src/mame/drivers/mpu4.c @@ -445,7 +445,7 @@ static MACHINE_RESET( mpu4 ) memory_configure_bank(machine, "bank1", 0, 8, &rom[0x01000], 0x10000); memory_set_bank(machine, "bank1",0); - device_reset(devtag_get_device(machine, "maincpu")); + machine->device("maincpu")->reset(); } } diff --git a/src/mame/drivers/neogeo.c b/src/mame/drivers/neogeo.c index 1ddcd27d5ce..306c860be63 100644 --- a/src/mame/drivers/neogeo.c +++ b/src/mame/drivers/neogeo.c @@ -1123,7 +1123,7 @@ static MACHINE_RESET( neogeo ) for (offs = 0; offs < 8; offs++) system_control_w(space, offs, 0, 0x00ff); - device_reset(devtag_get_device(machine, "maincpu")); + machine->device("maincpu")->reset(); neogeo_reset_rng(machine); diff --git a/src/mame/drivers/pgm.c b/src/mame/drivers/pgm.c index 163bd4808c8..b92eb987f85 100644 --- a/src/mame/drivers/pgm.c +++ b/src/mame/drivers/pgm.c @@ -414,7 +414,7 @@ static WRITE16_HANDLER ( z80_reset_w ) if (data == 0x5050) { - device_reset(state->ics); + state->ics->reset(); cpu_set_input_line(state->soundcpu, INPUT_LINE_HALT, CLEAR_LINE); cpu_set_input_line(state->soundcpu, INPUT_LINE_RESET, PULSE_LINE); if(0) diff --git a/src/mame/drivers/policetr.c b/src/mame/drivers/policetr.c index e2148491114..a363bdd09b9 100644 --- a/src/mame/drivers/policetr.c +++ b/src/mame/drivers/policetr.c @@ -166,7 +166,7 @@ static WRITE32_HANDLER( control_w ) { running_device *device = devtag_get_device(space->machine, "bsmt"); bsmt2000_data_w(device, bsmt_data_bank, 0, 0xffff); - device_reset(device); + device->reset(); } /* log any unknown bits */ diff --git a/src/mame/drivers/tmaster.c b/src/mame/drivers/tmaster.c index e7e0adc152e..7482184d354 100644 --- a/src/mame/drivers/tmaster.c +++ b/src/mame/drivers/tmaster.c @@ -936,7 +936,7 @@ static MACHINE_RESET( galgames ) galgames_update_rombank(machine, 0); - device_reset(devtag_get_device(machine, "maincpu")); + machine->device("maincpu")->reset(); } static MACHINE_DRIVER_START( galgames ) diff --git a/src/mame/drivers/videopkr.c b/src/mame/drivers/videopkr.c index 93aba2bcc12..16bc42fc66b 100644 --- a/src/mame/drivers/videopkr.c +++ b/src/mame/drivers/videopkr.c @@ -891,7 +891,7 @@ static WRITE8_DEVICE_HANDLER(baby_sound_p3_w) if (!(sbp3 & 0x10)) { - device_reset(device); + device->reset(); logerror("AY3-8910: Reset\n"); } diff --git a/src/mame/drivers/vmetal.c b/src/mame/drivers/vmetal.c index 4aa0f8521e5..329de39bf7a 100644 --- a/src/mame/drivers/vmetal.c +++ b/src/mame/drivers/vmetal.c @@ -163,7 +163,7 @@ static WRITE8_DEVICE_HANDLER( vmetal_control_w ) coin_lockout_w(device->machine, 1,data & 0x02); /* never activated in game mode?? */ if ((data & 0x40) == 0) - device_reset(device); + device->reset(); else es8712_play(device); diff --git a/src/mame/machine/balsente.c b/src/mame/machine/balsente.c index 472ced8bc21..3ca3c653c36 100644 --- a/src/mame/machine/balsente.c +++ b/src/mame/machine/balsente.c @@ -181,7 +181,7 @@ MACHINE_RESET( balsente ) memory_configure_bank(machine, "bank2", 0, numbanks, &memory_region(machine, "maincpu")[0x12000], 0x6000); memory_set_bank(space->machine, "bank1", 0); memory_set_bank(space->machine, "bank2", 0); - device_reset(devtag_get_device(machine, "maincpu")); + machine->device("maincpu")->reset(); /* start a timer to generate interrupts */ state->scanline_timer = devtag_get_device(machine, "scan_timer"); diff --git a/src/mame/machine/namcos1.c b/src/mame/machine/namcos1.c index 846adaee72b..ae7e1b1768f 100644 --- a/src/mame/machine/namcos1.c +++ b/src/mame/machine/namcos1.c @@ -864,7 +864,7 @@ MACHINE_RESET( namcos1 ) namcos1_bankswitch(machine, 1, 0x0e01, 0xff); /* reset Cpu 0 and stop all other CPUs */ - device_reset(devtag_get_device(machine, "maincpu")); + machine->device("maincpu")->reset(); cputag_set_input_line(machine, "sub", INPUT_LINE_RESET, ASSERT_LINE); cputag_set_input_line(machine, "audiocpu", INPUT_LINE_RESET, ASSERT_LINE); cputag_set_input_line(machine, "mcu", INPUT_LINE_RESET, ASSERT_LINE); diff --git a/src/mame/machine/s16fd.c b/src/mame/machine/s16fd.c index 0acc86ad9a8..2fe98a4716c 100644 --- a/src/mame/machine/s16fd.c +++ b/src/mame/machine/s16fd.c @@ -156,7 +156,7 @@ void fd1094_machine_init(running_device *device) m68k_set_rte_callback(device, fd1094_rte_callback); cpu_set_irq_callback(device, fd1094_int_callback); - device_reset(device); + device->reset(); } static STATE_POSTLOAD( fd1094_postload ) diff --git a/src/mame/machine/s24fd.c b/src/mame/machine/s24fd.c index f5a6e0691b0..c689bda8869 100644 --- a/src/mame/machine/s24fd.c +++ b/src/mame/machine/s24fd.c @@ -134,7 +134,7 @@ void s24_fd1094_machine_init(running_machine *machine) m68k_set_rte_callback(devtag_get_device(machine, "sub"), s24_fd1094_rte_callback); cpu_set_irq_callback(devtag_get_device(machine, "sub"), s24_fd1094_int_callback); - device_reset(devtag_get_device(machine, "sub")); + machine->device("sub")->reset(); } static STATE_POSTLOAD( s24_fd1094_postload ) diff --git a/src/mame/video/dday.c b/src/mame/video/dday.c index 9cae80e4385..322005ac20a 100644 --- a/src/mame/video/dday.c +++ b/src/mame/video/dday.c @@ -299,7 +299,7 @@ WRITE8_HANDLER( dday_control_w ) /* bit 4 is sound enable */ if (!(data & 0x10) && (state->control & 0x10)) - device_reset(state->ay1); + state->ay1->reset(); sound_global_enable(space->machine, data & 0x10); |
