Previous 15994 Revisions Next

r14698 Tuesday 6th March, 2012 at 07:34:42 UTC by Miodrag Milanović
Converted omti and sc499 image devices to modern (no whatsnew)
[src/emu]diimage.c diimage.h
[src/emu/imagedev]flopdrv.c
[src/mess/machine]omti8621.c sc499.c

src/emu/diimage.c
r14697r14698
10971097    update_names - update brief and instance names
10981098-------------------------------------------------*/
10991099
1100void device_image_interface::update_names()
1100void device_image_interface::update_names(const device_type device_type, const char *inst, const char *brief)
11011101{
11021102   image_interface_iterator iter(device().mconfig().root_device());
11031103   int count = 0;
r14697r14698
11061106   {
11071107      if (this == image)
11081108         index = count;
1109      if (image->image_type() == image_type())
1109      if ((image->image_type() == image_type() && device_type==NULL) || (device_type==image->device().type()))
11101110         count++;
11111111   }
1112   const char *inst_name = (device_type!=NULL) ? inst : device_typename(image_type());
1113   const char *brief_name = (device_type!=NULL) ? brief : device_brieftypename(image_type());
11121114   if (count > 1)
11131115   {
1114      m_instance_name.printf("%s%d", device_typename(image_type()), index + 1);
1115      m_brief_instance_name.printf("%s%d", device_brieftypename(image_type()), index + 1);
1116      m_instance_name.printf("%s%d", inst_name , index + 1);
1117      m_brief_instance_name.printf("%s%d", brief_name, index + 1);
11161118   }
11171119   else
11181120   {
1119      m_instance_name = device_typename(image_type());
1120      m_brief_instance_name = device_brieftypename(image_type());
1121      m_instance_name = inst_name;
1122      m_brief_instance_name = brief_name;
11211123   }
11221124}
11231125
src/emu/diimage.h
r14697r14698
272272   int read_hash_config(const char *sysname);
273273   void run_hash(void (*partialhash)(hash_collection &, const unsigned char *, unsigned long, const char *), hash_collection &hashes, const char *types);
274274   void image_checkhash();
275   void update_names();
275   void update_names(const device_type device_type = NULL, const char *inst = NULL, const char *brief = NULL);
276276   // derived class overrides
277277
278278   // configuration
src/emu/imagedev/flopdrv.c
r14697r14698
117117/***************************************************************************
118118    IMPLEMENTATION
119119***************************************************************************/
120//DECLARE_LEGACY_IMAGE_DEVICE(FLOPPY_APPLE, apple525);
121//DECLARE_LEGACY_IMAGE_DEVICE(FLOPPY_SONY, sonydriv);
122120
123121INLINE floppy_drive *get_safe_token(device_t *device)
124122{
125123   assert( device != NULL );
126   //assert( device->type() == LEGACY_FLOPPY || device->type() == FLOPPY_APPLE || device->type() == FLOPPY_SONY);
127124   return (floppy_drive *) downcast<legacy_floppy_image_device *>(device)->token();
128125}
129126
src/mess/machine/sc499.c
r14697r14698
148148#define SC499_TIMER_6 6
149149#define SC499_TIMER_7 7
150150
151typedef struct _ctape_data ctape_data;
152struct _ctape_data
153{
154   device_image_interface *image;
155};
156151
157152/***************************************************************************
158153    IMPLEMENTATION
r14697r14698
196191   m_timer1 = m_device->machine().scheduler().timer_alloc(FUNC(static_timer_func), this);
197192
198193   device_t *ctape_device = machine().device(SC499_CTAPE_TAG);
199   ctape_data *ctape = (ctape_data *) downcast<legacy_device_base *> (ctape_device)->token();
200   m_image = ctape->image;
194   m_image = dynamic_cast<device_image_interface *> (ctape_device);
201195
202196   if (m_image->image_core_file() == NULL)
203197   {
r14697r14698
11441138}
11451139
11461140//##########################################################################
1147
1148DECLARE_LEGACY_IMAGE_DEVICE(SC499_CTAPE, sc499_ctape);
1149
1150/*-------------------------------------------------
1151    ctape device start callback
1152-------------------------------------------------*/
1153
1154static DEVICE_START( sc499_ctape )
1141class sc499_ctape_image_device :   public device_t,
1142                           public device_image_interface
11551143{
1156   assert(device != NULL);
1157   assert(device->type() == SC499_CTAPE);
1158   ctape_data *ctape = (ctape_data *) downcast<legacy_device_base *>(device)->token();
1144public:
1145   // construction/destruction
1146   sc499_ctape_image_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
11591147
1160   ctape->image = dynamic_cast<device_image_interface *> (device);
1161}
1148   // image-level overrides
1149   virtual iodevice_t image_type() const { return IO_MAGTAPE; }
11621150
1163/*-------------------------------------------------
1164    ctape device get info callback
1165-------------------------------------------------*/
1151   virtual bool is_readable()  const { return 1; }
1152   virtual bool is_writeable() const { return 1; }
1153   virtual bool is_creatable() const { return 1; }
1154   virtual bool must_be_loaded() const { return 0; }
1155   virtual bool is_reset_on_load() const { return 0; }
1156   virtual const char *image_interface() const { return NULL; }
1157   virtual const char *file_extensions() const { return "act"; }
1158   virtual const option_guide *create_option_guide() const { return NULL; }
1159protected:
1160   // device-level overrides
1161    virtual void device_config_complete();
1162   virtual void device_start() { };
1163};
11661164
1167DEVICE_GET_INFO( sc499_ctape )
1168{
1169   switch (state)
1170   {
1171      /* --- the following bits of info are returned as 64-bit signed integers --- */
1172      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(ctape_data); break;
1173      case DEVINFO_INT_INLINE_CONFIG_BYTES:   info->i = 0; break;
1174      case DEVINFO_INT_IMAGE_TYPE:         info->i = IO_MAGTAPE; break;
1175      case DEVINFO_INT_IMAGE_READABLE:      info->i = 1; break;
1176      case DEVINFO_INT_IMAGE_WRITEABLE:      info->i = 1; break;
1177      case DEVINFO_INT_IMAGE_CREATABLE:      info->i = 1; break;
1165// device type definition
1166extern const device_type SC499_CTAPE;
11781167
1179      /* --- the following bits of info are returned as pointers to data or functions --- */
1180      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(sc499_ctape); break;
1168const device_type SC499_CTAPE = &device_creator<sc499_ctape_image_device>;
11811169
1182      /* --- the following bits of info are returned as NULL-terminated strings --- */
1183      case DEVINFO_STR_NAME:               strcpy(info->s, "Cartridge Tape");   break;
1184      case DEVINFO_STR_FAMILY:            strcpy(info->s, "Cartridge Tape");   break;
1185      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.0");            break;
1186
1187      case DEVINFO_STR_IMAGE_INSTANCE_NAME:      strcpy(info->s, "ctape");      break;
1188      case DEVINFO_STR_IMAGE_BRIEF_INSTANCE_NAME:   strcpy(info->s, "ct");         break;
1189      case DEVINFO_STR_IMAGE_FILE_EXTENSIONS:      strcpy(info->s, "act");       break;
1190   }
1170sc499_ctape_image_device::sc499_ctape_image_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
1171    : device_t(mconfig, SC499_CTAPE, "Cartridge Tape", tag, owner, clock),
1172     device_image_interface(mconfig, *this)
1173{
11911174}
11921175
1193DEFINE_LEGACY_IMAGE_DEVICE(SC499_CTAPE, sc499_ctape);
1176void sc499_ctape_image_device::device_config_complete()
1177{   
1178   update_names(SC499_CTAPE, "ctape", "ct");
1179};
11941180
11951181MACHINE_CONFIG_FRAGMENT( sc499_ctape )
11961182   MCFG_DEVICE_ADD(SC499_CTAPE_TAG, SC499_CTAPE, 0)
src/mess/machine/omti8621.c
r14697r14698
11981198DEFINE_LEGACY_DEVICE(OMTI8621, omti8621);
11991199
12001200//##########################################################################
1201class omti_disk_image_device :   public device_t,
1202                        public device_image_interface
1203{
1204public:
1205   // construction/destruction
1206   omti_disk_image_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
12011207
1202DECLARE_LEGACY_IMAGE_DEVICE(OMTI_DISK0, omti_disk0);
1203DECLARE_LEGACY_IMAGE_DEVICE(OMTI_DISK1, omti_disk1);
1208   // image-level overrides
1209   virtual iodevice_t image_type() const { return IO_HARDDISK; }
12041210
1211   virtual bool is_readable()  const { return 1; }
1212   virtual bool is_writeable() const { return 1; }
1213   virtual bool is_creatable() const { return 1; }
1214   virtual bool must_be_loaded() const { return 0; }
1215   virtual bool is_reset_on_load() const { return 0; }
1216   virtual const char *image_interface() const { return NULL; }
1217   virtual const char *file_extensions() const { return "awd"; }
1218   virtual const option_guide *create_option_guide() const { return NULL; }
1219   
1220   virtual bool call_create(int format_type, option_resolution *format_options);
1221   
1222   disk_data *token() { return &m_token; }   
1223protected:
1224   // device-level overrides
1225    virtual void device_config_complete();
1226   virtual void device_start();
1227   virtual void device_reset();
1228   
1229   disk_data m_token;
1230};
1231
1232// device type definition
1233extern const device_type OMTI_DISK;
1234
1235const device_type OMTI_DISK = &device_creator<omti_disk_image_device>;
1236
1237omti_disk_image_device::omti_disk_image_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
1238    : device_t(mconfig, OMTI_DISK, "Winchester", tag, owner, clock),
1239     device_image_interface(mconfig, *this)
1240{
1241}
1242
1243void omti_disk_image_device::device_config_complete()
1244{   
1245   update_names(OMTI_DISK, "disk", "disk");
1246};
1247
1248
12051249/***************************************************************************
12061250 get_safe_disk_token - makes sure that the passed in device is a OMTI disk
12071251 ***************************************************************************/
12081252
12091253INLINE disk_data *get_safe_disk_token(device_t *device) {
12101254   assert(device != NULL);
1211   assert(device->type() == OMTI_DISK0 || device->type() == OMTI_DISK1);
1212   return (disk_data *) downcast<legacy_device_base *>(device)->token();
1255   assert(device->type() == OMTI_DISK);
1256   return (disk_data *) downcast<omti_disk_image_device *>(device)->token();
12131257}
12141258
12151259/***************************************************************************
r14697r14698
12451289    device start callback
12461290-------------------------------------------------*/
12471291
1248static DEVICE_START( omti_disk )
1292void omti_disk_image_device::device_start()
12491293{
1250   disk_data *disk = get_safe_disk_token(device);
1294   disk_data *disk = get_safe_disk_token(this);
12511295
1252   disk->device = device;
1296   disk->device = this;
12531297   // note: we must have disk->device before we can log
12541298
1255   disk->image = dynamic_cast<device_image_interface *> (disk->device);
1299   disk->image = this;
12561300
12571301   if (disk->image->image_core_file() == NULL)
12581302   {
r14697r14698
12711315    device reset callback
12721316-------------------------------------------------*/
12731317
1274static DEVICE_RESET( omti_disk )
1318void omti_disk_image_device::device_reset()
12751319{
1276   disk_data *disk = get_safe_disk_token(device);
1320   disk_data *disk = get_safe_disk_token(this);
12771321   DLOG1(("device_reset_omti_disk"));
12781322
1279   if (disk->image->exists() && disk->image->fseek(0, SEEK_END) == 0)
1323   if (exists() && fseek(0, SEEK_END) == 0)
12801324   {
1281      UINT32 disk_size = (UINT32)(disk->image->ftell() / OMTI_DISK_SECTOR_SIZE);
1325      UINT32 disk_size = (UINT32)(ftell() / OMTI_DISK_SECTOR_SIZE);
12821326      UINT16 disk_type = disk_size >= 300000 ? OMTI_DISK_TYPE_348_MB : OMTI_DISK_TYPE_155_MB;
12831327      if (disk_type != disk->type) {
12841328         DLOG1(("device_reset_omti_disk: disk size=%d blocks, disk type=%x", disk_size, disk_type ));
r14697r14698
12911335   disk image create callback
12921336-------------------------------------------------*/
12931337
1294DEVICE_IMAGE_CREATE( omti_disk )
1338bool omti_disk_image_device::call_create(int format_type, option_resolution *format_options)
12951339{
1296   disk_data *disk = get_safe_disk_token(&image.device());
1340   disk_data *disk = get_safe_disk_token(this);
12971341   DLOG(("device_create_omti_disk: creating OMTI Disk with %d blocks", disk->sector_count));
12981342
12991343   int x;
r14697r14698
13031347   memset(sectordata, 0x55, sizeof(sectordata));
13041348   for (x = 0; x < disk->sector_count; x++)
13051349   {
1306      if (image.fwrite(sectordata, OMTI_DISK_SECTOR_SIZE)
1350      if (fwrite(sectordata, OMTI_DISK_SECTOR_SIZE)
13071351            < OMTI_DISK_SECTOR_SIZE)
13081352      {
13091353         return IMAGE_INIT_FAIL;
r14697r14698
13121356   return IMAGE_INIT_PASS;
13131357}
13141358
1315/*-------------------------------------------------
1316    device get info callback
1317-------------------------------------------------*/
1318
1319DEVICE_GET_INFO( omti_disk0 )
1320{
1321   switch (state)
1322   {
1323      /* --- the following bits of info are returned as 64-bit signed integers --- */
1324      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(disk_data);      break;
1325      case DEVINFO_INT_INLINE_CONFIG_BYTES:   info->i = 0;         break;
1326      case DEVINFO_INT_IMAGE_TYPE:         info->i = IO_HARDDISK;   break;
1327      case DEVINFO_INT_IMAGE_READABLE:      info->i = 1; break;
1328      case DEVINFO_INT_IMAGE_WRITEABLE:      info->i = 1; break;
1329      case DEVINFO_INT_IMAGE_CREATABLE:      info->i = 1; break;
1330
1331      /* --- the following bits of info are returned as pointers to data or functions --- */
1332      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(omti_disk); break;
1333      case DEVINFO_FCT_STOP:               /* Nothing */                        break;
1334      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME(omti_disk); break;
1335//      case DEVINFO_FCT_IMAGE_LOAD:            info->f = (genf *) DEVICE_IMAGE_LOAD_NAME(omti_disk); break;
1336//      case DEVINFO_FCT_IMAGE_UNLOAD:          info->f = (genf *) DEVICE_IMAGE_UNLOAD_NAME(omti_disk); break;
1337      case DEVINFO_FCT_IMAGE_CREATE:         info->f = (genf *)DEVICE_IMAGE_CREATE_NAME(omti_disk);   break;
1338
1339
1340      /* --- the following bits of info are returned as NULL-terminated strings --- */
1341      case DEVINFO_STR_NAME:               strcpy(info->s, "Winchester");   break;
1342      case DEVINFO_STR_FAMILY:            strcpy(info->s, "Winchester");   break;
1343      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.0");         break;
1344      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, __FILE__);      break;
1345      case DEVINFO_STR_CREDITS:            strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
1346
1347      case DEVINFO_STR_IMAGE_INSTANCE_NAME:      strcpy(info->s, "disk");   break;
1348      case DEVINFO_STR_IMAGE_BRIEF_INSTANCE_NAME:   strcpy(info->s, "disk");   break;
1349      case DEVINFO_STR_IMAGE_FILE_EXTENSIONS:      strcpy(info->s, "awd");    break;
1350   }
1351}
1352
1353DEVICE_GET_INFO( omti_disk1 )
1354{
1355   switch (state)
1356   {
1357   /* --- the following bits of info are returned as NULL-terminated strings --- */
1358   case DEVINFO_STR_NAME:                  strcpy(info->s, "Winchester 1");   break;
1359   case DEVINFO_STR_IMAGE_INSTANCE_NAME:      strcpy(info->s, "disk1");         break;
1360   case DEVINFO_STR_IMAGE_BRIEF_INSTANCE_NAME:   strcpy(info->s, "disk1");         break;
1361
1362   default:                           DEVICE_GET_INFO_CALL( omti_disk0 ); break;
1363   }
1364}
1365
1366DEFINE_LEGACY_IMAGE_DEVICE(OMTI_DISK0, omti_disk0);
1367DEFINE_LEGACY_IMAGE_DEVICE(OMTI_DISK1, omti_disk1);
1368
13691359MACHINE_CONFIG_FRAGMENT( omti_disk )
1370   MCFG_DEVICE_ADD(OMTI_DISK0_TAG, OMTI_DISK0, 0)
1371   MCFG_DEVICE_ADD(OMTI_DISK1_TAG, OMTI_DISK1, 0)
1360   MCFG_DEVICE_ADD(OMTI_DISK0_TAG, OMTI_DISK, 0)
1361   MCFG_DEVICE_ADD(OMTI_DISK1_TAG, OMTI_DISK, 0)
13721362MACHINE_CONFIG_END
13731363

Previous 15994 Revisions Next


© 1998-2018 The MESS Team