src/mess/devices/messram.c
| r6253 | r6254 | |
| 159 | 159 | int is_valid = FALSE; |
| 160 | 160 | UINT32 specified_ram = 0; |
| 161 | 161 | int error = FALSE; |
| 162 | const char *gamename_option = NULL; |
| 162 | 163 | |
| 163 | 164 | /* verify default ram value */ |
| 164 | | if (ram_parse_string(config->default_size) == 0) |
| 165 | if (config!=NULL && ram_parse_string(config->default_size) == 0) |
| 165 | 166 | { |
| 166 | 167 | mame_printf_error("%s: '%s' has an invalid default RAM option: %s\n", driver->source_file, driver->name, config->default_size); |
| 167 | 168 | error = TRUE; |
| 168 | 169 | } |
| 169 | | |
| 170 | |
| 170 | 171 | /* command line options are only parsed for the device named "messram" */ |
| 171 | | if (strcmp(device->tag, "messram") == 0) |
| 172 | if (device->tag!=NULL && strcmp(device->tag, "messram") == 0) |
| 172 | 173 | { |
| 174 | if (mame_options()==NULL) return FALSE; |
| 173 | 175 | /* verify command line ram option */ |
| 174 | 176 | ramsize_string = options_get_string(mame_options(), OPTION_RAMSIZE); |
| 177 | gamename_option = options_get_string(mame_options(), OPTION_GAMENAME); |
| 175 | 178 | |
| 176 | 179 | if ((ramsize_string != NULL) && (ramsize_string[0] != '\0')) |
| 177 | 180 | { |
| r6253 | r6254 | |
| 182 | 185 | mame_printf_error("%s: '%s' cannot recognize the RAM option %s\n", driver->source_file, driver->name, ramsize_string); |
| 183 | 186 | error = TRUE; |
| 184 | 187 | } |
| 185 | | } |
| 186 | | else |
| 187 | | { |
| 188 | | /* not specifying the ramsize on the command line is valid as well */ |
| 189 | | is_valid = TRUE; |
| 190 | | } |
| 188 | if (gamename_option!=NULL && strlen(gamename_option) > 0 && strcmp(gamename_option, driver->name) == 0) |
| 189 | { |
| 190 | /* compare command line option to default value */ |
| 191 | if (ram_parse_string(config->default_size) == specified_ram) |
| 192 | is_valid = TRUE; |
| 191 | 193 | |
| 192 | | /* compare command line option to default value */ |
| 193 | | if (ram_parse_string(config->default_size) == specified_ram) |
| 194 | | is_valid = TRUE; |
| 195 | | } |
| 196 | | else |
| 197 | | is_valid = TRUE; |
| 194 | /* verify extra ram options */ |
| 195 | if (config->extra_options != NULL) |
| 196 | { |
| 197 | const char *s; |
| 198 | 198 | |
| 199 | | /* verify extra ram options */ |
| 200 | | if (config->extra_options != NULL) |
| 201 | | { |
| 202 | | const char *s; |
| 199 | astring *buffer = astring_alloc(); |
| 200 | astring_cpyc(buffer, config->extra_options); |
| 201 | astring_replacechr(buffer, ',', 0); |
| 203 | 202 | |
| 204 | | astring *buffer = astring_alloc(); |
| 205 | | astring_cpyc(buffer, config->extra_options); |
| 206 | | astring_replacechr(buffer, ',', 0); |
| 203 | s = astring_c(buffer); |
| 207 | 204 | |
| 208 | | s = astring_c(buffer); |
| 205 | /* try to parse each option */ |
| 206 | while(*s != '\0') |
| 207 | { |
| 208 | UINT32 option_ram_size = ram_parse_string(s); |
| 209 | 209 | |
| 210 | | /* try to parse each option */ |
| 211 | | while(*s != '\0') |
| 212 | | { |
| 213 | | UINT32 option_ram_size = ram_parse_string(s); |
| 210 | if (option_ram_size == 0) |
| 211 | { |
| 212 | mame_printf_error("%s: '%s' has an invalid RAM option: %s\n", driver->source_file, driver->name, s); |
| 213 | error = TRUE; |
| 214 | } |
| 214 | 215 | |
| 215 | | if (option_ram_size == 0) |
| 216 | | { |
| 217 | | mame_printf_error("%s: '%s' has an invalid RAM option: %s\n", driver->source_file, driver->name, s); |
| 218 | | error = TRUE; |
| 219 | | } |
| 216 | if (option_ram_size == specified_ram) |
| 217 | is_valid = TRUE; |
| 220 | 218 | |
| 221 | | if (option_ram_size == specified_ram) |
| 219 | s += strlen(s) + 1; |
| 220 | } |
| 221 | |
| 222 | astring_free(buffer); |
| 223 | } |
| 224 | |
| 225 | } else { |
| 226 | /* if not for this driver then return ok */ |
| 222 | 227 | is_valid = TRUE; |
| 223 | | |
| 224 | | s += strlen(s) + 1; |
| 228 | } |
| 225 | 229 | } |
| 226 | | |
| 227 | | astring_free(buffer); |
| 230 | else |
| 231 | { |
| 232 | /* not specifying the ramsize on the command line is valid as well */ |
| 233 | is_valid = TRUE; |
| 234 | } |
| 228 | 235 | } |
| 229 | | |
| 236 | else |
| 237 | is_valid = TRUE; |
| 238 | |
| 230 | 239 | if (!is_valid) |
| 231 | 240 | { |
| 232 | 241 | mame_printf_error("%s: '%s' cannot recognize the RAM option %s", driver->source_file, driver->name, ramsize_string); |
| r6253 | r6254 | |
| 241 | 250 | } |
| 242 | 251 | |
| 243 | 252 | return error; |
| 253 | |
| 244 | 254 | } |
| 245 | 255 | |
| 246 | 256 | |