Previous 15994 Revisions Next

r6254 Monday 2nd November, 2009 at 12:19:43 UTC by Miodrag Milanović
Fixed messram validity check, fixes bug #1879 and problem with mess -validate
[src/mess/devices]messram.c

src/mess/devices/messram.c
r6253r6254
159159   int is_valid = FALSE;
160160   UINT32 specified_ram = 0;
161161   int error = FALSE;
162   const char *gamename_option = NULL;
162163
163164   /* verify default ram value */
164   if (ram_parse_string(config->default_size) == 0)
165   if (config!=NULL && ram_parse_string(config->default_size) == 0)
165166   {
166167      mame_printf_error("%s: '%s' has an invalid default RAM option: %s\n", driver->source_file, driver->name, config->default_size);
167168      error = TRUE;
168169   }
169
170   
170171   /* 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)
172173   {
174      if (mame_options()==NULL) return FALSE;
173175      /* verify command line ram option */
174176      ramsize_string = options_get_string(mame_options(), OPTION_RAMSIZE);
177      gamename_option = options_get_string(mame_options(), OPTION_GAMENAME);
175178
176179      if ((ramsize_string != NULL) && (ramsize_string[0] != '\0'))
177180      {
r6253r6254
182185            mame_printf_error("%s: '%s' cannot recognize the RAM option %s\n", driver->source_file, driver->name, ramsize_string);
183186            error = TRUE;
184187         }
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;
191193
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;
198198
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);
203202
204      astring *buffer = astring_alloc();
205      astring_cpyc(buffer, config->extra_options);
206      astring_replacechr(buffer, ',', 0);
203               s = astring_c(buffer);
207204
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);
209209
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                  }
214215
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;
220218
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 */
222227            is_valid = TRUE;
223
224         s += strlen(s) + 1;
228         }
225229      }
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      }
228235   }
229
236   else
237      is_valid = TRUE;
238           
230239   if (!is_valid)
231240   {
232241      mame_printf_error("%s: '%s' cannot recognize the RAM option %s", driver->source_file, driver->name, ramsize_string);
r6253r6254
241250   }
242251
243252   return error;
253   
244254}
245255
246256

Previous 15994 Revisions Next


© 1998-2018 The MESS Team