trunk/src/emu/ui/imginfo.c
| r242874 | r242875 | |
| 42 | 42 | |
| 43 | 43 | void ui_menu_image_info::populate() |
| 44 | 44 | { |
| 45 | | astring tempstring; |
| 46 | | image_info_astring(machine(), tempstring); |
| 47 | | item_append(tempstring, NULL, MENU_FLAG_MULTILINE, NULL); |
| 45 | item_append(machine().system().description, NULL, MENU_FLAG_DISABLE, NULL); |
| 46 | item_append("", NULL, MENU_FLAG_DISABLE, NULL); |
| 47 | |
| 48 | image_interface_iterator iter(machine().root_device()); |
| 49 | for (device_image_interface *image = iter.first(); image != NULL; image = iter.next()) |
| 50 | image_info(image); |
| 48 | 51 | } |
| 49 | 52 | |
| 50 | 53 | |
| r242874 | r242875 | |
| 60 | 63 | |
| 61 | 64 | |
| 62 | 65 | //------------------------------------------------- |
| 63 | | // stripspace |
| 66 | // image_info - display image info for a specific |
| 67 | // image interface device |
| 64 | 68 | //------------------------------------------------- |
| 65 | 69 | |
| 66 | | static char *stripspace(const char *src) |
| 70 | void ui_menu_image_info::image_info(device_image_interface *image) |
| 67 | 71 | { |
| 68 | | static char buff[512]; |
| 69 | | if( src ) |
| 72 | if (image->exists()) |
| 70 | 73 | { |
| 71 | | char *dst; |
| 72 | | while( *src && isspace(*src) ) |
| 73 | | src++; |
| 74 | | strcpy(buff, src); |
| 75 | | dst = buff + strlen(buff); |
| 76 | | while( dst >= buff && isspace(*--dst) ) |
| 77 | | *dst = '\0'; |
| 78 | | return buff; |
| 79 | | } |
| 80 | | return NULL; |
| 81 | | } |
| 74 | // display device type and filename |
| 75 | item_append(image->brief_instance_name(), image->basename(), 0, NULL); |
| 82 | 76 | |
| 83 | | |
| 84 | | //------------------------------------------------- |
| 85 | | // strip_extension |
| 86 | | //------------------------------------------------- |
| 87 | | |
| 88 | | static char *strip_extension(const char *filename) |
| 89 | | { |
| 90 | | char *newname; |
| 91 | | char *c; |
| 92 | | |
| 93 | | // NULL begets NULL |
| 94 | | if (!filename) |
| 95 | | return NULL; |
| 96 | | |
| 97 | | // allocate space for it |
| 98 | | newname = (char *) malloc(strlen(filename) + 1); |
| 99 | | if (!newname) |
| 100 | | return NULL; |
| 101 | | |
| 102 | | // copy in the name |
| 103 | | strcpy(newname, filename); |
| 104 | | |
| 105 | | // search backward for a period, failing if we hit a slash or a colon |
| 106 | | for (c = newname + strlen(newname) - 1; c >= newname; c--) |
| 107 | | { |
| 108 | | // if we hit a period, NULL terminate and break |
| 109 | | if (*c == '.') |
| 77 | // if image has been loaded through softlist, let's add some more info |
| 78 | if (image->software_entry()) |
| 110 | 79 | { |
| 111 | | *c = 0; |
| 112 | | break; |
| 113 | | } |
| 80 | astring string; |
| 114 | 81 | |
| 115 | | // if we hit a slash or colon just stop |
| 116 | | if (*c == '\\' || *c == '/' || *c == ':') |
| 117 | | break; |
| 118 | | } |
| 82 | // display long filename |
| 83 | item_append(image->longname(), "", MENU_FLAG_DISABLE, NULL); |
| 84 | |
| 85 | // display manufacturer and year |
| 86 | string.catprintf("%s, %s", image->manufacturer(), image->year()); |
| 87 | item_append(string, "", MENU_FLAG_DISABLE, NULL); |
| 119 | 88 | |
| 120 | | return newname; |
| 121 | | } |
| 122 | | |
| 123 | | |
| 124 | | //------------------------------------------------- |
| 125 | | // image_info_astring - populate an allocated |
| 126 | | // string with the image info text |
| 127 | | //------------------------------------------------- |
| 128 | | |
| 129 | | void ui_menu_image_info::image_info_astring(running_machine &machine, astring &string) |
| 130 | | { |
| 131 | | string.printf("%s\n\n", machine.system().description); |
| 132 | | |
| 133 | | #if 0 |
| 134 | | if (mess_ram_size > 0) |
| 135 | | { |
| 136 | | char buf2[RAM_STRING_BUFLEN]; |
| 137 | | string.catprintf("RAM: %s\n\n", ram_string(buf2, mess_ram_size)); |
| 138 | | } |
| 139 | | #endif |
| 140 | | |
| 141 | | image_interface_iterator iter(machine.root_device()); |
| 142 | | for (device_image_interface *image = iter.first(); image != NULL; image = iter.next()) |
| 143 | | { |
| 144 | | const char *name = image->filename(); |
| 145 | | if (name != NULL) |
| 146 | | { |
| 147 | | const char *base_filename; |
| 148 | | const char *info; |
| 149 | | char *base_filename_noextension; |
| 150 | | |
| 151 | | base_filename = image->basename(); |
| 152 | | base_filename_noextension = strip_extension(base_filename); |
| 153 | | |
| 154 | | // display device type and filename |
| 155 | | string.catprintf("%s: %s\n", image->device().name(), base_filename); |
| 156 | | |
| 157 | | // display long filename, if present and doesn't correspond to name |
| 158 | | info = image->longname(); |
| 159 | | if (info && (!base_filename_noextension || core_stricmp(info, base_filename_noextension))) |
| 160 | | string.catprintf("%s\n", info); |
| 161 | | |
| 162 | | // display manufacturer, if available |
| 163 | | info = image->manufacturer(); |
| 164 | | if (info != NULL) |
| 89 | // display supported information, if available |
| 90 | switch (image->supported()) |
| 165 | 91 | { |
| 166 | | string.catprintf("%s", info); |
| 167 | | info = stripspace(image->year()); |
| 168 | | if (info && *info) |
| 169 | | string.catprintf(", %s", info); |
| 170 | | string.catprintf("\n"); |
| 92 | case SOFTWARE_SUPPORTED_NO: |
| 93 | item_append("Not supported", "", MENU_FLAG_DISABLE, NULL); |
| 94 | break; |
| 95 | case SOFTWARE_SUPPORTED_PARTIAL: |
| 96 | item_append("Partially supported", "", MENU_FLAG_DISABLE, NULL); |
| 97 | break; |
| 98 | default: |
| 99 | break; |
| 171 | 100 | } |
| 172 | | |
| 173 | | // display supported information, if available |
| 174 | | switch(image->supported()) { |
| 175 | | case SOFTWARE_SUPPORTED_NO : string.catprintf("Not supported\n"); break; |
| 176 | | case SOFTWARE_SUPPORTED_PARTIAL : string.catprintf("Partially supported\n"); break; |
| 177 | | default : break; |
| 178 | | } |
| 179 | | |
| 180 | | if (base_filename_noextension != NULL) |
| 181 | | free(base_filename_noextension); |
| 182 | 101 | } |
| 183 | | else |
| 184 | | { |
| 185 | | string.catprintf("%s: ---\n", image->device().name()); |
| 186 | | } |
| 187 | 102 | } |
| 103 | else |
| 104 | item_append(image->brief_instance_name(), "[empty]", 0, NULL); |
| 105 | item_append("", NULL, MENU_FLAG_DISABLE, NULL); |
| 188 | 106 | } |