Exemple #1
0
        // construction/destruction

        //-------------------------------------------------
        //  driver_device - constructor
        //-------------------------------------------------

        public driver_device(machine_config mconfig, device_type type, string tag)
            : base(mconfig, type, tag, null, 0)
        {
            m_system        = null;
            m_flip_screen_x = 0;
            m_flip_screen_y = 0;
        }
Exemple #2
0
        favorite_manager m_favorite;    // internal data from inifile.c for favorites


        // construction/destruction
        //-------------------------------------------------
        //  mame_machine_manager - constructor
        //-------------------------------------------------
        mame_machine_manager(emu_options options, osd_interface osd)
            : base(options, osd)
        {
            m_plugins            = new plugin_options();
            m_lua                = new lua_engine();
            m_new_driver_pending = null;
            m_firstrun           = true;
            m_autoboot_timer     = null;
        }
Exemple #3
0
            //using is_transparent = std::true_type;

            //bool operator()(ui_software_info const &lhs, ui_software_info const &rhs) const;

            //bool operator()(ui_software_info const &lhs, game_driver const &rhs) const;
            //bool operator()(game_driver const &lhs, ui_software_info const &rhs) const;
            public static bool op(game_driver lhs, ui_software_info rhs)
            {
                global_object.assert(rhs.driver != null);

                if (rhs.startempty == 0)
                {
                    return(true);
                }
                else
                {
                    return(0 > std.strncmp(lhs.name, rhs.driver.name, lhs.name.Length));
                }
            }
Exemple #4
0
            //using is_transparent = std::true_type;

            //bool operator()(ui_software_info const &lhs, ui_software_info const &rhs) const;

            //bool operator()(ui_software_info const &lhs, game_driver const &rhs) const;
            //bool operator()(game_driver const &lhs, ui_software_info const &rhs) const;
            public static bool op(game_driver lhs, ui_software_info rhs)
            {
                assert(rhs.driver != null);

                if (rhs.startempty == 0)
                {
                    return(true);
                }
                else
                {
                    return(0 > std.strncmp(lhs.name, rhs.driver.name, std.size(lhs.name)));
                }
            }
Exemple #5
0
        string m_string_buffer;  //mutable util::ovectorstream m_string_buffer;


        // construction/destruction

        //-------------------------------------------------
        //  running_machine - constructor
        //-------------------------------------------------
        public running_machine(machine_config _config, machine_manager manager)
        {
            m_side_effects_disabled = 0;
            debug_flags             = 0;
            m_config                 = _config;
            m_system                 = _config.gamedrv();
            m_manager                = manager;
            m_current_phase          = machine_phase.PREINIT;
            m_paused                 = false;
            m_hard_reset_pending     = false;
            m_exit_pending           = false;
            m_soft_reset_timer       = null;
            m_rand_seed              = 0x9d14abd7;
            m_ui_active              = _config.options().ui_active();
            m_basename               = _config.gamedrv().name;
            m_sample_rate            = _config.options().sample_rate();
            m_saveload_schedule      = saveload_schedule.NONE;
            m_saveload_schedule_time = attotime.zero;
            m_saveload_searchpath    = null;

            m_save      = new save_manager(this);
            m_memory    = new memory_manager(this);
            m_ioport    = new ioport_manager(this);
            m_scheduler = new device_scheduler(this);
            m_scheduler.device_scheduler_after_ctor(this);


            for (int i = 0; i < m_notifier_list.Length; i++)
            {
                m_notifier_list[i] = new std.list <notifier_callback_item>();
            }

            m_base_time = 0;

            // set the machine on all devices
            device_enumerator iter = new device_enumerator(root_device());

            foreach (device_t device in iter)
            {
                device.set_machine(this);
            }

            // fetch core options
            if (options().debug())
            {
                debug_flags = (DEBUG_FLAG_ENABLED | DEBUG_FLAG_CALL_HOOK) | (DEBUG_FLAG_OSD_ENABLED);
            }
        }
Exemple #6
0
        //-------------------------------------------------
        //  filter - filter the driver list against the
        //  given driver
        //-------------------------------------------------
        size_t filter(game_driver driver)
        {
            // reset the count
            exclude_all();

            // match name against each driver in the list
            for (size_t index = 0; index < s_driver_count; index++)
            {
                if (s_drivers_sorted[index] == driver)
                {
                    include(index);
                }
            }

            return(m_filtered_count);
        }
