cassette.c/flopdrv.c: added support for a display info callback function [Miodrag Milanovic]

This commit is contained in:
Miodrag Milanovic 2011-04-08 10:13:21 +00:00
parent bad53a6bdf
commit 5770771c02
4 changed files with 63 additions and 2 deletions

View File

@ -50,6 +50,12 @@ INLINE dev_cassette_t *get_safe_token(device_t *device)
return (dev_cassette_t *) downcast<legacy_device_base *>(device)->token();
}
INLINE const inline_cassette_config *get_config_dev(const device_config *device)
{
assert(device != NULL);
assert(device->type() == CASSETTE);
return (const inline_cassette_config *)downcast<const legacy_device_config_base *>(device)->inline_config();
}
/*********************************************************************
cassette IO
@ -410,7 +416,7 @@ DEVICE_GET_INFO(cassette)
{
/* --- the following bits of info are returned as 64-bit signed integers --- */
case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(dev_cassette_t); break;
case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break;
case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = sizeof(inline_cassette_config); break;
case DEVINFO_INT_IMAGE_TYPE: info->i = IO_CASSETTE; break;
case DEVINFO_INT_IMAGE_READABLE: info->i = 1; break;
case DEVINFO_INT_IMAGE_WRITEABLE: info->i = 1; break;
@ -422,6 +428,13 @@ DEVICE_GET_INFO(cassette)
case DEVINFO_FCT_IMAGE_UNLOAD: info->f = (genf *) DEVICE_IMAGE_UNLOAD_NAME(cassette); break;
case DEVINFO_FCT_IMAGE_DISPLAY: info->f = (genf *) DEVICE_IMAGE_DISPLAY_NAME(cassette); break;
case DEVINFO_FCT_IMAGE_SOFTLIST_LOAD: info->f = (genf *) DEVICE_IMAGE_SOFTLIST_LOAD_NAME(cassette); break;
case DEVINFO_FCT_IMAGE_DISPLAY_INFO:
if ( device && downcast<const legacy_image_device_config_base *>(device)->inline_config() && get_config_dev(device)->device_displayinfo) {
info->f = (genf *) get_config_dev(device)->device_displayinfo;
} else {
info->f = NULL;
}
break;
/* --- the following bits of info are returned as NULL-terminated strings --- */
case DEVINFO_STR_NAME: strcpy(info->s, "Cassette"); break;

View File

@ -49,6 +49,11 @@ struct cassette_config_t
const char * interface;
};
typedef struct inline_cassette_config_t inline_cassette_config;
struct inline_cassette_config_t
{
device_image_display_info_func device_displayinfo;
};
/***************************************************************************
FUNCTION PROTOTYPES
@ -80,6 +85,9 @@ DECLARE_LEGACY_IMAGE_DEVICE(CASSETTE, cassette);
MCFG_DEVICE_MODIFY(_tag) \
MCFG_DEVICE_CONFIG(_config)
#define MCFG_CASSETTE_DISPLAY_INFO(_displayinfo) \
MCFG_DEVICE_CONFIG_DATAPTR(inline_cassette_config, device_displayinfo, DEVICE_IMAGE_DISPLAY_INFO_NAME(_displayinfo))
extern const cassette_config default_cassette_config;
#endif /* CASSETTE_H */

View File

