コード例 #1
0
        //-------------------------------------------------
        //  save drivers infos to file
        //-------------------------------------------------
        //void init_sorted_list()


        //-------------------------------------------------
        //  load drivers infos from file
        //-------------------------------------------------
        bool load_available_machines()
        {
            // try to load available drivers from file
            emu_file file = new emu_file(ui().options().ui_path(), OPEN_FLAG_READ);

            if (file.open(emulator_info.get_configname() + "_avail.ini"))
            {
                return(false);
            }

            string rbuf;  //char rbuf[MAX_CHAR_INFO];
            string readbuf;

            file.gets(out rbuf, MAX_CHAR_INFO);
            file.gets(out rbuf, MAX_CHAR_INFO);
            readbuf = chartrimcarriage(rbuf);
            string a_rev = string_format("{0}{1}", UI_VERSION_TAG, bare_build_version);

            // version not matching ? exit
            if (a_rev != readbuf)
            {
                file.close();
                return(false);
            }

            // load available list
            std.unordered_set <string> available = new std.unordered_set <string>();
            while (file.gets(out rbuf, MAX_CHAR_INFO) != null)
            {
                readbuf = rbuf.Trim();                      //readbuf = strtrimspace(rbuf);

                if (readbuf.empty() || ('#' == readbuf[0])) // ignore empty lines and line comments
                {
                }
                else if ('[' == readbuf[0]) // throw out the rest of the file if we find a section heading
                {
                    break;
                }
                else
                {
                    available.emplace(readbuf);
                }
            }
            file.close();

            // turn it into the sorted system list we all love
            foreach (ui_system_info info in m_persistent_data.sorted_list())
            {
                var  it    = available.find(info.driver.name);
                bool found = it;
                info.available = found;
                if (found)
                {
                    available.erase(info.driver.name);
                }
            }

            return(true);
        }
コード例 #2
0
ファイル: inifile.cs プロジェクト: kwanboy/mcs
        // load games from category
        public void load_ini_category(UInt32 file, UInt32 category, std.unordered_set <game_driver> result)
        {
            string   filename = m_ini_index[(int)file].Key;
            emu_file fp       = new emu_file(m_options.categoryini_path(), OPEN_FLAG_READ);

            if (fp.open(filename) != osd_file.error.NONE)
            {
                osd_printf_error("Failed to open category file {0} for reading\n", filename.c_str());
                return;
            }

            Int64 offset = m_ini_index[(int)file].Value[(int)category].Value;

            if (fp.seek(offset, emu_file.SEEK_SET) != 0 || (fp.tell() != (UInt64)offset))
            {
                fp.close();
                osd_printf_error("Failed to seek to category offset in file {0}\n", filename.c_str());
                return;
            }

            string rbuf;  // char rbuf[MAX_CHAR_INFO];

            while (fp.gets(out rbuf, utils_global.MAX_CHAR_INFO) != null && !string.IsNullOrEmpty(rbuf) && ('[' != rbuf[0]))
            {
                //var tail = std::find_if(std::begin(rbuf), std::prev(std::end(rbuf)));//, [] (char ch) { return !ch || ('\r' == ch) || ('\n' == ch); });
                //*tail = '\0';
                var tail = rbuf.IndexOfAny("\r\n".ToCharArray());
                rbuf = rbuf.Substring(tail);
                int dfind = driver_list.find(rbuf);
                if (0 <= dfind)
                {
                    result.emplace(driver_list.driver(dfind));
                }
            }

            fp.close();
        }
コード例 #3
0
 public override void detach(std.unordered_set <handler_entry> handlers)
 {
     throw new emu_unimplemented();
 }
