Previous 15994 Revisions Next

r5731 Monday 14th September, 2009 at 12:34:16 UTC by Curt Coder
Added device_find_child_by_tag function.
[src/emu]devintrf.c devintrf.h
[src/mess/audio]vp550.c
[src/mess/machine]conkort.c

src/emu/devintrf.c
r5730r5731
361361
362362
363363/*-------------------------------------------------
364    device_find_child_by_tag - retrieve a child
365   device configuration based on a tag
366-------------------------------------------------*/
367
368const device_config *device_find_child_by_tag(const device_config *owner, const char *tag)
369{
370   astring *tempstring;
371   const device_config *child;
372   
373   assert(owner != NULL);
374   assert(tag != NULL);
375
376   tempstring = astring_alloc();
377   child = device_list_find_by_tag(owner->machine->config->devicelist, device_build_tag(tempstring, owner, tag));
378   astring_free(tempstring);
379
380   return child;
381}
382
383
384/*-------------------------------------------------
364385    device_list_index - return the index of a
365386    device based on its type and tag;
366387    DEVICE_TYPE_WILDCARD is allowed
src/emu/devintrf.h
r5730r5731
367367/* retrieve a device configuration based on a tag */
368368const device_config *device_list_find_by_tag(const device_config *listhead, const char *tag);
369369
370/* retrieve a child device configuration based on a tag */
371const device_config *device_find_child_by_tag(const device_config *owner, const char *tag);
372
370373/* return the index of a device based on its type and tag; DEVICE_TYPE_WILDCARD is allowed */
371374int device_list_index(const device_config *listhead, device_type type, const char *tag);
372375
src/mess/audio/vp550.c
r5730r5731
136136
137137static WRITE8_DEVICE_HANDLER( vp550_vlmn_w )
138138{
139   float gain = 0.625f * (data & 0x0f);
139   //float gain = 0.625f * (data & 0x0f);
140140
141   sound_set_output_gain(device, 0, gain);
141//   sound_set_output_gain(device, 0, gain);
142142
143143   if (LOG) logerror("VP550 '%s' Volume: %u\n", device->tag, data & 0x0f);
144144}
r5730r5731
257257   vp550_t *vp550 = get_safe_token(device);
258258
259259   /* look up devices */
260   vp550->cdp1863[CHANNEL_A] = devtag_get_device(device->machine, "vp551:u1");
261   vp550->cdp1863[CHANNEL_B] = devtag_get_device(device->machine, "vp551:u2");
262   vp550->cdp1863[CHANNEL_C] = devtag_get_device(device->machine, "vp551:cdp1863c");
263   vp550->cdp1863[CHANNEL_D] = devtag_get_device(device->machine, "vp551:cdp1863d");
264   vp550->sync_timer = devtag_get_device(device->machine, "vp551:sync");
260   vp550->cdp1863[CHANNEL_A] = device_find_child_by_tag(device, CDP1863_A_TAG);
261   vp550->cdp1863[CHANNEL_B] = device_find_child_by_tag(device, CDP1863_B_TAG);
262   vp550->cdp1863[CHANNEL_C] = device_find_child_by_tag(device, CDP1863_C_TAG);
263   vp550->cdp1863[CHANNEL_D] = device_find_child_by_tag(device, CDP1863_D_TAG);
264   vp550->sync_timer = device_find_child_by_tag(device, "sync");
265265
266266   /* set initial values */
267267   vp550->channels = 4;
src/mess/machine/conkort.c
r5730r5731
822822static DEVICE_START( luxor_55_10828 )
823823{
824824   slow_t *conkort = device->token;
825   astring *tempstring = astring_alloc();
826825
827   /* validate arguments */
828   assert(device->tag != NULL);
829
830826   /* find our CPU */
831   astring_printf(tempstring, "%s:%s", device->tag, Z80_TAG);
832   conkort->cpu = cputag_get_cpu(device->machine, astring_c(tempstring));
827   conkort->cpu = device_find_child_by_tag(device, Z80_TAG);
833828
834829   /* find devices */
835   astring_printf(tempstring, "%s:%s", device->tag, Z80PIO_TAG);
836   conkort->z80pio = devtag_get_device(device->machine, astring_c(tempstring));
837   astring_printf(tempstring, "%s:%s", device->tag, WD1791_TAG);
838   conkort->wd1791 = devtag_get_device(device->machine, astring_c(tempstring));
830   conkort->z80pio = device_find_child_by_tag(device, Z80PIO_TAG);
831   conkort->wd1791 = device_find_child_by_tag(device, WD1791_TAG);
839832
840833   /* register for state saving */
841834   state_save_register_device_item(device, 0, conkort->status);
842835   state_save_register_device_item(device, 0, conkort->data);
843836   state_save_register_device_item(device, 0, conkort->pio_ardy);
844837   state_save_register_device_item(device, 0, conkort->fdc_irq);
845
846   astring_free(tempstring);
847838}
848839
849840/*-------------------------------------------------
r5730r5731
894885static DEVICE_START( luxor_55_21046 )
895886{
896887   fast_t *conkort = device->token;
897   astring *tempstring = astring_alloc();
898888
899   /* validate arguments */
900   assert(device->tag != NULL);
901
902889   /* find our CPU */
903   astring_printf(tempstring, "%s:%s", device->tag, Z80_TAG);
904   conkort->cpu = cputag_get_cpu(device->machine, astring_c(tempstring));
890   conkort->cpu = device_find_child_by_tag(device, Z80_TAG);
905891
906892   /* find devices */
907   astring_printf(tempstring, "%s:%s", device->tag, Z80DMA_TAG);
908   conkort->z80dma = devtag_get_device(device->machine, astring_c(tempstring));
909   astring_printf(tempstring, "%s:%s", device->tag, SAB1793_TAG);
910   conkort->wd1793 = devtag_get_device(device->machine, astring_c(tempstring));
893   conkort->z80dma = device_find_child_by_tag(device, Z80DMA_TAG);
894   conkort->wd1793 = device_find_child_by_tag(device, SAB1793_TAG);
911895
912896   /* register for state saving */
913897   state_save_register_device_item(device, 0, conkort->status);
914898   state_save_register_device_item(device, 0, conkort->data);
915899   state_save_register_device_item(device, 0, conkort->fdc_irq);
916
917   astring_free(tempstring);
918900}
919901
920902/*-------------------------------------------------

Previous 15994 Revisions Next


© 1998-2018 The MESS Team