コード例 #1
0
        /*
         * Read a file into memory
         */
        public void Load(String filename)
        {
            XmlReader reader = XmlReader.Create(filename);

            if (Resources == null)
            {
                Resources = new ResourceChecker();
            }
            else
            {
                Resources.Clear();
            }
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    if (reader.Name.Equals("data"))
                    {
                        LoadMemory(reader.GetAttribute("address"), reader.ReadElementContentAsString());
                    }
                    if (reader.Name.Equals("resource"))
                    {
                        ResourceChecker.Resource res = new ResourceChecker.Resource
                        {
                            Name         = reader.GetAttribute("name"),
                            SourceFile   = reader.GetAttribute("source"),
                            StartAddress = Convert.ToInt32(reader.GetAttribute("start-address"), 16),
                            Length       = Convert.ToInt32(reader.GetAttribute("length"), 16)
                        };
                        Resources.Add(res);
                    }
                }
            }
            reader.Close();
        }
コード例 #2
0
        /*
         * Read a file into memory
         */
        public void Load(String filename)
        {
            XmlReader reader = XmlReader.Create(filename);

            Version = BoardVersion.RevB;
            kernel.ResCheckerRef.Clear();
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    if (reader.Name.Equals("data"))
                    {
                        LoadMemory(reader.GetAttribute("address"), reader.ReadElementContentAsString());
                        continue;
                    }
                    if (reader.Name.Equals("resource"))
                    {
                        ResourceChecker.Resource res = new ResourceChecker.Resource
                        {
                            Name         = reader.GetAttribute("name"),
                            SourceFile   = reader.GetAttribute("source"),
                            StartAddress = Convert.ToInt32(reader.GetAttribute("start-address"), 16),
                            Length       = Convert.ToInt32(reader.GetAttribute("length"), 16)
                        };
                        string resType = reader.GetAttribute("resource-type");
                        if (resType != null)
                        {
                            res.FileType = (ResourceType)Enum.Parse(typeof(ResourceType), resType);
                        }
                        else
                        {
                            res.FileType = ResourceType.raw;
                        }
                        kernel.ResCheckerRef.Add(res);
                        continue;
                    }
                    if (reader.Name.Equals("code"))
                    {
                        string addrStr = reader.GetAttribute("address");
                        if (addrStr.Length > 0)
                        {
                            int       address = Convert.ToInt32(addrStr.Replace("$", ""), 16);
                            string    label   = reader.GetAttribute("label");
                            string    source  = reader.GetAttribute("source");
                            string    command = reader.GetAttribute("command");
                            DebugLine code    = new DebugLine(address);
                            code.SetLabel(label);
                            code.SetMnemonic(source);
                            code.SetOpcodes(command);
                            if (codeList.ContainsKey(address))
                            {
                                codeList.Remove(address);
                            }
                            codeList.Add(address, code);
                        }
                        continue;
                    }
                    if (reader.Name.Equals("breakpoint"))
                    {
                        string address = reader.GetAttribute("address");
                        BreakPoints.Add(address);
                        continue;
                    }
                    if (reader.Name.Equals("project"))
                    {
                        String version = reader.GetAttribute("version");
                        if (version != null)
                        {
                            Enum.TryParse <BoardVersion>(version, out Version);
                        }
                        continue;
                    }
                    if (reader.Name.Equals("watch"))
                    {
                        int           address = Convert.ToInt32(reader.GetAttribute("address"), 16);
                        string        name    = reader.GetAttribute("label");
                        WatchedMemory mem     = new WatchedMemory(name, address, 0, 0);
                        if (watchList.ContainsKey(address))
                        {
                            watchList.Remove(address);
                        }
                        watchList.Add(address, mem);
                    }
                }
            }
            reader.Close();
        }