Exemple #7
0
        // operations

        //void check_driver(const game_driver &driver);

        //-------------------------------------------------
        //  check_shared_source - check all drivers that
        //  share the same source file as the given driver
        //-------------------------------------------------
        public void check_shared_source(game_driver driver)
        {
            // initialize
            validate_begin();

            // then iterate over all drivers and check the ones that share the same source file
            m_drivlist.reset();
            while (m_drivlist.next())
            {
                if (strcmp(driver.type.source(), m_drivlist.driver().type.source()) == 0)
                {
                    validate_one(m_drivlist.driver());
                }
            }

            // cleanup
            validate_end();
        }
Exemple #8
0
        // getters
        //const game_driver &system() const { assert(m_system != NULL); return *m_system; }


        // inline configuration helpers

        //-------------------------------------------------
        //  set_game_driver - set the game in the device
        //  configuration
        //-------------------------------------------------
        public void set_game_driver(game_driver game)
        {
            assert(m_system == null);

            // set the system
            m_system = game;

            // and set the search path to include all parents
            m_searchpath = game.name;
            std.set <game_driver> seen = new std.set <game_driver>();
            for (int parent = driver_list.clone(game); parent != -1; parent = driver_list.clone(parent))
            {
                if (!seen.insert(driver_list.driver(parent)))  //.second)
                {
                    throw new emu_fatalerror("driver_device::set_game_driver({0}): parent/clone relationships form a loop", game.name);
                }
                m_searchpath += ";" + driver_list.driver(parent).name;
            }
        }
Exemple #9
0
        // construction/destruction

        //-------------------------------------------------
        //  driver_device - constructor
        //-------------------------------------------------

        public driver_device(machine_config mconfig, device_type type, string tag)
            : base(mconfig, type, tag, null, 0)
        {
            m_system        = mconfig.gamedrv();
            m_flip_screen_x = 0;
            m_flip_screen_y = 0;


            // set the search path to include all parents and cache it because devices search system paths
            m_searchpath.emplace_back(m_system.name);
            std.set <game_driver> seen = new std.set <game_driver>();
            for (int ancestor = driver_list.clone(m_system); 0 <= ancestor; ancestor = driver_list.clone((size_t)ancestor))
            {
                if (!seen.insert(driver_list.driver((size_t)ancestor)))
                {
                    throw new emu_fatalerror("driver_device({0}): parent/clone relationships form a loop", m_system.name);
                }
                m_searchpath.emplace_back(driver_list.driver((size_t)ancestor).name);
            }
        }
Exemple #10
0
        //-------------------------------------------------
        //  validity_checker - constructor
        //-------------------------------------------------
        public validity_checker(emu_options options)
        {
            m_drivlist       = new driver_enumerator(options);
            m_errors         = 0;
            m_warnings       = 0;
            m_print_verbose  = options.verbose();
            m_current_driver = null;
            m_current_config = null;
            m_current_device = null;
            m_current_ioport = null;
            m_validate_all   = false;


            // pre-populate the defstr map with all the default strings
            for (int strnum = 1; strnum < (int)INPUT_STRING.INPUT_STRING_COUNT; strnum++)
            {
                string str = ioport_string_from_index((UInt32)strnum);
                if (!string.IsNullOrEmpty(str))
                {
                    m_defstr_map.insert(str, strnum);
                }
            }
        }
Exemple #11
0
        /*-------------------------------------------------
        *   write_config - emit current option statuses as
        *   INI files
        *  -------------------------------------------------*/
        int write_config(emu_options options, string filename, game_driver gamedrv)
        {
            string buffer;
            int    retval = 1;

            if (gamedrv != null)
            {
                buffer   = string.Format("{0}.ini", gamedrv.name);
                filename = buffer;
            }

            emu_file file = new emu_file(options.ini_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE);

            osd_file.error filerr = file.open(filename);
            if (filerr == osd_file.error.NONE)
            {
                string inistring = options.output_ini();
                file.puts(inistring);
                retval = 0;
            }
            file.close();

            return(retval);
        }
