diff options
author | 2010-01-18 09:34:43 +0000 | |
---|---|---|
committer | 2010-01-18 09:34:43 +0000 | |
commit | e738b79785852050ce8b83e369a7fc4dd46a071b (patch) | |
tree | 1ac39e9f40790b375c57fea4e5d56ca8d132babc /src/emu/devcb.c | |
parent | 3f87f47a2ecdccb9d9627d0d52b76f262becb949 (diff) |
Correct a long-standing design flaw: device configuration state
is now separate from runtime device state. I have larger plans
for devices, so there is some temporary scaffolding to hold
everything together, but this first step does separate things
out.
There is a new class 'running_device' which represents the
state of a live device. A list of these running_devices sits
in machine->devicelist and is created when a running_machine
is instantiated.
To access the configuration state, use device->baseconfig()
which returns a reference to the configuration.
The list of running_devices in machine->devicelist has a 1:1
correspondance with the list of device configurations in
machine->config->devicelist, and most navigation options work
equally on either (scanning by class, type, etc.)
For the most part, drivers will now deal with running_device
objects instead of const device_config objects. In fact, in
order to do this patch, I did the following global search &
replace:
const device_config -> running_device
device->static_config -> device->baseconfig().static_config
device->inline_config -> device->baseconfig().inline_config
and then fixed up the compiler errors that fell out.
Some specifics:
Removed device_get_info_* functions and replaced them with
methods called get_config_*.
Added methods for get_runtime_* to access runtime state from
the running_device.
DEVICE_GET_INFO callbacks are only passed a device_config *.
This means they have no access to the token or runtime state
at all. For most cases this is fine.
Added new DEVICE_GET_RUNTIME_INFO callback that is passed
the running_device for accessing data that is live at runtime.
In the future this will go away to make room for a cleaner
mechanism.
Cleaned up the handoff of memory regions from the memory
subsystem to the devices.
Diffstat (limited to 'src/emu/devcb.c')
-rw-r--r-- | src/emu/devcb.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/emu/devcb.c b/src/emu/devcb.c index ac80e63cf36..81f0275fe42 100644 --- a/src/emu/devcb.c +++ b/src/emu/devcb.c @@ -30,10 +30,10 @@ static READ_LINE_DEVICE_HANDLER( trampoline_read_port_to_read_line ) static READ_LINE_DEVICE_HANDLER( trampoline_read8_to_read_line ) { const devcb_resolved_read_line *resolved = (const devcb_resolved_read_line *)device; - return ((*resolved->real.readdevice)((const device_config *)resolved->realtarget, 0) & 1) ? ASSERT_LINE : CLEAR_LINE; + return ((*resolved->real.readdevice)((running_device *)resolved->realtarget, 0) & 1) ? ASSERT_LINE : CLEAR_LINE; } -void devcb_resolve_read_line(devcb_resolved_read_line *resolved, const devcb_read_line *config, const device_config *device) +void devcb_resolve_read_line(devcb_resolved_read_line *resolved, const devcb_read_line *config, running_device *device) { /* reset the resolved structure */ memset(resolved, 0, sizeof(*resolved)); @@ -51,7 +51,7 @@ void devcb_resolve_read_line(devcb_resolved_read_line *resolved, const devcb_rea else if (config->type >= DEVCB_TYPE_MEMORY(ADDRESS_SPACE_PROGRAM) && config->type < DEVCB_TYPE_MEMORY(ADDRESS_SPACES) && config->readspace != NULL) { FPTR spacenum = (FPTR)config->type - (FPTR)DEVCB_TYPE_MEMORY(ADDRESS_SPACE_PROGRAM); - const device_config *cpu; + running_device *cpu; if (device->owner != NULL) cpu = device->owner->subdevice(config->tag); @@ -111,17 +111,17 @@ static WRITE_LINE_DEVICE_HANDLER( trampoline_write_port_to_write_line ) static WRITE_LINE_DEVICE_HANDLER( trampoline_write8_to_write_line ) { const devcb_resolved_write_line *resolved = (const devcb_resolved_write_line *)device; - (*resolved->real.writedevice)((const device_config *)resolved->realtarget, 0, state); + (*resolved->real.writedevice)((running_device *)resolved->realtarget, 0, state); } static WRITE_LINE_DEVICE_HANDLER( trampoline_writecpu_to_write_line ) { const devcb_resolved_write_line *resolved = (const devcb_resolved_write_line *)device; - const device_config *cpu = (const device_config *)resolved->realtarget; + running_device *cpu = (running_device *)resolved->realtarget; cpu_set_input_line(cpu, resolved->real.writeline, state ? ASSERT_LINE : CLEAR_LINE); } -void devcb_resolve_write_line(devcb_resolved_write_line *resolved, const devcb_write_line *config, const device_config *device) +void devcb_resolve_write_line(devcb_resolved_write_line *resolved, const devcb_write_line *config, running_device *device) { /* reset the resolved structure */ memset(resolved, 0, sizeof(*resolved)); @@ -138,7 +138,7 @@ void devcb_resolve_write_line(devcb_resolved_write_line *resolved, const devcb_w else if (config->type >= DEVCB_TYPE_MEMORY(ADDRESS_SPACE_PROGRAM) && config->type < DEVCB_TYPE_MEMORY(ADDRESS_SPACES) && config->writespace != NULL) { FPTR spacenum = (FPTR)config->type - (FPTR)DEVCB_TYPE_MEMORY(ADDRESS_SPACE_PROGRAM); - const device_config *cpu; + running_device *cpu; if (device->owner != NULL) cpu = device->owner->subdevice(config->tag); @@ -159,7 +159,7 @@ void devcb_resolve_write_line(devcb_resolved_write_line *resolved, const devcb_w else if (config->type >= DEVCB_TYPE_CPU_LINE(0) && config->type < DEVCB_TYPE_CPU_LINE(MAX_INPUT_LINES)) { FPTR line = (FPTR)config->type - (FPTR)DEVCB_TYPE_CPU_LINE(0); - const device_config *cpu; + running_device *cpu; if (device->owner != NULL) cpu = device->owner->subdevice(config->tag); @@ -217,10 +217,10 @@ static READ8_DEVICE_HANDLER( trampoline_read_port_to_read8 ) static READ8_DEVICE_HANDLER( trampoline_read_line_to_read8 ) { const devcb_resolved_read8 *resolved = (const devcb_resolved_read8 *)device; - return (*resolved->real.readline)((const device_config *)resolved->realtarget); + return (*resolved->real.readline)((running_device *)resolved->realtarget); } -void devcb_resolve_read8(devcb_resolved_read8 *resolved, const devcb_read8 *config, const device_config *device) +void devcb_resolve_read8(devcb_resolved_read8 *resolved, const devcb_read8 *config, running_device *device) { /* reset the resolved structure */ memset(resolved, 0, sizeof(*resolved)); @@ -238,7 +238,7 @@ void devcb_resolve_read8(devcb_resolved_read8 *resolved, const devcb_read8 *conf else if (config->type >= DEVCB_TYPE_MEMORY(ADDRESS_SPACE_PROGRAM) && config->type < DEVCB_TYPE_MEMORY(ADDRESS_SPACES) && config->readspace != NULL) { FPTR spacenum = (FPTR)config->type - (FPTR)DEVCB_TYPE_MEMORY(ADDRESS_SPACE_PROGRAM); - const device_config *cpu; + running_device *cpu; if (device->owner != NULL) cpu = device->owner->subdevice(config->tag); @@ -289,10 +289,10 @@ static WRITE8_DEVICE_HANDLER( trampoline_write_port_to_write8 ) static WRITE8_DEVICE_HANDLER( trampoline_write_line_to_write8 ) { const devcb_resolved_write8 *resolved = (const devcb_resolved_write8 *)device; - (*resolved->real.writeline)((const device_config *)resolved->realtarget, (data & 1) ? ASSERT_LINE : CLEAR_LINE); + (*resolved->real.writeline)((running_device *)resolved->realtarget, (data & 1) ? ASSERT_LINE : CLEAR_LINE); } -void devcb_resolve_write8(devcb_resolved_write8 *resolved, const devcb_write8 *config, const device_config *device) +void devcb_resolve_write8(devcb_resolved_write8 *resolved, const devcb_write8 *config, running_device *device) { /* reset the resolved structure */ memset(resolved, 0, sizeof(*resolved)); @@ -309,7 +309,7 @@ void devcb_resolve_write8(devcb_resolved_write8 *resolved, const devcb_write8 *c else if (config->type >= DEVCB_TYPE_MEMORY(ADDRESS_SPACE_PROGRAM) && config->type < DEVCB_TYPE_MEMORY(ADDRESS_SPACES) && config->writespace != NULL) { FPTR spacenum = (FPTR)config->type - (FPTR)DEVCB_TYPE_MEMORY(ADDRESS_SPACE_PROGRAM); - const device_config *cpu; + running_device *cpu; if (device->owner != NULL) cpu = device->owner->subdevice(config->tag); |