Пример #1
0
        public static void Main()
        {
            //https://docs.microsoft.com/en-us/dotnet/api/system.reflection.emit.assemblybuilder?view=netcore-3.1
            //https://eldred.fr/gb-asm-tutorial/what_is_gb.html
            //http://gameboy.mongenel.com/asmschool.html
            //http://gameboy.mongenel.com/dmg/mbc3.txt //Pokemon Red
            //https://binji.github.io/posts/pokegb/ //emulating just pokemon red

            //https://sneslab.net/wiki/Graphics_Format#2bpp

            var files = new[]
            {
                @"DKGBDisasm/macros/gfx.asm",

                @"tetris_disassembly/main.asm",
                @"LADX-Disassembly/src/main.asm",

                @"DKGBDisasm/home.asm",
                @"DKGBDisasm/main.asm",

                @"kirbydreamland/main.asm",

                @"marioland2/home.asm",
                @"marioland2/main.asm",

                //@"mmania\main.asm", //INCBIN too slow...

                @"rgbds-template/src/hello-world.asm",

                @"supermarioland/bank0.asm",
                @"supermarioland/bank1.asm",
                @"supermarioland/bank2.asm",
                @"supermarioland/bank3.asm",
                @"supermarioland/music.asm",

                @"blankasm.asm",
                @"hello.asm",
                @"hello-world.asm",
                @"mrdo.asm",

                @"hello.asm",
                @"hello-world.asm",
                @"score_bcd.asm",
                @"score_hex.asm",

                @"DMG_ROM.asm",
                @"dmg_boot.asm",
                @"dmg0_rom.asm",
                @"fortune_rom.asm",
                @"gamefighter_rom.asm",
                @"dmg_boot (2) orig.asm",
                @"dmg_boot (2).asm",

                @"pokered/macros/const.asm",
                @"pokered/main.asm",
                @"pokered/home.asm",
                @"Pokemon Red (UE) [S][!].asm",

                @"poketcg/src/main.asm",

                @"shi-kong-xing-shou/main.asm",
                @"shi-kong-xing-shou/home.asm",

                @"telefang/telefang.inc",

                @"robopon/home.asm",
                @"robopon/main.asm",
            };


            foreach (var file in files)
            {
                Console.WriteLine();
                Console.WriteLine(file);
                Console.WriteLine(new string('=', file.Length));
                Console.WriteLine();

                var fileName   = Path.Combine(Environment.CurrentDirectory, "..", "..", "..", "..", "Assembly", file);
                var fileLines1 = File.ReadAllLines(fileName);
                Parser.RootFolder = Path.GetDirectoryName(fileName);
                fileLines1        = Parser.FlattenMultiLine(fileLines1);
                var parsedLines = Parser.GetLines(fileLines1, fileName);

                //TODO compile checks: see if all the values exist


                Restructure.RestructureMacros(parsedLines);
                Restructure.RestructureIfs(parsedLines);
                Restructure.RestructureRepeats(parsedLines);

                //var c = new Foo.C();
                //c.M();

                //var serializedJson = Parser.ExportJson(parsedLines);
                //File.WriteAllText(fileName + ".json", serializedJson);

                //var deserialized = JsonConvert.DeserializeObject<IAsmLine>(serialized, settings);
                //TODO: base the CIL off of the decompiled c#
                //CIL.GenerateCIL();

                var root = Path.GetDirectoryName(fileName);

                var sb = CSharp.GenerateCsharp(fileName, parsedLines, root);

                File.WriteAllText(fileName + ".cs", sb);
            }
        }
Пример #2
0
        public static void Main()
        {
            //https://docs.microsoft.com/en-us/dotnet/api/system.reflection.emit.assemblybuilder?view=netcore-3.1
            //https://eldred.fr/gb-asm-tutorial/what_is_gb.html
            //http://gameboy.mongenel.com/asmschool.html
            //http://gameboy.mongenel.com/dmg/mbc3.txt //Pokemon Red

            var files = new[]
            {
                @"\OneDrive\Documents\Gameboy Hello World\tetris.asm",
                //@"C:\Users\pierc\source\LADX-Disassembly\src\main.asm",

                @"\OneDrive\Documents\Gameboy Hello World\blankasm.asm",
                @"\OneDrive\Documents\Gameboy Hello World\hello.asm",
                @"\OneDrive\Documents\Gameboy Hello World\hello-world.asm",
                @"\OneDrive\Documents\Gameboy Hello World\mrdo.asm",

                // @"C:\source\pokered\macros/const.asm",

                // @"C:\Users\hce_a\OneDrive\Documents\Gameboy Hello World\hello.asm",
                // @"C:\Users\hce_a\OneDrive\Documents\Gameboy Hello World\hello-world.asm",
                // @"C:\Users\hce_a\OneDrive\Documents\Gameboy Hello World\score_bcd.asm",
                // @"C:\Users\hce_a\OneDrive\Documents\Gameboy Hello World\score_hex.asm",

                // @"C:\Users\hce_a\OneDrive\Documents\Gameboy Hello World\DMG_ROM.asm",
                // @"C:\Users\hce_a\OneDrive\Documents\Gameboy Hello World\dmg_boot.asm",
                // @"C:\Users\hce_a\OneDrive\Documents\Gameboy Hello World\dmg0_rom.asm",
                // @"C:\Users\hce_a\OneDrive\Documents\Gameboy Hello World\fortune_rom.asm",
                // @"C:\Users\hce_a\OneDrive\Documents\Gameboy Hello World\gamefighter_rom.asm",
                // @"C:\Users\hce_a\OneDrive\Documents\Gameboy Hello World\dmg_boot (2) orig.asm",
                // @"C:\Users\hce_a\OneDrive\Documents\Gameboy Hello World\dmg_boot (2).asm",

                // @"C:\source\pokered\main.asm",
                // @"C:\source\pokered\home.asm",
                // @"C:\Users\hce_a\OneDrive\Documents\Gameboy Hello World\Pokemon Red (UE) [S][!].asm",

                // @"C:\Users\hce_a\OneDrive\Documents\Gameboy Hello World\sources\Multiplatform\Sources\SimpleHelloWorld\GB_HelloWorld.asm"
            };

            //var files = Directory.GetFiles(@"C:\Users\pierc\source\pokered", "*.asm", SearchOption.AllDirectories);
            //var files = Directory.GetFiles(@"C:\Users\hce_a\OneDrive\Documents\Gameboy Hello World\", "*.asm", SearchOption.AllDirectories);

            foreach (var file in files)
            {
                var fileName   = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + file;
                var fileLines1 = File.ReadAllLines(fileName);
                Parser.RootFolder = Path.GetDirectoryName(fileName);
                fileLines1        = Parser.FlattenMultiLine(fileLines1);
                var parsedLines = Parser.GetLines(fileLines1, fileName);

                //TODO compile checks: see if all the values exist


                RestructureLines(parsedLines);


                //var c = new Foo.C();
                //c.M();

                Parser.ExportJson(fileName, parsedLines);

                //var deserialized = JsonConvert.DeserializeObject<IAsmLine>(serialized, settings);

                //CIL.GenerateCIL();

                CSharp.GenerateCsharp(fileName, parsedLines);
            }
        }