Exemple #12
0
        /*-------------------------------------------------
        *   write_config - emit current option statuses as
        *   INI files
        *  -------------------------------------------------*/
        int write_config(emu_options options, string filename, game_driver gamedrv)
        {
            string buffer;
            int    retval = 1;

            if (gamedrv != null)
            {
                sprintf(out buffer, "{0}.ini", gamedrv.name);
                filename = buffer;
            }

            emu_file file = new emu_file(options.ini_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE);

            std.error_condition filerr = file.open(filename);
            if (!filerr)
            {
                string inistring = options.output_ini();
                file.puts(inistring);
                retval = 0;
            }
            file.close();

            return(retval);
        }
Exemple #13
0
 //-------------------------------------------------
 //  mame_schedule_new_driver - schedule a new game to
 //  be loaded
 //-------------------------------------------------
 public void schedule_new_driver(game_driver driver)
 {
     m_new_driver_pending = driver;
 }
Exemple #14
0
        /* execute as configured by the OPTION_SYSTEMNAME option on the specified options */
        //-------------------------------------------------
        //  execute - run the core emulation
        //-------------------------------------------------
        public int execute()
        {
            bool started_empty = false;

            bool firstgame = true;

            // loop across multiple hard resets
            bool exit_pending = false;
            int  error        = EMU_ERR_NONE;

            while (error == EMU_ERR_NONE && !exit_pending)
            {
                m_new_driver_pending = null;

                // if no driver, use the internal empty driver
                game_driver system = mame_options.system(m_options);
                if (system == null)
                {
                    system = ___empty.driver____empty;
                    if (firstgame)
                    {
                        started_empty = true;
                    }
                }

                firstgame = false;

                // parse any INI files as the first thing
                if (m_options.read_config())
                {
                    // but first, revert out any potential game-specific INI settings from previous runs via the internal UI
                    m_options.revert(OPTION_PRIORITY_INI);

                    string errors;
                    mame_options.parse_standard_inis(m_options, out errors);
                }

                // otherwise, perform validity checks before anything else
                bool is_empty = system == ___empty.driver____empty;
                if (!is_empty)
                {
                    validity_checker valid = new validity_checker(m_options, true);
                    valid.set_verbose(false);
                    valid.check_shared_source(system);
                    valid.Dispose();
                }

                // create the machine configuration
                machine_config config = new machine_config(system, m_options);

                // create the machine structure and driver
                running_machine machine = new running_machine(config, this);

                set_machine(machine);

                // run the machine
                error      = machine.run(is_empty);
                m_firstrun = false;

                // check the state of the machine
                if (m_new_driver_pending != null)
                {
                    // set up new system name and adjust device options accordingly
                    m_options.set_system_name(m_new_driver_pending.name);
                    m_firstrun = true;
                }
                else
                {
                    if (machine.exit_pending())
                    {
                        m_options.set_system_name("");
                    }
                }

                if (machine.exit_pending() && (!started_empty || is_empty))
                {
                    exit_pending = true;
                }

                // machine will go away when we exit scope
                machine.Dispose();
                set_machine(null);
            }

            // return an error
            return(error);
        }
Exemple #15
0
 public static int find(game_driver driver)
 {
     return(find(driver.name));
 }
Exemple #16
0
 public static int non_bios_clone(game_driver driver)
 {
     int index = find(driver); assert(index >= 0); return(non_bios_clone((size_t)index));
 }
