Beispiel #1
0
        public void OpenResource(Panel parentPanel, PhactoryHost.Database.Resource resource)
        {
            View.View view = new View.View(resource);
            view.Parent = parentPanel;
            view.Dock   = System.Windows.Forms.DockStyle.Fill;

            ResourceBinding resourceBinding = new ResourceBinding(parentPanel, view);

            viewBinding.Add(resource, resourceBinding);

            resourceBinding.View.Document = Host.XMLRead <Document.Document>(Host.GetFileInfo(resource).FullName);

            if (resourceBinding.View.Document is Document.Document)
            {
                if (Host.IsVerboseOutput())
                {
                    Host.Log(resource.DisplayName + " loaded");
                }
            }
            else
            {
                Host.Log("Problem while loading " + resource.DisplayName);
            }

            view.RefreshUI();
            view.RefreshTitle();

            view.IsReady = true;
        }
Beispiel #2
0
        public void OpenResource(Panel parentPanel, PhactoryHost.Database.Resource resource)
        {
            View.View view = new View.View(resource);
            view.Parent = parentPanel;
            view.Dock   = System.Windows.Forms.DockStyle.Fill;

            viewBinding.Add(resource, new ResourceBinding(parentPanel, view));

            bool highLight = false;

            string language = "";

            switch (Host.GetFileInfo(resource).Extension.ToLower())
            {
            case ".s":
            case ".asm":
            case ".c":
            case ".h":
            case ".cxx":
            case ".cpp":
                highLight = true;
                break;

            default:
                highLight = false;
                break;
            }
            if (language.Length != 0)
            {
                //view.textEditorControl.ConfigurationManager.Language = language;
            }

            if (highLight)
            {
                HighlightingManager.Manager.AddSyntaxModeFileProvider(new FileSyntaxModeProvider(Application.StartupPath));
                view.textEditorControl.Document.HighlightingStrategy = HighlightingManager.Manager.FindHighlighter("c_z80");
            }

            FileInfo fileInfo    = Host.GetFileInfo(resource);
            string   fileContent = File.ReadAllText(fileInfo.FullName);;

            view.textEditorControl.Text = fileContent;

            if (Host.IsVerboseOutput())
            {
                Host.Log(resource.DisplayName + " loaded");
            }

            view.IsReady = true;

            if (resource.IsOutputResource)
            {
                view.SetReadOnly(true);
            }

            view.RefreshTitle();
        }
Beispiel #3
0
        public bool Run(PhactoryHost.Database.Resource resource)
        {
            PhactoryHost.Database.Resource parentResource = Host.GetResource(resource.IdDependencies[0]);

            Document.Document document = Host.XMLRead <Document.Document>(Host.GetFileInfo(parentResource).FullName);

            string fileToExecute = "";

            foreach (Document.Item item in document.Items)
            {
                if (item.ExecAdress != 0)
                {
                    fileToExecute = item.AmsdosFilename;
                }
            }

            string DSKFilename = Host.GetFileInfo(resource).FullName;

            DSKFilename = DSKFilename.Replace(".cpcdsk", ".dsk");

            FileInfo DSKFileInfo = new FileInfo(DSKFilename);

            string WinAPEFullPath = Host.GetPluginsPath() + "WinAPE.exe";

            string arguments = "\"" + DSKFileInfo.FullName + "\" /A";

            if (Host.IsVerboseOutput())
            {
                Host.Log(WinAPEFullPath + " " + arguments);
            }

            return(Host.StartAndWaitAfterProcess(WinAPEFullPath, arguments, DSKFileInfo.DirectoryName));
        }
Beispiel #4
0
        public void OpenResource(Panel parentPanel, PhactoryHost.Database.Resource resource)
        {
            View.View view = new View.View(resource);
            view.Parent = parentPanel;
            view.Dock   = System.Windows.Forms.DockStyle.Fill;

            viewBinding.Add(resource, new ResourceBinding(parentPanel, view));

            try
            {
                view.PictureBox.Image   = Image.FromFile(Host.GetFileInfo(resource).FullName, true);
                view.PictureWidth.Text  = "" + view.PictureBox.Image.Width + " Pixel(s)";
                view.PictureHeight.Text = "" + view.PictureBox.Image.Height + " Pixel(s)";
                view.PictureDepth.Text  = "" + view.PictureBox.Image.PixelFormat.ToString();

                if (Host.IsVerboseOutput())
                {
                    Host.Log(resource.DisplayName + " loaded");
                }
            }
            catch (System.IO.FileNotFoundException)
            {
                Host.Log("Problem while loading " + resource.DisplayName);
            }

            view.RefreshTitle();

            view.IsReady = true;
        }
