Exemplo n.º 1
0
        public static void load_translation(emu_options m_options)
        {
            util.unload_translation();

            string name = m_options.language();

            if (name.empty())
            {
                return;
            }

            strreplace(ref name, " ", "_");
            strreplace(ref name, "(", "");
            strreplace(ref name, ")", "");
            emu_file file = new emu_file(m_options.language_path(), OPEN_FLAG_READ);

            if (file.open(name + PATH_SEPARATOR + "strings.mo"))
            {
                osd_printf_error("Error opening translation file {0}\n", name);
                return;
            }

            osd_printf_verbose("Loading translation file {0}\n", file.fullpath());
            util.load_translation(file.core_file_get());
        }
Exemplo n.º 2
0
 public static void init(emu_options options)
 {
     s_beam_width_min        = options.beam_width_min();
     s_beam_width_max        = options.beam_width_max();
     s_beam_dot_size         = options.beam_dot_size();
     s_beam_intensity_weight = options.beam_intensity_weight();
     s_flicker = options.flicker();
 }
Exemplo n.º 3
0
 public static mame_machine_manager instance(emu_options options, osd_interface osd)
 {
     if (s_manager == null)
     {
         s_manager = new mame_machine_manager(options, osd);
     }
     return(s_manager);
 }
Exemplo n.º 4
0
        //-------------------------------------------------
        //  populate_hashpath_from_args_and_inis
        //-------------------------------------------------
        public static void populate_hashpath_from_args_and_inis(emu_options options, std.vector <string> args)
        {
            // The existence of this function comes from the fact that for softlist options to be properly
            // evaluated, we need to have the hashpath variable set.  The problem is that the hashpath may
            // be set anywhere on the command line, but also in any of the myriad INI files that we parse, some
            // of which may be system specific (e.g. - nes.ini) or otherwise influenced by the system (e.g. - vector.ini)
            //
            // I think that it is terrible that we have to do a completely independent pass on the command line and every
            // argument simply because any one of these things might be setting - hashpath.Unless we invest the effort in
            // building some sort of "late binding" apparatus for options(e.g. - delay evaluation of softlist options until
            // we've scoured all INIs for hashpath) that can completely straddle the command line and the INI worlds, doing
            // this is the best that we can do IMO.

            // parse the command line
            emu_options temp_options = new emu_options(emu_options.option_support.GENERAL_AND_SYSTEM);

            // pick up whatever changes the osd did to the default inipath
            temp_options.set_default_value(emu_options.OPTION_INIPATH, options.ini_path());

            try
            {
                temp_options.parse_command_line(args, emu_options.OPTION_PRIORITY_CMDLINE, true);
            }
            catch (options_exception)
            {
                // Something is very long; we have bigger problems than -hashpath possibly
                // being in never-never land.  Punt and let the main code fail
                return;
            }

            // if we have an auxillary verb, hashpath is irrelevant
            if (!temp_options.command().empty())
            {
                return;
            }

            // read INI files
            if (temp_options.read_config())
            {
                string error_stream;  //std::ostringstream error_stream;
                parse_standard_inis(temp_options, out error_stream);
            }

            // and fish out hashpath
            var entry = temp_options.get_entry(emu_options.OPTION_HASHPATH);

            if (entry != null)
            {
                try
                {
                    options.set_value(emu_options.OPTION_HASHPATH, entry.value(), entry.priority());
                }
                catch (options_exception)
                {
                }
            }
        }
Exemplo n.º 5
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;
        }
Exemplo n.º 6
0
        machine_config_cache m_config;  //mutable machine_config_cache m_config;


        // construction/destruction
        //-------------------------------------------------
        //  driver_enumerator - constructor
        //-------------------------------------------------
        public driver_enumerator(emu_options options)
            : base()
        {
            m_current        = -1;
            m_filtered_count = 0;
            m_options        = options;
            m_included       = new std.vector <bool>();
            m_included.resize(drivlist_global.s_driver_count);
            m_config = new util.lru_cache_map <int, machine_config>(CONFIG_CACHE_COUNT);


            include_all();
        }
Exemplo n.º 7
0
        machine_config_cache m_config;  //mutable machine_config_cache m_config;


        // construction/destruction
        //-------------------------------------------------
        //  driver_enumerator - constructor
        //-------------------------------------------------
        public driver_enumerator(emu_options options)
            : base()
        {
            m_current        = -1;
            m_filtered_count = 0;
            m_options        = options;
            m_included       = new std.vector <bool>();
            m_included.resize(s_driver_count);
            m_config = new machine_config_cache(CONFIG_CACHE_COUNT);


            include_all();
        }
Exemplo n.º 8
0
        //-------------------------------------------------
        //  config - return a machine_config for the given
        //  driver, allocating on demand if needed
        //-------------------------------------------------
        machine_config config(size_t index, emu_options options)
        {
            assert(index < s_driver_count);

            // if we don't have it cached, add it
            machine_config config = m_config.find(index);  //m_config[index];

            if (config == null)
            {
                config = new machine_config(s_drivers_sorted[index], options);
            }

            return(config);
        }