@ -127,6 +127,13 @@ INLINE floppy_drive *get_safe_token(device_t *device)
return (floppy_drive *) downcast<legacy_device_base *>(device)->token();
}
INLINE const inline_floppy_config *get_config_dev(const device_config *device)
{
assert(device != NULL);
assert( device->type() == FLOPPY || device->type() == FLOPPY_APPLE || device->type() == FLOPPY_SONY);
return (const inline_floppy_config *)downcast<const legacy_device_config_base *>(device)->inline_config();
}
floppy_image *flopimg_get_image(device_t *image)
{
return get_safe_token(image)->floppy;
@ -963,7 +970,7 @@ DEVICE_GET_INFO(floppy)
{
/* --- the following bits of info are returned as 64-bit signed integers --- */
case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(floppy_drive); break;
case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break;
case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = sizeof(inline_floppy_config); break;
case DEVINFO_INT_IMAGE_TYPE: info->i = IO_FLOPPY; break;
case DEVINFO_INT_IMAGE_READABLE: info->i = 1; break;
case DEVINFO_INT_IMAGE_WRITEABLE: info->i = 1; break;
@ -987,6 +994,14 @@ DEVICE_GET_INFO(floppy)
case DEVINFO_FCT_IMAGE_LOAD: info->f = (genf *) DEVICE_IMAGE_LOAD_NAME(floppy); break;
case DEVINFO_FCT_IMAGE_UNLOAD: info->f = (genf *) DEVICE_IMAGE_UNLOAD_NAME(floppy); break;
case DEVINFO_FCT_IMAGE_SOFTLIST_LOAD: info->f = (genf *) DEVICE_IMAGE_SOFTLIST_LOAD_NAME(floppy); break;
case DEVINFO_FCT_IMAGE_DISPLAY_INFO:
if ( device && downcast<const legacy_image_device_config_base *>(device)->inline_config() && get_config_dev(device)->device_displayinfo) {
info->f = (genf *) get_config_dev(device)->device_displayinfo;
} else {
info->f = NULL;
}
break;
case DEVINFO_PTR_IMAGE_CREATE_OPTGUIDE: info->p = (void *)floppy_option_guide; break;
case DEVINFO_INT_IMAGE_CREATE_OPTCOUNT:
{

View File

@ -55,6 +55,12 @@ struct floppy_type_t
UINT8 max_density;
};
typedef struct inline_floppy_config_t inline_floppy_config;
struct inline_floppy_config_t
{
device_image_display_info_func device_displayinfo;
};
typedef struct floppy_config_t floppy_config;
struct floppy_config_t
{
@ -242,4 +248,23 @@ extern DEVICE_IMAGE_UNLOAD( floppy );
MCFG_DEVICE_REMOVE(FLOPPY_0) \
MCFG_DEVICE_REMOVE(FLOPPY_1)
#define MCFG_FLOPPY_DRIVE_DISPLAY_INFO(_displayinfo) \
MCFG_DEVICE_CONFIG_DATAPTR(inline_floppy_config, device_displayinfo, DEVICE_IMAGE_DISPLAY_INFO_NAME(_displayinfo))
#define MCFG_FLOPPY_2_DRIVES_DISPLAY_INFO(_displayinfo) \
MCFG_DEVICE_MODIFY(FLOPPY_0) \
MCFG_DEVICE_CONFIG_DATAPTR(inline_floppy_config, device_displayinfo, DEVICE_IMAGE_DISPLAY_INFO_NAME(_displayinfo)) \
MCFG_DEVICE_MODIFY(FLOPPY_1) \
MCFG_DEVICE_CONFIG_DATAPTR(inline_floppy_config, device_displayinfo, DEVICE_IMAGE_DISPLAY_INFO_NAME(_displayinfo))
#define MCFG_FLOPPY_4_DRIVES_DISPLAY_INFO(_displayinfo) \
MCFG_DEVICE_MODIFY(FLOPPY_0) \
MCFG_DEVICE_CONFIG_DATAPTR(inline_floppy_config, device_displayinfo, DEVICE_IMAGE_DISPLAY_INFO_NAME(_displayinfo)) \
MCFG_DEVICE_MODIFY(FLOPPY_1) \
MCFG_DEVICE_CONFIG_DATAPTR(inline_floppy_config, device_displayinfo, DEVICE_IMAGE_DISPLAY_INFO_NAME(_displayinfo)) \
MCFG_DEVICE_MODIFY(FLOPPY_2) \
MCFG_DEVICE_CONFIG_DATAPTR(inline_floppy_config, device_displayinfo, DEVICE_IMAGE_DISPLAY_INFO_NAME(_displayinfo)) \
MCFG_DEVICE_MODIFY(FLOPPY_3) \
MCFG_DEVICE_CONFIG_DATAPTR(inline_floppy_config, device_displayinfo, DEVICE_IMAGE_DISPLAY_INFO_NAME(_displayinfo))
#endif /* __FLOPDRV_H__ */