Пример #1
0
        private string snes_path_request(int slot, string hint)
        {
            // every rom requests msu1.rom... why? who knows.
            // also handle msu-1 pcm files here
            bool isMsu1Rom = hint == "msu1.rom";
            bool isMsu1Pcm = Path.GetExtension(hint).ToLower() == ".pcm";

            if (isMsu1Rom || isMsu1Pcm)
            {
                // well, check if we have an msu-1 xml
                if (_romxml?["cartridge"]?["msu1"] != null)
                {
                    var msu1 = _romxml["cartridge"]["msu1"];
                    if (isMsu1Rom && msu1["rom"]?.Attributes["name"] != null)
                    {
                        return(CoreComm.CoreFileProvider.PathSubfile(msu1["rom"].Attributes["name"].Value));
                    }

                    if (isMsu1Pcm)
                    {
                        // return @"D:\roms\snes\SuperRoadBlaster\SuperRoadBlaster-1.pcm";
                        // return "";
                        int wantsTrackNumber = int.Parse(hint.Replace("track-", "").Replace(".pcm", ""));
                        wantsTrackNumber++;
                        string wantsTrackString = wantsTrackNumber.ToString();
                        foreach (var child in msu1.ChildNodes.Cast <XmlNode>())
                        {
                            if (child.Name == "track" && child.Attributes["number"].Value == wantsTrackString)
                            {
                                return(CoreComm.CoreFileProvider.PathSubfile(child.Attributes["name"].Value));
                            }
                        }
                    }
                }

                // not found.. what to do? (every rom will get here when msu1.rom is requested)
                return("");
            }

            // not MSU-1.  ok.
            string firmwareId;

            switch (hint)
            {
            case "cx4.rom": firmwareId = "CX4"; break;

            case "dsp1.rom": firmwareId = "DSP1"; break;

            case "dsp1b.rom": firmwareId = "DSP1b"; break;

            case "dsp2.rom": firmwareId = "DSP2"; break;

            case "dsp3.rom": firmwareId = "DSP3"; break;

            case "dsp4.rom": firmwareId = "DSP4"; break;

            case "st010.rom": firmwareId = "ST010"; break;

            case "st011.rom": firmwareId = "ST011"; break;

            case "st018.rom": firmwareId = "ST018"; break;

            default:
                CoreComm.ShowMessage($"Unrecognized SNES firmware request \"{hint}\".");
                return("");
            }

            string ret;
            var    data = CoreComm.CoreFileProvider.GetFirmware("SNES", firmwareId, false, "Game may function incorrectly without the requested firmware.");

            if (data != null)
            {
                ret = hint;
                Api.AddReadonlyFile(data, hint);
            }
            else
            {
                ret = "";
            }

            Console.WriteLine("Served libsnes request for firmware \"{0}\"", hint);

            // return the path we built
            return(ret);
        }