Beispiel #5
0
        public bool Compile(PhactoryHost.Database.Resource resource)
        {
            FileInfo fileInfo = Host.GetFileInfo(resource);

            if (fileInfo == null)
            {
                return(false);
            }

            if (!IsResourceSupported(resource))
            {
                return(false);
            }

            var compiler = new Phactory.Modules.Cloud.Compiler.CloudCompiler();

            Document.Document tempDocument = Host.XMLRead <Document.Document>(Host.GetFileInfo(resource).FullName);
            if (!tempDocument.CompileInternal())
            {
                return(false);
            }

            foreach (Document.Item item in tempDocument.Items)
            {
                PhactoryHost.Database.Resource resItem = Host.GetResource(item.ResourceID);
                if (resItem == null)
                {
                    Host.Log("Unknown resource identifier : " + item.ResourceID);
                    return(false);
                }

                FileInfo resFileInfo    = Host.GetFileInfo(resItem);
                string   outputFilename = resFileInfo.FullName;

                if (Host.IsVerboseOutput())
                {
                    Host.Log(outputFilename);
                }

                string outputFilenameBin = outputFilename + ".bin";

                if (!compiler.WriteCloudBitmap(outputFilenameBin, item.CloudMaskData, item.CloudMaskWidth, item.CloudMaskHeight))
                {
                    return(false);
                }
            }

            return(true);
        }
Beispiel #6
0
        private bool ConvertDSK(string filename)
        {
            var dskFileInfo = new FileInfo(filename);

            string tempDir = "\\HFE_CONVERT";

            Directory.CreateDirectory(tempDir);

            string src = tempDir + "\\" + dskFileInfo.Name;

            if (File.Exists(src))
            {
                File.Delete(src);
            }
            File.Copy(dskFileInfo.FullName, src);

            string hfeConverterFullPath = _host.GetPluginsPath() + "flopimage_convert.exe";

            string arguments = tempDir + " " + tempDir + " -HFE";

            if (_host.IsVerboseOutput())
            {
                _host.Log(hfeConverterFullPath + " " + arguments);
            }

            string dst = "";

            bool isOK = _host.StartProcess(hfeConverterFullPath, arguments, tempDir, true);

            if (isOK)
            {
                string dskhfe = src.Replace(".dsk", "_dsk.hfe");
                dst = dskFileInfo.FullName.Replace(".dsk", ".hfe");

                if (File.Exists(dst))
                {
                    File.Delete(dst);
                }
                File.Copy(dskhfe, dst);

                File.Delete(src);
                File.Delete(dskhfe);
            }

            Directory.Delete(tempDir);

            return(File.Exists(dst));
        }
Beispiel #7
0
        public void OpenResource(Panel parentPanel, PhactoryHost.Database.Resource resource)
        {
            View.View view = new View.View(resource);
            view.Parent = parentPanel;
            view.Dock   = System.Windows.Forms.DockStyle.Fill;

            viewBinding.Add(resource, new ResourceBinding(parentPanel, view));

            view.RefreshContent();
            view.RefreshTitle();

            if (Host.IsVerboseOutput())
            {
                Host.Log(resource.DisplayName + " loaded");
            }

            view.IsReady = true;
        }
