summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/sound/pokey.c
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2010-01-18 09:34:43 +0000
committer Aaron Giles <aaron@aarongiles.com>2010-01-18 09:34:43 +0000
commite738b79785852050ce8b83e369a7fc4dd46a071b (patch)
tree1ac39e9f40790b375c57fea4e5d56ca8d132babc /src/emu/sound/pokey.c
parent3f87f47a2ecdccb9d9627d0d52b76f262becb949 (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/sound/pokey.c')
-rw-r--r--src/emu/sound/pokey.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/emu/sound/pokey.c b/src/emu/sound/pokey.c
index 2e1dd6fdacd..0ee9555956a 100644
--- a/src/emu/sound/pokey.c
+++ b/src/emu/sound/pokey.c
@@ -174,7 +174,7 @@ struct _pokey_state
UINT32 r9; /* rand9 index */
UINT32 r17; /* rand17 index */
UINT32 clockmult; /* clock multiplier */
- const device_config *device;
+ running_device *device;
sound_stream * channel; /* streams channel */
emu_timer *timer[3]; /* timers for channel 1,2 and 4 events */
attotime timer_period[3]; /* computed periods for these timers */
@@ -185,7 +185,7 @@ struct _pokey_state
devcb_resolved_read8 allpot_r;
devcb_resolved_read8 serin_r;
devcb_resolved_write8 serout_w;
- void (*interrupt_cb)(const device_config *device, int mask);
+ void (*interrupt_cb)(running_device *device, int mask);
UINT8 AUDF[4]; /* AUDFx (D200, D202, D204, D206) */
UINT8 AUDC[4]; /* AUDCx (D201, D203, D205, D207) */
UINT8 POTx[8]; /* POTx (R/D200-D207) */
@@ -522,7 +522,7 @@ static TIMER_CALLBACK( pokey_pot_trigger );
#endif
-INLINE pokey_state *get_safe_token(const device_config *device)
+INLINE pokey_state *get_safe_token(running_device *device)
{
assert(device != NULL);
assert(device->token != NULL);
@@ -575,7 +575,7 @@ static void rand_init(UINT8 *rng, int size, int left, int right, int add)
}
-static void register_for_save(pokey_state *chip, const device_config *device)
+static void register_for_save(pokey_state *chip, running_device *device)
{
state_save_register_device_item_array(device, 0, chip->counter);
state_save_register_device_item_array(device, 0, chip->divisor);
@@ -621,8 +621,8 @@ static DEVICE_START( pokey )
int sample_rate = device->clock;
int i;
- if (device->static_config)
- memcpy(&chip->intf, device->static_config, sizeof(pokey_interface));
+ if (device->baseconfig().static_config)
+ memcpy(&chip->intf, device->baseconfig().static_config, sizeof(pokey_interface));
chip->device = device;
chip->clock_period = ATTOTIME_IN_HZ(device->clock);
@@ -1338,13 +1338,13 @@ WRITE8_HANDLER( quad_pokey_w )
pokey_w(space->machine->device(devname[pokey_num]), pokey_reg, data);
}
-void pokey_serin_ready(const device_config *device, int after)
+void pokey_serin_ready(running_device *device, int after)
{
pokey_state *p = get_safe_token(device);
timer_set(device->machine, attotime_mul(p->clock_period, after), p, 0, pokey_serin_ready_cb);
}
-void pokey_break_w(const device_config *device, int shift)
+void pokey_break_w(running_device *device, int shift)
{
pokey_state *p = get_safe_token(device);
if( shift ) /* shift code ? */
@@ -1361,7 +1361,7 @@ void pokey_break_w(const device_config *device, int shift)
}
}
-void pokey_kbcode_w(const device_config *device, int kbcode, int make)
+void pokey_kbcode_w(running_device *device, int kbcode, int make)
{
pokey_state *p = get_safe_token(device);
/* make code ? */