Attached emu_options to the machine_config, and the running_machine

inherits it now.
This commit is contained in:
Aaron Giles 2011-03-10 10:17:30 +00:00
parent a6b4399f9d
commit 04c9a546b5
12 changed files with 54 additions and 55 deletions

View File

@ -24,7 +24,7 @@
static void audit_one_rom(emu_options &options, const rom_entry *rom, const char *regiontag, const game_driver *gamedrv, const char *validation, audit_record *record);
static void audit_one_disk(emu_options &options, const rom_entry *rom, const game_driver *gamedrv, const char *validation, audit_record *record);
static int rom_used_by_parent(const game_driver *gamedrv, const hash_collection &romhashes, const game_driver **parent);
static int rom_used_by_parent(emu_options &options, const game_driver *gamedrv, const hash_collection &romhashes, const game_driver **parent);
@ -56,7 +56,7 @@ INLINE void set_status(audit_record *record, UINT8 status, UINT8 substatus)
int audit_images(emu_options &options, const game_driver *gamedrv, const char *validation, audit_record **audit)
{
machine_config config(*gamedrv);
machine_config config(*gamedrv, options);
const rom_entry *region, *rom;
const rom_source *source;
audit_record *record;
@ -80,7 +80,7 @@ int audit_images(emu_options &options, const game_driver *gamedrv, const char *v
if (!hashes.flag(hash_collection::FLAG_NO_DUMP))
{
anyrequired = TRUE;
if (allshared && !rom_used_by_parent(gamedrv, hashes, NULL))
if (allshared && !rom_used_by_parent(options, gamedrv, hashes, NULL))
allshared = FALSE;
}
}
@ -122,7 +122,7 @@ int audit_images(emu_options &options, const game_driver *gamedrv, const char *v
continue;
}
if (source_is_gamedrv && record->status != AUDIT_STATUS_NOT_FOUND && (allshared || !rom_used_by_parent(gamedrv, record->exphashes, NULL)))
if (source_is_gamedrv && record->status != AUDIT_STATUS_NOT_FOUND && (allshared || !rom_used_by_parent(options, gamedrv, record->exphashes, NULL)))
anyfound = TRUE;
record++;
@ -151,7 +151,7 @@ int audit_images(emu_options &options, const game_driver *gamedrv, const char *v
int audit_samples(emu_options &options, const game_driver *gamedrv, audit_record **audit)
{
machine_config config(*gamedrv);
machine_config config(*gamedrv, options);
audit_record *record;
int records = 0;
int sampnum;
@ -385,7 +385,7 @@ static void audit_one_rom(emu_options &options, const rom_entry *rom, const char
set_status(record, AUDIT_STATUS_NOT_FOUND, SUBSTATUS_NOT_FOUND_OPTIONAL);
/* not found and used by parent */
else if (rom_used_by_parent(gamedrv, record->exphashes, &parent))
else if (rom_used_by_parent(options, gamedrv, record->exphashes, &parent))
set_status(record, AUDIT_STATUS_NOT_FOUND, (parent->flags & GAME_IS_BIOS_ROOT) ? SUBSTATUS_NOT_FOUND_BIOS : SUBSTATUS_NOT_FOUND_PARENT);
/* just plain old not found */
@ -496,14 +496,14 @@ static void audit_one_disk(emu_options &options, const rom_entry *rom, const gam
ROM is also used by the parent
-------------------------------------------------*/
static int rom_used_by_parent(const game_driver *gamedrv, const hash_collection &romhashes, const game_driver **parent)
static int rom_used_by_parent(emu_options &options, const game_driver *gamedrv, const hash_collection &romhashes, const game_driver **parent)
{
const game_driver *drv;
/* iterate up the parent chain */
for (drv = driver_get_clone(gamedrv); drv != NULL; drv = driver_get_clone(drv))
{
machine_config config(*drv);
machine_config config(*drv, options);
const rom_entry *region;
const rom_entry *rom;

View File

@ -373,7 +373,7 @@ static void display_help(void)
void cli_info_listxml(emu_options &options, const char *gamename)
{
print_mame_xml(stdout, drivers, gamename);
print_mame_xml(stdout, drivers, gamename, options);
}
@ -524,7 +524,7 @@ void cli_info_listcrc(emu_options &options, const char *gamename)
for (int drvindex = 0; drivers[drvindex] != NULL; drvindex++)
if (mame_strwildcmp(gamename, drivers[drvindex]->name) == 0)
{
machine_config config(*drivers[drvindex]);
machine_config config(*drivers[drvindex], options);
const rom_entry *region, *rom;
const rom_source *source;
@ -562,7 +562,7 @@ void cli_info_listroms(emu_options &options, const char *gamename)
for (int drvindex = 0; drivers[drvindex] != NULL; drvindex++)
if (mame_strwildcmp(gamename, drivers[drvindex]->name) == 0)
{
machine_config config(*drivers[drvindex]);
machine_config config(*drivers[drvindex], options);
/* print the header */
if (count > 0)
@ -626,7 +626,7 @@ void cli_info_listsamples(emu_options &options, const char *gamename)
for (int drvindex = 0; drivers[drvindex] != NULL; drvindex++)
if (mame_strwildcmp(gamename, drivers[drvindex]->name) == 0)
{
machine_config config(*drivers[drvindex]);
machine_config config(*drivers[drvindex], options);
const device_config_sound_interface *sound = NULL;
/* find samples interfaces */
@ -664,7 +664,7 @@ void cli_info_listdevices(emu_options &options, const char *gamename)
for (int drvindex = 0; drivers[drvindex] != NULL; drvindex++)
if (mame_strwildcmp(gamename, drivers[drvindex]->name) == 0)
{
machine_config config(*drivers[drvindex]);
machine_config config(*drivers[drvindex], options);
if (count != 0)
printf("\n");
@ -800,7 +800,7 @@ static void info_listsoftware(emu_options &options, const char *gamename)
if ( mame_strwildcmp( gamename, drivers[drvindex]->name ) == 0 )
{
/* allocate the machine config */
machine_config config(*drivers[drvindex]);
machine_config config(*drivers[drvindex], options);
for (const device_config *dev = config.m_devicelist.first(SOFTWARE_LIST); dev != NULL; dev = dev->typenext())
{
@ -882,7 +882,7 @@ static void info_listsoftware(emu_options &options, const char *gamename)
if ( mame_strwildcmp( gamename, drivers[drvindex]->name ) == 0 )
{
/* allocate the machine config */
machine_config config(*drivers[drvindex]);
machine_config config(*drivers[drvindex], options);
for (const device_config *dev = config.m_devicelist.first(SOFTWARE_LIST); dev != NULL; dev = dev->typenext())
{
@ -1134,7 +1134,7 @@ static void info_listmedia(emu_options &options, const char *gamename)
if (mame_strwildcmp(gamename, drivers[drvindex]->name) == 0)
{
/* allocate the machine config */
machine_config config(*drivers[drvindex]);
machine_config config(*drivers[drvindex], options);
driver_name = drivers[drvindex]->name;
@ -1514,7 +1514,7 @@ static void match_roms(emu_options &options, const hash_collection &hashes, int
/* iterate over drivers */
for (int drvindex = 0; drivers[drvindex] != NULL; drvindex++)
{
machine_config config(*drivers[drvindex]);
machine_config config(*drivers[drvindex], options);
/* iterate over sources, regions and files within the region */
for (const rom_source *source = rom_first_source(config); source != NULL; source = rom_next_source(*source))

View File

@ -221,7 +221,7 @@ void emu_options::add_device_options()
return;
// create the configuration
machine_config config(*cursystem);
machine_config config(*cursystem, *this);
// iterate through all image devices
const device_config_image_interface *image = NULL;
@ -330,7 +330,7 @@ void emu_options::parse_standard_inis(astring &error_string)
// parse "vector.ini" for vector games
{
machine_config config(*cursystem);
machine_config config(*cursystem, *this);
for (const screen_device_config *devconfig = config.first_screen(); devconfig != NULL; devconfig = devconfig->next_screen())
if (devconfig->screen_type() == SCREEN_TYPE_VECTOR)
{

View File

@ -40,7 +40,7 @@ public:
const game_driver *drv;
machine_config mconfig;
parent_info(const game_driver *drv) : mconfig(*drv)
parent_info(const game_driver *drv, emu_options &options) : mconfig(*drv, options)
{
this->drv = drv;
}
@ -497,7 +497,7 @@ static void print_game_rom(FILE *out, const game_driver *game, const machine_con
for (; clone_of != NULL; clone_of = driver_get_clone(clone_of))
{
assert_always(parents < ARRAY_LENGTH(pinfoarray), "too many parents");
pinfoarray[parents++] = global_alloc(parent_info(clone_of));
pinfoarray[parents++] = global_alloc(parent_info(clone_of, config.options()));
}
/* iterate over 3 different ROM "types": BIOS, ROMs, DISKs */
@ -1038,10 +1038,10 @@ static void print_game_ramoptions(FILE *out, const game_driver *game, const mach
for one particular game driver
-------------------------------------------------*/
static void print_game_info(FILE *out, const game_driver *game)
static void print_game_info(FILE *out, const game_driver *game, emu_options &options)
{
const game_driver *clone_of;
machine_config config(*game);
machine_config config(*game, options);
ioport_list portlist;
const char *start;
@ -1127,7 +1127,7 @@ static void print_game_info(FILE *out, const game_driver *game)
for all known games
-------------------------------------------------*/
void print_mame_xml(FILE *out, const game_driver *const games[], const char *gamename)
void print_mame_xml(FILE *out, const game_driver *const games[], const char *gamename, emu_options &options)
{
int drvnum;
@ -1274,7 +1274,7 @@ void print_mame_xml(FILE *out, const game_driver *const games[], const char *gam
for (drvnum = 0; games[drvnum] != NULL; drvnum++)
if (mame_strwildcmp(gamename, games[drvnum]->name) == 0)
print_game_info(out, games[drvnum]);
print_game_info(out, games[drvnum], options);
fprintf(out, "</" XML_ROOT ">\n");
}

View File

@ -20,7 +20,7 @@
***************************************************************************/
/* print the MAME database in XML format */
void print_mame_xml(FILE* out, const game_driver* const games[], const char *gamename);
void print_mame_xml(FILE* out, const game_driver* const games[], const char *gamename, emu_options &options);
#endif /* __INFO_H__ */

View File

@ -138,7 +138,7 @@ static char giant_string_buffer[65536] = { 0 };
// running_machine - constructor
//-------------------------------------------------
running_machine::running_machine(const machine_config &_config, osd_interface &osd, emu_options &options, bool exit_to_game_select)
running_machine::running_machine(const machine_config &_config, osd_interface &osd, bool exit_to_game_select)
: m_regionlist(m_respool),
m_devicelist(m_respool),
config(&_config),
@ -152,7 +152,7 @@ running_machine::running_machine(const machine_config &_config, osd_interface &o
colortable(NULL),
shadow_table(NULL),
priority_bitmap(NULL),
sample_rate(options.sample_rate()),
sample_rate(_config.options().sample_rate()),
debug_flags(0),
ui_active(false),
memory_data(NULL),
@ -169,7 +169,6 @@ running_machine::running_machine(const machine_config &_config, osd_interface &o
m_logerror_list(NULL),
m_state(*this),
m_scheduler(*this),
m_options(options),
m_osd(osd),
m_basename(_config.gamedrv().name),
m_current_phase(MACHINE_PHASE_PREINIT),
@ -216,8 +215,8 @@ running_machine::running_machine(const machine_config &_config, osd_interface &o
}
// fetch core options
if (m_options.debug())
debug_flags = (DEBUG_FLAG_ENABLED | DEBUG_FLAG_CALL_HOOK) | (m_options.debug_internal() ? 0 : DEBUG_FLAG_OSD_ENABLED);
if (options().debug())
debug_flags = (DEBUG_FLAG_ENABLED | DEBUG_FLAG_CALL_HOOK) | (options().debug_internal() ? 0 : DEBUG_FLAG_OSD_ENABLED);
}
@ -328,12 +327,12 @@ void running_machine::start()
m_devicelist.start_all();
// if we're coming in with a savegame request, process it now
const char *savegame = m_options.state();
const char *savegame = options().state();
if (savegame[0] != 0)
schedule_load(savegame);
// if we're in autosave mode, schedule a load
else if (m_options.autosave() && (m_game.flags & GAME_SUPPORTS_SAVE) != 0)
else if (options().autosave() && (m_game.flags & GAME_SUPPORTS_SAVE) != 0)
schedule_load("auto");
// set up the cheat engine
@ -359,7 +358,7 @@ int running_machine::run(bool firstrun)
m_current_phase = MACHINE_PHASE_INIT;
// if we have a logfile, set up the callback
if (m_options.log())
if (options().log())
{
m_logfile = auto_alloc(this, emu_file(OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS));
file_error filerr = m_logfile->open("error.log");
@ -445,9 +444,9 @@ int running_machine::run(bool firstrun)
void running_machine::schedule_exit()
{
// if we are in-game but we started with the select game menu, return to that instead
if (m_exit_to_game_select && m_options.system_name()[0] != 0)
if (m_exit_to_game_select && options().system_name()[0] != 0)
{
m_options.set_system_name("");
options().set_system_name("");
ui_menu_force_game_select(this, &render().ui_container());
}
@ -459,7 +458,7 @@ void running_machine::schedule_exit()
m_scheduler.eat_all_cycles();
// if we're autosaving on exit, schedule a save as well
if (m_options.autosave() && (m_game.flags & GAME_SUPPORTS_SAVE) && this->time() > attotime::zero)
if (options().autosave() && (m_game.flags & GAME_SUPPORTS_SAVE) && this->time() > attotime::zero)
schedule_save("auto");
}
@ -525,7 +524,7 @@ void running_machine::set_saveload_filename(const char *filename)
}
else
{
m_saveload_searchpath = m_options.state_directory();
m_saveload_searchpath = options().state_directory();
m_saveload_pending_file.cpy(basename()).cat(PATH_SEPARATOR).cat(filename).cat(".sta");
}
}

View File

@ -323,7 +323,7 @@ class running_machine : public bindable_object
public:
// construction/destruction
running_machine(const machine_config &config, osd_interface &osd, emu_options &options, bool exit_to_game_select = false);
running_machine(const machine_config &config, osd_interface &osd, bool exit_to_game_select = false);
~running_machine();
// fetch items by name
@ -337,7 +337,7 @@ public:
// getters
const char *basename() const { return m_basename; }
emu_options &options() const { return m_options; }
emu_options &options() const { return m_config.options(); }
machine_phase phase() const { return m_current_phase; }
bool paused() const { return m_paused || (m_current_phase != MACHINE_PHASE_RUNNING); }
bool scheduled_event_pending() const { return m_exit_pending || m_hard_reset_pending; }
@ -477,7 +477,6 @@ private:
state_manager m_state; // state manager
device_scheduler m_scheduler; // scheduler object
emu_options & m_options;
osd_interface & m_osd;
astring m_context; // context string

View File

@ -177,30 +177,28 @@ int mame_execute(emu_options &options, osd_interface &osd)
}
// create the machine configuration
const machine_config *config = global_alloc(machine_config(*system));
machine_config config(*system, options);
// create the machine structure and driver
running_machine *machine = global_alloc(running_machine(*config, osd, options, started_empty));
running_machine machine(config, osd, started_empty);
// looooong term: remove this
global_machine = machine;
global_machine = &machine;
// run the machine
error = machine->run(firstrun);
error = machine.run(firstrun);
firstrun = false;
// check the state of the machine
if (machine->new_driver_pending())
if (machine.new_driver_pending())
{
options.set_system_name(machine->new_driver_name());
options.set_system_name(machine.new_driver_name());
firstrun = true;
}
if (machine->exit_pending())
if (machine.exit_pending())
exit_pending = true;
// destroy the machine and the config
global_free(machine);
global_free(config);
// machine will go away when we exit scope
global_machine = NULL;
}

View File

@ -49,7 +49,7 @@
// machine_config - constructor
//-------------------------------------------------
machine_config::machine_config(const game_driver &gamedrv)
machine_config::machine_config(const game_driver &gamedrv, emu_options &options)
: m_minimum_quantum(attotime::zero),
m_perfect_cpu_quantum(NULL),
m_watchdog_vblank_count(0),
@ -61,6 +61,7 @@ machine_config::machine_config(const game_driver &gamedrv)
m_total_colors(0),
m_default_layout(NULL),
m_gamedrv(gamedrv),
m_options(options),
m_parse_level(0)
{
// construct the config

View File

@ -126,13 +126,14 @@ class machine_config
public:
// construction/destruction
machine_config(const game_driver &gamedrv);
machine_config(const game_driver &gamedrv, emu_options &options);
~machine_config();
// getters
const game_driver &gamedrv() const { return m_gamedrv; }
const device_config *first_device() const { return m_devicelist.first(); }
screen_device_config *first_screen() const;
emu_options &options() const { return m_options; }
// public state
attotime m_minimum_quantum; // minimum scheduling quantum
@ -158,6 +159,7 @@ public:
private:
const game_driver & m_gamedrv;
emu_options & m_options;
int m_parse_level; // nested parsing level
};

View File

@ -1114,7 +1114,7 @@ chd_error open_disk_image(emu_options &options, const game_driver *gamedrv, cons
hash_collection romphashes(ROM_GETHASHDATA(romp));
for (drv = gamedrv; drv != NULL; drv = driver_get_clone(drv))
{
machine_config config(*drv);
machine_config config(*drv, options);
for (source = rom_first_source(config); source != NULL; source = rom_next_source(*source))
for (region = rom_first_region(*source); region != NULL; region = rom_next_region(region))
if (ROMREGION_ISDISKDATA(region))

View File

@ -1199,7 +1199,7 @@ void validate_drivers(emu_options &options, const game_driver *curdriver)
{
/* expand the machine driver */
expansion -= get_profile_ticks();
machine_config config(driver);
machine_config config(driver, options);
expansion += get_profile_ticks();
/* validate the driver entry */