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/machine/6840ptm.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/machine/6840ptm.c')
-rw-r--r-- | src/emu/machine/6840ptm.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/src/emu/machine/6840ptm.c b/src/emu/machine/6840ptm.c index 55d05b3611a..65889db8c1f 100644 --- a/src/emu/machine/6840ptm.c +++ b/src/emu/machine/6840ptm.c @@ -69,7 +69,7 @@ static const char *const opmode[] = "111 pulse width comparison mode" }; -static void ptm6840_timeout(const device_config *device, int idx); +static void ptm6840_timeout(running_device *device, int idx); /*************************************************************************** TYPE DEFINITIONS @@ -110,7 +110,7 @@ struct _ptm6840_state INLINE FUNCTIONS ***************************************************************************/ -INLINE ptm6840_state *get_safe_token(const device_config *device) +INLINE ptm6840_state *get_safe_token(running_device *device) { assert(device != NULL); assert(device->token != NULL); @@ -118,11 +118,11 @@ INLINE ptm6840_state *get_safe_token(const device_config *device) return (ptm6840_state *)device->token; } -INLINE const ptm6840_interface *get_interface(const device_config *device) +INLINE const ptm6840_interface *get_interface(running_device *device) { assert(device != NULL); assert((device->type == PTM6840)); - return (const ptm6840_interface *) device->static_config; + return (const ptm6840_interface *) device->baseconfig().static_config; } @@ -134,7 +134,7 @@ INLINE const ptm6840_interface *get_interface(const device_config *device) ptm6840_get_status - Get enabled status -------------------------------------------------*/ -int ptm6840_get_status( const device_config *device, int clock ) +int ptm6840_get_status( running_device *device, int clock ) { ptm6840_state *ptm6840 = get_safe_token(device); return ptm6840->enabled[clock - 1]; @@ -144,7 +144,7 @@ int ptm6840_get_status( const device_config *device, int clock ) ptm6840_get_irq - Get IRQ state -------------------------------------------------*/ -int ptm6840_get_irq( const device_config *device ) +int ptm6840_get_irq( running_device *device ) { ptm6840_state *ptm6840 = get_safe_token(device); return ptm6840->IRQ; @@ -154,7 +154,7 @@ int ptm6840_get_irq( const device_config *device ) subtract_from_counter - Subtract from Counter -------------------------------------------------*/ -static void subtract_from_counter( const device_config *device, int counter, int count ) +static void subtract_from_counter( running_device *device, int counter, int count ) { ptm6840_state *ptm6840 = get_safe_token(device); int clock; @@ -231,7 +231,7 @@ static void subtract_from_counter( const device_config *device, int counter, int ptm_tick -------------------------------------------------*/ -static void ptm_tick( const device_config *device, int counter, int count ) +static void ptm_tick( running_device *device, int counter, int count ) { ptm6840_state *ptm6840 = get_safe_token(device); @@ -255,7 +255,7 @@ static void ptm_tick( const device_config *device, int counter, int count ) update_interrupts - Update Internal Interrupts -------------------------------------------------*/ -INLINE void update_interrupts( const device_config *device ) +INLINE void update_interrupts( running_device *device ) { ptm6840_state *ptm6840 = get_safe_token(device); int new_state; @@ -281,7 +281,7 @@ INLINE void update_interrupts( const device_config *device ) compute_counter - Compute Counter -------------------------------------------------*/ -static UINT16 compute_counter( const device_config *device, int counter ) +static UINT16 compute_counter( running_device *device, int counter ) { ptm6840_state *ptm6840 = get_safe_token(device); int clock; @@ -324,7 +324,7 @@ static UINT16 compute_counter( const device_config *device, int counter ) reload_count - Reload Counter -------------------------------------------------*/ -static void reload_count( const device_config *device, int idx ) +static void reload_count( running_device *device, int idx ) { ptm6840_state *ptm6840 = get_safe_token(device); int clock; @@ -549,7 +549,7 @@ WRITE8_DEVICE_HANDLER( ptm6840_write ) ptm6840_timeout - Called if timer is mature -------------------------------------------------*/ -static void ptm6840_timeout( const device_config *device, int idx ) +static void ptm6840_timeout( running_device *device, int idx ) { ptm6840_state *ptm6840 = get_safe_token(device); @@ -598,19 +598,19 @@ static void ptm6840_timeout( const device_config *device, int idx ) static TIMER_CALLBACK( ptm6840_timer1_cb ) { - const device_config *device = (const device_config *)ptr; + running_device *device = (running_device *)ptr; ptm6840_timeout(device, 0); } static TIMER_CALLBACK( ptm6840_timer2_cb ) { - const device_config *device = (const device_config *)ptr; + running_device *device = (running_device *)ptr; ptm6840_timeout(device, 1); } static TIMER_CALLBACK( ptm6840_timer3_cb ) { - const device_config *device = (const device_config *)ptr; + running_device *device = (running_device *)ptr; ptm6840_timeout(device, 2); } @@ -619,7 +619,7 @@ static TIMER_CALLBACK( ptm6840_timer3_cb ) ptm6840_set_gate - set gate status (0 or 1) -------------------------------------------------*/ -INLINE void ptm6840_set_gate( const device_config *device, int state, int idx ) +INLINE void ptm6840_set_gate( running_device *device, int state, int idx ) { ptm6840_state *ptm6840 = get_safe_token(device); @@ -654,7 +654,7 @@ WRITE8_DEVICE_HANDLER( ptm6840_set_g3 ) ptm6840_set_clock - set clock status (0 or 1) -------------------------------------------------*/ -INLINE void ptm6840_set_clock( const device_config *device, int state, int idx ) +INLINE void ptm6840_set_clock( running_device *device, int state, int idx ) { ptm6840_state *ptm6840 = get_safe_token(device); @@ -691,7 +691,7 @@ WRITE8_DEVICE_HANDLER( ptm6840_set_c3 ) ptm6840_get_count - get count value -------------------------------------------------*/ -UINT16 ptm6840_get_count( const device_config *device, int counter ) +UINT16 ptm6840_get_count( running_device *device, int counter ) { return compute_counter(device, counter); } @@ -700,7 +700,7 @@ UINT16 ptm6840_get_count( const device_config *device, int counter ) ptm6840_set_ext_clock - set external clock frequency ------------------------------------------------------------*/ -void ptm6840_set_ext_clock( const device_config *device, int counter, int clock ) +void ptm6840_set_ext_clock( running_device *device, int counter, int clock ) { ptm6840_state *ptm6840 = get_safe_token(device); @@ -742,7 +742,7 @@ void ptm6840_set_ext_clock( const device_config *device, int counter, int clock ptm6840_get_ext_clock - get external clock frequency ------------------------------------------------------------*/ -int ptm6840_get_ext_clock( const device_config *device, int counter ) +int ptm6840_get_ext_clock( running_device *device, int counter ) { ptm6840_state *ptm6840 = get_safe_token(device); return ptm6840->external_clock[counter]; |