Esempio n. 1
0
        public override GR.Memory.ByteBuffer Compile()
        {
            _LastError = "";
            GR.Memory.ByteBuffer result = new GR.Memory.ByteBuffer();

            // C64-TAPE-RAW
            result.AppendHex("4336342D544150452D524157");
            // version (0 or 1)
            result.AppendU8(0);
            // reserved
            result.AppendU8(0);
            result.AppendU8(0);
            result.AppendU8(0);
            // size
            result.AppendU32(0);


            foreach (FileEntry file in TapFiles)
            {
                AppendFile(result, file);
            }

            result.SetU32At(16, result.Length - 20);
            return(result);
        }
Esempio n. 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);
            }
        public GR.Memory.ByteBuffer ToBuffer()
        {
            GR.Memory.ByteBuffer result = new GR.Memory.ByteBuffer();

            result.AppendI32(Width);
            result.AppendI32(Height);
            result.AppendU32((uint)PixelFormat);

            result.AppendI32(PaletteEntryCount);
            for (int i = 0; i < PaletteEntryCount; ++i)
            {
                result.AppendU8(PaletteRed(i));
                result.AppendU8(PaletteGreen(i));
                result.AppendU8(PaletteBlue(i));
            }
            result.Append(m_ImageData);
            return(result);
        }