コード例 #4
0
        //-------------------------------------------------
        //  game_info_string - return the game info text
        //-------------------------------------------------
        public string game_info_string()
        {
            string buf = "";  //std::ostringstream buf;

            // print description, manufacturer, and CPU:
            util.stream_format(ref buf, __("{0}\n{1} {2}\nDriver: {3}\n\nCPU:\n"),  //util::stream_format(buf, _("%1$s\n%2$s %3$s\nDriver: %4$s\n\nCPU:\n"),
                               system_list.instance().systems()[driver_list.find(m_machine.system().name)].description,
                               m_machine.system().year,
                               m_machine.system().manufacturer,
                               core_filename_extract_base(m_machine.system().type.source()));

            // loop over all CPUs
            execute_interface_enumerator execiter = new execute_interface_enumerator(m_machine.root_device());

            std.unordered_set <string> exectags = new std.unordered_set <string>();
            foreach (device_execute_interface exec in execiter)
            {
                if (!exectags.insert(exec.device().tag()))  //.second)
                {
                    continue;
                }

                // get cpu specific clock that takes internal multiplier/dividers into account
                u32 clock = exec.device().clock();

                // count how many identical CPUs we have
                int    count = 1;
                string name  = exec.device().name();
                foreach (device_execute_interface scan in execiter)
                {
                    if (exec.device().type() == scan.device().type() && std.strcmp(name, scan.device().name()) == 0 && exec.device().clock() == scan.device().clock())
                    {
                        if (exectags.insert(scan.device().tag()))  //.second)
                        {
                            count++;
                        }
                    }
                }

                string hz = std.to_string(clock);
                int    d  = (clock >= 1000000000) ? 9 : (clock >= 1000000) ? 6 : (clock >= 1000) ? 3 : 0;
                if (d > 0)
                {
                    size_t dpos = hz.length() - (size_t)d;
                    hz = hz.insert_(dpos, ".");
                    size_t last = hz.find_last_not_of('0');
                    hz = hz.substr(0, last + (last != dpos ? 1U : 0U));
                }

                // if more than one, prepend a #x in front of the CPU name and display clock
                util.stream_format(ref buf,
                                   (count > 1)
                            ? ((clock != 0) ? "{0}X{1} {2} {3}\n" : "{1}x{2}\n") //? ((clock != 0) ? "%1$d" UTF8_MULTIPLY "%2$s %3$s" UTF8_NBSP "%4$s\n" : "%1$d" UTF8_MULTIPLY "%2$s\n")
                            : ((clock != 0) ? "{1} {2} {3}\n" : "{1}\n"),        //: ((clock != 0) ? "%2$s %3$s" UTF8_NBSP "%4$s\n" : "%2$s\n"),
                                   count, name, hz,
                                   (d == 9) ? __("GHz") : (d == 6) ? __("MHz") : (d == 3) ? __("kHz") : __("Hz"));
            }

            // loop over all sound chips
            sound_interface_enumerator snditer = new sound_interface_enumerator(m_machine.root_device());

            std.unordered_set <string> soundtags = new std.unordered_set <string>();
            bool found_sound = false;

            foreach (device_sound_interface sound in snditer)
            {
                if (!sound.issound() || !soundtags.insert(sound.device().tag()))  //.second)
                {
                    continue;
                }

                // append the Sound: string
                if (!found_sound)
                {
                    buf += __("\nSound:\n");
                }

                found_sound = true;

                // count how many identical sound chips we have
                int count = 1;
                foreach (device_sound_interface scan in snditer)
                {
                    if (sound.device().type() == scan.device().type() && sound.device().clock() == scan.device().clock())
                    {
                        if (soundtags.insert(scan.device().tag()))  //.second)
                        {
                            count++;
                        }
                    }
                }

                u32    clock = sound.device().clock();
                string hz    = std.to_string(clock);
                int    d     = (clock >= 1000000000) ? 9 : (clock >= 1000000) ? 6 : (clock >= 1000) ? 3 : 0;
                if (d > 0)
                {
                    size_t dpos = hz.length() - (size_t)d;
                    hz = hz.insert_(dpos, ".");
                    size_t last = hz.find_last_not_of('0');
                    hz = hz.substr(0, last + (last != dpos ? 1U : 0U));
                }

                // if more than one, prepend a #x in front of the soundchip name and display clock
                util.stream_format(ref buf,
                                   (count > 1)
                            ? ((clock != 0) ? "{0}X{1} {2} {3}\n" : "{0}X{1}\n") //? ((clock != 0) ? "%1$d" UTF8_MULTIPLY "%2$s %3$s" UTF8_NBSP "%4$s\n" : "%1$d" UTF8_MULTIPLY "%2$s\n")
                            : ((clock != 0) ? "{1} {2} {3}\n" : "{1}\n"),        //: ((clock != 0) ? "%2$s %3$s" UTF8_NBSP "%4$s\n" : "%2$s\n"),
                                   count, sound.device().name(), hz,
                                   (d == 9) ? __("GHz") : (d == 6) ? __("MHz") : (d == 3) ? __("kHz") : __("Hz"));
            }

            // display screen information
            buf += __("\nVideo:\n");
            screen_device_enumerator scriter = new screen_device_enumerator(m_machine.root_device());
            int scrcount = scriter.count();

            if (scrcount == 0)
            {
                buf += __("None\n");
            }
            else
            {
                foreach (screen_device screen in scriter)
                {
                    string detail;
                    if (screen.screen_type() == screen_type_enum.SCREEN_TYPE_VECTOR)
                    {
                        detail = __("Vector");
                    }
                    else
                    {
                        string hz   = std.to_string((float)screen.frame_period().as_hz());
                        size_t last = hz.find_last_not_of('0');
                        size_t dpos = hz.find_last_of('.');
                        hz = hz.substr(0, last + (last != dpos ? 1U : 0U));

                        rectangle visarea = screen.visible_area();
                        detail = util.string_format("{0} X {1} ({2}) {3} Hz",  //detail = string_format("%d " UTF8_MULTIPLY " %d (%s) %s" UTF8_NBSP "Hz",
                                                    visarea.width(), visarea.height(),
                                                    (screen.orientation() & ORIENTATION_SWAP_XY) != 0 ? "V" : "H",
                                                    hz);
                    }

                    util.stream_format(ref buf,
                                       (scrcount > 1) ? __("{0}: {1}\n") : __("{1}\n"), //(scrcount > 1) ? _("%1$s: %2$s\n") : _("%2$s\n"),
                                       get_screen_desc(screen), detail);
                }
            }

            return(buf);
        }
