예제 #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);
                        }
                    });
                });
            }
        }
예제 #2
0
        public Hght ReadHghtMetadata()
        {
            Hght hght     = null;
            long?position = SMFileUtils.FindNextString(this, Hght.Identifier);

            if (position.HasValue)
            {
                hght = new Hght();
                hght.HeaderOffset = position.Value;
                hght.SizeOffset   = position.Value + Hght.Identifier.Length;
                this.BaseStream.Seek(position.Value + Hght.Identifier.Length, SeekOrigin.Begin);
                hght.Size          = BitConverter.ToUInt32(this.ReadBytes(4), 0);
                hght.ContentOffset = this.BaseStream.Position;
            }
            return(hght);
        }
예제 #3
0
        public Coli ReadColiMetadata()
        {
            Coli coli     = null;
            long?position = SMFileUtils.FindNextString(this, Coli.Identifier);

            if (position.HasValue)
            {
                coli = new Coli();
                coli.HeaderOffset = position.Value;
                coli.SizeOffset   = position.Value + Coli.Identifier.Length;
                this.BaseStream.Seek(position.Value + Coli.Identifier.Length, SeekOrigin.Begin);
                coli.Size          = BitConverter.ToUInt32(this.ReadBytes(4), 0);
                coli.ContentOffset = this.BaseStream.Position;
            }
            return(coli);
        }
예제 #4
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} |  |");
                }
            }
        }