Exemple #17
0
        // general helpers

        //void set_current(UInt32 index) { assert(index >= -1 && index <= s_driver_count); m_current = index; }

        //-------------------------------------------------
        //  driver_sort_callback - compare two items in
        //  an array of game_driver pointers
        //-------------------------------------------------
        public void find_approximate_matches(string string_, int count, out int [] results)
        {
            //#undef rand

            results = new int [count];

            // if no name, pick random entries
            if (string_.empty())
            {
                // seed the RNG first
                //srand(osd_ticks());
                Random r = new Random((int)m_osdcore.osd_ticks());

                // allocate a temporary list
                std.vector <int> templist = new std.vector <int>(m_filtered_count);
                int arrayindex            = 0;
                for (int index = 0; index < (int)s_driver_count; index++)
                {
                    if (m_included[index])
                    {
                        templist[arrayindex++] = index;
                    }
                }

                assert(arrayindex == (int)m_filtered_count);

                // shuffle
                for (int shufnum = 0; shufnum < (int)(4 * s_driver_count); shufnum++)
                {
                    int item1 = r.Next() % (int)m_filtered_count;
                    int item2 = r.Next() % (int)m_filtered_count;
                    int temp  = templist[item1];
                    templist[item1] = templist[item2];
                    templist[item2] = temp;
                }

                // copy out the first few entries
                for (int matchnum = 0; matchnum < count; matchnum++)
                {
                    results[matchnum] = templist[matchnum % (int)m_filtered_count];
                }
            }
            else
            {
                // allocate memory to track the penalty value
                std.vector <std.pair <double, int> > penalty = new std.vector <std.pair <double, int> >();
                penalty.reserve((size_t)count);
                string search = ustr_from_utf8(normalize_unicode(string_, unicode_normalization_form.D, true));
                string composed;
                string candidate;

                // scan the entire drivers array
                for (int index = 0; index < (int)s_driver_count; index++)
                {
                    if (m_included[index])
                    {
                        // cheat on the shortname as it's always lowercase ASCII
                        game_driver drv     = s_drivers_sorted[index];
                        size_t      namelen = std.strlen(drv.name);
                        //candidate.resize(namelen);
                        candidate = drv.name;  //std.copy_n(drv.name, namelen, candidate.begin());
                        double curpenalty = util.edit_distance(search, candidate);

                        // if it's not a perfect match, try the description
                        if (curpenalty != 0)
                        {
                            candidate = ustr_from_utf8(normalize_unicode(drv.type.fullname(), unicode_normalization_form.D, true));
                            double p = util.edit_distance(search, candidate);
                            if (p < curpenalty)
                            {
                                curpenalty = p;
                            }
                        }

                        // also check "<manufacturer> <description>"
                        if (curpenalty != 0)
                        {
                            composed  = drv.manufacturer;
                            composed += ' ';
                            composed += drv.type.fullname();
                            candidate = ustr_from_utf8(normalize_unicode(composed, unicode_normalization_form.D, true));
                            double p = util.edit_distance(search, candidate);
                            if (p < curpenalty)
                            {
                                curpenalty = p;
                            }
                        }

                        // insert into the sorted table of matches
                        //var it = std.upper_bound(penalty.begin(), penalty.end(), std.make_pair(curpenalty, index));
                        int it;
                        for (it = 0; it < penalty.Count; it++)
                        {
                            if (penalty[it].first > curpenalty)
                            {
                                break;
                            }
                        }

                        if (penalty.Count != it)
                        {
                            if ((int)penalty.size() >= count)
                            {
                                penalty.resize((size_t)count - 1);
                            }

                            penalty.emplace(it, new std.pair <double, int>(curpenalty, index));
                        }
                        else if ((int)penalty.size() < count)
                        {
                            penalty.emplace(it, new std.pair <double, int>(curpenalty, index));
                        }
                    }
                }

                // copy to output and pad with -1
                //std::fill(
                //        std::transform(
                //            penalty.begin(),
                //            penalty.end(),
                //            results,
                //            [] (std::pair<double, int> const &x) { return x.second; }),
                //        results + count,
                //        -1);
                results = new int [penalty.Count];
                for (int i = 0; i < results.Length; i++)
                {
                    results[i] = penalty[i].second;
                }
            }
        }
Exemple #18
0
 public driver_enumerator(emu_options options, game_driver driver)
     : this(options)
 {
     filter(driver);
 }
