Previous 15994 Revisions Next

r8323 Sunday 27th June, 2010 at 07:48:21 UTC by Miodrag Milanović
Changed cast to dynamic_cast fixes issue with Apple2GS and many more.
[src/mess/devices]appldriv.c cartslot.c coco_pak.c coco_vhd.c flopdrv.c printer.c sonydriv.c thomflop.c
[src/mess/drivers]adam.c apexc.c fm7.c gba.c jaguar.c tm990189.c vtech1.c x68k.c
[src/mess/machine]990_dk.c 990_hd.c 990_tap.c 994x_ser.c adam.c corvushd.c gb.c genesis.c hp48.c nes.c pc_hdc.c sms.c snescart.c svi318.c thomson.c tx0.c upd765.c vtech2.c wswan.c x68k_hdc.c

src/mess/devices/flopdrv.c
r8322r8323
118118/***************************************************************************
119119    IMPLEMENTATION
120120***************************************************************************/
121extern DEVICE_GET_INFO(apple525);
122extern DEVICE_GET_INFO(sonydriv);
121DECLARE_LEGACY_IMAGE_DEVICE(FLOPPY_APPLE, apple525);
122DECLARE_LEGACY_IMAGE_DEVICE(FLOPPY_SONY, sonydriv);
123123
124124INLINE floppy_drive *get_safe_token(running_device *device)
125125{
126126   assert( device != NULL );
127//   assert( device->type() == FLOPPY || device->type() == FLOPPY_APPLE || device->type() == FLOPPY_SONY);
127   assert( device->type() == FLOPPY || device->type() == FLOPPY_APPLE || device->type() == FLOPPY_SONY);
128128   return (floppy_drive *) downcast<legacy_device_base *>(device)->token();
129129}
130130
r8322r8323
346346void floppy_drive_set_ready_state(running_device *img, int state, int flag)
347347{
348348   floppy_drive *drive = get_safe_token(img);
349   device_image_interface *image = (device_image_interface *) img;
349   device_image_interface *image = dynamic_cast<device_image_interface *>(img);
350350   if (flag)
351351   {
352352      /* set ready only if drive is present, disk is in the drive,
r8322r8323
394394
395395void floppy_drive_seek(running_device *img, signed int signed_tracks)
396396{
397   device_image_interface *image = (device_image_interface *) img;
397   device_image_interface *image = dynamic_cast<device_image_interface *>(img);
398398   floppy_drive *pDrive;
399399
400400   pDrive = get_safe_token( img );
r8322r8323
469469void floppy_drive_read_track_data_info_buffer(running_device *img, int side, void *ptr, int *length )
470470{
471471   floppy_drive *flopimg;
472   device_image_interface *image = (device_image_interface *) img;
472   device_image_interface *image = dynamic_cast<device_image_interface *>(img);
473473
474474   if (image->exists())
475475   {
r8322r8323
484484void floppy_drive_write_track_data_info_buffer(running_device *img, int side, const void *ptr, int *length )
485485{
486486   floppy_drive *flopimg;
487   device_image_interface *image = (device_image_interface *) img;
487   device_image_interface *image = dynamic_cast<device_image_interface *>(img);
488488
489489   if (image->exists())
490490   {
r8322r8323
498498
499499void floppy_drive_format_sector(running_device *img, int side, int sector_index,int c,int h, int r, int n, int filler)
500500{
501   device_image_interface *image = (device_image_interface *) img;
501   device_image_interface *image = dynamic_cast<device_image_interface *>(img);
502502
503503   if (image->exists())
504504   {
r8322r8323
510510void floppy_drive_read_sector_data(running_device *img, int side, int index1, void *ptr, int length)
511511{
512512   floppy_drive *flopimg;
513   device_image_interface *image = (device_image_interface *) img;
513   device_image_interface *image = dynamic_cast<device_image_interface *>(img);
514514   
515515   if (image->exists())
516516   {
r8322r8323
529529void floppy_drive_write_sector_data(running_device *img, int side, int index1, const void *ptr,int length, int ddam)
530530{
531531   floppy_drive *flopimg;
532   device_image_interface *image = (device_image_interface *) img;
532   device_image_interface *image = dynamic_cast<device_image_interface *>(img);
533533
534534   if (image->exists())
535535   {
r8322r8323
586586{
587587   floppy_drive *drv = get_safe_token( img );
588588   int size = 0;
589   device_image_interface *image = (device_image_interface*)img;
589   device_image_interface *image = dynamic_cast<device_image_interface *>(img);
590590
591591   if (image->exists())
592592   {
r8322r8323
887887WRITE_LINE_DEVICE_HANDLER( floppy_mon_w )
888888{
889889   floppy_drive *drive = get_safe_token(device);
890   device_image_interface *image = (device_image_interface *) device;
890   device_image_interface *image = dynamic_cast<device_image_interface *>(device);
891891   /* force off if there is no attached image */
892892   if (!image->exists())
893893      state = ASSERT_LINE;
src/mess/devices/sonydriv.c
r8322r8323
111111   floppy *f;
112112
113113   f = &sony_floppy[floppy_select];
114   cur_image = (device_image_interface *)floppy_get_device_by_type(device->machine, FLOPPY_TYPE_SONY, floppy_select);
114   cur_image = dynamic_cast<device_image_interface *>(floppy_get_device_by_type(device->machine, FLOPPY_TYPE_SONY, floppy_select));
115115
116116   track_size = floppy_get_track_size(flopimg_get_image(&cur_image->device()), f->head, floppy_drive_get_current_track(&cur_image->device()));
117117   new_data = (UINT8*)cur_image->image_realloc(f->loadedtrack_data, track_size);
r8322r8323
130130
131131static void save_track_data(running_device *device, int floppy_select)
132132{
133   running_device *cur_image;
133   device_image_interface *cur_image;
134134   floppy *f;
135135   int len;
136136
137137   f = &sony_floppy[floppy_select];
138   cur_image = floppy_get_device_by_type(device->machine, FLOPPY_TYPE_SONY, floppy_select);
138   cur_image = dynamic_cast<device_image_interface *>(floppy_get_device_by_type(device->machine, FLOPPY_TYPE_SONY, floppy_select));
139139
140140   if (f->loadedtrack_dirty)
141141   {
142142      len = f->loadedtrack_size;
143      floppy_drive_write_track_data_info_buffer(cur_image, f->head, f->loadedtrack_data, &len);
143      floppy_drive_write_track_data_info_buffer(&cur_image->device(), f->head, f->loadedtrack_data, &len);
144144      f->loadedtrack_dirty = 0;
145145   }
146146}
r8322r8323
157157      return 0xFF;         /* right ??? */
158158
159159   f = &sony_floppy[sony_floppy_select];
160   cur_image = (device_image_interface*)floppy_get_device_by_type(device->machine, FLOPPY_TYPE_SONY, sony_floppy_select);
160   cur_image = dynamic_cast<device_image_interface *>(floppy_get_device_by_type(device->machine, FLOPPY_TYPE_SONY, sony_floppy_select));
161161   if (!cur_image->exists())
162162      return 0xFF;
163163
r8322r8323
176176   floppy *f;
177177
178178   f = &sony_floppy[sony_floppy_select];
179   cur_image = (device_image_interface*)floppy_get_device_by_type(device->machine, FLOPPY_TYPE_SONY, sony_floppy_select);
179   cur_image = dynamic_cast<device_image_interface *>(floppy_get_device_by_type(device->machine, FLOPPY_TYPE_SONY, sony_floppy_select));
180180   if (!cur_image->exists())
181181      return;
182182
r8322r8323
191191static int sony_rpm(floppy *f, running_device *cur_image)
192192{
193193   int result = 0;
194   device_image_interface *image =(device_image_interface*)cur_image;
194   device_image_interface *image =dynamic_cast<device_image_interface *>(cur_image);
195195   /*
196196     * The Mac floppy controller was interesting in that its speed was adjusted
197197     * while the thing was running.  On the tracks closer to the rim, it was
r8322r8323
259259   if ((! sony_enable2()) && sony_floppy_enable)
260260   {
261261      f = &sony_floppy[sony_floppy_select];
262      cur_image = (device_image_interface*)floppy_get_device_by_type(device->machine, FLOPPY_TYPE_SONY, sony_floppy_select);
262      cur_image = dynamic_cast<device_image_interface *>(floppy_get_device_by_type(device->machine, FLOPPY_TYPE_SONY, sony_floppy_select));
263263      if (!cur_image->exists())
264264         cur_image = NULL;
265265
r8322r8323
365365   if (sony_floppy_enable)
366366   {
367367      f = &sony_floppy[sony_floppy_select];
368      cur_image = (device_image_interface*)floppy_get_device_by_type(device->machine, FLOPPY_TYPE_SONY, sony_floppy_select);
368      cur_image = dynamic_cast<device_image_interface *>(floppy_get_device_by_type(device->machine, FLOPPY_TYPE_SONY, sony_floppy_select));
369369      if (!cur_image->exists())
370370         cur_image = NULL;
371371
r8322r8323
471471   DEVICE_START_CALL(floppy);
472472   floppy_set_type(device,FLOPPY_TYPE_SONY);
473473}
474//
475//static DEVICE_IMAGE_UNLOAD( sonydriv_floppy )
476//{
477//   int id;
478//   running_device *fdc;
479//
480//   /* locate the FDC */
481//   fdc = devtag_get_device(image->machine, "fdc");
482//
483//   id = floppy_get_drive_by_type(image,FLOPPY_TYPE_SONY);
484//   save_track_data(fdc, id);
485//   memset(&sony_floppy[id], 0, sizeof(sony_floppy[id]));
486//
487//   DEVICE_IMAGE_UNLOAD_NAME(floppy)(image);
488//}
489//
474
475static DEVICE_IMAGE_UNLOAD( sonydriv_floppy )
476{
477   int id;
478   running_device *fdc;
479
480   /* locate the FDC */
481   fdc = devtag_get_device(image.device().machine, "fdc");
482
483   id = floppy_get_drive_by_type(&image.device(),FLOPPY_TYPE_SONY);
484   save_track_data(fdc, id);
485   memset(&sony_floppy[id], 0, sizeof(sony_floppy[id]));
486
487   DEVICE_IMAGE_UNLOAD_NAME(floppy)(image);
488}
489
490490DEVICE_GET_INFO( sonydriv )
491491{
492492   switch (state)
493493   {
494494      case DEVINFO_STR_NAME:                  strcpy(info->s, "Floppy Disk [Sony]"); break;
495495      case DEVINFO_FCT_START:                  info->start = DEVICE_START_NAME(sonydriv_floppy); break;
496      //case DEVINFO_FCT_IMAGE_UNLOAD:            info->f = (genf *) DEVICE_IMAGE_UNLOAD_NAME(sonydriv_floppy); break;
496      case DEVINFO_FCT_IMAGE_UNLOAD:            info->f = (genf *) DEVICE_IMAGE_UNLOAD_NAME(sonydriv_floppy); break;
497497
498498      default:                           DEVICE_GET_INFO_CALL(floppy);            break;
499499   }
src/mess/devices/coco_pak.c
r8322r8323
4848
4949   memset(pak_pcb, 0, sizeof(*pak_pcb));
5050   pak_pcb->cococart = device->owner()->owner();
51   pak_pcb->cart = (device_image_interface*)device->owner();
51   pak_pcb->cart = dynamic_cast<device_image_interface *>(device->owner());
5252}
5353
5454
src/mess/devices/cartslot.c
r8322r8323
197197void *cartslot_get_socket(running_device *device, const char *socket_name)
198198{
199199   cartslot_t *cart = get_token(device);
200   device_image_interface *image = (device_image_interface*)device;
200   device_image_interface *image = dynamic_cast<device_image_interface *>(device);
201201   void *result = NULL;
202202
203203   if (cart->mc != NULL)
src/mess/devices/appldriv.c
r8322r8323
167167   int spinfract_divisor;
168168   int spinfract_dividend;
169169   const appledriv_config *config = get_config(img);
170   device_image_interface *image = (device_image_interface*)img;
170   device_image_interface *image = dynamic_cast<device_image_interface *>(img);
171171
172172   disk = (struct apple525_disk *)  flopimg_get_custom_data(img);
173173   spinfract_dividend = config->dividend;
r8322r8323
250250   {
251251      if (apple525_enable_mask & (1 << i))
252252      {
253         image = (device_image_interface*)floppy_get_device_by_type(device->machine, FLOPPY_TYPE_APPLE, i);
253         image = dynamic_cast<device_image_interface *>(floppy_get_device_by_type(device->machine, FLOPPY_TYPE_APPLE, i));
254254         if (image && !image->is_writable())
255255            result = 1;
256256      }
src/mess/devices/printer.c
r8322r8323
2222
2323int printer_is_ready(running_device *printer)
2424{
25   device_image_interface *image = (device_image_interface*)printer;
25   device_image_interface *image = dynamic_cast<device_image_interface *>(printer);
2626   /* if there is a file attached to it, it's online */
2727   return image->exists() != 0;
2828}
r8322r8323
3535
3636void printer_output(running_device *printer, UINT8 data)
3737{
38   device_image_interface *image = (device_image_interface*)printer;
38   device_image_interface *image = dynamic_cast<device_image_interface *>(printer);
3939   if (image->exists())
4040   {
4141      image->fwrite(&data, 1);
src/mess/devices/coco_vhd.c
r8322r8323
113113static void coco_vhd_readwrite(running_device *device, UINT8 data)
114114{
115115   vhd_info *vhd = get_safe_token(device);
116   device_image_interface *image = (device_image_interface*)device;
116   device_image_interface *image = dynamic_cast<device_image_interface *>(device);
117117   int result;
118118   int phyOffset;
119119   UINT32 nBA = vhd->buffer_address;
src/mess/devices/thomflop.c
r8322r8323
719719   case 8: /* floppy status */
720720   {
721721      UINT8 data = 0;
722      device_image_interface* img = (device_image_interface*)to7_qdd_image(space->machine);
722      device_image_interface* img = dynamic_cast<device_image_interface *>(to7_qdd_image(space->machine));
723723      if ( ! img->exists() )
724724         data |= 0x40; /* disk present */
725725      if ( to7qdd->index_pulse )
r8322r8323
958958   if ( image != thmfc_floppy_image(image->machine) )
959959      return;
960960
961   if ( thmfc_floppy_is_qdd((device_image_interface*)image) )
961   if ( thmfc_floppy_is_qdd(dynamic_cast<device_image_interface *>(image)))
962962   {
963963      /* pulse each time the whole-disk spiraling track ends */
964964      floppy_drive_set_rpm( image, 16.92f /* 423/25 */ );
r8322r8323
10791079   /* rebuild track if needed */
10801080   if ( ! thmfc1->data_raw_size )
10811081   {
1082      if ( thmfc_floppy_is_qdd((device_image_interface*)thmfc_floppy_image(machine)) )
1082      if ( thmfc_floppy_is_qdd(dynamic_cast<device_image_interface *>(thmfc_floppy_image(machine))))
10831083         /* QDD: track = whole disk */
10841084         thmfc1->data_raw_size = thom_qdd_make_disk ( thmfc_floppy_image(machine), thmfc1->data );
10851085      else
r8322r8323
12681268   case 1: /* STAT1 */
12691269   {
12701270      UINT8 data = 0;
1271      device_image_interface * img = (device_image_interface*)thmfc_floppy_image(space->machine);
1271      device_image_interface * img = dynamic_cast<device_image_interface *>(thmfc_floppy_image(space->machine));
12721272      int flags = floppy_drive_get_flag_state( &img->device(), -1 );
12731273      if ( thmfc_floppy_is_qdd(img) )
12741274      {
r8322r8323
13311331   case 0: /* CMD0 */
13321332   {
13331333      int wsync = (data >> 4) & 1;
1334      int qdd = thmfc_floppy_is_qdd((device_image_interface*)thmfc_floppy_image(space->machine));
1334      int qdd = thmfc_floppy_is_qdd(dynamic_cast<device_image_interface *>(thmfc_floppy_image(space->machine)));
13351335      chrn_id id;
13361336      thmfc1->formatting = (data >> 2) & 1;
13371337      LOG (( "%f $%04x thmfc_floppy_w: CMD0=$%02X dens=%s wsync=%i dsync=%i fmt=%i op=%i\n",
r8322r8323
14381438      thmfc1->drive = data & 2;
14391439
14401440      img = thmfc_floppy_image(space->machine);
1441      if ( thmfc_floppy_is_qdd((device_image_interface*)img) )
1441      if ( thmfc_floppy_is_qdd(dynamic_cast<device_image_interface *>(img)))
14421442      {
14431443         motor = !(data & 0x40);
14441444         /* no side select & no seek for QDD */
r8322r8323
14761476
14771477   case 3: /* WDATA */
14781478      thmfc1->wsync = data;
1479      if ( thmfc_floppy_is_qdd((device_image_interface*)thmfc_floppy_image(space->machine)) )
1479      if ( thmfc_floppy_is_qdd(dynamic_cast<device_image_interface *>(thmfc_floppy_image(space->machine))))
14801480         thmfc_floppy_qdd_write_byte( space->machine, data );
14811481      else if ( thmfc1->op==THMFC1_OP_WRITE_SECT )
14821482         thmfc_floppy_write_byte( space->machine, data );
src/mess/machine/hp48.c
r8322r8323
194194/* end of send event */
195195static TIMER_CALLBACK( hp48_rs232_byte_sent_cb )
196196{
197   device_image_interface *xmodem = (device_image_interface*)devtag_get_device(machine, "rs232_x");
198   device_image_interface *kermit = (device_image_interface*)devtag_get_device(machine, "rs232_k");
197   device_image_interface *xmodem = dynamic_cast<device_image_interface *>(devtag_get_device(machine, "rs232_x"));
198   device_image_interface *kermit = dynamic_cast<device_image_interface *>(devtag_get_device(machine, "rs232_k"));
199199
200200   LOG_SERIAL(( "%f hp48_rs232_byte_sent_cb: end of send, data=%02x\n",
201201           attotime_to_double(timer_get_time(machine)), param ));
r8322r8323
594594   {
595595                /* second nibble of received data */
596596
597      device_image_interface *xmodem = (device_image_interface *)devtag_get_device(space->machine, "rs232_x");
598      device_image_interface *kermit = (device_image_interface *)devtag_get_device(space->machine, "rs232_k");
597      device_image_interface *xmodem = dynamic_cast<device_image_interface *>(devtag_get_device(space->machine, "rs232_x"));
598      device_image_interface *kermit = dynamic_cast<device_image_interface *>(devtag_get_device(space->machine, "rs232_k"));
599599
600600      hp48_io[0x11] &= ~1;  /* clear byte received */
601601      data = hp48_io[offset];
src/mess/machine/upd765.c
r8322r8323
19121912         if (floppy_drive_get_flag_state(img, FLOPPY_DRIVE_READY))
19131913         {
19141914            /* is disk inserted? */
1915            device_image_interface *image = (device_image_interface*) img;
1915            device_image_interface *image = dynamic_cast<device_image_interface *>( img);
19161916            if (image->exists())
19171917            {
19181918               int index_count = 0;
r8322r8323
22252225            else
22262226               img = devtag_get_device(device->machine, fdc->intf->floppy_drive_tags[i]);
22272227
2228            device_image_interface *image = (device_image_interface*) img;
2228            device_image_interface *image = dynamic_cast<device_image_interface *>( img);
22292229            if (image->exists())
22302230            {
22312231               a_drive_is_ready = 1;
src/mess/machine/adam.c
r8322r8323
539539
540540         if (deviceNum>=4 && deviceNum<=7)
541541         {
542            image = (device_image_interface*)floppy_get_device(machine, deviceNum - 4);
542            image = dynamic_cast<device_image_interface *>(floppy_get_device(machine, deviceNum - 4));
543543            if (image->exists())
544544               ram[statusDCB+20] = (ram[statusDCB+20]&0xF0); /* Inserted Media */
545545            else
r8322r8323
561561               }
562562               else if (deviceNum>=4 && deviceNum<=7)
563563               {
564                  image = (device_image_interface*)floppy_get_device(machine, deviceNum - 4);
564                  image = dynamic_cast<device_image_interface *>(floppy_get_device(machine, deviceNum - 4));
565565                  if (image->exists())
566566                  {
567567                     ram[statusDCB] = 0x80;
r8322r8323
622622               }
623623               else if (deviceNum>=4 && deviceNum<=7)
624624               {
625                  image = (device_image_interface*)floppy_get_device(machine, deviceNum - 4);
625                  image = dynamic_cast<device_image_interface *>(floppy_get_device(machine, deviceNum - 4));
626626                  if (image->exists())
627627                  {
628628                     sectorNmbr = ((ram[statusDCB+5])+(ram[statusDCB+6]<<8)+(ram[statusDCB+7]<<16)+(ram[statusDCB+8]<<24))<<1;
src/mess/machine/gb.c
r8322r8323
433433   /* NOTE: The reason we save the carts RAM this way instead of using MAME's
434434       built in macros is because they force the filename to be the name of
435435       the machine.  We need to have a separate name for each game. */
436   device_image_interface *image = (device_image_interface*)devtag_get_device(machine, "cart");
436   device_image_interface *image = dynamic_cast<device_image_interface *>(devtag_get_device(machine, "cart"));
437437   image->battery_save(gb_driver_data.gb_cart_ram, gb_driver_data.RAMBanks * 0x2000);
438438}
439439
src/mess/machine/990_hd.c
r8322r8323
342342   hdc.w[7] = w7_idle;
343343
344344   /* get references to harddisk devices */
345   hdc.d[0].img = (device_image_interface *)devtag_get_device(machine, "harddisk1");
346   hdc.d[1].img = (device_image_interface *)devtag_get_device(machine, "harddisk2");
347   hdc.d[2].img = (device_image_interface *)devtag_get_device(machine, "harddisk3");
348   hdc.d[3].img = (device_image_interface *)devtag_get_device(machine, "harddisk4");
345   hdc.d[0].img = dynamic_cast<device_image_interface *>(devtag_get_device(machine, "harddisk1"));
346   hdc.d[1].img = dynamic_cast<device_image_interface *>(devtag_get_device(machine, "harddisk2"));
347   hdc.d[2].img = dynamic_cast<device_image_interface *>(devtag_get_device(machine, "harddisk3"));
348   hdc.d[3].img = dynamic_cast<device_image_interface *>(devtag_get_device(machine, "harddisk4"));
349349
350350   hdc.interrupt_callback = interrupt_callback;
351351
src/mess/machine/thomson.c
r8322r8323
8686static int to7_get_cassette ( running_machine *machine )
8787{
8888   running_device* img = thom_cassette_img(machine);
89   device_image_interface *image = (device_image_interface*)img;
89   device_image_interface *image = dynamic_cast<device_image_interface *>(img);
9090   if ( image->exists() )
9191   {
9292      cassette_image* cass = cassette_get_image( img );
r8322r8323
187187static int mo5_get_cassette ( running_machine *machine )
188188{
189189   running_device* img = thom_cassette_img(machine);
190   device_image_interface *image = (device_image_interface*)img;
190   device_image_interface *image = dynamic_cast<device_image_interface *>(img);
191191   
192192   if ( image->exists() )
193193   {
r8322r8323
771771static to7_io_dev to7_io_mode( running_machine *machine )
772772{
773773   running_device *centronics = devtag_get_device(machine, "centronics");
774   device_image_interface *serial = (device_image_interface*)devtag_get_device(machine, "cc90232");
774   device_image_interface *serial = dynamic_cast<device_image_interface *>(devtag_get_device(machine, "cc90232"));
775775
776776   if (centronics_pe_r(centronics) == TRUE)
777777      return TO7_IO_CENTRONICS;
src/mess/machine/tx0.c
r8322r8323
551551
552552DEVICE_START( tx0_magtape )
553553{
554   magtape.img = (device_image_interface*)device;
554   magtape.img = dynamic_cast<device_image_interface *>(device);
555555}
556556
557557/*
src/mess/machine/990_dk.c
r8322r8323
117117
118118   for (i=0; i<MAX_FLOPPIES; i++)
119119   {
120      fd800.drv[i].img = (device_image_interface*)floppy_get_device(machine, i);
120      fd800.drv[i].img = dynamic_cast<device_image_interface *>(floppy_get_device(machine, i));
121121      fd800.drv[i].phys_cylinder = -1;
122122      fd800.drv[i].log_cylinder[0] = fd800.drv[i].log_cylinder[1] = -1;
123123      fd800.drv[i].seclen = 64;
src/mess/machine/pc_hdc.c
r8322r8323
231231   switch( id )
232232   {
233233   case 0:
234      img = (device_image_interface*)devtag_get_device(machine, "harddisk1");
234      img = dynamic_cast<device_image_interface *>(devtag_get_device(machine, "harddisk1"));
235235      break;
236236   case 1:
237      img = (device_image_interface*)devtag_get_device(machine, "harddisk2");
237      img = dynamic_cast<device_image_interface *>(devtag_get_device(machine, "harddisk2"));
238238      break;
239239   case 2:
240      img = (device_image_interface*)devtag_get_device(machine, "harddisk3");
240      img = dynamic_cast<device_image_interface *>(devtag_get_device(machine, "harddisk3"));
241241      break;
242242   case 3:
243      img = (device_image_interface*)devtag_get_device(machine, "harddisk4");
243      img = dynamic_cast<device_image_interface *>(devtag_get_device(machine, "harddisk4"));
244244      break;
245245   }
246246
src/mess/machine/sms.c
r8322r8323
931931{
932932   /* Does the cartridge have SRAM that should be saved? */
933933   if (sms_state.cartridge[sms_state.current_cartridge].sram_save) {
934      device_image_interface *image = (device_image_interface*)devtag_get_device(machine, "cart1");
934      device_image_interface *image = dynamic_cast<device_image_interface *>(devtag_get_device(machine, "cart1"));
935935      image->battery_save(sms_state.cartridge[sms_state.current_cartridge].cartSRAM, sizeof(UINT8) * NVRAM_SIZE );
936936   }
937937}
src/mess/machine/svi318.c
r8322r8323
818818
819819int svi318_cassette_present(running_machine *machine, int id)
820820{
821   device_image_interface *image = (device_image_interface*)devtag_get_device(machine, "cassette");
821   device_image_interface *image = dynamic_cast<device_image_interface *>(devtag_get_device(machine, "cassette"));
822822
823823   if ( image == NULL )
824824      return FALSE;
src/mess/machine/994x_ser.c
r8322r8323
213213static WRITE8_DEVICE_HANDLER(ti99_4_pio_w)
214214{
215215   pio_t *pio = get_safe_token_pio(device);
216   device_image_interface *image = (device_image_interface*)device;
216   device_image_interface *image = dynamic_cast<device_image_interface *>(device);
217217   switch (offset & 7)
218218   {
219219      case 0:
r8322r8323
414414static TMS9902_XMIT_CALLBACK( xmit_callback_0 )
415415{
416416   UINT8 buf = data;
417   device_image_interface *rs232_fp = (device_image_interface *)devtag_get_device(device->machine, "rs232:port0");
417   device_image_interface *rs232_fp = dynamic_cast<device_image_interface *>(devtag_get_device(device->machine, "rs232:port0"));
418418
419419   if (rs232_fp)
420420      rs232_fp->fwrite(&buf, 1);
r8322r8323
423423static TMS9902_XMIT_CALLBACK( xmit_callback_1 )
424424{
425425   UINT8 buf = data;
426   device_image_interface *rs232_fp = (device_image_interface *)devtag_get_device(device->machine, "rs232:port1");
426   device_image_interface *rs232_fp = dynamic_cast<device_image_interface *>(devtag_get_device(device->machine, "rs232:port1"));
427427
428428   if (rs232_fp)
429429      rs232_fp->fwrite(&buf, 1);
src/mess/machine/vtech2.c
r8322r8323
374374    if( laser_drive >= 0 && laser_file(machine) != NULL )
375375    {
376376        int size, offs;
377      device_image_interface *image = (device_image_interface*)laser_file(machine);
377      device_image_interface *image = dynamic_cast<device_image_interface *>(laser_file(machine));
378378        size = TRKSIZE_VZ;
379379        offs = TRKSIZE_VZ * laser_track_x2[laser_drive]/2;
380380        image->fseek(offs, SEEK_SET);
r8322r8323
387387
388388static void laser_put_track(running_machine *machine)
389389{
390   device_image_interface *image = (device_image_interface*)laser_file(machine);
390   device_image_interface *image = dynamic_cast<device_image_interface *>(laser_file(machine));
391391    /* drive selected and image file ok? */
392392    if( laser_drive >= 0 && laser_file(machine) != NULL )
393393    {
src/mess/machine/corvushd.c
r8322r8323
11811181   /* Only one harddisk supported right now */
11821182   assert ( id == 0 );
11831183
1184   img = (device_image_interface*)devtag_get_device(machine, tags[id]);
1184   img = dynamic_cast<device_image_interface *>(devtag_get_device(machine, tags[id]));
11851185
11861186   if ( !img )
11871187      return NULL;
src/mess/machine/wswan.c
r8322r8323
211211
212212static void wswan_machine_stop( running_machine *machine )
213213{
214   device_image_interface *image = (device_image_interface*)devtag_get_device(machine, "cart");
214   device_image_interface *image = dynamic_cast<device_image_interface *>(devtag_get_device(machine, "cart"));
215215   if ( eeprom.size )
216216   {
217217      image->battery_save(eeprom.data, eeprom.size );
src/mess/machine/x68k_hdc.c
r8322r8323
3030
3131static unsigned char SASIReadByte(running_device* device)
3232{
33   device_image_interface *image = (device_image_interface*)device;
33   device_image_interface *image = dynamic_cast<device_image_interface *>(device);
3434   //int ret;
3535   unsigned char val;
3636
r8322r8323
4141
4242static void SASIWriteByte(running_device* device, unsigned char val)
4343{
44   device_image_interface *image = (device_image_interface*)device;
44   device_image_interface *image = dynamic_cast<device_image_interface *>(device);
4545   image->fwrite(&val,1);
4646}
4747
r8322r8323
7878   sasi_ctrl_t* sasi = (sasi_ctrl_t*)downcast<legacy_device_base *>(device)->token();
7979   unsigned int lba = 0;
8080   char* blk;
81   device_image_interface *image = (device_image_interface*)device;
81   device_image_interface *image = dynamic_cast<device_image_interface *>(device);
8282   switch(offset)
8383   {
8484   case 0x00:  // data I/O
r8322r8323
331331READ16_DEVICE_HANDLER( x68k_hdc_r )
332332{
333333   sasi_ctrl_t* sasi = (sasi_ctrl_t*)downcast<legacy_device_base *>(device)->token();
334   device_image_interface *image = (device_image_interface*)device;
334   device_image_interface *image = dynamic_cast<device_image_interface *>(device);
335335   int retval = 0xff;
336336
337337   switch(offset)
src/mess/machine/990_tap.c
r8322r8323
139139   t = &tpc->t[id];
140140   memset(t, 0, sizeof(*t));
141141
142   t->img = (device_image_interface*)device;
142   t->img = dynamic_cast<device_image_interface *>(device);
143143   t->wp = 1;
144144   t->bot = 0;
145145   t->eot = 0;
src/mess/machine/nes.c
r8322r8323
297297static void nes_machine_stop( running_machine *machine )
298298{
299299   nes_state *state = (nes_state *)machine->driver_data;
300   device_image_interface *image = (device_image_interface*)state->cart;
300   device_image_interface *image = dynamic_cast<device_image_interface *>(state->cart);
301301   /* Write out the battery file if necessary */
302302   if (state->battery)   
303303      image->battery_save(state->battery_ram, state->battery_size);
src/mess/machine/snescart.c
r8322r8323
128128
129129   battery_ram = (UINT8*)malloc(state->cart[0].sram_max);
130130   ptr = battery_ram;
131   device_image_interface *image = (device_image_interface*)devtag_get_device(machine, "cart");
131   device_image_interface *image = dynamic_cast<device_image_interface *>(devtag_get_device(machine, "cart"));
132132   image->battery_load(battery_ram, state->cart[0].sram_max, 0xff);
133133
134134   if (state->cart[0].mode == SNES_MODE_20)
r8322r8323
205205         ptr += 0x2000;
206206      }
207207   }
208   device_image_interface *image = (device_image_interface*)devtag_get_device(machine, "cart");
208   device_image_interface *image = dynamic_cast<device_image_interface *>(devtag_get_device(machine, "cart"));
209209   image->battery_save(battery_ram, state->cart[0].sram_max);
210210
211211   free(battery_ram);
r8322r8323
235235   
236236   battery_ram = (UINT8*)malloc(0x20000);
237237   ptr = battery_ram;
238   device_image_interface *image = (device_image_interface*)devtag_get_device(machine, cart_tag);
238   device_image_interface *image = dynamic_cast<device_image_interface *>(devtag_get_device(machine, cart_tag));
239239   image->battery_load(battery_ram, 0x20000, 0);
240240   
241241   if (strcmp(cart_tag, "slot_a") == 0)
r8322r8323
271271      {
272272         memmove(ptr + ii * 0x8000, &snes_ram[0x608000 + (ii * 0x010000)], 0x8000);
273273      }
274      device_image_interface *image = (device_image_interface*)devtag_get_device(machine, "slot_a");
274      device_image_interface *image = dynamic_cast<device_image_interface *>(devtag_get_device(machine, "slot_a"));
275275      image->battery_save(battery_ram, 0x20000);
276276   }
277277
r8322r8323
281281      {
282282         memmove(ptr + ii * 0x8000, &snes_ram[0x708000 + (ii * 0x010000)], 0x8000);
283283      }
284      device_image_interface *image = (device_image_interface*)devtag_get_device(machine, "slot_b");
284      device_image_interface *image = dynamic_cast<device_image_interface *>(devtag_get_device(machine, "slot_b"));
285285      image->battery_save(battery_ram, 0x20000);
286286   }
287287   
src/mess/machine/genesis.c
r8322r8323
579579static void alloc_sram(running_machine *machine)
580580{
581581   genesis_sram = auto_alloc_array(machine, UINT16, (genesis_sram_end - genesis_sram_start + 1) / sizeof(UINT16));
582   device_image_interface *image = (device_image_interface*)devtag_get_device(machine, "cart");
582   device_image_interface *image = dynamic_cast<device_image_interface *>(devtag_get_device(machine, "cart"));
583583   image->battery_load(genesis_sram, genesis_sram_end - genesis_sram_start + 1, 0x00);
584584   memcpy(megadriv_backupram, genesis_sram, genesis_sram_end - genesis_sram_start + 1);
585585}
src/mess/drivers/jaguar.c
r8322r8323
186186/*
187187static mame_file *jaguar_nvram_fopen( running_machine *machine, UINT32 openflags)
188188{
189   device_image_interface *image = (device_image_interface*)devtag_get_device(machine, "cart");
189   device_image_interface *image = dynamic_cast<device_image_interface *>(devtag_get_device(machine, "cart"));
190190   astring *fname;
191191   file_error filerr;
192192   mame_file *file;
src/mess/drivers/adam.c
r8322r8323
600600
601601static MACHINE_RESET( adam )
602602{
603   device_image_interface *image = (device_image_interface*)devtag_get_device(machine, "cart");
603   device_image_interface *image = dynamic_cast<device_image_interface *>(devtag_get_device(machine, "cart"));
604604
605605   if (image->exists())
606606   {
src/mess/drivers/tm990189.c
r8322r8323
360360static TIMER_CALLBACK(rs232_input_callback)
361361{
362362   UINT8 buf;
363   device_image_interface *image = (device_image_interface*)ptr;
363   device_image_interface *image = (device_image_interface *)(ptr);
364364   if (/*rs232_rts &&*/ /*(mame_ftell(rs232_fp) < mame_fsize(rs232_fp))*/1)
365365   {
366366      if (image->fread(&buf, 1) == 1)
src/mess/drivers/vtech1.c
r8322r8323
312312static void vtech1_get_track(running_machine *machine)
313313{
314314   vtech1_state *vtech1 = (vtech1_state *)machine->driver_data;
315   device_image_interface *image = (device_image_interface*)floppy_get_device(machine,vtech1->drive);
315   device_image_interface *image = dynamic_cast<device_image_interface *>(floppy_get_device(machine,vtech1->drive));
316316
317317   /* drive selected or and image file ok? */
318318   if (vtech1->drive >= 0 && image->exists())
r8322r8323
338338   if (vtech1->drive >= 0 && floppy_get_device(machine,vtech1->drive) != NULL)
339339   {
340340      int size, offs;
341      device_image_interface *image = (device_image_interface*)floppy_get_device(machine,vtech1->drive);
341      device_image_interface *image = dynamic_cast<device_image_interface *>(floppy_get_device(machine,vtech1->drive));
342342      offs = TRKSIZE_VZ * vtech1->fdc_track_x2[vtech1->drive]/2;
343343      image->fseek(offs + vtech1->fdc_start, SEEK_SET);
344344      size = image->fwrite(&vtech1->fdc_data[vtech1->fdc_start], vtech1->fdc_write);
src/mess/drivers/fm7.c
r8322r8323
799799   }
800800   else
801801   {
802      device_image_interface *image = (device_image_interface*)devtag_get_device(space->machine,"lpt:printer");
802      device_image_interface *image = dynamic_cast<device_image_interface *>(devtag_get_device(space->machine,"lpt:printer"));
803803      if(image->exists())
804804      {
805805         if(centronics_pe_r(printer_dev))
src/mess/drivers/apexc.c
r8322r8323
261261static READ8_DEVICE_HANDLER(tape_read)
262262{
263263   UINT8 reply;
264   device_image_interface *image = (device_image_interface*)device;
264   device_image_interface *image = dynamic_cast<device_image_interface *>(device);
265265   
266266   if (image->exists() && (image->fread(& reply, 1) == 1))
267267      return reply & 0x1f;
r8322r8323
272272static WRITE8_DEVICE_HANDLER(tape_write)
273273{
274274   UINT8 data5 = (data & 0x1f);
275   device_image_interface *image = (device_image_interface*)device;
275   device_image_interface *image = dynamic_cast<device_image_interface *>(device);
276276   
277277   if (image->exists())
278278      image->fwrite(& data5, 1);
src/mess/drivers/x68k.c
r8322r8323
981981               output_set_indexed_value("eject_drv",drive,(data & 0x40) ? 1 : 0);
982982               if(data & 0x20)  // ejects disk
983983               {
984                  ((device_image_interface*)floppy_get_device(space->machine, drive))->unload();
984                  (dynamic_cast<device_image_interface *>(floppy_get_device(space->machine, drive)))->unload();
985985                  floppy_mon_w(floppy_get_device(space->machine, drive), ASSERT_LINE);
986986               }
987987            }
r8322r8323
24262426   // check for disks
24272427   for(drive=0;drive<4;drive++)
24282428   {
2429      device_image_interface *image = (device_image_interface*)floppy_get_device(machine, drive);
2429      device_image_interface *image = dynamic_cast<device_image_interface *>(floppy_get_device(machine, drive));
24302430      if(image->exists())
24312431         x68k_sys.fdc.disk_inserted[drive] = 1;
24322432      else
src/mess/drivers/gba.c
r8322r8323
4949   // only do this if the cart loader detected some form of backup
5050   if (state->nvsize > 0)
5151   {
52      device_image_interface *image = (device_image_interface*)state->nvimage;
52      device_image_interface *image = dynamic_cast<device_image_interface *>(state->nvimage);
5353      image->battery_save(state->nvptr, state->nvsize);
5454   }
5555}

Previous 15994 Revisions Next


© 1998-2018 The MESS Team