Beispiel #1
0
        private int HandleCharsetProject(GR.Text.ArgumentParser ArgParser)
        {
            if (!ValidateExportType("charset project", ArgParser.Parameter("TYPE"), new string[] { "CHARS" }))
            {
                return(1);
            }

            var charsetProject = new C64Studio.Formats.CharsetProject();

            if (!charsetProject.ReadFromBuffer(GR.IO.File.ReadAllBytes(ArgParser.Parameter("CHARSETPROJECT"))))
            {
                System.Console.WriteLine("Couldn't read charset project from file " + ArgParser.Parameter("CHARSETPROJECT"));
                return(1);
            }

            int firstUnit = 0;
            int count     = -1;

            if (ArgParser.IsParameterSet("OFFSET"))
            {
                firstUnit = GR.Convert.ToI32(ArgParser.Parameter("OFFSET"));
            }
            if (ArgParser.IsParameterSet("COUNT"))
            {
                count = GR.Convert.ToI32(ArgParser.Parameter("COUNT"));
            }
            if (count == -1)
            {
                count = charsetProject.Characters.Count;
            }

            if ((firstUnit < 0) ||
                (firstUnit >= charsetProject.Characters.Count))
            {
                System.Console.WriteLine("OFFSET is invalid");
                return(1);
            }
            if ((count <= 0) ||
                (firstUnit + count > charsetProject.Characters.Count))
            {
                System.Console.WriteLine("COUNT is invalid");
                return(1);
            }

            GR.Memory.ByteBuffer exportData = new GR.Memory.ByteBuffer((uint)(count * 8));
            for (int i = 0; i < count; ++i)
            {
                charsetProject.Characters[firstUnit + i].Data.CopyTo(exportData, 0, 8, i * 8);
            }

            if (!GR.IO.File.WriteAllBytes(ArgParser.Parameter("EXPORT"), exportData))
            {
                return(1);
            }
            return(0);
        }
        private int HandleMapProject(GR.Text.ArgumentParser ArgParser)
        {
            if (!ValidateExportType("map project file", ArgParser.Parameter("TYPE"), new string[] { "MAPDATA", "MAPDATAASM" }))
            {
                return(1);
            }

            GR.Memory.ByteBuffer data = GR.IO.File.ReadAllBytes(ArgParser.Parameter("MAPPROJECT"));
            if (data == null)
            {
                System.Console.WriteLine("Couldn't read binary char file " + ArgParser.Parameter("MAPPROJECT"));
                return(1);
            }

            var mapProject = new RetroDevStudio.Formats.MapProject();

            if (!mapProject.ReadFromBuffer(data))
            {
                System.Console.WriteLine("Couldn't read map project from file " + ArgParser.Parameter("MAPPROJECT"));
                return(1);
            }

            GR.Memory.ByteBuffer resultingData = new GR.Memory.ByteBuffer();

            if (ArgParser.Parameter("TYPE").Contains("MAPDATAASM"))
            {
                foreach (var map in mapProject.Maps)
                {
                    var mapData = new ByteBuffer((uint)(map.Tiles.Width * map.Tiles.Height));

                    for (int j = 0; j < 0 + map.Tiles.Height; ++j)
                    {
                        for (int i = 0; i < 0 + map.Tiles.Width; ++i)
                        {
                            mapData.SetU8At(i + j * map.Tiles.Width, (byte)map.Tiles[i, j]);
                        }
                    }
                    resultingData.Append(Encoding.ASCII.GetBytes("MAP_" + map.Name + "\n!hex \"" + mapData.ToString() + "\"\n"));
                }
            }
            else if (ArgParser.Parameter("TYPE").Contains("MAPDATA"))
            {
                foreach (var map in mapProject.Maps)
                {
                    for (int j = 0; j < 0 + map.Tiles.Height; ++j)
                    {
                        for (int i = 0; i < 0 + map.Tiles.Width; ++i)
                        {
                            resultingData.AppendU8((byte)map.Tiles[i, j]);
                        }
                    }
                }
            }
            if (!GR.IO.File.WriteAllBytes(ArgParser.Parameter("EXPORT"), resultingData))
            {
                Console.WriteLine("Could not write to file " + ArgParser.Parameter("EXPORT"));
                return(1);
            }
            return(0);
        }
        private int HandleSpriteProject(GR.Text.ArgumentParser ArgParser)
        {
            if (!ValidateExportType("sprite project", ArgParser.Parameter("TYPE"), new string[] { "SPRITES" }))
            {
                return(1);
            }

            var spriteProject = new C64Studio.Formats.SpriteProject();

            if (!spriteProject.ReadFromBuffer(GR.IO.File.ReadAllBytes(ArgParser.Parameter("SPRITEPROJECT"))))
            {
                System.Console.WriteLine("Couldn't read sprite project from file " + ArgParser.Parameter("SPRITEPROJECT"));
                return(1);
            }

            int firstSprite = 0;
            int count       = -1;

            if (ArgParser.IsParameterSet("OFFSET"))
            {
                firstSprite = GR.Convert.ToI32(ArgParser.Parameter("OFFSET"));
            }
            if (ArgParser.IsParameterSet("COUNT"))
            {
                count = GR.Convert.ToI32(ArgParser.Parameter("COUNT"));
            }
            if (count == -1)
            {
                count = spriteProject.TotalNumberOfSprites;
            }

            if ((firstSprite < 0) ||
                (firstSprite >= spriteProject.TotalNumberOfSprites))
            {
                System.Console.WriteLine("OFFSET is invalid");
                return(1);
            }
            if ((count <= 0) ||
                (firstSprite + count > spriteProject.TotalNumberOfSprites))
            {
                System.Console.WriteLine("COUNT is invalid");
                return(1);
            }

            GR.Memory.ByteBuffer spriteData = new GR.Memory.ByteBuffer((uint)(count * 64));
            for (int i = 0; i < count; ++i)
            {
                spriteProject.Sprites[firstSprite + i].Tile.Data.CopyTo(spriteData, 0, 63, i * 64);
            }

            if (!GR.IO.File.WriteAllBytes(ArgParser.Parameter("EXPORT"), spriteData))
            {
                Console.WriteLine("Could not write to file " + ArgParser.Parameter("EXPORT"));
                return(1);
            }
            return(0);
        }
