mirror of
https://github.com/holub/mame
synced 2025-04-21 07:52:35 +03:00
Removed expand_machine_driver().
Replaced with machine_config_alloc() and machine_config_free(). Updated all call sites. Normalized info.c style and simplified some of the code.
This commit is contained in:
parent
07290e4c0e
commit
3e34860ccc
@ -120,18 +120,17 @@ int audit_images(core_options *options, const game_driver *gamedrv, UINT32 valid
|
||||
|
||||
int audit_samples(core_options *options, const game_driver *gamedrv, audit_record **audit)
|
||||
{
|
||||
machine_config config;
|
||||
machine_config *config = machine_config_alloc(gamedrv->drv);
|
||||
audit_record *record;
|
||||
int sndnum, sampnum;
|
||||
int records = 0;
|
||||
|
||||
/* count the number of sample records attached to this driver */
|
||||
expand_machine_driver(gamedrv->drv, &config);
|
||||
#if HAS_SAMPLES
|
||||
for (sndnum = 0; sndnum < ARRAY_LENGTH(config.sound); sndnum++)
|
||||
if (config.sound[sndnum].type == SOUND_SAMPLES)
|
||||
for (sndnum = 0; sndnum < ARRAY_LENGTH(config->sound); sndnum++)
|
||||
if (config->sound[sndnum].type == SOUND_SAMPLES)
|
||||
{
|
||||
const struct Samplesinterface *intf = (const struct Samplesinterface *)config.sound[sndnum].config;
|
||||
const struct Samplesinterface *intf = (const struct Samplesinterface *)config->sound[sndnum].config;
|
||||
|
||||
if (intf->samplenames != NULL)
|
||||
{
|
||||
@ -145,7 +144,7 @@ int audit_samples(core_options *options, const game_driver *gamedrv, audit_recor
|
||||
|
||||
/* if no records, just quit now */
|
||||
if (records == 0)
|
||||
return records;
|
||||
goto skip;
|
||||
|
||||
/* allocate memory for the records */
|
||||
*audit = malloc_or_die(sizeof(**audit) * records);
|
||||
@ -153,10 +152,10 @@ int audit_samples(core_options *options, const game_driver *gamedrv, audit_recor
|
||||
record = *audit;
|
||||
|
||||
/* now iterate over sample entries */
|
||||
for (sndnum = 0; sndnum < ARRAY_LENGTH(config.sound); sndnum++)
|
||||
if (config.sound[sndnum].type == SOUND_SAMPLES)
|
||||
for (sndnum = 0; sndnum < ARRAY_LENGTH(config->sound); sndnum++)
|
||||
if (config->sound[sndnum].type == SOUND_SAMPLES)
|
||||
{
|
||||
const struct Samplesinterface *intf = (const struct Samplesinterface *)config.sound[sndnum].config;
|
||||
const struct Samplesinterface *intf = (const struct Samplesinterface *)config->sound[sndnum].config;
|
||||
const char *sharedname = NULL;
|
||||
|
||||
if (intf->samplenames != NULL)
|
||||
@ -197,6 +196,8 @@ int audit_samples(core_options *options, const game_driver *gamedrv, audit_recor
|
||||
}
|
||||
}
|
||||
|
||||
skip:
|
||||
machine_config_free(config);
|
||||
return records;
|
||||
}
|
||||
|
||||
|
@ -558,17 +558,14 @@ int cli_info_listsamples(core_options *options, const char *gamename)
|
||||
for (drvindex = 0; drivers[drvindex]; drvindex++)
|
||||
if (mame_strwildcmp(gamename, drivers[drvindex]->name) == 0)
|
||||
{
|
||||
machine_config drv;
|
||||
machine_config *config = machine_config_alloc(drivers[drvindex]->drv);
|
||||
int sndnum;
|
||||
|
||||
/* expand the machine driver */
|
||||
expand_machine_driver(drivers[drvindex]->drv, &drv);
|
||||
|
||||
/* find samples interfaces */
|
||||
for (sndnum = 0; sndnum < MAX_SOUND && drv.sound[sndnum].type != SOUND_DUMMY; sndnum++)
|
||||
if (drv.sound[sndnum].type == SOUND_SAMPLES)
|
||||
for (sndnum = 0; sndnum < MAX_SOUND && config->sound[sndnum].type != SOUND_DUMMY; sndnum++)
|
||||
if (config->sound[sndnum].type == SOUND_SAMPLES)
|
||||
{
|
||||
const char *const *samplenames = ((const struct Samplesinterface *)drv.sound[sndnum].config)->samplenames;
|
||||
const char *const *samplenames = ((const struct Samplesinterface *)config->sound[sndnum].config)->samplenames;
|
||||
int sampnum;
|
||||
|
||||
/* if the list is legit, walk it and print the sample info */
|
||||
@ -578,6 +575,7 @@ int cli_info_listsamples(core_options *options, const char *gamename)
|
||||
}
|
||||
|
||||
count++;
|
||||
machine_config_free(config);
|
||||
}
|
||||
|
||||
/* clean up our tracked resources */
|
||||
|
@ -43,26 +43,44 @@ static int penalty_compare(const char *source, const char *target);
|
||||
***************************************************************************/
|
||||
|
||||
/*-------------------------------------------------
|
||||
expand_machine_driver - construct a machine
|
||||
driver from the macroized state
|
||||
machine_config_alloc - allocate a new
|
||||
machine configuration and populate it using
|
||||
the supplied constructor
|
||||
-------------------------------------------------*/
|
||||
|
||||
void expand_machine_driver(void (*constructor)(machine_config *), machine_config *output)
|
||||
machine_config *machine_config_alloc(void (*constructor)(machine_config *))
|
||||
{
|
||||
/* initialize the tag on the first screen */
|
||||
memset(output, 0, sizeof(*output));
|
||||
output->watchdog_time = attotime_zero;
|
||||
|
||||
/* keeping this function allows us to pre-init the driver before constructing it */
|
||||
(*constructor)(output);
|
||||
machine_config *config;
|
||||
|
||||
/* allocate a new configuration object */
|
||||
config = malloc_or_die(sizeof(*config));
|
||||
if (config == NULL)
|
||||
return NULL;
|
||||
memset(config, 0, sizeof(*config));
|
||||
|
||||
/* call the function to construct the data */
|
||||
(*constructor)(config);
|
||||
|
||||
/* if no screen tagged, tag screen 0 as main */
|
||||
if (output->screen[0].tag == NULL && output->screen[0].defstate.format != BITMAP_FORMAT_INVALID)
|
||||
output->screen[0].tag = "main";
|
||||
if (config->screen[0].tag == NULL && config->screen[0].defstate.format != BITMAP_FORMAT_INVALID)
|
||||
config->screen[0].tag = "main";
|
||||
|
||||
/* if no screens, set a dummy refresh for the main screen */
|
||||
if (output->screen[0].tag == NULL)
|
||||
output->screen[0].defstate.refresh = HZ_TO_ATTOSECONDS(60);
|
||||
if (config->screen[0].tag == NULL)
|
||||
config->screen[0].defstate.refresh = HZ_TO_ATTOSECONDS(60);
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
machine_config_free - release memory allocated
|
||||
for a machine configuration
|
||||
-------------------------------------------------*/
|
||||
|
||||
void machine_config_free(machine_config *config)
|
||||
{
|
||||
free(config);
|
||||
}
|
||||
|
||||
|
||||
|
@ -572,7 +572,8 @@ extern const game_driver driver_empty;
|
||||
FUNCTION PROTOTYPES
|
||||
***************************************************************************/
|
||||
|
||||
void expand_machine_driver(void (*constructor)(machine_config *), machine_config *output);
|
||||
machine_config *machine_config_alloc(void (*constructor)(machine_config *));
|
||||
void machine_config_free(machine_config *config);
|
||||
|
||||
cpu_config *driver_add_cpu(machine_config *machine, const char *tag, cpu_type type, int cpuclock);
|
||||
cpu_config *driver_find_cpu(machine_config *machine, const char *tag);
|
||||
|
776
src/emu/info.c
776
src/emu/info.c
File diff suppressed because it is too large
Load Diff
@ -16,7 +16,13 @@
|
||||
|
||||
#include "mamecore.h"
|
||||
|
||||
/* Print the MAME database in XML format */
|
||||
|
||||
/***************************************************************************
|
||||
FUNCTION PROTOTYPES
|
||||
***************************************************************************/
|
||||
|
||||
/* print the MAME database in XML format */
|
||||
void print_mame_xml(FILE* out, const game_driver* const games[], const char *gamename);
|
||||
|
||||
|
||||
#endif /* __INFO_H__ */
|
||||
|
@ -1329,15 +1329,14 @@ void mame_parse_ini_files(core_options *options, const game_driver *driver)
|
||||
{
|
||||
const game_driver *parent = driver_get_clone(driver);
|
||||
const game_driver *gparent = (parent != NULL) ? driver_get_clone(parent) : NULL;
|
||||
machine_config *config;
|
||||
astring *sourcename;
|
||||
machine_config drv;
|
||||
|
||||
/* expand the machine driver to look at the info */
|
||||
expand_machine_driver(driver->drv, &drv);
|
||||
|
||||
/* parse "vector.ini" for vector games */
|
||||
if (drv.video_attributes & VIDEO_TYPE_VECTOR)
|
||||
config = machine_config_alloc(driver->drv);
|
||||
if (config->video_attributes & VIDEO_TYPE_VECTOR)
|
||||
parse_ini_file(options, "vector");
|
||||
machine_config_free(config);
|
||||
|
||||
/* next parse "source/<sourcefile>.ini"; if that doesn't exist, try <sourcefile>.ini */
|
||||
sourcename = core_filename_extract_base(astring_alloc(), driver->source_file, TRUE);
|
||||
@ -1411,11 +1410,8 @@ static running_machine *create_machine(const game_driver *driver)
|
||||
|
||||
/* initialize the driver-related variables in the machine */
|
||||
machine->gamedrv = driver;
|
||||
machine->drv = malloc(sizeof(*machine->drv));
|
||||
if (machine->drv == NULL)
|
||||
goto error;
|
||||
machine->basename = mame_strdup(machine->gamedrv->name);
|
||||
expand_machine_driver(machine->gamedrv->drv, (machine_config *)machine->drv);
|
||||
machine->basename = mame_strdup(driver->name);
|
||||
machine->drv = machine_config_alloc(driver->drv);
|
||||
|
||||
/* allocate the driver data */
|
||||
if (machine->drv->driver_data_size != 0)
|
||||
@ -1430,7 +1426,7 @@ error:
|
||||
if (machine->driver_data != NULL)
|
||||
free(machine->driver_data);
|
||||
if (machine->drv != NULL)
|
||||
free((machine_config *)machine->drv);
|
||||
machine_config_free((machine_config *)machine->drv);
|
||||
if (machine->mame_data != NULL)
|
||||
free(machine->mame_data);
|
||||
if (machine != NULL)
|
||||
@ -1499,7 +1495,7 @@ static void destroy_machine(running_machine *machine)
|
||||
if (machine->driver_data != NULL)
|
||||
free(machine->driver_data);
|
||||
if (machine->drv != NULL)
|
||||
free((machine_config *)machine->drv);
|
||||
machine_config_free((machine_config *)machine->drv);
|
||||
if (machine->mame_data != NULL)
|
||||
free(machine->mame_data);
|
||||
if (machine->basename != NULL)
|
||||
|
@ -1422,7 +1422,7 @@ int mame_validitychecks(const game_driver *curdriver)
|
||||
{
|
||||
const game_driver *driver = drivers[drivnum];
|
||||
UINT32 region_length[REGION_MAX];
|
||||
machine_config drv;
|
||||
machine_config *config;
|
||||
|
||||
/* ASG -- trying this for a while to see if submission failures increase */
|
||||
#if 1
|
||||
@ -1433,43 +1433,45 @@ int mame_validitychecks(const game_driver *curdriver)
|
||||
|
||||
/* expand the machine driver */
|
||||
expansion -= osd_profiling_ticks();
|
||||
expand_machine_driver(driver->drv, &drv);
|
||||
config = machine_config_alloc(driver->drv);
|
||||
expansion += osd_profiling_ticks();
|
||||
|
||||
/* validate the driver entry */
|
||||
driver_checks -= osd_profiling_ticks();
|
||||
error = validate_driver(drivnum, &drv) || error;
|
||||
error = validate_driver(drivnum, config) || error;
|
||||
driver_checks += osd_profiling_ticks();
|
||||
|
||||
/* validate the ROM information */
|
||||
rom_checks -= osd_profiling_ticks();
|
||||
error = validate_roms(drivnum, &drv, region_length) || error;
|
||||
error = validate_roms(drivnum, config, region_length) || error;
|
||||
rom_checks += osd_profiling_ticks();
|
||||
|
||||
/* validate the CPU information */
|
||||
cpu_checks -= osd_profiling_ticks();
|
||||
error = validate_cpu(drivnum, &drv, region_length) || error;
|
||||
error = validate_cpu(drivnum, config, region_length) || error;
|
||||
cpu_checks += osd_profiling_ticks();
|
||||
|
||||
/* validate the display */
|
||||
display_checks -= osd_profiling_ticks();
|
||||
error = validate_display(drivnum, &drv) || error;
|
||||
error = validate_display(drivnum, config) || error;
|
||||
display_checks += osd_profiling_ticks();
|
||||
|
||||
/* validate the graphics decoding */
|
||||
gfx_checks -= osd_profiling_ticks();
|
||||
error = validate_gfx(drivnum, &drv, region_length) || error;
|
||||
error = validate_gfx(drivnum, config, region_length) || error;
|
||||
gfx_checks += osd_profiling_ticks();
|
||||
|
||||
/* validate input ports */
|
||||
input_checks -= osd_profiling_ticks();
|
||||
error = validate_inputs(drivnum, &drv, &inputports) || error;
|
||||
error = validate_inputs(drivnum, config, &inputports) || error;
|
||||
input_checks += osd_profiling_ticks();
|
||||
|
||||
/* validate sounds and speakers */
|
||||
sound_checks -= osd_profiling_ticks();
|
||||
error = validate_sound(drivnum, &drv) || error;
|
||||
error = validate_sound(drivnum, config) || error;
|
||||
sound_checks += osd_profiling_ticks();
|
||||
|
||||
machine_config_free(config);
|
||||
}
|
||||
|
||||
#ifdef MESS
|
||||
|
Loading…
Reference in New Issue
Block a user