# MDP - mdp_error.h: Error Codes

#### Mega Drive Plugins v1.0.0
Revision 0

It can happen that a function doesn't succeed for some reason. MDP provides a full set of error codes that can be used to determine if an error occurred, and to determine what error happened specifically.

MDP uses POSIX notation for return values. That is, a negative return value from any function indicates an error code. For instance, if invalid parameters were passed to an MDP host services function, the function would return the value -MDP_ERR_INVALID_PARAMETERS.

Error codes are split up into various different categories. The high word of an error code indicates the category, and the low word indicates the actual error.

MDP General Errors (category == 0x0000)
Name | Value | Description
--- | --- | ---
MDP_ERR_OK | 0x00000000 | No error occurred.
MDP_ERR_CANNOT_OPEN_DLL | 0x00000001 | The emulator could not open an MDP plugin. Possible reasons include that the plugin was compiled for a different architecture or operating system.
MDP_ERR_NO_MDP_SYMBOL | 0x00000002 | No MDP symbol was found in the plugin.
MDP_ERR_INCORRECT_MAJOR_VERSION | 0x00000003 | The plugin's major MDP interface version number is different than the emulator's major MDP interface version number.
MDP_ERR_DUPLICATE_UUID | 0x00000004 | The plugin's UUID is the same as another plugin that was previously loaded.
MDP_ERR_NEEDS_CPUFLAGS | 0x00000005 | The plugin requires certain CPU features that are not present on the current system.
MDP_ERR_INVALID_LICENSE | 0x00000006 | The plugin's license is not compatible with the emulator.
MDP_ERR_FUNCTION_NOT_IMPLEMENTED | 0x00000101 | A plugin called an MDP Host Services function marked as "No (NULL)" in mdp_host.h, and the emulator does not implement it.
MDP_ERR_INVALID_PARAMETERS | 0x00000102 | Invalid parameters were passed to a function.
MDP_ERR_OUT_OF_MEMORY | 0x00000103 | The emulator ran out of memory.
MDP_ERR_UNKNOWN_PTRID | 0x00000201 | Unused. This is a leftover from MDP v0.1.0.
MDP_ERR_UNKNOWN_VALID | 0x00000202 | An unknown MDP value was requested in mdp_host_t->val_get() or mdp_host_t->val_set(). See MDP_VAL for a list of valid value IDs.
MDP_ERR_VAL_READ_ONLY | 0x00000203 | The plugin attempted to set an MDP value that is marked as read-only.
MDP_ERR_UNSUPPORTED_UI | 0x00000204 | The plugin does not support the current UI subsystem.
MDP_ERR_ROM_NOT_LOADED | 0x00000205 | The plugin attempted to do something that requires a ROM to be loaded, but no ROM is loaded.
MDP_ERR_UNKNOWN | 0x0000FFFF | Unknown error. This should not happen!

MDP Renderer Errors (category == 0x0001)
Name | Value | Description
--- | --- | ---
MDP_ERR_RENDER_DUPLICATE_TAG | 0x00010001 | The plugin attempted to register a renderer with a tag that belongs to a renderer that was previously registered.
MDP_ERR_RENDER_INVALID_RENDERINFO | 0x00010002 | One of two possible meanings: A plugin attempted to register a renderer with no tag. A renderer's blit function received a NULL render information struct.
MDP_ERR_RENDER_UNSUPPORTED_FLAG | 0x00010003 | One of two possible meanings: A renderer has a feature flag that isn't supported by the emulator. The emulator uses a feature flag that isn't supported by the renderer.
MDP_ERR_RENDER_UNSUPPORTED_VMODE | 0x00010004 | The emulator is attempting to use a video mode that isn't supported by the renderer.