Beispiel #8
0
        public bool Compile(PhactoryHost.Database.Resource resource)
        {
            FileInfo fileInfo = Host.GetFileInfo(resource);

            if (fileInfo == null)
            {
                return(false);
            }

            if (!IsResourceSupported(resource))
            {
                return(false);
            }

            bool isOK = true;

            string DSKFilename = Host.GetFileInfo(resource).FullName;

            DSKFilename = DSKFilename.Replace(".cpcdsk", ".dsk");
            FileInfo DSKFileInfo = new FileInfo(DSKFilename);

            Host.Log(new FileInfo(DSKFilename).Name);

            Document.Document document = Host.XMLRead <Document.Document>(Host.GetFileInfo(resource).FullName);
            if (!(document is Document.Document))
            {
                return(false);
            }

            // create empty DSK
            if (document.TrackLoaderDisc)
            {
                App.Controller.View.AppDoEvents();

                if (File.Exists(DSKFilename))
                {
                    try
                    {
                        File.Delete(DSKFilename);
                    }
                    catch
                    {
                        Host.Log("Can't delete " + DSKFilename + " - is the file locked by other process ?");
                    }
                }
                try
                {
                    string discsysExeFullPath = Host.GetPluginsPath() + "discsys.exe";
                    var    arguments          = "-f \"myd\" " + DSKFileInfo.FullName;

                    if (Host.IsVerboseOutput())
                    {
                        Host.Log(discsysExeFullPath + " " + arguments);
                    }

                    isOK = Host.StartProcess(discsysExeFullPath, arguments, fileInfo.DirectoryName, true);
                }
                catch
                {
                }
            }
            else
            {
                string dskTemplateFilename = Host.GetPluginsPath() + "Empty.dsk";
                if (File.Exists(DSKFilename))
                {
                    try
                    {
                        File.Delete(DSKFilename);
                    }
                    catch
                    {
                        Host.Log("Can't delete " + DSKFilename + " - is the file locked by other process ?");
                    }
                }
                try
                {
                    File.Copy(dskTemplateFilename, DSKFilename);
                }
                catch
                {
                }
            }

            // copy files into DSK
            if (document.TrackLoaderDisc)
            {
                foreach (Document.Item item in document.Items)
                {
                    PhactoryHost.Database.Resource depResource = Host.GetResource(item.ResourceID);
                    if (depResource == null)
                    {
                        Host.Log("Unknown resource identifier : " + item.ResourceID);
                        return(false);
                    }

                    FileInfo depFileInfo = Host.GetFileInfo(depResource);

                    if (!item.TrackLoaderItem)
                    {
                        // addhead -a -t "binary" -s 8192 -x 8192 boot.bin boot.bin

                        string addheadExeFullPath = Host.GetPluginsPath() + "addhead.exe";

                        string arguments = String.Empty;

                        if (item.ItemType == Document.ItemType.Basic)
                        {
                            arguments  = "-a -t \"basic\" ";
                            arguments += "-s " + 368 + " ";
                            arguments += "-x " + 368 + " ";
                            arguments += depFileInfo.FullName + " ";

                            arguments += "\"" + Path.GetTempPath() + item.AmsdosFilename + "\"";
                        }
                        else
                        {
                            arguments  = "-a -t \"binary\" ";
                            arguments += "-s " + item.LoadAdress + " ";
                            arguments += "-x " + item.ExecAdress + " ";
                            arguments += depFileInfo.FullName + " ";
                            arguments += "\"" + Path.GetTempPath() + item.AmsdosFilename + "\"";
                        }


                        if (Host.IsVerboseOutput())
                        {
                            Host.Log(addheadExeFullPath + " " + arguments);
                        }

                        isOK = Host.StartProcess(addheadExeFullPath, arguments, fileInfo.DirectoryName, true);
                        if (isOK)
                        {
                            string cpcxfsExeFullPath = Host.GetPluginsPath() + "cpcxfs.exe";
                            var    dstCpcXfsExe      = Path.GetTempPath() + new FileInfo(cpcxfsExeFullPath).Name;
                            var    dstCpmDisksDef    = Path.GetTempPath() + "cpmdisks.def";
                            if (!File.Exists(dstCpcXfsExe))
                            {
                                File.Copy(cpcxfsExeFullPath, dstCpcXfsExe, true);
                            }
                            if (!File.Exists(dstCpmDisksDef))
                            {
                                File.Copy(Host.GetPluginsPath() + "cpmdisks.def", dstCpmDisksDef, true);
                            }

                            arguments  = "-o MLOD " + DSKFilename + " -f -b -p ";
                            arguments += "\"" + Path.GetTempPath() + item.AmsdosFilename + "\"";
                            if (Host.IsVerboseOutput())
                            {
                                Host.Log(cpcxfsExeFullPath + " " + arguments);
                            }

                            isOK = Host.StartProcess(cpcxfsExeFullPath, arguments, Path.GetTempPath(), true);

                            var lastErrorOutput    = Host.GetLastErrorOutput();
                            var lastStandardOutput = Host.GetLastStandardOutput();

                            App.Controller.View.AppDoEvents();

                            if (File.Exists(dstCpcXfsExe))
                            {
                                File.Delete(dstCpcXfsExe);
                            }
                            if (File.Exists(dstCpmDisksDef))
                            {
                                File.Delete(dstCpmDisksDef);
                            }
                        }

                        if (File.Exists(Path.GetTempPath() + item.AmsdosFilename))
                        {
                            File.Delete(Path.GetTempPath() + item.AmsdosFilename);
                        }
                    }
                }

                int itemCount = 0;
                var content   = String.Empty;
                foreach (Document.Item item in document.Items)
                {
                    PhactoryHost.Database.Resource depResource = Host.GetResource(item.ResourceID);
                    if (depResource == null)
                    {
                        Host.Log("Unknown resource identifier : " + item.ResourceID);
                        return(false);
                    }

                    if (item.TrackLoaderItem)
                    {
                        // discsys test.dsk 1 sabotr2.ayc

                        FileInfo depFileInfo = Host.GetFileInfo(depResource);

                        content += itemCount + " \"" + depFileInfo.FullName + "\"\n";

                        itemCount++;
                    }
                }

                string fileListFilename = Host.GetFileInfo(resource).FullName;
                fileListFilename = fileListFilename.Replace(".cpcdsk", ".filelist");
                File.WriteAllText(fileListFilename, content);

                // discsys test.dsk 1 sabotr2.ayc

                var discsysExeFullPath = Host.GetPluginsPath() + "discsys.exe";
                var disksysArguments   = "-l \"" + fileListFilename + "\" \"" + DSKFilename + "\"";

                if (Host.IsVerboseOutput())
                {
                    Host.Log(discsysExeFullPath + " " + disksysArguments);
                }
                isOK = Host.StartProcess(discsysExeFullPath, disksysArguments, fileInfo.DirectoryName, true);
            }
            else
            {
                string exeFullPath = Host.GetPluginsPath() + "ManageDSK.EXE";

                foreach (Document.Item item in document.Items)
                {
                    App.Controller.View.AppDoEvents();

                    PhactoryHost.Database.Resource depResource = Host.GetResource(item.ResourceID);
                    if (depResource == null)
                    {
                        Host.Log("Unknown resource identifier : " + item.ResourceID);
                        return(false);
                    }

                    FileInfo depFileInfo = Host.GetFileInfo(depResource);

                    string arguments = "-L\"" + DSKFileInfo.FullName + "\" ";

                    arguments += "-I\"" + depFileInfo.FullName + "\"";

                    arguments += "/" + item.AmsdosFilename;

                    if (item.ItemType == Document.ItemType.Basic)
                    {
                        arguments += "/BAS/368";
                    }
                    else
                    {
                        arguments += "/BIN";

                        arguments += "/" + item.LoadAdress;
                        arguments += "/" + item.ExecAdress;
                    }

                    arguments += " ";

                    arguments += "-S\"" + DSKFileInfo.FullName + "\"";

                    if (Host.IsVerboseOutput())
                    {
                        Host.Log(exeFullPath + " " + arguments);
                    }

                    isOK = Host.StartProcess(exeFullPath, arguments, fileInfo.DirectoryName, true);
                    if (isOK)
                    {
                        if (Host.GetLastErrorOutput().ToUpper().IndexOf("ERREUR") != -1)
                        {
                            isOK = false;
                        }
                    }

                    if (item.CopyToWinAPEROMFolder)
                    {
                        string romFilename     = item.AmsdosFilename; // depFileInfo.Name.Replace(depFileInfo.Extension, ".ROM");
                        string destROMFilename = Host.GetPluginsPath() + "ROM\\" + romFilename;
                        if (File.Exists(destROMFilename))
                        {
                            File.Delete(destROMFilename);
                        }
                        File.Copy(depFileInfo.FullName, destROMFilename);

                        App.Controller.View.AppDoEvents();
                    }
                }
            }

            if (document.GenerateHFE)
            {
                Host.Log(new FileInfo(DSKFilename.Replace(".dsk", ".hfe")).Name);

                string tempDir = "\\HFE_CONVERT";

                App.Controller.View.AppDoEvents();

                Directory.CreateDirectory(tempDir);

                App.Controller.View.AppDoEvents();

                string src = tempDir + "\\" + DSKFileInfo.Name;
                if (File.Exists(src))
                {
                    File.Delete(src);
                }
                File.Copy(DSKFileInfo.FullName, src);

                App.Controller.View.AppDoEvents();

                string hfeConverterFullPath = Host.GetPluginsPath() + "flopimage_convert.exe";

                string arguments = tempDir + " " + tempDir + " -HFE";

                if (Host.IsVerboseOutput())
                {
                    Host.Log(hfeConverterFullPath + " " + arguments);
                }

                string dst = "";

                isOK = Host.StartProcess(hfeConverterFullPath, arguments, fileInfo.DirectoryName, true);
                if (isOK)
                {
                    string dskhfe = src.Replace(".dsk", "_dsk.hfe");
                    dst = DSKFileInfo.FullName.Replace(".dsk", ".hfe");

                    App.Controller.View.AppDoEvents();

                    if (File.Exists(dst))
                    {
                        File.Delete(dst);
                    }
                    if (File.Exists(dskhfe))
                    {
                        File.Copy(dskhfe, dst);
                        File.Delete(dskhfe);
                    }

                    File.Delete(src);
                }

                App.Controller.View.AppDoEvents();

                Directory.Delete(tempDir, true);

                if (File.Exists(dst) == false)
                {
                    isOK = false;
                }
            }

            return(isOK);
        }
