Table of Contents

device_getinfo

The device_getinfo functions are used by MESS to get additional info about the devices used in a system. They are generally located in the systems/<drivername>.c file.

Syntax

All data that you want to return must be copied into the info union. A switch is used to selected the info MESS wants. Possible states are:

DEVINFO_INT_TYPE

The type of the device. Possible values are:

DEVINFO_INT_READABLE

Boolean value whether this device can read data. Possible values:

DEVINFO_INT_WRITEABLE

Boolean value whether this device can write data. Possible values:

DEVINFO_INT_CREATABLE

Boolean value whether new files can be created for use with this device or not. Possible values:

DEVINFO_INT_COUNT

The number of devices this system can possibly use.

DEVINFO_INT_MUST_BE_LOADED

Boolean value whether this system needs a file attached to this device to boot.

DEVINFO_PTR_LOAD

This is a pointer to the function which is called when the user mounts a new file for use with this device.

DEVINFO_STR_FILE_EXTENSIONS

This is a comma separated list representing the possible file extensions for this device.

Example

This could be the function for a floppy drive:

static void mydriver_floppy_getinfo(const device_class *devclass, UINT32 state, union devinfo *info)
{
	/* floppy */
	switch(state)
	{
		/* --- the following bits of info are returned as 64-bit signed integers --- */
		case DEVINFO_INT_TYPE:            info->i = IO_FLOPPY; break;
		case DEVINFO_INT_READABLE:        info->i = 1; break;
		case DEVINFO_INT_WRITEABLE:       info->i = 1; break;
		case DEVINFO_INT_CREATABLE:       info->i = 1; break;
		case DEVINFO_INT_COUNT:           info->i = 2; break;
 
		/* --- the following bits of info are returned as pointers to data or functions --- */
		case DEVINFO_PTR_LOAD:            info->load = device_load_mydriver_floppy; break;
 
		/* --- the following bits of info are returned as NULL-terminated strings --- */
		case DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "dsk"); break;
	}
}

In this example, we create a device of type IO_FLOPPY, that is readable, writable and creatable. The system supports two floppy drives. The function device_load_mydriver_floppy is called when the user mounts a new file (we don't actually write this function as is, we use the macro DEVICE_LOAD). The file extension is just dsk.

See also