Esempio n. 1
0
        public static IEnumerable <String> GetRomSetNames()
        {
            var list = new List <String>();

            try
            {
                var mapping = new XmlDocument();
                using (Stream stream = RomPack.GetImageStream("~mapping.xml"))
                {
                    mapping.Load(stream);
                }
                // "/Mapping/RomSet"
                foreach (XmlNode romSetNode in mapping.DocumentElement.ChildNodes)
                {
                    if (string.Compare(romSetNode.Name, "RomSet", true) != 0)
                    {
                        continue;
                    }
                    var romSet = Utils.GetXmlAttributeAsString(romSetNode, "name", string.Empty);
                    list.Add(romSet);
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
            return(list);
        }
Esempio n. 2
0
        public static Stream GetUlaRomStream(string romName)
        {
            var mapping = new XmlDocument();

            using (var stream = RomPack.GetImageStream("~ula.xml"))
            {
                mapping.Load(stream);
            }
            // "/Mapping/Rom"
            foreach (XmlNode romNode in mapping.DocumentElement.ChildNodes)
            {
                if (string.Compare(romNode.Name, "Rom", true) != 0)
                {
                    continue;
                }
                if (romNode.Attributes["name"] == null ||
                    romNode.Attributes["image"] == null)
                {
                    continue;
                }
                var name  = romNode.Attributes["name"].InnerText;
                var image = romNode.Attributes["image"].InnerText;
                if (name != string.Empty &&
                    image != string.Empty &&
                    string.Compare(name, romName, true) == 0)
                {
                    return(GetImageStream(image));
                }
            }
            throw new FileNotFoundException(string.Format("ULA ROM file not found: {0}", romName));
        }
Esempio n. 3
0
 private void LoadRomSet()
 {
     for (var i = 0; i < RomPages.Length; i++)
     {
         for (var j = 0; j < RomPages[i].Length; j++)
         {
             RomPages[i][j] = 0xFF;
         }
     }
     foreach (var page in RomPack.GetRomSet(m_romSetName))
     {
         OnLoadRomPage(page.Name, page.Content);
     }
 }
Esempio n. 4
0
        public static IEnumerable <RomPage> GetRomSet(String romSetName)
        {
            var list = new List <RomPage>();

            try
            {
                var mapping = new XmlDocument();
                using (var stream = RomPack.GetImageStream("~mapping.xml"))
                {
                    mapping.Load(stream);
                }
                // "/Mapping/RomSet"
                foreach (XmlNode romSetNode in mapping.DocumentElement.ChildNodes)
                {
                    if (string.Compare(romSetNode.Name, "RomSet", true) != 0)
                    {
                        continue;
                    }
                    var romSet = Utils.GetXmlAttributeAsString(romSetNode, "name", string.Empty);
                    if (romSet == string.Empty ||
                        string.Compare(romSetName, romSet, true) != 0)
                    {
                        continue;
                    }
                    // "Page"
                    foreach (XmlNode pageNode in romSetNode.ChildNodes)
                    {
                        if (string.Compare(pageNode.Name, "Page", true) != 0)
                        {
                            continue;
                        }
                        var pageName  = Utils.GetXmlAttributeAsString(pageNode, "name", string.Empty);
                        var pageImage = Utils.GetXmlAttributeAsString(pageNode, "image", string.Empty);
                        if (pageName == string.Empty ||
                            pageImage == string.Empty)
                        {
                            continue;
                        }
                        var fileOffset = 0;
                        var fileLength = (int)RomPack.GetImageLength(pageImage);
                        if (pageNode.Attributes["offset"] != null)
                        {
                            fileOffset  = Utils.ParseSpectrumInt(pageNode.Attributes["offset"].InnerText);
                            fileLength -= fileOffset;
                        }
                        if (pageNode.Attributes["length"] != null)
                        {
                            fileLength = Utils.ParseSpectrumInt(pageNode.Attributes["length"].InnerText);
                        }
                        var data = new byte[fileLength];
                        using (var stream = RomPack.GetImageStream(pageImage))
                        {
                            stream.Seek(fileOffset, SeekOrigin.Begin);
                            stream.Read(data, 0, data.Length);
                        }

                        list.Add(new RomPage(pageName, data));
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "Load RomSet failed, romSet=\"{0}\"", romSetName);
            }
            return(list);
        }