Previous 15994 Revisions Next

r1329 Saturday 24th November, 2007 at 22:58:35 UTC by Nathan Woods
1. Cleaned up MESS validity checks; added a check for recursive compatible_with

2. [BBCBC] Fixed bug #1436
[src/mess]mesvalid.c
[src/mess/drivers]bbcbc.c

src/mess/mesvalid.c
r1328r1329
1414#include "inputx.h"
1515
1616
17/*************************************
18 *
19 *  Validate devices
20 *
21 *************************************/
22
1723static int validate_device(const device_class *devclass)
1824{
1925   int error = 0;
r1328r1329
178184
179185
180186
187static int validate_driver_devices(const game_driver *drv)
188{
189   int error = 0;
190   int i;
191   struct SystemConfigurationParamBlock cfg;
192   device_getinfo_handler handlers[64];
193   device_class devclass;
194   int count_overrides[sizeof(handlers) / sizeof(handlers[0])];
195
196   if (drv->sysconfig_ctor)
197   {
198      memset(&cfg, 0, sizeof(cfg));
199      memset(handlers, 0, sizeof(handlers));
200      cfg.device_slotcount = sizeof(handlers) / sizeof(handlers[0]);
201      cfg.device_handlers = handlers;
202      cfg.device_countoverrides = count_overrides;
203      drv->sysconfig_ctor(&cfg);
204
205      for (i = 0; handlers[i]; i++)
206      {
207         devclass.gamedrv = drv;
208         devclass.get_info = handlers[i];
209
210         error = validate_device(&devclass) || error;
211      }
212   }
213   return error;
214}
215
216
217
218/*************************************
219 *
220 *  Validate compatibility chain
221 *
222 *************************************/
223
224static int validate_compatibility_chain(const game_driver *drv)
225{
226   int error = 0;
227   const game_driver *next_drv;
228   const game_driver *other_drv;
229   const char *compatible_with;
230
231   /* normalize drv->compatible_with */
232   compatible_with = drv->compatible_with;
233   if ((compatible_with != NULL) && !strcmp(compatible_with, "0"))
234      compatible_with = NULL;
235
236   /* check for this driver being compatible with a non-existant driver */
237   if ((compatible_with != NULL) && (driver_get_name(drv->compatible_with) == NULL))
238   {
239      mame_printf_error("%s: is compatible with %s, which is not in drivers[]\n", drv->name, drv->compatible_with);
240      error = 1;
241   }
242
243   /* check for clone_of and compatible_with being specified at the same time */
244   if ((driver_get_clone(drv) != NULL) && (compatible_with != NULL))
245   {
246      mame_printf_error("%s: both compatible_with and clone_of are specified\n", drv->name);
247      error = 1;
248   }
249
250   /* look for recursive compatibility */
251   while(!error && (drv != NULL))
252   {
253      /* identify the next driver */
254      next_drv = mess_next_compatible_driver(drv);
255
256      /* find any recursive dependencies on the current driver */
257      for (other_drv = next_drv; other_drv != NULL; other_drv = mess_next_compatible_driver(other_drv))
258      {
259         if (drv == other_drv)
260         {
261            mame_printf_error("%s: recursive compatibility\n", drv->name);
262            error = 1;
263            break;
264         }
265      }
266
267      /* advance to next driver */
268      drv = next_drv;
269   }
270
271   return error;
272}
273
274
275
276
277/*************************************
278 *
279 *  MESS validity checks
280 *
281 *************************************/
282
181283int mess_validitychecks(void)
182284{
183   int i, j;
285   int i;
184286   int error = 0;
185287   iodevice_t devtype;
186   const struct IODevice *devices;
187288   const char *name;
188289   input_port_entry *inputports = NULL;
189290   extern int device_valididtychecks(void);
190291   extern const char *mess_default_text[];
191   struct SystemConfigurationParamBlock cfg;
192   device_getinfo_handler handlers[64];
193   int count_overrides[sizeof(handlers) / sizeof(handlers[0])];
194   device_class devclass;
195292
196293   /* make sure that all of the UI_* strings are set for all devices */
197294   for (devtype = 0; devtype < IO_COUNT; devtype++)
r1328r1329
207304   /* MESS specific driver validity checks */
208305   for (i = 0; drivers[i]; i++)
209306   {
210      devices = devices_allocate(drivers[i]);
211
212      /* make sure that there are no clones that reference nonexistant drivers */
213      if (driver_get_clone(drivers[i]))
214      {
215         if (driver_get_name(drivers[i]->compatible_with) != NULL)
216         {
217            mame_printf_error("%s: both compatible_with and clone_of are specified\n", drivers[i]->name);
218            error = 1;
219         }
220
221         for (j = 0; drivers[j]; j++)
222         {
223            if (driver_get_clone(drivers[i]) == drivers[j])
224               break;
225         }
226         if (!drivers[j])
227         {
228            mame_printf_error("%s: is a clone of %s, which is not in drivers[]\n", drivers[i]->name, driver_get_clone(drivers[i])->name);
229            error = 1;
230         }
231      }
232
233      /* make sure that there are no clones that reference nonexistant drivers */
234      if (driver_get_name(drivers[i]->compatible_with) != NULL)
235      {
236         for (j = 0; drivers[j]; j++)
237         {
238            if (driver_get_name(drivers[i]->compatible_with) == drivers[j])
239               break;
240         }
241         if (!drivers[j])
242         {
243            mame_printf_error("%s: is compatible with %s, which is not in drivers[]\n", drivers[i]->name, drivers[i]->compatible_with);
244            error = 1;
245         }
246      }
247
248307      /* check devices */
249      if (drivers[i]->sysconfig_ctor)
250      {
251         memset(&cfg, 0, sizeof(cfg));
252         memset(handlers, 0, sizeof(handlers));
253         cfg.device_slotcount = sizeof(handlers) / sizeof(handlers[0]);
254         cfg.device_handlers = handlers;
255         cfg.device_countoverrides = count_overrides;
256         drivers[i]->sysconfig_ctor(&cfg);
308      error = validate_driver_devices(drivers[i]) || error;
257309
258         for (j = 0; handlers[j]; j++)
259         {
260            devclass.gamedrv = drivers[i];
261            devclass.get_info = handlers[j];
310      /* check compatibility chain */
311      error = validate_compatibility_chain(drivers[i]) || error;
262312
263            if (validate_device(&devclass))
264               error = 1;
265         }
266      }
267
268313      /* check system config */
269314      ram_option_count(drivers[i]);
270315
271316      /* make sure that our input system likes this driver */
272      if (inputx_validitycheck(drivers[i], &inputports))
273         error = 1;
274
275      devices_free(devices);
276      devices = NULL;
317      error = inputx_validitycheck(drivers[i], &inputports) || error;
277318   }
278319
279320   /* call other validity checks */
280   if (inputx_validitycheck(NULL, &inputports))
281      error = 1;
282   if (device_valididtychecks())
283      error = 1;
321   error = inputx_validitycheck(NULL, &inputports) || error;
322   error = device_valididtychecks() || error;
284323
285   /* now that we are completed, re-expand the actual driver to compensate
286    * for the tms9928a hack */
287   if (Machine && Machine->gamedrv)
288   {
289      machine_config drv;
290      expand_machine_driver(Machine->gamedrv->drv, &drv);
291   }
292
293324   return error;
294325}
src/mess/drivers/bbcbc.c
r1328r1329
8888ROM_END
8989 
9090SYSTEM_CONFIG_START( bbcbc )
91    CONFIG_DEVICE(cartslot_device_getinfo)
91    CONFIG_DEVICE(cartslot_device_getinfo)
9292SYSTEM_CONFIG_END
9393 
9494/***************************************************************************
r1328r1329
9898***************************************************************************/
9999 
100100/*   YEAR  NAME  PARENT  COMPAT  MACHINE INPUT  INIT  CONFIG  COMPANY  FULLNAME  FLAGS */
101CONS(1985, bbcbc,     0, bbcbc,  bbcbc,  bbcbc, 0,    bbcbc,  "BBC",   "Bridge Companion", GAME_NOT_WORKING )
101CONS(1985, bbcbc,     0, 0,      bbcbc,  bbcbc, 0,    bbcbc,  "BBC",   "Bridge Companion", GAME_NOT_WORKING )
102102 

Previous 15994 Revisions Next


© 1998-2018 The MESS Team