Exemplo n.º 1
0
        public static void DumpFormatted0005ColsToFile(List <Old.Cols.ColiInfo> c, string filename)
        {
            FileStream l = File.Open(filename, FileMode.Create);

            using (StreamWriter sw = new StreamWriter(l))
            {
                var zeroFiveStrings = new List <string>();
                c.ForEach(h =>
                {
                    h.ColiObjs.ForEach(j =>
                    {
                        if ((j.ColiType == 0x00) && (j.ColiSubType.HasValue && j.ColiSubType.Value == 0x05))
                        {
                            var coli        = (Old.ColiType0005)j;
                            StringBuilder s = new StringBuilder();
                            sw.WriteLine($"[{coli.ObjData[0]}, 0, {coli.ObjData[1]}]");
                            sw.WriteLine($"| Hex | Float | Int32 |");
                            sw.WriteLine($"|-----|-------|-------|");
                            for (int i = 2; i < coli.ObjData.Count; i++)
                            {
                                byte[] wordBytes = BitConverter.GetBytes(coli.ObjData[i]);
                                var byteString   = SMFileUtils.ConvertBytesToString(wordBytes);
                                sw.Write($"| {byteString} ");                                      // string
                                sw.Write($"| {coli.ObjData[i]} ");                                 // float
                                sw.Write($"| {BitConverter.ToInt32(wordBytes, 0)} |{sw.NewLine}"); // int32
                            }
                            sw.Write(sw.NewLine);
                        }
                    });
                });
            }
        }
Exemplo n.º 2
0
        public static void DumpFormatted0005FreqsToFile(List <Old.Cols.ColiInfo> c, string filename)
        {
            FileStream l = File.Open(filename, FileMode.Create);

            using (StreamWriter sw = new StreamWriter(l))
            {
                var zeroThreeCounts = new Dictionary <string, int>();
                c.ForEach(h =>
                {
                    h.ColiObjs.ForEach(j =>
                    {
                        if ((j.ColiType == 0x00) && (j.ColiSubType.HasValue && j.ColiSubType.Value == 0x05))
                        {
                            var coli = (Old.ColiType0005)j;
                            for (int i = 2; i < coli.ObjData.Count; i++)
                            {
                                var byteString = SMFileUtils.ConvertBytesToString(BitConverter.GetBytes(coli.ObjData[i]));
                                if (zeroThreeCounts.ContainsKey(byteString))
                                {
                                    zeroThreeCounts[byteString]++;
                                }
                                else
                                {
                                    zeroThreeCounts[byteString] = 1;
                                }
                            }
                        }
                    });
                });
                sw.WriteLine("| Address? | Count | What is it? |");
                sw.WriteLine("|----------|-------|-------------|");
                var kvl = zeroThreeCounts.ToList();
                kvl.Sort((a, b) => b.Value.CompareTo(a.Value));
                foreach (var kv in kvl)
                {
                    sw.WriteLine($"| {kv.Key} | {kv.Value} |  |");
                }
            }
        }