Esempio n. 4
0
        public GR.Memory.ByteBuffer SaveToBuffer()
        {
            GR.Memory.ByteBuffer projectFile = new GR.Memory.ByteBuffer();

            // version
            projectFile.AppendU32(1);
            // Name
            projectFile.AppendString(Name);
            // Value table
            // number of entries
            projectFile.AppendI32(ValueTable.Values.Count);
            foreach (var entry in ValueTable.Values)
            {
                projectFile.AppendString(entry);
            }
            projectFile.AppendString(ValueTable.Formula);
            projectFile.AppendString(ValueTable.StartValue);
            projectFile.AppendString(ValueTable.EndValue);
            projectFile.AppendString(ValueTable.StepValue);

            return(projectFile);
        }
        public GR.Memory.ByteBuffer SaveToBuffer()
        {
            GR.Memory.ByteBuffer projectFile = new GR.Memory.ByteBuffer();

            // version
            projectFile.AppendU32(2);

            var chunkCharsetProject = new GR.IO.FileChunk(RetroDevStudio.FileChunkConstants.CHARSET_PROJECT);


            var chunkCharsetInfo = new GR.IO.FileChunk(RetroDevStudio.FileChunkConstants.CHARSET_INFO);

            chunkCharsetInfo.AppendI32((int)Mode);
            chunkCharsetInfo.AppendI32(TotalNumberOfCharacters);
            chunkCharsetInfo.AppendI32(ShowGrid ? 1 : 0);
            chunkCharsetProject.Append(chunkCharsetInfo.ToBuffer());


            var chunkColorSettings = new GR.IO.FileChunk(RetroDevStudio.FileChunkConstants.CHARSET_COLOR_SETTINGS);

            chunkColorSettings.AppendI32(Colors.BackgroundColor);
            chunkColorSettings.AppendI32(Colors.MultiColor1);
            chunkColorSettings.AppendI32(Colors.MultiColor2);
            chunkColorSettings.AppendI32(Colors.BGColor4);
            chunkColorSettings.AppendI32(Colors.ActivePalette);
            chunkCharsetProject.Append(chunkColorSettings.ToBuffer());

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

            var chunkExport = new GR.IO.FileChunk(RetroDevStudio.FileChunkConstants.CHARSET_EXPORT);

            chunkExport.AppendI32(ExportStartCharacter);
            chunkExport.AppendI32(ExportNumCharacters);
            chunkExport.AppendString(ExportFilename);

            chunkCharsetProject.Append(chunkExport.ToBuffer());


            foreach (var character in Characters)
            {
                var chunkCharsetChar = new GR.IO.FileChunk(RetroDevStudio.FileChunkConstants.CHARSET_CHAR);

                //chunkCharsetChar.AppendI32( (int)character.Mode );
                chunkCharsetChar.AppendI32(0); // was mode
                chunkCharsetChar.AppendI32(character.Tile.CustomColor);
                chunkCharsetChar.AppendI32(character.Category);
                chunkCharsetChar.AppendI32((int)character.Tile.Data.Length);
                chunkCharsetChar.Append(character.Tile.Data);

                chunkCharsetProject.Append(chunkCharsetChar.ToBuffer());
            }

            foreach (var category in Categories)
            {
                var chunkCategory = new GR.IO.FileChunk(RetroDevStudio.FileChunkConstants.CHARSET_CATEGORY);
                chunkCategory.AppendString(category);

                chunkCharsetProject.Append(chunkCategory.ToBuffer());
            }

            var chunkPlayground = new GR.IO.FileChunk(RetroDevStudio.FileChunkConstants.CHARSET_PLAYGROUND);

            chunkPlayground.AppendI32(PlaygroundWidth);
            chunkPlayground.AppendI32(PlaygroundHeight);
            for (int i = 0; i < PlaygroundChars.Count; ++i)
            {
                // 16 bit index, 16 bit color
                chunkPlayground.AppendU32(PlaygroundChars[i]);
            }
            chunkCharsetProject.Append(chunkPlayground.ToBuffer());

            projectFile.Append(chunkCharsetProject.ToBuffer());

            /*
             * // version
             * projectFile.AppendU32( 1 );
             * // Name
             * projectFile.AppendString( System.IO.Path.GetFileNameWithoutExtension( Name ) );
             * // charset Filename
             * projectFile.AppendString( System.IO.Path.GetFileNameWithoutExtension( Name ) );
             *
             * for ( int i = 0; i < 256; ++i )
             * {
             * projectFile.AppendI32( Characters[i].Color );
             * }
             * for ( int i = 0; i < 256; ++i )
             * {
             * projectFile.AppendU8( (byte)Characters[i].Mode );
             * }
             * projectFile.AppendI32( BackgroundColor );
             * projectFile.AppendI32( MultiColor1 );
             * projectFile.AppendI32( MultiColor2 );
             *
             * for ( int i = 0; i < 256; ++i )
             * {
             * // Tile colors
             * projectFile.AppendI32( 0 );
             * projectFile.AppendI32( 0 );
             * projectFile.AppendI32( 0 );
             * projectFile.AppendI32( 0 );
             * // Tile chars
             * projectFile.AppendI32( 0 );
             * projectFile.AppendI32( 0 );
             * projectFile.AppendI32( 0 );
             * projectFile.AppendI32( 0 );
             * }
             *
             * // generic multi color
             * projectFile.AppendI32( 0 );
             *
             * // test bed
             * projectFile.Append( new GR.Memory.ByteBuffer( 64 ) );
             *
             * // charset data
             * for ( int i = 0; i < 256; ++i )
             * {
             * projectFile.Append( Characters[i].Data );
             * }
             *
             * // used tiles
             * projectFile.AppendU32( UsedTiles );
             *
             * // export name
             * projectFile.AppendString( ExportFilename );
             * // export path block table
             * projectFile.AppendString( "" );
             * // export path charset
             * projectFile.AppendString( "" );
             * // export path editor tiles
             * projectFile.AppendString( "" );
             * // categories
             * projectFile.AppendI32( Categories.Count );
             * for ( int i = 0; i < Categories.Count; ++i )
             * {
             * projectFile.AppendI32( i );
             * projectFile.AppendString( Categories[i] );
             * }
             * for ( int i = 0; i < 256; ++i )
             * {
             * projectFile.AppendI32( Characters[i].Category );
             * }
             * projectFile.AppendI32( NumCharacters );
             * projectFile.AppendI32( ShowGrid ? 1 : 0 );
             * projectFile.AppendI32( StartCharacter );
             * projectFile.AppendI32( BGColor4 );
             *
             * // playground
             * projectFile.AppendI32( 16 );  // w
             * projectFile.AppendI32( 16 );  // h
             *
             * for ( int i = 0; i < PlaygroundChars.Count; ++i )
             * {
             * projectFile.AppendU16( PlaygroundChars[i] );
             * }
             *
             * projectFile.AppendI32( (int)Mode );
             */
            return(projectFile);
        }
        public GR.Memory.ByteBuffer SaveToBuffer()
        {
            GR.Memory.ByteBuffer projectFile = new GR.Memory.ByteBuffer();

            // version
            projectFile.AppendU32(1);
            // Name
            projectFile.AppendString(System.IO.Path.GetFileNameWithoutExtension(Name));
            // charset Filename
            projectFile.AppendString(System.IO.Path.GetFileNameWithoutExtension(Name));

            for (int i = 0; i < 256; ++i)
            {
                projectFile.AppendI32(Characters[i].Color);
            }
            for (int i = 0; i < 256; ++i)
            {
                projectFile.AppendU8(Characters[i].Multicolor ? (byte)1 : (byte)0);
            }
            projectFile.AppendI32(BackgroundColor);
            projectFile.AppendI32(MultiColor1);
            projectFile.AppendI32(MultiColor2);

            for (int i = 0; i < 256; ++i)
            {
                // Tile colors
                projectFile.AppendI32(0);
                projectFile.AppendI32(0);
                projectFile.AppendI32(0);
                projectFile.AppendI32(0);
                // Tile chars
                projectFile.AppendI32(0);
                projectFile.AppendI32(0);
                projectFile.AppendI32(0);
                projectFile.AppendI32(0);
            }

            // generic multi color
            projectFile.AppendI32(0);

            // test bed
            projectFile.Append(new GR.Memory.ByteBuffer(64));

            // charset data
            for (int i = 0; i < 256; ++i)
            {
                projectFile.Append(Characters[i].Data);
            }

            // used tiles
            projectFile.AppendU32(UsedTiles);

            // export name
            projectFile.AppendString(ExportFilename);
            // export path block table
            projectFile.AppendString("");
            // export path charset
            projectFile.AppendString("");
            // export path editor tiles
            projectFile.AppendString("");
            // categories
            projectFile.AppendI32(Categories.Count);
            foreach (System.Collections.Generic.KeyValuePair <int, string> category in Categories)
            {
                projectFile.AppendI32(category.Key);
                projectFile.AppendString(category.Value);
            }
            for (int i = 0; i < 256; ++i)
            {
                projectFile.AppendI32(Characters[i].Category);
            }
            return(projectFile);
        }