Exemple #19
0
        //-------------------------------------------------
        //  machine_config - constructor
        //-------------------------------------------------
        public machine_config(game_driver gamedrv, emu_options options)
        {
            m_minimum_quantum = attotime.zero;
            m_gamedrv         = gamedrv;
            m_options         = options;
            m_root_device     = null;
            m_default_layouts = new Dictionary <string, internal_layout>();  //([] (char const *a, char const *b) { return 0 > std::strcmp(a, b); })
            m_current_device  = null;


            // add the root device
            device_add("root", gamedrv.type, 0);

            // intialize slot devices - make sure that any required devices have been allocated
            foreach (device_slot_interface slot in new slot_interface_iterator(root_device()))
            {
                device_t owner            = slot.device();
                string   slot_option_name = owner.tag().Substring(1); // + 1;

                // figure out which device goes into this slot
                bool   has_option = options.has_slot_option(slot_option_name);
                string selval;
                bool   is_default;
                if (!has_option)
                {
                    // The only time we should be getting here is when emuopts.cpp is invoking
                    // us to evaluate slot/image options, and the internal state of emuopts.cpp has
                    // not caught up yet
                    selval     = slot.default_option();
                    is_default = true;
                }
                else
                {
                    slot_option opt = options.slot_option(slot_option_name);
                    selval     = opt.value().c_str();
                    is_default = !opt.specified();
                }

                if (!string.IsNullOrEmpty(selval))
                {
                    // TODO: make this thing more self-contained so it can apply itself - shouldn't need to know all this here
                    device_slot_interface.slot_option option = slot.option(selval);

                    if ((option != null) && (is_default || option.selectable()))
                    {
                        // create the device
                        using (token tok = begin_configuration(owner))
                        {
                            device_t new_dev = device_add(option.name(), option.devtype(), option.clock());
                            slot.set_card_device(new_dev);

                            string default_bios = option.default_bios();
                            if (!string.IsNullOrEmpty(default_bios))
                            {
                                new_dev.set_default_bios_tag(default_bios);
                            }

                            var additions = option.machine_config();
                            if (additions != null)
                            {
                                additions(this, new_dev);
                            }

                            input_device_default [] input_device_defaults = option.input_device_defaults();
                            if (input_device_defaults != null)
                            {
                                new_dev.set_input_default(input_device_defaults);
                            }
                        }
                    }
                    else
                    {
                        throw new emu_fatalerror("Unknown slot option '{0}' in slot '{1}'", selval, owner.tag().Substring(1));
                    }
                }
            }

            // then notify all devices that their configuration is complete
            foreach (device_t device in new device_iterator(root_device()))
            {
                if (!device.configured())
                {
                    device.config_complete();
                }
            }
        }
Exemple #20
0
        //WRITE8_MEMBER( namco_51xx_device::write )
        public void write(address_space space, offs_t offset, u8 data, u8 mem_mask = 0xff)
        {
            data &= 0x07;

            if (VERBOSE)
            {
                logerror("{0}: custom 51XX write {1}\n", machine().describe_context(), data);
            }

            if (m_coincred_mode != 0)
            {
                switch (m_coincred_mode--)
                {
                case 4: m_coins_per_cred[0] = data; break;

                case 3: m_creds_per_coin[0] = data; break;

                case 2: m_coins_per_cred[1] = data; break;

                case 1: m_creds_per_coin[1] = data; break;
                }
            }
            else
            {
                switch (data)
                {
                case 0:     // nop
                    break;

                case 1:     // set coinage
                    m_coincred_mode = 4;
                    /* this is a good time to reset the credits counter */
                    m_credits = 0;

                    {
                        /* kludge for a possible bug in Xevious */
                        //static const game_driver *namcoio_51XX_driver = NULL;
                        //static int namcoio_51XX_kludge = 0;

                        /* Only compute namcoio_51XX_kludge when gamedrv changes */
                        if (write_namcoio_51XX_driver != machine().system())
                        {
                            write_namcoio_51XX_driver = machine().system();
                            if (write_namcoio_51XX_driver.name == "xevious" ||
                                write_namcoio_51XX_driver.parent == "xevious")
                            {
                                write_namcoio_51XX_kludge = 1;
                            }
                            else
                            {
                                write_namcoio_51XX_kludge = 0;
                            }
                        }

                        if (write_namcoio_51XX_kludge != 0)
                        {
                            m_coincred_mode = 6;
                            m_remap_joy     = 1;
                        }
                    }
                    break;

                case 2:     // go in "credits" mode and enable start buttons
                    m_mode     = 1;
                    m_in_count = 0;
                    break;

                case 3:     // disable joystick remapping
                    m_remap_joy = 0;
                    break;

                case 4:     // enable joystick remapping
                    m_remap_joy = 1;
                    break;

                case 5:     // go in "switch" mode
                    m_mode     = 0;
                    m_in_count = 0;
                    break;

                default:
                    logerror("unknown 51XX command {0}\n", data);
                    break;
                }
            }
        }
