Exemple #1
0
        public MasmParser(TextReader reader)
        {
            for (int i = 0; ; i++)
            {
                string temp_line = reader.ReadLine();
                if (temp_line == null)
                {
                    break;
                }

                string line = temp_line;

                // remove comments and empty lines
                if (line.Contains('/'))
                {
                    line = temp_line.Substring(0, temp_line.IndexOf('/'));
                }

                if (!string.IsNullOrWhiteSpace(line))
                {
                    lines.Add((i, line));
                }

                OriginalLines.Add(temp_line);
            }
        }
Exemple #2
0
        public void Decompile(string filepath)
        {
            using (FileStream stream = new FileStream(filepath, FileMode.Open))
            {
                using (BinaryReader reader = new BinaryReader(stream, Encoding.Latin1))
                {
                    string signature = reader.ReadFixedString(15);
                    if (signature != TRA_SIGNATURE)
                    {
                        Debug.Assert(false, "Invalid TRA signature!");
                        return;
                    }

                    for (; ;)
                    {
                        Int32 blockType = reader.ReadInt32();
                        Int32 blockSize = reader.ReadInt32();

                        if (blockType == (int)BlockType.Content)
                        {
                            for (; ;)
                            {
                                string original    = reader.ReadEncryptedCString();
                                string translation = reader.ReadEncryptedCString();

                                if ((original.Length < 1) && (translation.Length < 1))
                                {
                                    break;
                                }

                                OriginalLines.Add(original);
                                TranslatedLines.Add(translation);
                            }
                        }
                        else if (blockType == (int)BlockType.Header)
                        {
                            GameID   = reader.ReadInt32();
                            GameName = reader.ReadEncryptedCString();
                        }
                        else if (blockType == (int)BlockType.Settings)
                        {
                            //TODO(adm244): read settings
                            break;
                        }
                        else if (blockType == (int)BlockType.End)
                        {
                            break;
                        }
                        else
                        {
                            Debug.Assert(false, "Unknown block type encountered!");
                            break;
                        }
                    }
                }
            }
        }
Exemple #3
0
        public bool Add(string original, string translation)
        {
            if (string.IsNullOrEmpty(original) || string.IsNullOrEmpty(translation))
            {
                return(false);
            }

            OriginalLines.Add(original);
            TranslatedLines.Add(translation);

            return(true);
        }
Exemple #4
0
        public MasmParser(string path)
        {
            int i = 0;

            foreach (var temp_line in File.ReadLines(path))
            {
                string line = temp_line;

                // remove comments and empty lines
                if (line.Contains('/'))
                {
                    line = temp_line.Substring(0, temp_line.IndexOf('/'));
                }

                if (!string.IsNullOrWhiteSpace(line))
                {
                    lines.Add((i, line));
                }
                i++;

                OriginalLines.Add(temp_line);
            }
        }