Esempio n. 7
0
        public override GR.Memory.ByteBuffer Compile()
        {
            _LastError = "";

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

            // Tape Header
            // 0 32 DOS tape description + EOF (for type)
            // 32 2 tape version ($0200)
            // 34 2 number of directory entries
            // 36 2 number of used entries (can be 0 in my loader)
            // 38 2 free
            // 40 24 user description as displayed in tape menu
            int usedEntries = 0;

            for (int i = 0; i < 30; ++i)
            {
                // File Header
                // Offset Size Description
                // 0 1 entry type (see below)
                // 1 1 C64 file type
                // 2 2 start address
                // 4 2 end address
                // 6 2 free
                // 8 4 offset of file contents start within T64 file
                // 12 4 free
                // 16 16 C64 file name
                if ((i >= FileRecords.Count) ||
                    (FileRecords[i].EntryType == 0))
                {
                }
                else
                {
                    ++usedEntries;
                }
            }

            result.Append(PadString(TapeInfo.Description + (char)0x1a, 32, 0x2e));
            result.AppendU16(TapeInfo.Version);
            result.AppendU16(30);
            result.AppendU16((ushort)usedEntries);
            result.AppendU16(0);
            result.Append(PadString(TapeInfo.UserDescription, 24, 0x20));

            int completeOffset = 64 + 30 * 32;

            for (int i = 0; i < 30; ++i)
            {
                // File Header
                // Offset Size Description
                // 0 1 entry type (see below)
                // 1 1 C64 file type
                // 2 2 start address
                // 4 2 end address
                // 6 2 free
                // 8 4 offset of file contents start within T64 file
                // 12 4 free
                // 16 16 C64 file name
                if ((i >= FileRecords.Count) ||
                    (FileRecords[i].EntryType == 0))
                {
                    GR.Memory.ByteBuffer dummy = new GR.Memory.ByteBuffer(32);
                    result.Append(dummy);
                }
                else
                {
                    result.AppendU8((byte)FileRecords[i].EntryType);
                    result.AppendU8((byte)FileRecords[i].C64FileType);
                    result.AppendU16(FileRecords[i].StartAddress);
                    result.AppendU16((ushort)(FileRecords[i].StartAddress + FileDatas[i].Length));
                    result.AppendU16(0);
                    result.AppendU32((uint)completeOffset);
                    result.AppendU32(0);
                    result.Append(PadString(FileRecords[i].Filename, 16, 0x20));

                    completeOffset += (int)FileDatas[i].Length;
                }
            }
            for (int i = 0; i < FileRecords.Count; ++i)
            {
                result.Append(FileDatas[i]);
            }
            return(result);
        }