Exemple #21
0
        //static int compatible_with(UInt32 index) { return find(driver(index).compatible_with); }


        // any item by driver
        public static int clone(game_driver driver)
        {
            int index = find(driver); assert(index >= 0); return(clone(index));
        }
Exemple #22
0
        // parsing wrappers

        //-------------------------------------------------
        //  parse_standard_inis - parse the standard set
        //  of INI files
        //-------------------------------------------------
        public static void parse_standard_inis(emu_options options, out string error_stream, game_driver driver = null)
        {
            error_stream = "";

            // parse the INI file defined by the platform (e.g., "mame.ini")
            // we do this twice so that the first file can change the INI path
            parse_one_ini(options, emulator_info.get_configname(), OPTION_PRIORITY_MAME_INI, ref error_stream);
            parse_one_ini(options, emulator_info.get_configname(), OPTION_PRIORITY_MAME_INI, ref error_stream);

            // debug mode: parse "debug.ini" as well
            if (options.debug())
            {
                parse_one_ini(options, "debug", OPTION_PRIORITY_DEBUG_INI, ref error_stream);
            }

            // if we have a valid system driver, parse system-specific INI files
            game_driver cursystem = driver == null?system(options) : driver;

            if (cursystem == null)
            {
                return;
            }

            // parse "vertical.ini" or "horizont.ini"
            if (((UInt32)cursystem.flags & ORIENTATION_SWAP_XY) != 0)
            {
                parse_one_ini(options, "vertical", OPTION_PRIORITY_ORIENTATION_INI, ref error_stream);
            }
            else
            {
                parse_one_ini(options, "horizont", OPTION_PRIORITY_ORIENTATION_INI, ref error_stream);
            }

            switch (cursystem.flags & machine_flags.type.MASK_TYPE)
            {
            case machine_flags.type.TYPE_ARCADE:
                parse_one_ini(options, "arcade", OPTION_PRIORITY_SYSTYPE_INI, ref error_stream);
                break;

            case machine_flags.type.TYPE_CONSOLE:
                parse_one_ini(options, "console", OPTION_PRIORITY_SYSTYPE_INI, ref error_stream);
                break;

            case machine_flags.type.TYPE_COMPUTER:
                parse_one_ini(options, "computer", OPTION_PRIORITY_SYSTYPE_INI, ref error_stream);
                break;

            case machine_flags.type.TYPE_OTHER:
                parse_one_ini(options, "othersys", OPTION_PRIORITY_SYSTYPE_INI, ref error_stream);
                break;

            default:
                break;
            }

            machine_config config = new machine_config(cursystem, options);

            foreach (screen_device device in new screen_device_iterator(config.root_device()))
            {
                // parse "raster.ini" for raster games
                if (device.screen_type() == screen_type_enum.SCREEN_TYPE_RASTER)
                {
                    parse_one_ini(options, "raster", OPTION_PRIORITY_SCREEN_INI, ref error_stream);
                    break;
                }
                // parse "vector.ini" for vector games
                if (device.screen_type() == screen_type_enum.SCREEN_TYPE_VECTOR)
                {
                    parse_one_ini(options, "vector", OPTION_PRIORITY_SCREEN_INI, ref error_stream);
                    break;
                }
                // parse "lcd.ini" for lcd games
                if (device.screen_type() == screen_type_enum.SCREEN_TYPE_LCD)
                {
                    parse_one_ini(options, "lcd", OPTION_PRIORITY_SCREEN_INI, ref error_stream);
                    break;
                }
            }

            // next parse "source/<sourcefile>.ini"
            string sourcename = core_filename_extract_base(cursystem.type.source(), true).Insert(0, "source" + PATH_SEPARATOR);

            parse_one_ini(options, sourcename, OPTION_PRIORITY_SOURCE_INI, ref error_stream);

            // then parse the grandparent, parent, and system-specific INIs
            int parent  = driver_list.clone(cursystem);
            int gparent = (parent != -1) ? driver_list.clone(parent) : -1;

            if (gparent != -1)
            {
                parse_one_ini(options, driver_list.driver(gparent).name, OPTION_PRIORITY_GPARENT_INI, ref error_stream);
            }
            if (parent != -1)
            {
                parse_one_ini(options, driver_list.driver(parent).name, OPTION_PRIORITY_PARENT_INI, ref error_stream);
            }

            parse_one_ini(options, cursystem.name, OPTION_PRIORITY_DRIVER_INI, ref error_stream);
        }