MDP Memory Errors (category == 0x0002)
Name | Value | Description
--- | --- | ---
MDP_ERR_MEM_INVALID_MEMID | 0x00020001 | An invalid memory ID was specified.
MDP_ERR_MEM_NOT_ALLOCATED | 0x00020002 | An attempt was made to access a memory area that hasn't been allocated by the emulator, e.g. attempting to read 32X memory when a standard Mega Drive game is running.
MDP_ERR_MEM_OUT_OF_RANGE | 0x00020003 | The specified address and length exceeds the range of the specified memory ID.
MDP_ERR_MEM_NOT_RESIZABLE | 0x00020004 | An attempt was made to resize a memory area that is marked as non-resizable, e.g. Mega Drive main RAM.
MDP_ERR_MEM_UNALIGNED | 0x00020005 | An attempt was made to read or write 16-bit or 32-bit data from or to an unaligned (odd) address.

MDP Register Errors (category == 0x0003)
Name | Value | Description
--- | --- | ---
MDP_ERR_REG_INVALID_ICID | 0x00030001 | An invalid chip ID was specified.
MDP_ERR_REG_INVALID_REGID | 0x00030002 | An invalid register ID was specified.
MDP_ERR_REG_NOT_ALLOCATED | 0x00030003 | The specified chip's registers have not been allocated by the emulator. For example, this may happen if you try to access the SegaCD's 68000's registers while running a standard Mega Drive game.
MDP_ERR_REG_READ_ONLY | 0x00030004 | An attempt was made to write to a read-only register.
MDP_ERR_REG_WRITE_ONLY | 0x00030005 | An attempt was made to read from a write-only register.

MDP Menu Errors (category == 0x0004)
Name | Value | Description
--- | --- | ---
MDP_ERR_MENU_INVALID_MENUID | 0x00040001 | An invalid menu ID was specified.
MDP_ERR_MENU_TOO_MANY_ITEMS | 0x00040002 | The MDP menu system is full. No more menu items can be registered.

MDP Event Errors (category == 0x0005)
Name | Value | Description
--- | --- | ---
MDP_ERR_EVENT_INVALID_EVENTID | 0x00050001 | An invalid event ID was specified.
MDP_ERR_EVENT_NOT_REGISTERED | 0x00050002 | An attempt was made to unregister an event that the plugin didn't register in the first place.
MDP_ERR_EVENT_NOT_REGISTERED | 0x00050002 | An attempt was made to register an event that the plugin already registered.

MDP Window Errors (category == 0x0006)
Name | Value | Description
--- | --- | ---
MDP_ERR_WINDOW_INVALID_WINDOW | 0x00060001 | The specified window is not known to the emulator.
MDP_ERR_WINDOW_ALREADY_REGISTERED | 0x00060002 | An attempt was made to register a window that has already been registered.

MDP Emulator Control Errors (category == 0x0007)
Name | Value | Description
--- | --- | ---
MDP_ERR_WINDOW_INVALID_FUNCTION | 0x00070001 | An invalid function ID was specified.
MDP_ERR_WINDOW_FUNCTION_NOT_IMPLEMENTED | 0x00070002 | The specified function is not implemented in the emulator.

MDP Directory Errors (category == 0x0008)
Name | Value | Description
--- | --- | ---
MDP_ERR_DIR_INVALID_DIRID | 0x00080001 | An invalid directory ID was specified.

MDP Compression Errors (category == 0x0009)
Name | Value | Description
--- | --- | ---
MDP_ERR_Z_ARCHIVE_NOT_FOUND | 0x00090001 | The specified archive was not found.
MDP_ERR_Z_EXE_NOT_FOUND | 0x00090002 | An external program is required in order to open the specified archive, but the external program was not found.
MDP_ERR_Z_ARCHIVE_NOT_SUPPORTED | 0x00090003 | The specified archive is not supported by the emulator.
MDP_ERR_Z_CANT_OPEN_ARCHIVE | 0x00090004 | The archive could not be opened.
MDP_ERR_Z_NO_FILES_IN_ARCHIVE | 0x00090005 | No files were found in the specified archive.
MDP_ERR_Z_FILE_NOT_FOUND_IN_ARCHIVE | 0x00090006 | The requested file was not found in the archive.