Esempio n. 8
0
        public GR.Memory.ByteBuffer SaveToBuffer()
        {
            GR.Memory.ByteBuffer projectFile = new GR.Memory.ByteBuffer();

            // version
            projectFile.AppendU32(1);
            projectFile.AppendI32(Sprites.Count);
            // Name
            projectFile.AppendString(Name);
            for (int i = 0; i < Sprites.Count; ++i)
            {
                projectFile.AppendI32(Sprites[i].Color);
            }
            for (int i = 0; i < Sprites.Count; ++i)
            {
                projectFile.AppendU8(Sprites[i].Multicolor ? (byte)1 : (byte)0);
            }
            projectFile.AppendI32(BackgroundColor);
            projectFile.AppendI32(MultiColor1);
            projectFile.AppendI32(MultiColor2);
            // generic MC
            projectFile.AppendU32(0);
            for (int i = 0; i < Sprites.Count; ++i)
            {
                projectFile.Append(Sprites[i].Data);
                projectFile.AppendU8((byte)Sprites[i].Color);
            }
            projectFile.AppendU32(UsedSprites);

            // export name
            projectFile.AppendString(ExportFilename);

            // exportpath
            projectFile.AppendString("");

            // desc
            for (int i = 0; i < Sprites.Count; ++i)
            {
                projectFile.AppendString("");
            }

            // testbed (not used anymore, write 0 as number of sprites)
            projectFile.AppendI32(0);


            foreach (var layer in SpriteLayers)
            {
                GR.IO.FileChunk chunkLayer = new GR.IO.FileChunk(Types.FileChunk.SPRITESET_LAYER);

                GR.IO.FileChunk chunkLayerInfo = new GR.IO.FileChunk(Types.FileChunk.SPRITESET_LAYER_INFO);
                chunkLayerInfo.AppendString(layer.Name);
                chunkLayerInfo.AppendU8((byte)layer.BackgroundColor);
                chunkLayer.Append(chunkLayerInfo.ToBuffer());

                foreach (var sprite in layer.Sprites)
                {
                    GR.IO.FileChunk chunkLayerSprite = new GR.IO.FileChunk(Types.FileChunk.SPRITESET_LAYER_ENTRY);
                    chunkLayerSprite.AppendI32(sprite.Index);
                    chunkLayerSprite.AppendU8((byte)sprite.Color);
                    chunkLayerSprite.AppendI32(sprite.X);
                    chunkLayerSprite.AppendI32(sprite.Y);
                    chunkLayerSprite.AppendU8((byte)(sprite.ExpandX ? 1 : 0));
                    chunkLayerSprite.AppendU8((byte)(sprite.ExpandY ? 1 : 0));

                    chunkLayer.Append(chunkLayerSprite.ToBuffer());
                }
                projectFile.Append(chunkLayer.ToBuffer());
            }

            /*
             * int spriteTestCount = memIn.ReadInt32();
             * for ( int i = 0; i < spriteTestCount; ++i )
             * {
             * int spriteIndex = memIn.ReadInt32();
             * byte spriteColor = memIn.ReadUInt8();
             * bool spriteMultiColor = ( memIn.ReadUInt8() != 0 );
             * int spriteX = memIn.ReadInt32();
             * int spriteY = memIn.ReadInt32();
             * }*/
            return(projectFile);
        }
