Пример #1
0
        public GR.Memory.ByteBuffer SaveToBuffer()
        {
            GR.Memory.ByteBuffer data = new GR.Memory.ByteBuffer();

            data.Reserve(ScreenHeight * ScreenWidth * 8);

            GR.IO.FileChunk chunkScreenInfo = new GR.IO.FileChunk(FileChunkConstants.GRAPHIC_SCREEN_INFO);
            chunkScreenInfo.AppendU32((uint)SelectedCheckType);
            chunkScreenInfo.AppendI32(ScreenOffsetX);
            chunkScreenInfo.AppendI32(ScreenOffsetY);
            chunkScreenInfo.AppendI32(ScreenWidth);
            chunkScreenInfo.AppendI32(ScreenHeight);
            data.Append(chunkScreenInfo.ToBuffer());

            GR.IO.FileChunk chunkGraphicData = new GR.IO.FileChunk(FileChunkConstants.GRAPHIC_DATA);
            chunkGraphicData.AppendI32(Image.Width);
            chunkGraphicData.AppendI32(Image.Height);
            chunkGraphicData.AppendI32((int)Image.PixelFormat);
            chunkGraphicData.AppendI32(Image.PaletteEntryCount);
            for (int i = 0; i < Image.PaletteEntryCount; ++i)
            {
                chunkGraphicData.AppendU8(Image.PaletteRed(i));
                chunkGraphicData.AppendU8(Image.PaletteGreen(i));
                chunkGraphicData.AppendU8(Image.PaletteBlue(i));
            }
            GR.Memory.ByteBuffer imageData = Image.GetAsData();
            chunkGraphicData.AppendU32(imageData.Length);
            chunkGraphicData.Append(imageData);
            data.Append(chunkGraphicData.ToBuffer());

            GR.IO.FileChunk chunkScreenMultiColorData = new GR.IO.FileChunk(FileChunkConstants.MULTICOLOR_DATA);
            chunkScreenMultiColorData.AppendU8((byte)(MultiColor ? 1 : 0));
            chunkScreenMultiColorData.AppendU8((byte)Colors.BackgroundColor);
            chunkScreenMultiColorData.AppendU8((byte)Colors.MultiColor1);
            chunkScreenMultiColorData.AppendU8((byte)Colors.MultiColor2);
            chunkScreenMultiColorData.AppendI32(Colors.ActivePalette);
            data.Append(chunkScreenMultiColorData.ToBuffer());

            foreach (var pal in Colors.Palettes)
            {
                data.Append(pal.ToBuffer());
            }

            GR.IO.FileChunk chunkColorMapping = new GR.IO.FileChunk(FileChunkConstants.GRAPHIC_COLOR_MAPPING);
            chunkColorMapping.AppendI32(ColorMapping.Count);
            for (int i = 0; i < ColorMapping.Count; ++i)
            {
                var mappings = ColorMapping[i];

                chunkColorMapping.AppendI32(mappings.Count);
                for (int j = 0; j < mappings.Count; ++j)
                {
                    chunkColorMapping.AppendU8((byte)mappings[j]);
                }
            }
            data.Append(chunkColorMapping.ToBuffer());
            return(data);
        }
Пример #2
0
            public GR.Memory.ByteBuffer ToBuffer()
            {
                GR.Memory.ByteBuffer newBuffer = new GR.Memory.ByteBuffer();
                newBuffer.Reserve((int)Length);

                newBuffer.AppendU16(Type);
                newBuffer.AppendU32(base.Length);
                newBuffer.Append(this);
                return(newBuffer);
            }
Пример #3
0
        public GR.Memory.ByteBuffer Save()
        {
            GR.Memory.ByteBuffer bufferProject = new GR.Memory.ByteBuffer();

            bufferProject.Reserve(1000000);

            GR.IO.FileChunk chunkProject = new GR.IO.FileChunk(Types.FileChunk.PROJECT);

            // version 2 -> has adjusted debug start address (to get rid of 2049)
            chunkProject.AppendU32(2);
            chunkProject.AppendString(Settings.Name);
            chunkProject.AppendString(Settings.Filename);
            chunkProject.AppendU16(Settings.DebugPort);
            chunkProject.AppendU16(0);// obsolete Settings.DebugStartAddress
            chunkProject.AppendString(Settings.BuildTool);
            chunkProject.AppendString(Settings.RunTool);
            chunkProject.AppendString(Settings.MainDocument);
            chunkProject.AppendString(Settings.CurrentConfig.Name);
            if (Core.MainForm.ActiveElement != null)
            {
                chunkProject.AppendString(Core.MainForm.ActiveElement.Filename);
            }
            else
            {
                chunkProject.AppendString("");
            }
            uint flags = 0;

            chunkProject.AppendU32(flags);

            bufferProject.Append(chunkProject.ToBuffer());

            foreach (System.Windows.Forms.TreeNode node in Node.Nodes)
            {
                ProjectElement element = (ProjectElement)node.Tag;

                bufferProject.Append(ElementToBuffer(element));
            }

            foreach (ProjectConfig config in Settings.GetConfigurations())
            {
                bufferProject.Append(config.Save());
            }

            // only save watches once, for the active project
            foreach (var watch in Settings.WatchEntries)
            {
                bufferProject.Append(watch.Save());
            }

            return(bufferProject);
        }
Пример #4
0
        bool AppendFile(GR.Memory.ByteBuffer Buffer, FileEntry File)
        {
            _LastError = "";

            Buffer.Reserve((int)Buffer.Length + 3 * 27136 + 4 * 188 * 20 + 2 * (int)File.Data.Length * 20);
            // leading silence, 27136 bytes 0x30 (approx. 10 seconds)
            Buffer.AppendRepeated(0x30, 27136);
            //Buffer.AppendU32NetworkOrder( 0x000180DC );

            // Sync for header
            AppendSync(Buffer);
            AppendHeader(Buffer, File);

            // interblock gap
            Buffer.AppendRepeated(0x30, 0x4f);

            // Sync for header repeated
            AppendSyncRepeated(Buffer);
            AppendHeader(Buffer, File);

            // trailer
            Buffer.AppendRepeated(0x30, 0x4e);


            // leading silence, 27136 bytes 0x30 (approx. 10 seconds)
            Buffer.AppendRepeated(0x30, 27136);
            //Buffer.AppendU32NetworkOrder( 0x000180DC );

            // Sync
            AppendSync(Buffer);
            AppendData(Buffer, File.Data);

            // interblock gap
            Buffer.AppendRepeated(0x30, 0x4f);


            // Sync for header repeated
            AppendSyncRepeated(Buffer);
            AppendData(Buffer, File.Data);

            // trailer
            Buffer.AppendRepeated(0x30, 0x4e);


            /*
             * // data trailer
             *
             * // leading silence, 27136 bytes 0x30 (approx. 10 seconds)
             * Buffer.AppendRepeated( 0x30, 27136 );
             *
             * // Sync for header
             * AppendSync( Buffer );
             * AppendHeader( Buffer, File );
             *
             * // interblock gap
             * Buffer.AppendRepeated( 0x30, 0x4f );
             *
             * // Sync for header repeated
             * AppendSyncRepeated( Buffer );
             * AppendHeader( Buffer, File );
             *
             * // trailer
             * Buffer.AppendRepeated( 0x30, 0x4e );
             */
            return(true);
        }