src/mess/softlist.c
| r0 | r6928 | |
| 1 | /*************************************************************************** |
| 2 | |
| 3 | softlist.c |
| 4 | |
| 5 | Software list construction helpers. |
| 6 | |
| 7 | |
| 8 | ***************************************************************************/ |
| 9 | |
| 10 | #include "driver.h" |
| 11 | #include "softlist.h" |
| 12 | |
| 13 | |
| 14 | /*------------------------------------------------- |
| 15 | software_list_get_by_name - return a pointer to |
| 16 | a software list given its name. |
| 17 | -------------------------------------------------*/ |
| 18 | const software_list* software_list_get_by_name(const char *name) |
| 19 | { |
| 20 | int listnum; |
| 21 | |
| 22 | /* scan for a match in the list of software lists */ |
| 23 | for ( listnum = 0; software_lists[listnum] != NULL; listnum++ ) |
| 24 | { |
| 25 | if ( mame_stricmp( software_lists[listnum]->name, name ) == 0 ) |
| 26 | { |
| 27 | return software_lists[listnum]; |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | return NULL; |
| 32 | } |
| 33 | |
| 34 | |
| 35 | /*------------------------------------------------- |
| 36 | software_get_by_name - return a pointer to |
| 37 | a software entry list given its name and a |
| 38 | software list. |
| 39 | -------------------------------------------------*/ |
| 40 | |
| 41 | const software_entry* software_get_by_name(const software_list* list, const char *name) |
| 42 | { |
| 43 | int entrynum; |
| 44 | |
| 45 | |
| 46 | /* scan for a match in the software list */ |
| 47 | for ( entrynum = 0; list->entries[entrynum].name != NULL; entrynum++ ) |
| 48 | { |
| 49 | if ( mame_stricmp( list->entries[entrynum].name, name ) == 0 ) |
| 50 | { |
| 51 | return &list->entries[entrynum]; |
| 52 | } |
| 53 | } |
| 54 | return NULL; |
| 55 | } |
| 56 | |
src/mess/softlist.h
| r0 | r6928 | |
| 1 | /********************************************************************* |
| 2 | |
| 3 | softlist.h |
| 4 | |
| 5 | Software entry and software list information. |
| 6 | |
| 7 | *********************************************************************/ |
| 8 | |
| 9 | #ifndef __SOFTLIST_H_ |
| 10 | #define __SOFTLIST_H_ |
| 11 | |
| 12 | #include "romload.h" |
| 13 | |
| 14 | /* ----- software typedef ----- */ |
| 15 | |
| 16 | typedef struct _software_entry software_entry; |
| 17 | struct _software_entry |
| 18 | { |
| 19 | const char * name; /* short name of the software */ |
| 20 | const char * parent; /* parent */ |
| 21 | const char * fullname; /* full name of the software */ |
| 22 | const char * release_date; /* release date */ |
| 23 | const char * manufacturer; /* manufacturer */ |
| 24 | const char * region; /* region (World, USA, Japan, etc) */ |
| 25 | UINT64 userflags; /* freely usable flags, can be used to store things like board type or pcb features */ |
| 26 | UINT32 flags; /* general flags known to the framework */ |
| 27 | const rom_entry *rom_info; /* rom information for the software */ |
| 28 | }; |
| 29 | |
| 30 | |
| 31 | typedef struct _software_list software_list; |
| 32 | struct _software_list |
| 33 | { |
| 34 | const char * name; |
| 35 | const char * description; |
| 36 | const software_entry * entries; |
| 37 | }; |
| 38 | |
| 39 | |
| 40 | /* ----- software macros ----- */ |
| 41 | |
| 42 | #define SOFTWARE_LIST_NAME(name) software_list_##name |
| 43 | #define SOFTWARE_NAME(name) software_##name |
| 44 | #define SOFTWARE_LIST_START(name,desc) \ |
| 45 | static const software_entry SOFTWARE_NAME(name)[]; \ |
| 46 | const software_list SOFTWARE_LIST_NAME(name) = { #name, desc, software_##name }; \ |
| 47 | static const software_entry SOFTWARE_NAME(name)[] = { |
| 48 | |
| 49 | #define SOFTWARE_LIST_END { NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, NULL } }; |
| 50 | |
| 51 | #define SOFTWARE_ROM_NAME(name) software_rom_##name |
| 52 | #define SOFTWARE_START(name) static const rom_entry SOFTWARE_ROM_NAME(name)[] = { |
| 53 | #define SOFTWARE_END ROM_END |
| 54 | |
| 55 | |
| 56 | #define SOFTWARE(name,parent,year,manufacturer,fullname,region,userflags,flags) \ |
| 57 | { #name, #parent, fullname, #year, manufacturer, region, userflags, flags, SOFTWARE_ROM_NAME(name) }, |
| 58 | |
| 59 | |
| 60 | /*************************************************************************** |
| 61 | GLOBAL VARIABLES |
| 62 | ***************************************************************************/ |
| 63 | |
| 64 | extern const software_list * const software_lists[]; |
| 65 | |
| 66 | |
| 67 | /*************************************************************************** |
| 68 | FUNCTION PROTOTYPES |
| 69 | ***************************************************************************/ |
| 70 | |
| 71 | const software_list* software_list_get_by_name(const char *name); |
| 72 | const software_entry* software_get_by_name(const software_list* list, const char *name); |
| 73 | |
| 74 | #endif |
src/mess/messsoft.c
| r0 | r6928 | |
| 1 | /****************************************************************************** |
| 2 | |
| 3 | messsoft.c |
| 4 | |
| 5 | The list of all available software lists. Software lists have to be included |
| 6 | here to be recognized by the executable. |
| 7 | |
| 8 | To save some typing, we use a hack here. This file is recursively #included |
| 9 | twice, with different definitions of the SOFTWARE_LIST() macro. The first |
| 10 | one declares external references to the software lists; the second one builds |
| 11 | an array storing all the software lists. |
| 12 | |
| 13 | ******************************************************************************/ |
| 14 | |
| 15 | #include "driver.h" |
| 16 | #include "softlist.h" |
| 17 | |
| 18 | |
| 19 | #ifndef SOFTWARE_LIST_RECURSIVE |
| 20 | |
| 21 | #define SOFTWARE_LIST_RECURSIVE |
| 22 | |
| 23 | /* step 1: declare all external references */ |
| 24 | #define SOFTWARE_LIST(NAME) extern const software_list software_list_##NAME; |
| 25 | #include "messsoft.c" |
| 26 | |
| 27 | /* step 2: define the software_list[] array */ |
| 28 | #undef SOFTWARE_LIST |
| 29 | #define SOFTWARE_LIST(NAME) &software_list_##NAME, |
| 30 | const software_list * const software_lists[] = |
| 31 | { |
| 32 | #include "messsoft.c" |
| 33 | 0 /* end of array */ |
| 34 | }; |
| 35 | |
| 36 | #else /* SOFTWARE_LIST_RECURSIVE */ |
| 37 | |
| 38 | /****************SOFTWARE LISTS**********************************************/ |
| 39 | |
| 40 | SOFTWARE_LIST( gamepock_cart ) /* Epoch Game Pocket Computer cartridges */ |
| 41 | |
| 42 | #endif /* SOFTWARE_LIST_RECURSIVE */ |