コード例 #5
0
ファイル: info.cs プロジェクト: kwanboy/mcs
        //-------------------------------------------------
        //  game_info_string - return the game info text
        //-------------------------------------------------
        public string game_info_string()
        {
            string buf = "";  //std::ostringstream buf;

            // print description, manufacturer, and CPU:
            buf += string.Format("{0}\n{1} {2}\nDriver: {3}\n\nCPU:\n",  // %1$s\n%2$s %3$s\nDriver: %4$s\n\nCPU:\n
                                 m_machine.system().type.fullname(),
                                 m_machine.system().year,
                                 m_machine.system().manufacturer,
                                 core_filename_extract_base(m_machine.system().type.source()));

            // loop over all CPUs
            execute_interface_iterator execiter = new execute_interface_iterator(m_machine.root_device());

            std.unordered_set <string> exectags = new std.unordered_set <string>();
            foreach (device_execute_interface exec in execiter)
            {
                if (!exectags.insert(exec.device().tag()))  //.second)
                {
                    continue;
                }

                // get cpu specific clock that takes internal multiplier/dividers into account
                int clock = (int)exec.device().clock();

                // count how many identical CPUs we have
                int    count = 1;
                string name  = exec.device().name();
                foreach (device_execute_interface scan in execiter)
                {
                    if (exec.device().type() == scan.device().type() && strcmp(name, scan.device().name()) == 0 && exec.device().clock() == scan.device().clock())
                    {
                        if (exectags.insert(scan.device().tag()))  //.second)
                        {
                            count++;
                        }
                    }
                }

                // if more than one, prepend a #x in front of the CPU name
                // display clock in kHz or MHz
                buf += string.Format(
                    (count > 1) ? "{0}X{1} {2}.{3}{4}{5}\n" : "{1} {2}.{3}{4}{5}\n",      // (count > 1) ? "%1$d" UTF8_MULTIPLY "%2$s %3$d.%4$0*5$d%6$s\n" : "%2$s %3$d.%4$0*5$d%6$s\n",
                    count,
                    name,
                    (clock >= 1000000) ? (clock / 1000000) : (clock / 1000),
                    (clock >= 1000000) ? (clock % 1000000) : (clock % 1000),
                    (clock >= 1000000) ? 6 : 3,
                    (clock >= 1000000) ? "MHz" : "kHz");
            }

            // loop over all sound chips
            sound_interface_iterator snditer = new sound_interface_iterator(m_machine.root_device());

            std.unordered_set <string> soundtags = new std.unordered_set <string>();
            bool found_sound = false;

            foreach (device_sound_interface sound in snditer)
            {
                if (!sound.issound() || !soundtags.insert(sound.device().tag()))  //.second)
                {
                    continue;
                }

                // append the Sound: string
                if (!found_sound)
                {
                    buf += "\nSound:\n";
                }

                found_sound = true;

                // count how many identical sound chips we have
                int count = 1;
                foreach (device_sound_interface scan in snditer)
                {
                    if (sound.device().type() == scan.device().type() && sound.device().clock() == scan.device().clock())
                    {
                        if (soundtags.insert(scan.device().tag()))  //.second)
                        {
                            count++;
                        }
                    }
                }

                // if more than one, prepend a #x in front of the CPU name
                // display clock in kHz or MHz
                int clock = (int)sound.device().clock();
                buf += string.Format(
                    (count > 1)
                            ? ((clock != 0) ? "{0}X{1} {2}.{3}{4}{5}\n" : "{0}X{1}\n")  // "%1$d" UTF8_MULTIPLY "%2$s %3$d.%4$0*5$d%6$s\n" : "%1$d" UTF8_MULTIPLY "%2$s\n")
                            : ((clock != 0) ? "{1} {2}.{3}{4}{5}\n" : "{1}\n"),
                    count,
                    sound.device().name(),
                    (clock >= 1000000) ? (clock / 1000000) : (clock / 1000),
                    (clock >= 1000000) ? (clock % 1000000) : (clock % 1000),
                    (clock >= 1000000) ? 6 : 3,
                    (clock >= 1000000) ? "MHz" : "kHz");
            }

            // display screen information
            buf += "\nVideo:\n";
            screen_device_iterator scriter = new screen_device_iterator(m_machine.root_device());
            int scrcount = scriter.count();

            if (scrcount == 0)
            {
                buf += "None\n";
            }
            else
            {
                foreach (screen_device screen in scriter)
                {
                    string detail;
                    if (screen.screen_type() == screen_type_enum.SCREEN_TYPE_VECTOR)
                    {
                        detail = "Vector";
                    }
                    else
                    {
                        rectangle visarea = screen.visible_area();
                        detail = string.Format("{0} X {1} ({2}) {3} Hz",  //"%d " UTF8_MULTIPLY " %d (%s) %f" UTF8_NBSP "Hz",
                                               visarea.width(), visarea.height(),
                                               (screen.orientation() & ORIENTATION_SWAP_XY) != 0 ? "V" : "H",
                                               screen.frame_period().as_hz());
                    }

                    buf += string.Format(
                        (scrcount > 1) ? "{0}: {1}\n" : "{1}\n",      // "%1$s: %2$s\n") : _("%2$s\n"),
                        get_screen_desc(screen), detail);
                }
            }

            return(buf.str());
        }