Exemple #23
0
        // audit operations

        //-------------------------------------------------
        //  audit_media - audit the media described by the
        //  currently-enumerated driver
        //-------------------------------------------------
        public summary audit_media(string validation = AUDIT_VALIDATE_FULL)
        {
            // start fresh
            m_record_list.clear();

            // store validation for later
            m_validation = validation;

            // first walk the parent chain for required ROMs
            parent_rom_vector parentroms = new parent_rom_vector();

            for (var drvindex = driver_list.find(m_enumerator.driver().parent); 0 <= drvindex; drvindex = driver_list.find(driver_list.driver((size_t)drvindex).parent))  //for (auto drvindex = m_enumerator.find(m_enumerator.driver().parent); 0 <= drvindex; drvindex = m_enumerator.find(m_enumerator.driver(drvindex).parent))
            {
                game_driver parent = driver_list.driver((size_t)drvindex);
                LOG(null, "Checking parent {0} for ROM files\n", parent.type.shortname());
                std.vector <rom_entry> roms = rom_build_entries(parent.rom);
                for (Pointer <rom_entry> region = rom_first_region(new Pointer <rom_entry>(roms)); region != null; region = rom_next_region(region)) //for (rom_entry const *region = rom_first_region(&roms.front()); region; region = rom_next_region(region))
                {
                    for (Pointer <rom_entry> rom = rom_first_file(region); rom != null; rom = rom_next_file(rom))                                    //for (rom_entry const *rom = rom_first_file(region); rom; rom = rom_next_file(rom))
                    {
                        LOG(null, "Adding parent ROM {0}\n", rom.op.name());
                        parentroms.emplace_back(new parent_rom(parent.type, rom));
                    }
                }
            }

            parentroms.remove_redundant_parents();

            // count ROMs required/found
            size_t found           = 0;
            size_t required        = 0;
            size_t shared_found    = 0;
            size_t shared_required = 0;
            size_t parent_found    = 0;

            // iterate over devices and regions
            std.vector <string> searchpath = new std.vector <string>();
            foreach (device_t device in new device_enumerator(m_enumerator.config().root_device()))
            {
                searchpath.clear();

                // now iterate over regions and ROMs within
                for (Pointer <rom_entry> region = rom_first_region(device); region != null; region = rom_next_region(region))
                {
                    for (Pointer <rom_entry> rom = rom_first_file(region); rom != null; rom = rom_next_file(rom))
                    {
                        if (searchpath.empty())
                        {
                            LOG(null, "Audit media for device {0}({1})\n", device.shortname(), device.tag());
                            searchpath = device.searchpath();
                        }

                        // look for a matching parent or device ROM
                        string name = rom.op.name();
                        util.hash_collection hashes = new util.hash_collection(rom.op.hashdata());
                        bool        dumped          = !hashes.flag(util.hash_collection.FLAG_NO_DUMP);
                        device_type shared_device   = parentroms.find_shared_device(device, name, hashes, rom_file_size(rom));
                        if (shared_device != null)
                        {
                            LOG(null, "File '{0}' {1}{2}dumped shared with {3}\n", name, ROM_ISOPTIONAL(rom.op) ? "optional " : "", dumped ? "" : "un", shared_device.shortname());
                        }
                        else
                        {
                            LOG(null, "File '{0}' {1}{2}dumped\n", name, ROM_ISOPTIONAL(rom.op) ? "optional " : "", dumped ? "" : "un");
                        }

                        // count the number of files with hashes
                        if (dumped && !ROM_ISOPTIONAL(rom.op))
                        {
                            required++;
                            if (shared_device != null)
                            {
                                shared_required++;
                            }
                        }

                        // audit a file
                        audit_record record = null;
                        if (ROMREGION_ISROMDATA(region.op))
                        {
                            record = audit_one_rom(searchpath, rom);
                        }

                        // audit a disk
                        else if (ROMREGION_ISDISKDATA(region.op))
                        {
                            record = audit_one_disk(rom, device);
                        }

                        if (record != null)
                        {
                            // see if the actual content found belongs to a parent
                            var matchesshared = parentroms.actual_matches_shared(device, record);
                            if (matchesshared.first != null)
                            {
                                LOG(null, "Actual ROM file shared with {0}parent {1}\n", matchesshared.second ? "immediate " : "", matchesshared.first.shortname());
                            }

                            // count the number of files that are found.
                            if ((record.status() == audit_status.GOOD) || ((record.status() == audit_status.FOUND_INVALID) && (matchesshared.first == null)))
                            {
                                found++;
                                if (shared_device != null)
                                {
                                    shared_found++;
                                }
                                if (matchesshared.second)
                                {
                                    parent_found++;
                                }
                            }

                            record.set_shared_device(shared_device);
                        }
                    }
                }
            }

            if (!searchpath.empty())
            {
                LOG(null, "Total required={0} (shared={1}) found={2} (shared={3} parent={4})\n", required, shared_required, found, shared_found, parent_found);
            }

            // if we only find files that are in the parent & either the set has no unique files or the parent is not found, then assume we don't have the set at all
            if ((found == shared_found) && required != 0 && ((required != shared_required) || parent_found == 0))
            {
                m_record_list.clear();
                return(summary.NOTFOUND);
            }

            // return a summary
            return(summarize(m_enumerator.driver().name));
        }