Beispiel #9
0
        public bool Compile(PhactoryHost.Database.Resource resource)
        {
            FileInfo fileInfo = Host.GetFileInfo(resource);

            if (fileInfo == null)
            {
                return(false);
            }

            if (!IsResourceSupported(resource))
            {
                return(false);
            }

            string   CPCBitmapFilename = Host.GetFileInfo(resource).FullName;
            FileInfo CPCBitmapFileInfo = new FileInfo(CPCBitmapFilename);

            Document.Document tempDocument = Host.XMLRead <Document.Document>(Host.GetFileInfo(resource).FullName);
            if (!tempDocument.CompileInternal())
            {
                return(false);
            }

            var CPCBitmapFilenamePalette = CPCBitmapFilename + ".palette";

            if (WritePalette(tempDocument, CPCBitmapFilenamePalette) == false)
            {
                return(false);
            }

            var CPCBitmapFilenameFirmwarePalette = CPCBitmapFilename + ".firmwarePalette";

            if (WriteFirmwarePalette(tempDocument, CPCBitmapFilenameFirmwarePalette) == false)
            {
                return(false);
            }

            string destFilenameH = Host.GetFileInfo(resource).FullName + ".info.h";
            var    title         = resource.DisplayName.ToUpper().Replace(" ", "").Replace(".", "") + "H";

            var fileContent = String.Empty;

            fileContent += "// ----------------------------------------------------------------------------\n";
            fileContent += "#ifndef _" + title + "_INFO_H_\n";
            fileContent += "#define _" + title + "_INFO_H_\n";
            fileContent += "\n";

            fileContent += "// ----------------------------------------------------------------------------\n";

            List <Document.Item> items = new List <Document.Item>();
            bool isGroup = false;

            foreach (Document.Item item in tempDocument.Items)
            {
                if (item.IsGroupDelimiter)
                {
                    if (isGroup)
                    {
                        items.Add(item);
                        isGroup = false;
                    }
                    else
                    {
                        isGroup = true;
                    }
                }
                if (isGroup)
                {
                    items.Add(item);
                }
            }
            isGroup = false;
            int startIndex = -1;
            List <Document.Item> resolvedItems = new List <Document.Item>();

            for (int iItem = 0; iItem < tempDocument.Items.Count; iItem++)
            {
                Document.Item item     = tempDocument.Items[iItem];
                Document.Item prevItem = null;

                if (item.IsGroupDelimiter)
                {
                    if (isGroup)
                    {
                        prevItem = tempDocument.Items[iItem - 2];
                        isGroup  = false;
                    }
                    else
                    {
                        isGroup    = true;
                        startIndex = iItem;
                    }
                }

                if (isGroup)
                {
                    if (iItem == startIndex)
                    {
                        prevItem = tempDocument.Items[startIndex + items.Count - 1 - 1];
                    }
                    else
                    if (iItem == (startIndex + 1))
                    {
                        prevItem = tempDocument.Items[startIndex + items.Count - 1];
                    }
                    else
                    {
                        prevItem = tempDocument.Items[iItem - 2];
                    }
                }

                resolvedItems.Add(prevItem);
            }

            for (int iItem = 0; iItem < tempDocument.Items.Count; iItem++)
            {
                App.Controller.View.AppDoEvents();

                Document.Item item = tempDocument.Items[iItem];

                PhactoryHost.Database.Resource resItem = Host.GetResource(item.ResourceID);
                if (resItem == null)
                {
                    Host.Log("Unknown resource identifier : " + item.ResourceID);
                    return(false);
                }

                FileInfo resFileInfo    = Host.GetFileInfo(resItem);
                string   outputFilename = resFileInfo.FullName;

                if (Host.IsVerboseOutput())
                {
                    Host.Log(outputFilename);
                }

                bool useMask = false;
                if (item.UseMaskType == Document.UseMaskType.NoMask)
                {
                }
                else
                if (item.UseMaskType == Document.UseMaskType.ColorMask)
                {
                    useMask = true;
                }
                else
                if (item.UseMaskType == Document.UseMaskType.BitmapMask)
                {
                    useMask = true;
                }

                var itemResource = Host.GetResource(item.ResourceID);
                var itemTitle    = itemResource.DisplayName.ToUpper().Replace(" ", "").Replace(".", "");

                if (item.IsFade)
                {
                    for (int iTargetItem = 0; iTargetItem < tempDocument.Items.Count; iTargetItem++)
                    {
                        var targetItem = tempDocument.Items[iTargetItem];

                        if (targetItem.ResourceID == item.MaskFadeResourceID)
                        {
                            var targetItemResource = Host.GetResource(targetItem.ResourceID);

                            string outputFadeFilename = outputFilename + ".fadePalette";

                            if (!WriteFadePalette(tempDocument, outputFadeFilename, item, targetItem))
                            {
                                return(false);
                            }

                            break;
                        }
                    }
                }
                else if (item.Type == Document.ItemType.FullScreenBitmap)
                {
                    string outputTopFilename    = outputFilename + ".topBin";
                    string outputBottomFilename = outputFilename + ".bottomBin";

                    var bitmapCompiler = BitmapCompiler.CreateCompiler(tempDocument.VideoMode);
                    if (!bitmapCompiler.WriteFullscreenBitmap(outputTopFilename,
                                                              outputBottomFilename,
                                                              item.IsFullScreenTitle,
                                                              (byte)item.MaskPenIndex,
                                                              item.IntermediateImage.Width,
                                                              item.IntermediateImage.Height,
                                                              item.IntermediateImage.Data,
                                                              (byte)tempDocument.StartIndex))
                    {
                        return(false);
                    }

                    fileContent += "#define " + itemTitle + "_FSBITMAP_HEIGHT " + item.IntermediateImage.Height + "\n";
                    fileContent += "#define " + itemTitle + "_FSBITMAP_BYTEWIDTH " + item.IntermediateImage.Width / 2 + "\n";
                    fileContent += "#define " + itemTitle + "_FSBITMAP_SIZE " + (item.IntermediateImage.Height / 2) * (item.IntermediateImage.Width / 2) + "\n";
                }
                else if (item.Type == Document.ItemType.Font)
                {
                    string outputFontFilename = outputFilename + ".font";

                    var bitmapCompiler = BitmapCompiler.CreateCompiler(tempDocument.VideoMode);
                    if (!bitmapCompiler.WriteFont(outputFontFilename, item.FontAlignOnCharaterLine, item.FontCharWidthInBytes,
                                                  item.IntermediateImage.Width,
                                                  item.IntermediateImage.Height,
                                                  item.IntermediateImage.Data,
                                                  (byte)tempDocument.StartIndex))
                    {
                        return(false);
                    }

                    fileContent += "#define " + itemTitle + "_FONT_HEIGHT " + item.IntermediateImage.Height + "\n";
                    fileContent += "#define " + itemTitle + "_FONT_BYTEWIDTH " + item.FontCharWidthInBytes + "\n";
                    fileContent += "#define " + itemTitle + "_FONT_CHARCOUNT " + ((item.IntermediateImage.Width / 4) / item.FontCharWidthInBytes) + "\n";
                }
                else if (
                    (item.Type == Document.ItemType.SpriteFullScreen) ||
                    (item.Type == Document.ItemType.SpriteRawData) ||
                    (item.Type == Document.ItemType.SpriteScreenData) ||
                    (item.Type == Document.ItemType.SpriteData) ||
                    (item.Type == Document.ItemType.SpriteOpcodes) ||
                    (item.Type == Document.ItemType.Font))
                {
                    string outputSpriteBitplan1Filename = "";
                    string outputSpriteBitplan2Filename = "";

                    string outputCloudSpriteBitplan1Filename = "";

                    int spriteType = 0;

                    if (item.Type == Document.ItemType.SpriteRawData)
                    {
                        outputSpriteBitplan1Filename = outputFilename + ".sprRawData1";
                        outputSpriteBitplan2Filename = outputFilename + ".sprRawData2";

                        if (item.IsCloudSprite)
                        {
                            outputCloudSpriteBitplan1Filename = outputFilename + ".cloudSprite.sprRawData1";
                        }

                        spriteType = 0;
                    }
                    else if (item.Type == Document.ItemType.SpriteData)
                    {
                        outputSpriteBitplan1Filename = outputFilename + ".sprData1";
                        outputSpriteBitplan2Filename = outputFilename + ".sprData2";

                        spriteType = 1;
                    }
                    else if (item.Type == Document.ItemType.SpriteScreenData)
                    {
                        outputSpriteBitplan1Filename = outputFilename + ".sprScrData1";
                        outputSpriteBitplan2Filename = outputFilename + ".sprScrData2";

                        spriteType = 3;
                    }
                    else if (item.Type == Document.ItemType.SpriteOpcodes)
                    {
                        outputSpriteBitplan1Filename = outputFilename + ".sprZ801";
                        outputSpriteBitplan2Filename = outputFilename + ".sprZ802";

                        spriteType = 2;
                    }
                    else if (item.Type == Document.ItemType.SpriteFullScreen)
                    {
                        outputSpriteBitplan1Filename = outputFilename + ".sprFullScreen";
                        outputSpriteBitplan2Filename = String.Empty;

                        spriteType = 4;
                    }

                    int[] diffData = null;
                    if (resolvedItems[iItem] != null)
                    {
                        diffData = resolvedItems[iItem].IntermediateImage.Data;
                    }

                    var bitmapCompiler = BitmapCompiler.CreateCompiler(tempDocument.VideoMode);
                    if (!bitmapCompiler.WriteSprite(outputSpriteBitplan1Filename,
                                                    outputSpriteBitplan2Filename,
                                                    item.IntermediateImage.Width,
                                                    item.IntermediateImage.Height,
                                                    item.IntermediateImage.Data,
                                                    item.IntermediateImage.BackgroundData,
                                                    spriteType,
                                                    useMask,
                                                    item.IntermediateImage.MaskData,
                                                    tempDocument.StartIndex,
                                                    item.MergePosX,
                                                    item.MergePosY,
                                                    item.IsCloudSprite,
                                                    outputCloudSpriteBitplan1Filename,
                                                    item.IntermediateImage.CloudData,
                                                    item.IntermediateImage.CloudWidth,
                                                    item.IntermediateImage.CloudHeight,
                                                    diffData
                                                    ))
                    {
                        return(false);
                    }

                    fileContent += "#define " + itemTitle + "_SPR_HEIGHT " + bitmapCompiler.GetLastHeight() + "\n";

                    if (String.IsNullOrEmpty(outputSpriteBitplan2Filename))
                    {
                        fileContent += "#define " + itemTitle + "_SPR_BYTEWIDTH " + bitmapCompiler.GetLastWidthBytesBitplan1() + "\n";
                        fileContent += "#define " + itemTitle + "_SPR_SIZE 0x" + String.Format("{0:X4}", bitmapCompiler.GetLastWidthBytesBitplan1() * bitmapCompiler.GetLastHeight()) + "\n";
                    }
                    else
                    {
                        fileContent += "#define " + itemTitle + "_SPR_BYTEWIDTH1 " + bitmapCompiler.GetLastWidthBytesBitplan1() + "\n";
                        fileContent += "#define " + itemTitle + "_SPR_BYTEWIDTH2 " + bitmapCompiler.GetLastWidthBytesBitplan2() + "\n";
                        fileContent += "#define " + itemTitle + "_SPR_SIZE1 0x" + String.Format("{0:X4}", bitmapCompiler.GetLastWidthBytesBitplan1() * bitmapCompiler.GetLastHeight()) + "\n";
                        fileContent += "#define " + itemTitle + "_SPR_SIZE2 0x" + String.Format("{0:X4}", bitmapCompiler.GetLastWidthBytesBitplan2() * bitmapCompiler.GetLastHeight()) + "\n";
                    }

                    if (item.IsMerge)
                    {
                        fileContent += "#define " + itemTitle + "_MERGE_POSX " + item.MergePosX + "\n";
                        fileContent += "#define " + itemTitle + "_MERGE_POSY " + item.MergePosY + "\n";
                    }
                }
            }

            fileContent += "\n";

            fileContent += "// ----------------------------------------------------------------------------\n";
            fileContent += "#endif // _" + title + "_INFO_H_";

            File.WriteAllText(destFilenameH, fileContent);

            return(true);
        }
