Previous 15994 Revisions Next

r8421 Wednesday 7th July, 2010 at 12:57:17 UTC by Miodrag Milanović
- Added DEVICE_IMAGE_SOFTLIST_LOAD call to devices, so actual load of softlist item depends of implementation, moved current to cartslot.c
- Renamed feof -> image_feof to enable compile on FreeBSD (thanks to ElBarto)
- Removed snapshot and quickload softlist abilities since those are for ram images and can't be proper dumps
[src/emu]devimage.c devlegcy.h diimage.h softlist.c
[src/mess/devices]cartslot.c cassette.c flopdrv.c kermit.c snapquik.c snapquik.h z80bin.h
[src/mess/formats]trs_cmd.c

src/emu/diimage.h
r8420r8421
115115typedef void (*device_image_display_func)(device_image_interface &image);
116116typedef void (*device_image_partialhash_func)(char *, const unsigned char *, unsigned long, unsigned int);
117117typedef void (*device_image_get_devices_func)(device_image_interface &device);
118typedef bool (*device_image_softlist_load_func)(device_image_interface &image, char *swlist, char *swname, rom_entry *start_entry);
118119
119
120120//**************************************************************************
121121//  MACROS
122122//**************************************************************************
r8420r8421
141141#define DEVICE_IMAGE_GET_DEVICES_NAME(name) device_image_get_devices_##name
142142#define DEVICE_IMAGE_GET_DEVICES(name)      void DEVICE_IMAGE_GET_DEVICES_NAME(name)(device_image_interface &image)
143143
144#define DEVICE_IMAGE_SOFTLIST_LOAD_NAME(name)        device_softlist_load_##name
145#define DEVICE_IMAGE_SOFTLIST_LOAD(name)             bool DEVICE_IMAGE_SOFTLIST_LOAD_NAME(name)(device_image_interface &image, char *swlist, char *swname, rom_entry *start_entry)
144146
145147// ======================> device_config_image_interface
146148
r8420r8421
200202   virtual void unload() = 0;
201203
202204   virtual int call_load() = 0;
205   virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry) = 0;
203206   virtual int call_create(int format_type, option_resolution *format_options) = 0;
204207   virtual void call_unload() = 0;
205208   virtual void call_display() = 0;
r8420r8421
234237   UINT64 ftell() { check_for_file(); return core_ftell(m_file); }
235238   int fgetc() { char ch; if (fread(&ch, 1) != 1) ch = '\0'; return ch; }
236239   char *fgets(char *buffer, UINT32 length) { check_for_file(); return core_fgets(buffer, length, m_file); }
237   int feof() { check_for_file(); return core_feof(m_file); }
240   int image_feof() { check_for_file(); return core_feof(m_file); }
238241   void *ptr() {check_for_file(); return (void *) core_fbuffer(m_file); }
239242   // configuration access
240243   const device_config_image_interface &image_config() const { return m_image_config; }
src/emu/devlegcy.h
r8420r8421
159159    DEVINFO_FCT_IMAGE_DISPLAY,                                  /* R/O: device_image_display_func */
160160    DEVINFO_FCT_IMAGE_PARTIAL_HASH,                             /* R/O: device_image_partialhash_func */
161161    DEVINFO_FCT_IMAGE_GET_DEVICES,                              /* R/O: device_image_get_devices_func */
162   DEVINFO_FCT_IMAGE_SOFTLIST_LOAD,                            /* R/O: device_image_softlist_load_func */
162163    DEVINFO_FCT_IMAGE_LAST = DEVINFO_FCT_FIRST + 0x0fff,
163164
164165    /* --- the following bits of info are returned as NULL-terminated strings --- */
r8420r8421
633634   virtual bool create(const char *path, const image_device_format *create_format, option_resolution *create_args);
634635
635636   virtual int call_load();
637   virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry);
636638   virtual int call_create(int format_type, option_resolution *format_options);
637639   virtual void call_unload();
638640   virtual void call_display();
src/emu/softlist.c
r8420r8421
10871087   {
10881088      /* Load the software part */
10891089      try {
1090         load_software_part_region( &image->device(), (char *)swlist_name, (char *)software_info_ptr->shortname, software_part_ptr->romdata );
1090         result = image->call_softlist_load((char *)swlist_name, (char *)software_info_ptr->shortname, software_part_ptr->romdata );
10911091      }
10921092      catch (emu_fatalerror &fatal)
10931093      {
r8420r8421
11361136
11371137      /* Tell the world which part we actually loaded */
11381138      *full_sw_name = auto_alloc_array( image->device().machine, char, strlen(swlist_name) + strlen(software_info_ptr->shortname) + strlen(software_part_ptr->name) + 3 );
1139      sprintf( *full_sw_name, "%s:%s:%s", swlist_name, software_info_ptr->shortname, software_part_ptr->name );
1140
1141      result = true;
1139      sprintf( *full_sw_name, "%s:%s:%s", swlist_name, software_info_ptr->shortname, software_part_ptr->name );     
11421140   }
11431141
11441142   /* Close the software list if it's still open */
src/emu/devimage.c
r8420r8421
303303    image_error_t err;
304304    UINT32 open_plan[4];
305305    int i;
306   bool softload = FALSE;
306307
307308    /* first unload the image */
308309    unload();
r8420r8421
319320        goto done;
320321
321322   /* Check if there's a software list defined for this device and use that if we're not creating an image */
322   if (is_create || !load_software_part( this, path, &m_software_info_ptr, &m_software_part_ptr, &m_full_software_name ) )
323   if (is_create || !(softload=load_software_part( this, path, &m_software_info_ptr, &m_software_part_ptr, &m_full_software_name )) )
323324   {
324325      /* determine open plan */
325326      determine_open_plan(is_create, open_plan);
r8420r8421
333334            goto done;
334335      }
335336   }
336
337   
337338   /* Copy some image information when we have been loaded through a software list */
338339   if ( m_software_info_ptr )
339340   {
r8420r8421
344345   }
345346
346347   /* did we fail to find the file? */
347   if (!is_loaded())
348   if (!is_loaded() && !softload)
348349   {
349350      err = IMAGE_ERROR_FILENOTFOUND;
350351      goto done;
r8420r8421
502503   }
503504}
504505
506bool legacy_image_device_base::call_softlist_load(char *swlist, char *swname, rom_entry *start_entry)
507{
508   device_image_softlist_load_func func = reinterpret_cast<device_image_softlist_load_func>(m_config.get_legacy_config_fct(DEVINFO_FCT_IMAGE_SOFTLIST_LOAD));
509   if (func) {
510      return (*func)(*this,swlist,swname,start_entry);
511   } else {
512      return FALSE;
513   }
514}
515
505516int legacy_image_device_base::call_create(int format_type, option_resolution *format_options)
506517{
507518   device_image_create_func func = reinterpret_cast<device_image_create_func>(m_config.get_legacy_config_fct(DEVINFO_FCT_IMAGE_CREATE));
src/mess/devices/snapquik.h
r8420r8421
5757   const char *      file_extensions;   /* file extensions */
5858   seconds_t         delay_seconds;      /* loading delay (seconds) */
5959   attoseconds_t      delay_attoseconds;   /* loading delay (attoseconds) */
60   const char *      interface;   
6160};
6261
6362
r8420r8421
7372   MDRV_DEVICE_CONFIG_DATA64(snapquick_config, delay_seconds, (seconds_t) (_delay)) \
7473   MDRV_DEVICE_CONFIG_DATA64(snapquick_config, delay_attoseconds, (attoseconds_t) (((_delay) - (int)(_delay)) * ATTOSECONDS_PER_SECOND)) \
7574
76#define MDRV_SNAPSHOT_INTERFACE(_interface)                     \
77   MDRV_DEVICE_CONFIG_DATAPTR(snapquick_config, interface, _interface )
78
79
8075/***************************************************************************
8176    QUICKLOAD DEVICE CONFIGURATION MACROS
8277***************************************************************************/
r8420r8421
8883   MDRV_DEVICE_CONFIG_DATA64(snapquick_config, delay_seconds, (seconds_t) (_delay)) \
8984   MDRV_DEVICE_CONFIG_DATA64(snapquick_config, delay_attoseconds, (attoseconds_t) (((_delay) - (int)(_delay)) * ATTOSECONDS_PER_SECOND)) \
9085
91#define MDRV_QUICKLOAD_INTERFACE(_interface)                     \
92   MDRV_DEVICE_CONFIG_DATAPTR(snapquick_config, interface, _interface )
93
94
95
9686/***************************************************************************
9787    FUNCTION PROTOTYPES
9888***************************************************************************/
src/mess/devices/cassette.c
r8420r8421
396396   ui_draw_text_box(render_container_get_ui(), buf, JUSTIFY_LEFT, x, y, UI_BACKGROUND_COLOR);
397397}
398398
399/*-------------------------------------------------
400    DEVICE_IMAGE_SOFTLIST_LOAD(cassette)
401-------------------------------------------------*/
402static DEVICE_IMAGE_SOFTLIST_LOAD(cassette)
403{
404   return FALSE;
405}
399406
400407DEVICE_GET_INFO(cassette)
401408{
r8420r8421
414421      case DEVINFO_FCT_IMAGE_LOAD:            info->f = (genf *) DEVICE_IMAGE_LOAD_NAME(cassette); break;
415422      case DEVINFO_FCT_IMAGE_UNLOAD:            info->f = (genf *) DEVICE_IMAGE_UNLOAD_NAME(cassette); break;
416423      case DEVINFO_FCT_IMAGE_DISPLAY:            info->f = (genf *) DEVICE_IMAGE_DISPLAY_NAME(cassette); break;
424      case DEVINFO_FCT_IMAGE_SOFTLIST_LOAD:      info->f = (genf *) DEVICE_IMAGE_SOFTLIST_LOAD_NAME(cassette);   break;
417425
418426      /* --- the following bits of info are returned as NULL-terminated strings --- */
419427      case DEVINFO_STR_NAME:                  strcpy(info->s, "Cassette"); break;
src/mess/devices/flopdrv.c
r8420r8421
993993      return !floppy_get_heads_per_disk(drive->floppy);
994994}
995995
996/*-------------------------------------------------
997    DEVICE_IMAGE_SOFTLIST_LOAD(floppy)
998-------------------------------------------------*/
999static DEVICE_IMAGE_SOFTLIST_LOAD(floppy)
1000{
1001   return FALSE;
1002}
1003
9961004/*************************************
9971005 *
9981006 *  Device specification function
r8420r8421
10361044      case DEVINFO_FCT_IMAGE_CREATE:            info->f = (genf *) DEVICE_IMAGE_CREATE_NAME(floppy); break;
10371045      case DEVINFO_FCT_IMAGE_LOAD:            info->f = (genf *) DEVICE_IMAGE_LOAD_NAME(floppy); break;
10381046      case DEVINFO_FCT_IMAGE_UNLOAD:            info->f = (genf *) DEVICE_IMAGE_UNLOAD_NAME(floppy); break;
1047      case DEVINFO_FCT_IMAGE_SOFTLIST_LOAD:      info->f = (genf *) DEVICE_IMAGE_SOFTLIST_LOAD_NAME(floppy);   break;
10391048      case DEVINFO_PTR_IMAGE_CREATE_OPTGUIDE:      info->p = (void *)floppy_option_guide; break;
10401049      case DEVINFO_INT_IMAGE_CREATE_OPTCOUNT:
10411050      {
src/mess/devices/z80bin.h
r8420r8421
5252   MDRV_DEVICE_CONFIG_DATA64(snapquick_config, delay_attoseconds, (attoseconds_t) (((_delay) - (int)(_delay)) * ATTOSECONDS_PER_SECOND)) \
5353   MDRV_DEVICE_CONFIG_DATAPTR(z80bin_config, execute, Z80BIN_EXECUTE_NAME(_execute))
5454
55#define MDRV_Z80BIN_QUICKLOAD_INTERFACE(_interface)                     \
56   MDRV_DEVICE_CONFIG_DATAPTR(snapquick_config, interface, _interface )
57
5855#endif /* __Z80BIN_H__ */
src/mess/devices/cartslot.c
r8420r8421
398398   }
399399}
400400
401/*-------------------------------------------------
402    DEVICE_IMAGE_SOFTLIST_LOAD(cartslot)
403-------------------------------------------------*/
404static DEVICE_IMAGE_SOFTLIST_LOAD(cartslot)
405{
406   load_software_part_region( &image.device(), swlist, swname, start_entry );
407   return TRUE;
408}
401409
402410/*-------------------------------------------------
403411    DEVICE_GET_INFO( cartslot )
r8420r8421
428436      case DEVINFO_FCT_IMAGE_LOAD:            info->f = (genf *) DEVICE_IMAGE_LOAD_NAME(cartslot);      break;
429437      case DEVINFO_FCT_IMAGE_UNLOAD:            info->f = (genf *) DEVICE_IMAGE_UNLOAD_NAME(cartslot);      break;
430438      case DEVINFO_FCT_IMAGE_GET_DEVICES:         info->f = (genf *) DEVICE_IMAGE_GET_DEVICES_NAME(cartslot);   break;
439      case DEVINFO_FCT_IMAGE_SOFTLIST_LOAD:      info->f = (genf *) DEVICE_IMAGE_SOFTLIST_LOAD_NAME(cartslot);   break;
431440      case DEVINFO_FCT_IMAGE_PARTIAL_HASH:
432441         if ( device && downcast<const legacy_image_device_config_base *>(device)->inline_config() && get_config_dev(device)->device_partialhash) {
433442            info->f = (genf *) get_config_dev(device)->device_partialhash;
src/mess/devices/kermit.c
r8420r8421
223223   for ( len = 2; len < state->maxl-2; len++ )
224224   {
225225      UINT8 c;
226      if ( state->image->feof() ) break;
226      if ( state->image->image_feof() ) break;
227227      c = state->image->fgetc();
228228      if ( kermit_is_ctl( c ) )
229229      {
r8420r8421
552552
553553                  case KERMIT_SEND_DATA:
554554                     /* send next data packet or EOF */
555                     if ( state->image->feof() )
555                     if ( state->image->image_feof() )
556556                     {
557557                        kermit_send_simple_packet( state, KERMIT_EOF );
558558                        state->state = KERMIT_SEND_EOF;
src/mess/devices/snapquik.c
r8420r8421
188188      /* --- the following bits of info are returned as NULL-terminated strings --- */
189189      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__); break;
190190      case DEVINFO_STR_IMAGE_FILE_EXTENSIONS:         strcpy(info->s, get_config_dev(device)->file_extensions); break;
191      case DEVINFO_STR_IMAGE_INTERFACE:
192         if ( device && device->static_config() && get_config_dev(device)->interface)
193         {
194            strcpy(info->s, get_config_dev(device)->interface );
195         }
196         break;
197     
198191   }
199192}
200193
src/mess/formats/trs_cmd.c
r8420r8421
4242   UINT8 addr[2];
4343   void *ptr;
4444
45   while (!image.feof())
45   while (!image.image_feof())
4646   {
4747      image.fread( &type, 1);
4848      image.fread( &length, 1);

Previous 15994 Revisions Next


© 1998-2018 The MESS Team