Esempio n. 9
0
        public GR.Memory.ByteBuffer SaveToBuffer()
        {
            GR.Memory.ByteBuffer projectFile = new GR.Memory.ByteBuffer();

            // version
            projectFile.AppendU32(1);
            // Name
            projectFile.AppendString(System.IO.Path.GetFileNameWithoutExtension(Name));
            // charset Filename
            projectFile.AppendString(System.IO.Path.GetFileNameWithoutExtension(Name));

            for (int i = 0; i < 256; ++i)
            {
                projectFile.AppendI32(Characters[i].Color);
            }
            for (int i = 0; i < 256; ++i)
            {
                projectFile.AppendU8((byte)Characters[i].Mode);
            }
            projectFile.AppendI32(BackgroundColor);
            projectFile.AppendI32(MultiColor1);
            projectFile.AppendI32(MultiColor2);

            for (int i = 0; i < 256; ++i)
            {
                // Tile colors
                projectFile.AppendI32(0);
                projectFile.AppendI32(0);
                projectFile.AppendI32(0);
                projectFile.AppendI32(0);
                // Tile chars
                projectFile.AppendI32(0);
                projectFile.AppendI32(0);
                projectFile.AppendI32(0);
                projectFile.AppendI32(0);
            }

            // generic multi color
            projectFile.AppendI32(0);

            // test bed
            projectFile.Append(new GR.Memory.ByteBuffer(64));

            // charset data
            for (int i = 0; i < 256; ++i)
            {
                projectFile.Append(Characters[i].Data);
            }

            // used tiles
            projectFile.AppendU32(UsedTiles);

            // export name
            projectFile.AppendString(ExportFilename);
            // export path block table
            projectFile.AppendString("");
            // export path charset
            projectFile.AppendString("");
            // export path editor tiles
            projectFile.AppendString("");
            // categories
            projectFile.AppendI32(Categories.Count);
            for (int i = 0; i < Categories.Count; ++i)
            {
                projectFile.AppendI32(i);
                projectFile.AppendString(Categories[i]);
            }
            for (int i = 0; i < 256; ++i)
            {
                projectFile.AppendI32(Characters[i].Category);
            }
            projectFile.AppendI32(NumCharacters);
            projectFile.AppendI32(ShowGrid ? 1 : 0);
            projectFile.AppendI32(StartCharacter);
            projectFile.AppendI32(BGColor4);

            // playground
            projectFile.AppendI32(16); // w
            projectFile.AppendI32(16); // h

            for (int i = 0; i < PlaygroundChars.Count; ++i)
            {
                projectFile.AppendU16(PlaygroundChars[i]);
            }
            return(projectFile);
        }
Esempio n. 10
0
        public bool CopyToClipboard()
        {
            if (Entries.Count == 0)
            {
                return(false);
            }

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

            dataSelection.AppendI32(Entries.Count);
            dataSelection.AppendI32(ColumnBased ? 1 : 0);

            dataSelection.AppendI32(Colors.BackgroundColor);
            dataSelection.AppendI32(Colors.MultiColor1);
            dataSelection.AppendI32(Colors.MultiColor2);
            dataSelection.AppendI32(Colors.BGColor4);

            dataSelection.AppendI32(Colors.Palettes.Count);
            for (int j = 0; j < Colors.Palettes.Count; ++j)
            {
                var pal = Colors.Palettes[j];
                dataSelection.AppendI32(pal.NumColors);
                for (int i = 0; i < pal.NumColors; ++i)
                {
                    dataSelection.AppendU32(pal.ColorValues[i]);
                }
            }

            int prevIndex = Entries[0].Index;

            foreach (var entry in Entries)
            {
                // delta in indices
                dataSelection.AppendI32(entry.Index - prevIndex);
                prevIndex = entry.Index;

                dataSelection.AppendI32((int)entry.Tile.Mode);
                dataSelection.AppendI32(entry.Tile.CustomColor);
                dataSelection.AppendI32(entry.Tile.Colors.ActivePalette);
                dataSelection.AppendI32(entry.Tile.Width);
                dataSelection.AppendI32(entry.Tile.Height);
                dataSelection.AppendU32(entry.Tile.Data.Length);
                dataSelection.Append(entry.Tile.Data);
                dataSelection.AppendI32(entry.Index);
            }

            DataObject dataObj = new DataObject();

            dataObj.SetData("C64Studio.ImageList", false, dataSelection.MemoryStream());


            // add as one image
            var fullImage = new GR.Image.MemoryImage(Entries.Count * Entries[0].Tile.Width, Entries[0].Tile.Height, System.Drawing.Imaging.PixelFormat.Format32bppRgb);
            int curX      = 0;

            foreach (var entry in Entries)
            {
                entry.Tile.Image.DrawTo(fullImage, curX, 0);
                curX += entry.Tile.Width;
            }

            GR.Memory.ByteBuffer dibData2 = fullImage.CreateHDIBAsBuffer();

            System.IO.MemoryStream ms2 = dibData2.MemoryStream();
            dataObj.SetData("DeviceIndependentBitmap", ms2);

            Clipboard.SetDataObject(dataObj, true);
            return(true);
        }