Previous 15994 Revisions Next

r8334 Sunday 27th June, 2010 at 19:33:11 UTC by Miodrag Milanović
Made dynamic add of device trough cartslot possible again.
Fixes coco and ti99 regression.
[src/emu]devlegcy.h image.c mconfig.c mconfig.h
[src/mess/devices]aescart.c cartslot.c coco_fdc.c cococart.c ti99cart.c

src/emu/devlegcy.h
r8333r8334
467467public:
468468   // access to legacy token
469469   void *token() const { return m_token; }
470
470   
471   INT64 get_config_int(UINT32 state) const { return m_config.get_legacy_config_int(state); }
472   genf *get_config_fct(UINT32 state) const { return m_config.get_legacy_config_fct(state); }
473   void *get_config_ptr(UINT32 state) const { return m_config.get_legacy_config_ptr(state); }
471474protected:
472475   // device-level overrides
473476   virtual void device_start();
src/emu/image.c
r8333r8334
245245            fatalerror_exitcode(machine, MAMERR_DEVICE, "Driver requires that device \"%s\" must have an image to load", image->image_config().instance_name());
246246         }
247247      }
248     
249      image->call_get_devices();
248250   }
249251}
250252
src/emu/mconfig.c
r8333r8334
2626***************************************************************************/
2727
2828/*-------------------------------------------------
29    machine_config_alloc - allocate a new
29    machine_config_alloc_owner - allocate a new
3030    machine configuration and populate it using
31    the supplied constructor
31    the supplied constructor, and assign owner
3232-------------------------------------------------*/
3333
34machine_config *machine_config_alloc(const machine_config_token *tokens)
34machine_config *machine_config_alloc_owner(const machine_config_token *tokens, const device_config *owner)
3535{
3636   machine_config *config;
3737
r8333r8334
3939   config = global_alloc_clear(machine_config);
4040
4141   /* parse tokens into the config */
42   machine_config_detokenize(config, tokens, NULL);
42   machine_config_detokenize(config, tokens, owner);
4343
4444   /* process any device-specific machine configurations */
4545   for (const device_config *device = config->devicelist.first(); device != NULL; device = device->next())
r8333r8334
5656   return config;
5757}
5858
59/*-------------------------------------------------
60    machine_config_alloc - allocate a new
61    machine configuration and populate it using
62    the supplied constructor
63-------------------------------------------------*/
64machine_config *machine_config_alloc(const machine_config_token *tokens)
65{
66   return machine_config_alloc_owner(tokens,NULL);
67}
5968
6069/*-------------------------------------------------
6170    machine_config_free - release memory allocated
src/emu/mconfig.h
r8333r8334
423423/* allocate a new machine configuration and populate it using the supplied constructor */
424424machine_config *machine_config_alloc(const machine_config_token *tokens);
425425
426machine_config *machine_config_alloc_owner(const machine_config_token *tokens, const device_config *owner);
427
426428/* release memory allocated for a machine configuration */
427429void machine_config_free(machine_config *config);
428430
src/mess/devices/ti99cart.c
r8333r8334
578578   ti99_multicart_state *cartslots = (ti99_multicart_state *)downcast<legacy_device_base *>(cartsys)->token();
579579   ti99_pcb_t *pcb_def = (ti99_pcb_t *)downcast<legacy_device_base *>(pcb)->token();
580580
581//  pcb_def->read = (read16_device_func) pcb->get_config_fct(TI99CARTINFO_FCT_6000_R);
582//  pcb_def->write = (write16_device_func) pcb->get_config_fct(TI99CARTINFO_FCT_6000_W);
583//  pcb_def->read8 = (read8_device_func) pcb->get_config_fct(TI99CARTINFO_FCT_6000_R8);
584//  pcb_def->write8 = (write8_device_func) pcb->get_config_fct(TI99CARTINFO_FCT_6000_W8);
585//  pcb_def->cruread = (read8_device_func) pcb->get_config_fct(TI99CARTINFO_FCT_CRU_R);
586//  pcb_def->cruwrite = (write8_device_func) pcb->get_config_fct(TI99CARTINFO_FCT_CRU_W);
581   pcb_def->read = (read16_device_func) downcast<legacy_device_base *>(pcb)->get_config_fct(TI99CARTINFO_FCT_6000_R);
582   pcb_def->write = (write16_device_func) downcast<legacy_device_base *>(pcb)->get_config_fct(TI99CARTINFO_FCT_6000_W);
583   pcb_def->read8 = (read8_device_func) downcast<legacy_device_base *>(pcb)->get_config_fct(TI99CARTINFO_FCT_6000_R8);
584   pcb_def->write8 = (write8_device_func) downcast<legacy_device_base *>(pcb)->get_config_fct(TI99CARTINFO_FCT_6000_W8);
585   pcb_def->cruread = (read8_device_func) downcast<legacy_device_base *>(pcb)->get_config_fct(TI99CARTINFO_FCT_CRU_R);
586   pcb_def->cruwrite = (write8_device_func) downcast<legacy_device_base *>(pcb)->get_config_fct(TI99CARTINFO_FCT_CRU_W);
587587
588//  pcb_def->assemble = (assmfct *)pcb->get_config_fct(TI99CART_FCT_ASSM);
589//  pcb_def->disassemble = (assmfct *)pcb->get_config_fct(TI99CART_FCT_DISASSM);
588    pcb_def->assemble = (assmfct *)downcast<legacy_device_base *>(pcb)->get_config_fct(TI99CART_FCT_ASSM);
589    pcb_def->disassemble = (assmfct *)downcast<legacy_device_base *>(pcb)->get_config_fct(TI99CART_FCT_DISASSM);
590590
591591   pcb_def->cartridge = &cartslots->cartridge[index];
592592   pcb_def->cartridge->pcb = pcb;
src/mess/devices/cartslot.c
r8333r8334
383383   return pcb_type;
384384}
385385
386static machine_config *device_cfg = NULL;
386387
388static void memory_exit(running_machine *machine)
389{
390   machine_config_free(device_cfg);
391}
392
387393/*-------------------------------------------------
388394    DEVICE_IMAGE_GET_DEVICES(cartslot)
389395-------------------------------------------------*/
390static void add_device_with_subdevices(const running_device *_owner, device_type _type, const char *_tag, UINT32 _clock)
396static void add_device_with_subdevices(device_t *_owner, device_type _type, const char *_tag, UINT32 _clock)
391397{
392/*  astring tempstring;
393    device_list *devlist = &_owner->machine->devicelist;
394    const device_config *cfg = new device_config(&_owner->baseconfig(), _type, _tag, _clock);
395    running_device *dev = devlist->append(_owner->subtag(tempstring,_tag), new running_device(*_owner->machine, *cfg));
396
397    const machine_config_token *tokens = (const machine_config_token *)dev->get_config_ptr(DEVINFO_PTR_MACHINE_CONFIG);
398    machine_config *config;
399    const device_config *config_dev;
400    running_device *new_dev = NULL;
401    if (tokens != NULL)
402    {
403        config = machine_config_alloc(tokens);
404        for (config_dev = config->devicelist.first(); config_dev != NULL; config_dev = config_dev->next)
398   astring tempstring;
399   device_list *devlist = &_owner->machine->devicelist;   
400   const machine_config *config = _owner->machine->config;
401   
402   device_config *devconfig = _type(*config, _owner->subtag(tempstring,_tag), &_owner->baseconfig(), _clock);
403   
404   running_device *dev = devlist->append(_owner->subtag(tempstring,_tag), devconfig->alloc_device(*_owner->machine));
405   const machine_config_token *tokens = dev->machine_config_tokens();
406   if (tokens != NULL)
407    {     
408        device_cfg = machine_config_alloc_owner(tokens,&dev->baseconfig());
409        for (const device_config *config_dev = device_cfg->devicelist.first(); config_dev != NULL; config_dev = config_dev->next())
405410        {
406            device_config *new_cfg = new device_config(cfg, config_dev->type, config_dev->tag(), config_dev->clock);
407            new_cfg->static_config = config_dev->static_config;
408            memcpy(
409                new_cfg->inline_config,
410                config_dev->inline_config,
411                new_cfg->get_config_int(DEVINFO_INT_INLINE_CONFIG_BYTES));
412            new_dev = devlist->append(dev->subtag(tempstring,config_dev->tag()), new running_device(*_owner->machine, *new_cfg));
413            new_dev->owner = dev;
411         devlist->append(config_dev->tag(), config_dev->alloc_device(*_owner->machine));
414412        }
415        machine_config_free(config);
416    }*/
413      add_exit_callback(_owner->machine, memory_exit);       
414    }
417415}
418416
419417static DEVICE_IMAGE_GET_DEVICES(cartslot)
src/mess/devices/coco_fdc.c
r8333r8334
228228static DEVICE_START(fdc)
229229{
230230   fdc_t *fdc = get_token(device);
231//  const fdc_hardware_type *hwtype = (const fdc_hardware_type *)device->get_config_ptr(FDCINFO_PTR_HWTYPE);
231    const fdc_hardware_type *hwtype = (const fdc_hardware_type *)downcast<legacy_device_base *>(device)->get_config_ptr(FDCINFO_PTR_HWTYPE);   
232232
233233   /* initialize variables */
234234   memset(fdc, 0, sizeof(*fdc));
235//  fdc->hwtype         = hwtype;
236//  fdc->drq            = hwtype->initial_drq;
235   fdc->hwtype         = hwtype;
236   fdc->drq            = hwtype->initial_drq;
237237   fdc->cococart      = device->owner()->owner();
238238   fdc->disto_msm6242   = device->subdevice(DISTO_TAG);
239239   fdc->ds1315         = device->subdevice(CLOUD9_TAG);
src/mess/devices/aescart.c
r8333r8334
221221   aes_multicart_t *cartslots = (aes_multicart_t *)downcast<legacy_device_base *>(cartsys)->token();
222222   aes_pcb_t *pcb_def = (aes_pcb_t *)downcast<legacy_device_base *>(pcb)->token();
223223
224   //pcb_def->assemble = (assmfct *)pcb->get_config_fct(AESCART_FCT_ASSM);
225   //pcb_def->disassemble = (assmfct *)pcb->get_config_fct(AESCART_FCT_DISASSM);
224   pcb_def->assemble = (assmfct *)downcast<legacy_device_base *>(pcb)->get_config_fct(AESCART_FCT_ASSM);
225   pcb_def->disassemble = (assmfct *)downcast<legacy_device_base *>(pcb)->get_config_fct(AESCART_FCT_DISASSM);
226226
227227   pcb_def->cartridge = &cartslots->cartridge[index];
228228   pcb_def->cartridge->pcb = pcb;
src/mess/devices/cococart.c
r8333r8334
9898         throw device_missing_dependencies();
9999      }
100100
101//      cococart->pcb_r = (read8_device_func) cococart->pcb->get_config_fct(COCOCARTINFO_FCT_FF40_R);
102//      cococart->pcb_w = (write8_device_func) cococart->pcb->get_config_fct(COCOCARTINFO_FCT_FF40_W);
101      cococart->pcb_r = (read8_device_func) downcast<legacy_device_base *>(cococart->pcb)->get_config_fct(COCOCARTINFO_FCT_FF40_R);
102      cococart->pcb_w = (write8_device_func) downcast<legacy_device_base *>(cococart->pcb)->get_config_fct(COCOCARTINFO_FCT_FF40_W);
103103   }
104104
105105   /* finish setup */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team