Exemple #24
0
        //-------------------------------------------------
        //  validate_drivers - master validity checker
        //-------------------------------------------------
        void validate_one(game_driver driver)
        {
            // help verbose validation detect configuration-related crashes
            if (m_print_verbose)
            {
                output_via_delegate(osd_output_channel.OSD_OUTPUT_CHANNEL_ERROR, "Validating driver {0} ({1})...\n", driver.name, core_filename_extract_base(driver.type.source()).c_str());
            }

            // set the current driver
            m_current_driver = driver;
            m_current_config = null;
            m_current_device = null;
            m_current_ioport = null;
            m_region_map.clear();

            // reset error/warning state
            int start_errors   = m_errors;
            int start_warnings = m_warnings;

            m_error_text   = "";
            m_warning_text = "";
            m_verbose_text = "";

            // wrap in try/except to catch fatalerrors
            try
            {
                machine_config config = new machine_config(driver, m_blank_options);
                m_current_config = config;
                validate_driver();
                validate_roms(m_current_config.root_device());
                validate_inputs();
                validate_devices();
                m_current_config = null;
            }
            catch (emu_fatalerror err)
            {
                osd_printf_error("Fatal error {0}", err.str());
            }


            // if we had warnings or errors, output
            if (m_errors > start_errors || m_warnings > start_warnings || !string.IsNullOrEmpty(m_verbose_text))
            {
                if (!m_print_verbose)
                {
                    output_via_delegate(osd_output_channel.OSD_OUTPUT_CHANNEL_ERROR, "Driver {0} (file {1}): {2} errors, {3} warnings\n", driver.name, core_filename_extract_base(driver.type.source()), m_errors - start_errors, m_warnings - start_warnings);
                }

                output_via_delegate(osd_output_channel.OSD_OUTPUT_CHANNEL_ERROR, "{0} errors, {1} warnings\n", m_errors - start_errors, m_warnings - start_warnings);

                if (m_errors > start_errors)
                {
                    output_indented_errors(m_error_text, "Errors");
                }
                if (m_warnings > start_warnings)
                {
                    output_indented_errors(m_warning_text, "Warnings");
                }
                if (!string.IsNullOrEmpty(m_verbose_text))
                {
                    output_indented_errors(m_verbose_text, "Messages");
                }

                output_via_delegate(osd_output_channel.OSD_OUTPUT_CHANNEL_ERROR, "\n");
            }

            // reset the driver/device
            m_current_driver = null;
            m_current_config = null;
            m_current_device = null;
            m_current_ioport = null;
        }
Exemple #25
0
        // add
        //void add_favorite_system(game_driver const &driver);
        //void add_favorite_software(ui_software_info const &swinfo);
        //void add_favorite(running_machine &machine);


        // check
        public bool is_favorite_system(game_driver driver)
        {
            return(check_impl(driver));
        }