Beispiel #4
0
        private int HandleCharFile(GR.Text.ArgumentParser ArgParser)
        {
            if (!ValidateExportType("charset file", ArgParser.Parameter("TYPE"), new string[] { "CHARS" }))
            {
                return(1);
            }

            GR.Memory.ByteBuffer data = GR.IO.File.ReadAllBytes(ArgParser.Parameter("CHARS"));
            if (data == null)
            {
                System.Console.WriteLine("Couldn't read binary char file " + ArgParser.Parameter("CHARS"));
                return(1);
            }
            int firstUnit = 0;
            int count     = -1;

            if (ArgParser.IsParameterSet("OFFSET"))
            {
                firstUnit = GR.Convert.ToI32(ArgParser.Parameter("OFFSET"));
            }
            if (ArgParser.IsParameterSet("COUNT"))
            {
                count = GR.Convert.ToI32(ArgParser.Parameter("COUNT"));
            }
            if (count == -1)
            {
                count = (int)data.Length / 8;
            }

            if ((firstUnit < 0) ||
                (firstUnit >= (int)data.Length / 8))
            {
                System.Console.WriteLine("OFFSET is invalid");
                return(1);
            }
            if ((count <= 0) ||
                (firstUnit + count > (int)data.Length / 8))
            {
                System.Console.WriteLine("COUNT is invalid");
                return(1);
            }

            GR.Memory.ByteBuffer spriteData = new GR.Memory.ByteBuffer((uint)(count * 8));
            data.CopyTo(spriteData, firstUnit * 8, count * 8);

            if (!GR.IO.File.WriteAllBytes(ArgParser.Parameter("EXPORT"), spriteData))
            {
                Console.WriteLine("Could not write to file " + ArgParser.Parameter("EXPORT"));
                return(1);
            }
            return(0);
        }
