コード例 #1
0
ファイル: Program.cs プロジェクト: shawlucas/MasterOcarina
        private static void WriteCsvTask(ParserTask task, List <OutputToken> OutputFormat, WriteRow writeRow)
        {
            StringBuilder sb = new StringBuilder();

            using (BinaryReader br = new BinaryReader(new FileStream(task.FileIn, FileMode.Open, FileAccess.Read)))
            {
                br.BaseStream.Position = task.StartAddress;
                for (long i = 0; i < task.LoopFor; i++)
                {
                    List <string> outlist = new List <string>();
                    foreach (OutputToken item in OutputFormat)
                    {
                        var result = item.Process(br, task);
                        if (item.IsValueReturning)
                        {
                            outlist.Add(result);
                        }
                    }
                    writeRow(sb, outlist);
                    task.Index += task.Inc;
                }
            }
            using (StreamWriter sw = new StreamWriter(task.FileOut))
            {
                sw.Write(sb.ToString());
                Console.WriteLine($"{task.FileOut} created");
            }
        }
コード例 #2
0
        private static List <ParserTask> GetParserTasks(List <SettingsToken> settings)
        {
            List <ParserTask>      tasks         = new List <ParserTask>();
            List <string>          builds        = (List <string>)Get(settings, SettingsTokensEnum.build);
            List <FormatTypesEnum> outputFormats =
                (List <FormatTypesEnum>)Get(settings, SettingsTokensEnum.format);

            int i = -1;

            foreach (var build in builds)
            {
                i++;
                foreach (var format in outputFormats)
                {
                    ParserTask task = new ParserTask();
                    task.FileLocationToken = build;
                    task.Format            = format;
                    task.StartAddress      = (long)GetSingle(settings, SettingsTokensEnum.start, i);
                    task.LoopFor           = (long)GetSingle(settings, SettingsTokensEnum.loop, i);
                    task.Inc   = (long)GetSingle(settings, SettingsTokensEnum.inc, i);
                    task.Index = (long)GetSingle(settings, SettingsTokensEnum.iterator, i);
                    tasks.Add(task);
                }
            }
            return(tasks);
        }
コード例 #3
0
        private static List <ParserTask> GetParserTasks(List <SettingsToken> settings)
        {
            List <ParserTask>      tasks         = new List <ParserTask>();
            List <string>          builds        = (List <string>)Get(settings, SettingsTokens.build);
            List <FormatTypesEnum> outputFormats =
                (List <FormatTypesEnum>)Get(settings, SettingsTokens.format);

            for (int i = 0; i < builds.Count; i++)
            {
                var build = builds[i];
                foreach (var format in outputFormats)
                {
                    var        game = (string)GetSingle(settings, SettingsTokens.game, i);
                    ParserTask task = new ParserTask
                    {
                        Name         = (string)GetSingle(settings, SettingsTokens.name, i),
                        Version      = new RomVersion(game, build),
                        Format       = format,
                        StartAddress = (long)GetSingle(settings, SettingsTokens.start, i),
                        LoopFor      = (long)GetSingle(settings, SettingsTokens.loop, i),
                        Inc          = (long)GetSingle(settings, SettingsTokens.inc, i),
                        Index        = (long)GetSingle(settings, SettingsTokens.iterator, i)
                    };
                    tasks.Add(task);
                }
            }
            return(tasks);
        }
コード例 #4
0
        public string Process(BinaryReader br, ParserTask v)
        {
            ulong result = 0;

            switch (Type)
            {
            case OutputTokensEnum.align:
                if (Parameter != 4 && Parameter != 8)
                {
                    throw new InvalidOperationException();
                }
                long off = ((br.BaseStream.Position + Parameter - 1) / Parameter) * Parameter;
                br.BaseStream.Position = off;
                break;

            case OutputTokensEnum.go:
                br.BaseStream.Position += Parameter;
                break;

            //Standard Captures
            case OutputTokensEnum.s8:
                return(string.Format("{0:" + Format + "}", br.ReadSByte()));

            case OutputTokensEnum.u8:
                return(string.Format("{0:" + Format + "}", br.ReadByte()));

            case OutputTokensEnum.s16:
                return(string.Format("{0:" + Format + "}", br.ReadBigInt16()));

            case OutputTokensEnum.u16:
                return(string.Format("{0:" + Format + "}", br.ReadBigUInt16()));

            case OutputTokensEnum.s32:
                return(string.Format("{0:" + Format + "}", br.ReadBigInt32()));

            case OutputTokensEnum.u32:
                return(string.Format("{0:" + Format + "}", br.ReadBigUInt32()));

            case OutputTokensEnum.f32:
                return(string.Format("{0:" + Format + "}", br.ReadBigFloat()));

            case OutputTokensEnum.c8:
                result = CaptureShift(br.ReadByte());
                br.BaseStream.Position -= 1;
                return(string.Format("{0:" + Format + "}", (ushort)result));

            case OutputTokensEnum.sc8:
                result = CaptureShift(br.ReadByte());
                br.BaseStream.Position -= 1;
                return(string.Format("{0:" + Format + "}", (ushort)result));

            case OutputTokensEnum.c16:
                result = CaptureShift(br.ReadBigUInt16());
                br.BaseStream.Position -= 2;
                return(string.Format("{0:" + Format + "}", (ushort)result));

            case OutputTokensEnum.sc16:
                result = CaptureShift(br.ReadBigUInt16());
                br.BaseStream.Position -= 2;
                return(string.Format("{0:" + Format + "}", (ushort)result));

            case OutputTokensEnum.c32:
                result = CaptureShift(br.ReadBigUInt32());
                br.BaseStream.Position -= 4;
                return(string.Format("{0:" + Format + "}", (uint)result));

            case OutputTokensEnum.sc32:
                result = CaptureShift(br.ReadBigUInt32());
                br.BaseStream.Position -= 4;
                return(string.Format("{0:" + Format + "}", (uint)result));

            case OutputTokensEnum.index:
                return(string.Format("{0:" + Format + "}", v.Index));
            }
            return(string.Empty);
        }