예제 #1
0
        public static CodeDataLog Create(IEnumerable <HuC6280.MemMapping> mm)
        {
            var t = new CodeDataLog();

            foreach (var kvp in SizesFromHuMap(mm))
            {
                t[kvp.Key] = new byte[kvp.Value];
            }
            return(t);
        }
예제 #2
0
        public static CodeDataLog Load(Stream s)
        {
            var    t  = new CodeDataLog();
            var    r  = new BinaryReader(s);
            string id = r.ReadString();

            if (id != "BIZHAWK-CDL-1")
            {
                throw new InvalidDataException("File is not a Bizhawk CDL file!");
            }
            int count = r.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                string key  = r.ReadString();
                int    len  = r.ReadInt32();
                byte[] data = r.ReadBytes(len);
                t[key] = data;
            }
            return(t);
        }
예제 #3
0
        public void DisassembleCDL(Stream s, CodeDataLog cdl, IMemoryDomains mem)
        {
            var w = new StreamWriter(s);

            w.WriteLine("; Bizhawk CDL Disassembly");
            w.WriteLine();
            foreach (var kvp in cdl)
            {
                w.WriteLine(".\"{0}\" size=0x{1:x8}", kvp.Key, kvp.Value.Length);

                byte[] cd = kvp.Value;
                var    md = mem[kvp.Key];

                for (int i = 0; i < kvp.Value.Length; i++)
                {
                    if ((kvp.Value[i] & (byte)HuC6280.CDLUsage.Code) != 0)
                    {
                        int    unused;
                        string dis = HuC6280.DisassembleExt(
                            0,
                            out unused,
                            delegate(ushort addr)
                        {
                            return(md.PeekByte(addr + i));
                        },
                            delegate(ushort addr)
                        {
                            return(md.PeekWord(addr + i, false));
                        }
                            );
                        w.WriteLine("0x{0:x8}: {1}", i, dis);
                    }
                }
                w.WriteLine();
            }
            w.WriteLine("; EOF");
            w.Flush();
        }
예제 #4
0
        public void LogicalOrFrom(CodeDataLog other)
        {
            if (this.Count != other.Count)
            {
                throw new InvalidDataException("Dictionaries must have the same number of keys!");
            }

            foreach (var kvp in other)
            {
                byte[] fromdata = kvp.Value;
                byte[] todata   = this[kvp.Key];

                if (fromdata.Length != todata.Length)
                {
                    throw new InvalidDataException("Memory regions must be the same size!");
                }

                for (int i = 0; i < todata.Length; i++)
                {
                    todata[i] |= fromdata[i];
                }
            }
        }