Beispiel #10
0
        public bool Compile(PhactoryHost.Database.Resource resource)
        {
            FileInfo fileInfo = Host.GetFileInfo(resource);

            if (fileInfo == null)
            {
                return(false);
            }

            if (!IsResourceSupported(resource))
            {
                return(false);
            }

            var compiler = new Phactory.Modules.RawBitmap.Compiler.RawCompiler();

            Document.Document tempDocument = Host.XMLRead <Document.Document>(Host.GetFileInfo(resource).FullName);
            if (!tempDocument.CompileInternal())
            {
                return(false);
            }

            List <string> outputFilenames = new List <string>();

            foreach (Document.Item item in tempDocument.Items)
            {
                App.Controller.View.AppDoEvents();

                PhactoryHost.Database.Resource resItem = Host.GetResource(item.ResourceID);
                if (resItem == null)
                {
                    Host.Log("Unknown resource identifier : " + item.ResourceID);
                    return(false);
                }

                FileInfo resFileInfo    = Host.GetFileInfo(resItem);
                string   outputFilename = resFileInfo.FullName;

                if (Host.IsVerboseOutput())
                {
                    Host.Log(outputFilename);
                }

                Document.ItemType type = item.Type;

                if (type == CPCRawBitmap.Document.ItemType.Raw)
                {
                    string outputTopFilename = outputFilename + ".rawBin";

                    if (!compiler.WriteRawBinFile(outputTopFilename,
                                                  item.IntermediateImage.Width,
                                                  item.IntermediateImage.Height,
                                                  item.IntermediateImage.Data,
                                                  false))
                    {
                        return(false);
                    }
                }
                else if (type == CPCRawBitmap.Document.ItemType.VerticalRaw)
                {
                    string outputTopFilename = outputFilename + ".verticalRawBin";

                    if (!compiler.WriteRawBinFile(outputTopFilename,
                                                  item.IntermediateImage.Width,
                                                  item.IntermediateImage.Height,
                                                  item.IntermediateImage.Data,
                                                  true))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }