public bool ExportToBuffer(out GR.Memory.ByteBuffer CharData, out GR.Memory.ByteBuffer ColorData, out GR.Memory.ByteBuffer CharSetData, int X, int Y, int Width, int Height, bool RowByRow) { CharData = new GR.Memory.ByteBuffer(); ColorData = new GR.Memory.ByteBuffer(); CharSetData = new GR.Memory.ByteBuffer(CharSet.CharacterData()); int numBytesPerChar = Lookup.NumBytesOfSingleCharacter(Lookup.TextCharModeFromTextMode(Mode)); if (RowByRow) { // row by row for (int i = 0; i < Height; ++i) { for (int x = 0; x < Width; ++x) { byte newColor = (byte)((Chars[(Y + i) * ScreenWidth + X + x] & 0xff0000) >> 16); ushort newChar = (ushort)(Chars[(Y + i) * ScreenWidth + X + x] & 0xffff); if (numBytesPerChar == 2) { CharData.AppendU16(newChar); } else { CharData.AppendU8((byte)newChar); } if (Lookup.TextModeUsesColor(Mode)) { ColorData.AppendU8(newColor); } } } } else { for (int x = 0; x < Width; ++x) { for (int i = 0; i < Height; ++i) { byte newColor = (byte)((Chars[(Y + i) * ScreenWidth + X + x] & 0xff0000) >> 16); ushort newChar = (ushort)(Chars[(Y + i) * ScreenWidth + X + x] & 0xffff); if (numBytesPerChar == 2) { CharData.AppendU16(newChar); } else { CharData.AppendU8((byte)newChar); } if (Lookup.TextModeUsesColor(Mode)) { ColorData.AppendU8(newColor); } } } } return(true); }
public override Types.FileInfo LoadFile(GR.Memory.ByteBuffer Filename) { _LastError = ""; int fileIndex = 0; var fileInfo = new Types.FileInfo(); foreach (FileRecord file in FileRecords) { if (file.EntryType == 1) { if (file.Filename == Filename) { GR.Memory.ByteBuffer exportData = new GR.Memory.ByteBuffer(); exportData.AppendU16(file.StartAddress); exportData.Append(FileDatas[fileIndex]); fileInfo.Data = exportData; fileInfo.Filename = new GR.Memory.ByteBuffer(file.Filename); fileInfo.Type = Types.FileType.PRG; return(fileInfo); } } ++fileIndex; } _LastError = "file not found"; return(null); }
public override GR.Memory.ByteBuffer Compile() { _LastError = ""; GR.Memory.ByteBuffer result = new GR.Memory.ByteBuffer(); result.AppendU16(LoadAddress); result.Append(Data); return(result); }
/* * Koalafile http://www.c64-wiki.de/index.php?title=Koala_Painter#Koala-Dateiformat * Koalaformat has an Loading address (first two bytes) [00 60] * ==================================================================== * Offset (hex): Content * -------------------------------------------------------------------- * 0000 - 1F3F : Bitmap 8000 Bytes * 1F40 - 2327 : Screen-RAM 1000 Bytes * 2328 - 270F : Color-RAM 1000 Bytes * 2710 : Background 1 Byte * * * C64 MC Mode http://www.c64-wiki.de/index.php/Multicolor * ==================================================================== * Color-Bits Corresponding-Color Address * -------------------------------------------------------------------- * 00 Background 53281 * 01 Upper (four Bits/Nibble)... 1024-2023 * 10 Lower (four Bits/Nibble) of Screen-RAM 1024-2023 * 11 Color-RAM 55296-56295 */ public static GR.Memory.ByteBuffer KoalaFromBitmap(GR.Memory.ByteBuffer BitmapData, GR.Memory.ByteBuffer ScreenRAM, GR.Memory.ByteBuffer ColorRAM, byte BackgroundColor) { GR.Memory.ByteBuffer result = new GR.Memory.ByteBuffer(); result.AppendU16(0x6000); result.Append(BitmapData); result.Append(ScreenRAM); result.Append(ColorRAM); return(result); }
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 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); }
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); }