Beispiel #5
0
        private int HandleSpriteFile(GR.Text.ArgumentParser ArgParser)
        {
            if (!ValidateExportType("sprite file", ArgParser.Parameter("TYPE"), new string[] { "SPRITES" }))
            {
                return(1);
            }

            GR.Memory.ByteBuffer data = GR.IO.File.ReadAllBytes(ArgParser.Parameter("SPRITES"));
            if (data == null)
            {
                System.Console.WriteLine("Couldn't read binary sprite file " + ArgParser.Parameter("SPRITES"));
                return(1);
            }
            int firstSprite = 0;
            int count       = -1;

            if (ArgParser.IsParameterSet("OFFSET"))
            {
                firstSprite = GR.Convert.ToI32(ArgParser.Parameter("OFFSET"));
            }
            if (ArgParser.IsParameterSet("COUNT"))
            {
                count = GR.Convert.ToI32(ArgParser.Parameter("COUNT"));
            }
            if (count == -1)
            {
                count = (int)data.Length / 64;
            }

            if ((firstSprite < 0) ||
                (firstSprite >= (int)data.Length / 64))
            {
                System.Console.WriteLine("OFFSET is invalid");
                return(1);
            }
            if ((count <= 0) ||
                (firstSprite + count > (int)data.Length / 64))
            {
                System.Console.WriteLine("COUNT is invalid");
                return(1);
            }

            GR.Memory.ByteBuffer spriteData = new GR.Memory.ByteBuffer((uint)(count * 64));
            data.CopyTo(spriteData, firstSprite * 64, count * 64);

            if (!GR.IO.File.WriteAllBytes(ArgParser.Parameter("EXPORT"), spriteData))
            {
                return(1);
            }
            return(0);
        }
Beispiel #6
0
        private int HandleGraphicscreenFile(GR.Text.ArgumentParser ArgParser)
        {
            string exportType = ArgParser.Parameter("TYPE");

            if (!ValidateExportType("graphicscreen file", exportType,
                                    new string[] { "MULTICOLORBITMAPSCREENCOLOR", "MULTICOLORBITMAPCOLORSCREEN", "MULTICOLORBITMAPSCREEN", "MULTICOLORBITMAPCOLOR", "MULTICOLORBITMAP",
                                                   "HIRESBITMAPSCREENCOLOR", "HIRESBITMAPCOLORSCREEN", "HIRESBITMAPSCREEN", "HIRESBITMAPCOLOR", "HIRESBITMAP" }))
            {
                return(1);
            }

            string inputFile = ArgParser.Parameter("GRAPHICSCREEN");

            GR.Memory.ByteBuffer data = GR.IO.File.ReadAllBytes(inputFile);
            if (data == null)
            {
                System.Console.WriteLine("Couldn't read binary char file " + inputFile);
                return(1);
            }

            var graphicScreen = new C64Studio.Formats.GraphicScreenProject();

            if (!graphicScreen.ReadFromBuffer(data))
            {
                System.Console.WriteLine("Couldn't read graphicscreen project from file " + inputFile);
                return(1);
            }

            // import
            if (ArgParser.IsParameterSet("IMPORTIMAGE"))
            {
                var image = LoadImageFromFile(ArgParser.Parameter("IMPORTIMAGE"));
                if (image == null)
                {
                    System.Console.WriteLine("Couldn't read image from file " + ArgParser.Parameter("IMPORTIMAGE"));
                    return(1);
                }
                if ((image.Width > graphicScreen.ScreenWidth) ||
                    (image.Height > graphicScreen.ScreenHeight))
                {
                    System.Console.WriteLine("Couldn't read image from file " + ArgParser.Parameter("IMPORTIMAGE"));
                    return(1);
                }
                if (image.PixelFormat != System.Drawing.Imaging.PixelFormat.Format8bppIndexed)
                {
                    image.Dispose();
                    Console.WriteLine("Image format invalid!\nNeeds to be 8bit index");
                    return(1);
                }
            }

            // export
            int x      = 0;
            int y      = 0;
            int width  = -1;
            int height = -1;

            if (ArgParser.IsParameterSet("AREA"))
            {
                string   rangeInfo  = ArgParser.Parameter("AREA");
                string[] rangeParts = rangeInfo.Split(',');
                if (rangeParts.Length != 4)
                {
                    System.Console.WriteLine("AREA is invalid, expected four values separated by comma: x,y,width,height");
                    return(1);
                }
                x      = GR.Convert.ToI32(rangeParts[0]);
                y      = GR.Convert.ToI32(rangeParts[1]);
                width  = GR.Convert.ToI32(rangeParts[2]);
                height = GR.Convert.ToI32(rangeParts[3]);

                if ((width <= 0) ||
                    (height <= 0) ||
                    (x < 0) ||
                    (y < 0) ||
                    (x + width > graphicScreen.ScreenWidth) ||
                    (y + height > graphicScreen.ScreenHeight))
                {
                    System.Console.WriteLine("AREA values are out of bounds or invalid, expected four values separated by comma: x,y,width,height");
                    return(1);
                }
            }
            else
            {
                width  = graphicScreen.ScreenWidth;
                height = graphicScreen.ScreenHeight;
            }

            bool exportMC     = exportType.Contains("MULTICOLOR");
            bool exportScreen = exportType.Contains("SCREEN");
            bool exportColors = exportType.Contains("COLORS");
            bool exportBitmap = exportType.Contains("BITMAP");

            GR.Memory.ByteBuffer screenChar  = new GR.Memory.ByteBuffer();
            GR.Memory.ByteBuffer screenColor = new GR.Memory.ByteBuffer();
            GR.Memory.ByteBuffer bitmapData  = new GR.Memory.ByteBuffer();

            bool[,]   errornousChars = new bool[(width + 7) / 8, (height + 7) / 8];
            var charData  = new List <C64Studio.Formats.CharData>(errornousChars.Length);
            int numErrors = 0;

            if (!exportMC)
            {
                // HIRES
                numErrors = graphicScreen.ImageToHiresBitmapData(charData, errornousChars, x / 8, y / 8, width / 8, height / 8, out bitmapData, out screenChar, out screenColor);
            }
            else
            {
                // MC
                numErrors = graphicScreen.ImageToMCBitmapData(graphicScreen.ColorMapping, charData, errornousChars, x / 8, y / 8, width / 8, height / 8, out bitmapData, out screenChar, out screenColor);
            }
            if (numErrors > 0)
            {
                System.Console.WriteLine("Format did not match expectations (check for color clashes)");
                return(1);
            }

            // build export data
            GR.Memory.ByteBuffer exportData = new GR.Memory.ByteBuffer();

            if (exportType.Contains("BITMAPSCREENCOLORS"))
            {
                exportData.Append(bitmapData);
                exportData.Append(screenChar);
                exportData.Append(screenColor);
            }
            else if (exportType.Contains("BITMAPCOLORSSCREEN"))
            {
                exportData.Append(bitmapData);
                exportData.Append(screenColor);
                exportData.Append(screenChar);
            }
            else if (exportType.Contains("BITMAPCOLORS"))
            {
                exportData.Append(bitmapData);
                exportData.Append(screenColor);
            }
            else if (exportType.Contains("BITMAPSCREEN"))
            {
                exportData.Append(bitmapData);
                exportData.Append(screenChar);
            }
            else if (exportType.Contains("BITMAP"))
            {
                exportData.Append(bitmapData);
            }

            if (!GR.IO.File.WriteAllBytes(ArgParser.Parameter("EXPORT"), exportData))
            {
                Console.WriteLine("Could not write to file " + ArgParser.Parameter("EXPORT"));
                return(1);
            }

            return(0);
        }