Exemplo n.º 9
0
        public static void load_translation(emu_options m_options)
        {
            g_translation.Clear();
            emu_file file = new emu_file(m_options.language_path(), global_object.OPEN_FLAG_READ);
            var      name = m_options.language();

            name = name.Replace(" ", "_");
            name = name.Replace("(", "");
            name = name.Replace(")", "");
            if (file.open(name, global_object.PATH_SEPARATOR + "strings.mo") == osd_file.error.NONE)
            {
                uint64_t  size   = file.size();
                RawBuffer buffer = new RawBuffer(4 * (int)size / 4 + 1); //uint32_t *buffer = global_alloc_array(uint32_t, size / 4 + 1);
                file.read(new ListBytesPointer(buffer), (UInt32)size);
                file.close();

                if (buffer.get_uint32(0) != MO_MAGIC && buffer.get_uint32(0) != MO_MAGIC_REVERSED)
                {
                    buffer = null;  //global_free_array(buffer);
                    return;
                }
                if (buffer.get_uint32(0) == MO_MAGIC_REVERSED)
                {
                    for (var i = 0; i < ((int)size / 4) + 1; ++i)
                    {
                        buffer.set_uint32(i, endianchange(buffer[i]));
                    }
                }

                uint32_t number_of_strings        = buffer.get_uint32(2);
                uint32_t original_table_offset    = buffer.get_uint32(3) >> 2;
                uint32_t translation_table_offset = buffer.get_uint32(4) >> 2;

                RawBuffer data = buffer;  //const char *data = reinterpret_cast<const char*>(buffer);

                for (var i = 1; i < number_of_strings; ++i)
                {
                    string original    = "TODO original";    //(const char *)data + buffer[original_table_offset + 2 * i + 1];
                    string translation = "TODO translation"; //(const char *)data + buffer[translation_table_offset + 2 * i + 1];
                    g_translation.emplace(original, translation);
                }

                buffer = null;  //global_free_array(buffer);
            }
        }
Exemplo n.º 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);
                }
            }
        }
Exemplo n.º 11
0
        // INI parsing helper
        //-------------------------------------------------
        //  parse_one_ini - parse a single INI file
        //-------------------------------------------------
        static void parse_one_ini(emu_options options, string basename, int priority, ref string error_stream)
        {
            // don't parse if it has been disabled
            if (!options.read_config())
            {
                return;
            }

            // open the file; if we fail, that's ok
            emu_file file = new emu_file(options.ini_path(), OPEN_FLAG_READ);

            osd_printf_verbose("Attempting load of {0}.ini\n", basename);
            osd_file.error filerr = file.open(basename, ".ini");
            if (filerr != osd_file.error.NONE)
            {
                return;
            }

            // parse the file
            osd_printf_verbose("Parsing {0}.ini\n", basename);
            try
            {
                options.parse_ini_file(file.core_file_get(), priority, priority < OPTION_PRIORITY_DRIVER_INI, false);
            }
            catch (options_exception ex)
            {
                if (error_stream != null)
                {
                    error_stream += string.Format("While parsing {0}:\n{1}\n", file.fullpath(), ex.message());
                }
                return;
            }
            finally
            {
                file.close();
            }
        }
Exemplo n.º 12
0
Arquivo: image.cs Projeto: kwanboy/mcs
        /*-------------------------------------------------
        *   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);
        }
Exemplo n.º 13
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);
        }
Exemplo n.º 14
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);
        }
Exemplo n.º 15
0
Arquivo: main.cs Projeto: kwanboy/mcs
 // construction/destruction
 protected machine_manager(emu_options options, osd_interface osd)
 {
     m_osd     = osd;
     m_options = options;
     m_machine = null;
 }
Exemplo n.º 16
0
        public static int start_frontend(emu_options options, osd_interface osd, std.vector <string> args)
        {
            cli_frontend frontend = new cli_frontend(options, osd);

            return(frontend.execute(args));
        }
Exemplo n.º 17
0
 // construction/destruction
 //-------------------------------------------------
 //  info_xml_creator - constructor
 //-------------------------------------------------
 public info_xml_creator(emu_options options, bool dtd = true)
 {
     throw new emu_unimplemented();
 }
Exemplo n.º 18
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();
                }
            }
        }
Exemplo n.º 19
0
 public driver_enumerator(emu_options options, game_driver driver)
     : this(options)
 {
     filter(driver);
 }
Exemplo n.º 20
0
 public driver_enumerator(emu_options options, string str)
     : this(options)
 {
     filter(str);
 }
Exemplo n.º 21
0
        //-------------------------------------------------
        //  system - return a pointer to the specified
        //  system driver, or nullptr if no match
        //-------------------------------------------------
        public static game_driver system(emu_options options)
        {
            int index = driver_list.find(core_filename_extract_base(options.system_name(), true).c_str());

            return((index != -1) ? driver_list.driver(index) : null);
        }