Ejemplo n.º 1
0
 public space_config_vector(u32 count, std.pair <int, address_space_config> data = default) : base(count, data)
 {
 }
Ejemplo n.º 2
0
        //-------------------------------------------------
        //  part_of_mediapath - checks if 'path' is part of
        //  any media path
        //-------------------------------------------------
        bool part_of_mediapath(string path)
        {
            if (m_restrict_to_mediapath == 0)
            {
                return(true);
            }

            for (size_t i = 0U; (m_mediapaths.size() > i) && ((0 > m_restrict_to_mediapath) || (i < (size_t)m_restrict_to_mediapath)); i++)
            {
                m_mediapaths[i].first.reset();

                //if (!m_mediapaths[i].first.next(m_mediapaths[i].second))
                string next;
                var    ret = m_mediapaths[i].first.next(out next);
                m_mediapaths[i] = new std.pair <path_iterator, string>(m_mediapaths[i].first, next);
                if (!ret)
                {
                    return(false);
                }
            }

            string mediapath = "";

            while (true)
            {
                mediapath = "";  //mediapath.clear();
                for (size_t i = 0U; (m_mediapaths.size() > i) && ((0 > m_restrict_to_mediapath) || (i < (size_t)m_restrict_to_mediapath)); i++)
                {
                    mediapath = mediapath.append_(m_mediapaths[i].second);
                    if (!mediapath.empty() && !util.is_directory_separator(mediapath.back()))
                    {
                        mediapath = mediapath.append_(PATH_SEPARATOR);
                    }
                }

                if (path.compare(0, mediapath.size(), mediapath) == 0)
                {
                    LOG(null, "emu_file: path '{0}' matches media path '{1}'\n", path, mediapath);
                    return(true);
                }

                {
                    size_t i = 0U;
                    while ((m_mediapaths.size() > i) && ((0 > m_restrict_to_mediapath) || (i < (size_t)m_restrict_to_mediapath)))
                    {
                        //if (m_mediapaths[i].first.next(m_mediapaths[i].second))
                        string next;
                        var    ret = m_mediapaths[i].first.next(out next);
                        m_mediapaths[i] = new std.pair <path_iterator, string>(m_mediapaths[i].first, next);
                        if (ret)
                        {
                            for (size_t j = 0U; i != j; j++)
                            {
                                m_mediapaths[j].first.reset();

                                //m_mediapaths[j].first.next(m_mediapaths[j].second);
                                string next2;
                                var    ret2 = m_mediapaths[j].first.next(out next2);
                                m_mediapaths[j] = new std.pair <path_iterator, string>(m_mediapaths[j].first, next2);
                            }
                            break;
                        }
                        i++;
                    }

                    if ((m_mediapaths.size() == i) || ((0 <= m_restrict_to_mediapath) && (i == (size_t)m_restrict_to_mediapath)))
                    {
                        LOG(null, "emu_file: path '{0}' not in media path\n", path);
                        return(false);
                    }
                }
            }
        }
Ejemplo n.º 3
0
 //-------------------------------------------------
 //  device_add - configuration helper to add a
 //  new device
 //-------------------------------------------------
 public device_t device_add(string tag, device_type type, u32 clock)
 {
     std.pair <string, device_t> owner = resolve_owner(tag);
     return(add_device(type.create(this, owner.first, owner.second, clock), owner.second));
 }
Ejemplo n.º 4
0
        //-------------------------------------------------
        //  open_next - open the next file that matches
        //  the filename by iterating over paths
        //-------------------------------------------------
        public std.error_condition open_next()
        {
            // if we're open from a previous attempt, close up now
            if (m_file != null)
            {
                close();
            }

            // loop over paths
            LOG(null, "emu_file: open next '{0}'\n", m_filename);
            std.error_condition filerr = std.errc.no_such_file_or_directory;
            while (filerr)
            {
                if (m_first)
                {
                    m_first = false;
                    for (int iIdx = 0; iIdx < m_iterator.Count; iIdx++)  //for (searchpath_vector::value_type &i : m_iterator)
                    {
                        var i = m_iterator[iIdx];
                        i.first.reset();

                        //if (!i.first.next(i.second))
                        string next;
                        var    ret = i.first.next(out next);
                        m_iterator[iIdx] = new std.pair <path_iterator, string>(i.first, next);
                        if (!ret)
                        {
                            return(filerr);
                        }
                    }
                }
                else
                {
                    int iIdx = 0;                    //searchpath_vector::iterator i(m_iterator.begin());
                    while (iIdx != m_iterator.Count) //while (i != m_iterator.end())
                    {
                        var i = m_iterator[iIdx];

                        //if (i->first.next(i->second))
                        string next;
                        var    ret = i.first.next(out next);
                        m_iterator[iIdx] = new std.pair <path_iterator, string>(i.first, next);
                        i = m_iterator[iIdx];
                        if (ret)
                        {
                            LOG(null, "emu_file: next path {0} '{1}'\n", iIdx, i.second); //LOG("emu_file: next path %d '%s'\n", std::distance(m_iterator.begin(), i), i->second);
                            for (int jIdx = 0; iIdx != jIdx; ++jIdx)                      //for (searchpath_vector::iterator j = m_iterator.begin(); i != j; ++j)
                            {
                                var j = m_iterator[jIdx];
                                j.first.reset();

                                //j->first.next(j->second);
                                string jnext;
                                j.first.next(out jnext);
                                m_iterator[jIdx] = new std.pair <path_iterator, string>(j.first, jnext);
                            }
                            break;
                        }
                        ++iIdx;                   //++i;
                    }
                    if (m_iterator.Count == iIdx) //if (m_iterator.end() == i)
                    {
                        return(filerr);
                    }
                }

                // build full path
                m_fullpath = m_fullpath.clear_();
                foreach (var path in m_iterator)  //for (searchpath_vector::value_type const &path : m_iterator)
                {
                    m_fullpath = m_fullpath.append_(path.second);
                    if (!m_fullpath.empty() && !util.is_directory_separator(m_fullpath.back()))
                    {
                        m_fullpath = m_fullpath.append_(PATH_SEPARATOR);
                    }
                }
                m_fullpath = m_fullpath.append_(m_filename);

                // attempt to open the file directly
                LOG(null, "emu_file: attempting to open '{0}' directly\n", m_fullpath);
                filerr = util.core_file.open(m_fullpath, m_openflags, out m_file);

                // if we're opening for read-only we have other options
                if (filerr && ((m_openflags & (OPEN_FLAG_READ | OPEN_FLAG_WRITE)) == OPEN_FLAG_READ))
                {
                    LOG(null, "emu_file: attempting to open '{0}' from archives\n", m_fullpath);
                    filerr = attempt_zipped();
                }
            }

            return(filerr);
        }
Ejemplo n.º 5
0
        //-------------------------------------------------
        //  machine_config - constructor
        //-------------------------------------------------
        public machine_config(game_driver gamedrv, emu_options options)
        {
            m_gamedrv                = gamedrv;
            m_options                = options;
            m_root_device            = null;
            m_default_layouts        = new default_layout_map();  //([] (char const *a, char const *b) { return 0 > std::strcmp(a, b); })
            m_current_device         = null;
            m_maximum_quantums       = new maximum_quantum_map(); //m_maximum_quantums([] (char const *a, char const *b) { return 0 > std::strcmp(a, b); });
            m_perfect_quantum_device = new std.pair <device_t, string>(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_enumerator(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();
                    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_enumerator(root_device()))
            {
                if (!device.configured())
                {
                    device.config_complete();
                }
            }
        }