Beispiel #7
0
        public C64Studio.Parser.CompileConfig CheckParams(string[] Args)
        {
            C64Studio.Parser.CompileConfig config = null;

            if (Args.Length == 0)
            {
                WriteHelp();
                return(config);
            }

            if (!_Args.CheckParameters(Args))
            {
                WriteHelp();
                return(config);
            }

            // last arg is filename?
            if ((Args[Args.Length - 1].StartsWith("-")) ||
                (Args[Args.Length - 1].StartsWith("/")))
            {
                WriteHelp();
                return(config);
            }

            config           = new C64Studio.Parser.CompileConfig();
            config.InputFile = Args[Args.Length - 1];

            if (_Args.IsParameterSet("O"))
            {
                config.OutputFile = _Args.Parameter("O");
            }
            if (_Args.IsParameterSet("OUTFILE"))
            {
                config.OutputFile = _Args.Parameter("OUTFILE");
            }
            if (_Args.IsParameterSet("L"))
            {
                config.LabelDumpFile = _Args.Parameter("L");
            }
            if (_Args.IsParameterSet("-LABELDUMP"))
            {
                config.LabelDumpFile = _Args.Parameter("LABELDUMP");
            }
            if (_Args.IsParameterSet("LIB"))
            {
                config.LibraryFiles = _Args.Parameter("LIB").Split(',').ToList();
            }
            if (_Args.IsParameterSet("LIBRARY"))
            {
                config.LibraryFiles = _Args.Parameter("LIBRARY").Split(',').ToList();
            }
            config.AutoTruncateLiteralValues = _Args.IsParameterSet("-AUTOTRUNCATELITERALS");

            if ((_Args.IsParameterSet("F")) ||
                (_Args.IsParameterSet("-FORMAT")))
            {
                string outputFormat = _Args.IsParameterSet("F") ? _Args.Parameter("F") : _Args.Parameter("-FORMAT");

                if (string.Compare(outputFormat, "PLAIN", true) == 0)
                {
                    config.TargetType = C64Studio.Types.CompileTargetType.PLAIN;
                }
                else if (string.Compare(outputFormat, "CBM", true) == 0)
                {
                    config.TargetType = C64Studio.Types.CompileTargetType.PRG;
                }
            }

            if (_Args.IsParameterSet("-SETPC"))
            {
                int startPC = GR.Convert.ToI32(_Args.Parameter("-SETPC"));
                if ((startPC >= 0) &&
                    (startPC < 65536))
                {
                    config.StartAddress = startPC;
                }
            }
            return(config);
        }
        public RetroDevStudio.Parser.CompileConfig CheckParams(string[] Args, out string AdditionalDefines, out bool ShowNoWarnings, out List <string> WarningsToIgnore)
        {
            RetroDevStudio.Parser.CompileConfig config = null;
            AdditionalDefines = null;
            ShowNoWarnings    = false;
            WarningsToIgnore  = new List <string>();

            if (Args.Length == 0)
            {
                WriteHelp();
                return(config);
            }

            if (!_Args.CheckParameters(Args))
            {
                WriteHelp();
                return(config);
            }

            if ((_Args.IsParameterSet("V")) ||
                (_Args.IsParameterSet("-VERSION")))
            {
                Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;

                Console.WriteLine($"C64Ass Assembler V{version}");
                return(null);
            }

            // last arg is filename?
            if (_Args.UnknownArgumentCount() < 1)
            {
                // last arg should be file name!
                WriteHelp();
                return(config);
            }

            config           = new RetroDevStudio.Parser.CompileConfig();
            config.InputFile = _Args.UnknownArgument(_Args.UnknownArgumentCount() - 1);

            if (_Args.IsParameterSet("O"))
            {
                config.OutputFile = _Args.Parameter("O");
            }
            if (_Args.IsParameterSet("OUTFILE"))
            {
                config.OutputFile = _Args.Parameter("OUTFILE");
            }
            if (_Args.IsParameterSet("L"))
            {
                config.LabelDumpFile = _Args.Parameter("L");
            }
            if (_Args.IsParameterSet("-LABELDUMP"))
            {
                config.LabelDumpFile = _Args.Parameter("LABELDUMP");
            }
            if (_Args.IsParameterSet("LIB"))
            {
                config.LibraryFiles = _Args.Parameter("LIB").Split(',').ToList();
            }
            if (_Args.IsParameterSet("LIBRARY"))
            {
                config.LibraryFiles = _Args.Parameter("LIBRARY").Split(',').ToList();
            }
            if (_Args.IsParameterSet("N"))
            {
                ShowNoWarnings = true;
            }
            if (_Args.IsParameterSet("-NOWARNINGS"))
            {
                ShowNoWarnings = true;
            }
            if (_Args.IsParameterSet("I"))
            {
                ParseWarnings(WarningsToIgnore, _Args.Parameter("I"));
            }
            if (_Args.IsParameterSet("-IGNORE"))
            {
                ParseWarnings(WarningsToIgnore, _Args.Parameter("-IGNORE"));
            }
            config.AutoTruncateLiteralValues = _Args.IsParameterSet("-AUTOTRUNCATELITERALS");

            for (int i = 0; i < _Args.UnknownArgumentCount() - 1; ++i)
            {
                var curArg = _Args.UnknownArgument(i).ToUpper();
                if ((curArg == "-D") ||
                    (curArg == "--DEFINE"))
                {
                    if (i + 1 >= _Args.UnknownArgumentCount() - 1)
                    {
                        // no argument for define
                        WriteHelp();
                        return(null);
                    }
                    AdditionalDefines += _Args.UnknownArgument(i + 1) + "\r\n";
                    ++i;
                }
                else
                {
                    Console.WriteLine("Unsupported argument: " + _Args.UnknownArgument(i));
                    WriteHelp();
                    return(null);
                }
            }

            if ((_Args.IsParameterSet("F")) ||
                (_Args.IsParameterSet("-FORMAT")))
            {
                string outputFormat = _Args.IsParameterSet("F") ? _Args.Parameter("F") : _Args.Parameter("-FORMAT");

                if (string.Compare(outputFormat, "PLAIN", true) == 0)
                {
                    config.TargetType = RetroDevStudio.Types.CompileTargetType.PLAIN;
                }
                else if (string.Compare(outputFormat, "CBM", true) == 0)
                {
                    config.TargetType = RetroDevStudio.Types.CompileTargetType.PRG;
                }
                else if (string.Compare(outputFormat, "D64", true) == 0)
                {
                    config.TargetType = RetroDevStudio.Types.CompileTargetType.D64;
                }
            }

            if (_Args.IsParameterSet("-SETPC"))
            {
                int startPC = GR.Convert.ToI32(_Args.Parameter("-SETPC"));
                if ((startPC >= 0) &&
                    (startPC < 65536))
                {
                    config.StartAddress = startPC;
                }
            }
            return(config);
        }
        private int HandleCharscreenFile(GR.Text.ArgumentParser ArgParser)
        {
            if (!ValidateExportType("charscreen file", ArgParser.Parameter("TYPE"), new string[] { "CHARS", "CHARSCOLORS", "COLORS" }))
            {
                return(1);
            }

            GR.Memory.ByteBuffer data = GR.IO.File.ReadAllBytes(ArgParser.Parameter("CHARSCREEN"));
            if (data == null)
            {
                System.Console.WriteLine("Couldn't read binary char file " + ArgParser.Parameter("CHARSCREEN"));
                return(1);
            }

            var charScreenProject = new RetroDevStudio.Formats.CharsetScreenProject();

            if (!charScreenProject.ReadFromBuffer(data))
            {
                System.Console.WriteLine("Couldn't read charscreen project from file " + ArgParser.Parameter("CHARSCREEN"));
                return(1);
            }

            int x      = 0;
            int y      = 0;
            int width  = -1;
            int height = -1;

            if (ArgParser.IsParameterSet("AREA"))
            {
                string   rangeInfo  = ArgParser.Parameter("AREA");
                string[] rangeParts = rangeInfo.Split(',');
                if (rangeParts.Length != 4)
                {
                    System.Console.WriteLine("AREA is invalid, expected four values separated by comma: x,y,width,height");
                    return(1);
                }
                x      = GR.Convert.ToI32(rangeParts[0]);
                y      = GR.Convert.ToI32(rangeParts[1]);
                width  = GR.Convert.ToI32(rangeParts[2]);
                height = GR.Convert.ToI32(rangeParts[3]);

                if ((width <= 0) ||
                    (height <= 0) ||
                    (x < 0) ||
                    (y < 0) ||
                    (x + width > charScreenProject.ScreenWidth) ||
                    (y + height > charScreenProject.ScreenHeight))
                {
                    System.Console.WriteLine("AREA values are out of bounds or invalid, expected four values separated by comma: x,y,width,height");
                    return(1);
                }
            }
            else
            {
                width  = charScreenProject.ScreenWidth;
                height = charScreenProject.ScreenHeight;
            }

            GR.Memory.ByteBuffer resultingData = new GR.Memory.ByteBuffer();

            if (ArgParser.Parameter("TYPE").Contains("CHARS"))
            {
                for (int j = y; j < y + height; ++j)
                {
                    for (int i = x; i < x + width; ++i)
                    {
                        resultingData.AppendU8((byte)charScreenProject.Chars[i + j * charScreenProject.ScreenWidth]);
                    }
                }
            }
            if (ArgParser.Parameter("TYPE").Contains("COLORS"))
            {
                for (int j = y; j < y + height; ++j)
                {
                    for (int i = x; i < x + width; ++i)
                    {
                        resultingData.AppendU8((byte)(charScreenProject.Chars[i + j * charScreenProject.ScreenWidth] >> 8));
                    }
                }
            }
            if (!GR.IO.File.WriteAllBytes(ArgParser.Parameter("EXPORT"), resultingData))
            {
                Console.WriteLine("Could not write to file " + ArgParser.Parameter("EXPORT"));
                return(1);
            }
            return(0);
        }