public void OpenProject(GR.Memory.ByteBuffer ProjectData) { if (!m_Charset.ReadFromBuffer(ProjectData)) { return; } CharsetWasImported(); }
public bool ReadFromBuffer(GR.Memory.ByteBuffer ProjectFile) { GR.IO.MemoryReader memReader = new GR.IO.MemoryReader(ProjectFile); GR.IO.FileChunk chunk = new GR.IO.FileChunk(); while (chunk.ReadFromStream(memReader)) { GR.IO.MemoryReader chunkReader = chunk.MemoryReader(); switch (chunk.Type) { case FileChunkConstants.CHARSET_SCREEN_INFO: { int version = chunkReader.ReadInt32(); ScreenWidth = chunkReader.ReadInt32(); ScreenHeight = chunkReader.ReadInt32(); ExternalCharset = chunkReader.ReadString(); _Mode = (TextMode)chunkReader.ReadInt32(); ScreenOffsetX = chunkReader.ReadInt32(); ScreenOffsetY = chunkReader.ReadInt32(); CharOffset = chunkReader.ReadInt32(); Chars = new List <uint>(); for (int i = 0; i < ScreenWidth * ScreenHeight; ++i) { Chars.Add((uint)0x010020); } } break; case FileChunkConstants.MULTICOLOR_DATA: _Mode = (TextMode)chunkReader.ReadUInt8(); CharSet.Colors.BackgroundColor = chunkReader.ReadUInt8(); CharSet.Colors.MultiColor1 = chunkReader.ReadUInt8(); CharSet.Colors.MultiColor2 = chunkReader.ReadUInt8(); break; case FileChunkConstants.SCREEN_CHAR_DATA: for (int i = 0; i < Chars.Count; ++i) { if (Lookup.NumBytesOfSingleCharacter(Lookup.TextCharModeFromTextMode(Mode)) == 1) { Chars[i] = (uint)((Chars[i] & 0xffff0000) | chunkReader.ReadUInt8()); } else { Chars[i] = (uint)((Chars[i] & 0xffff0000) | chunkReader.ReadUInt16()); } } break; case FileChunkConstants.SCREEN_COLOR_DATA: for (int i = 0; i < Chars.Count; ++i) { if (Lookup.NumBytesOfSingleCharacter(Lookup.TextCharModeFromTextMode(Mode)) == 1) { Chars[i] = (uint)((Chars[i] & 0xffff) | ((uint)chunkReader.ReadUInt8() << 16)); } else { Chars[i] = (uint)((Chars[i] & 0xffff) | ((uint)chunkReader.ReadUInt16() << 16)); } } break; case FileChunkConstants.CHARSET_DATA: { if (!CharSet.ReadFromBuffer(chunk)) { return(false); } } break; } } memReader.Close(); return(true); }
public bool ReadFromBuffer(GR.Memory.ByteBuffer ProjectFile) { GR.IO.MemoryReader memReader = new GR.IO.MemoryReader(ProjectFile); GR.IO.FileChunk chunk = new GR.IO.FileChunk(); while (chunk.ReadFromStream(memReader)) { GR.IO.MemoryReader chunkReader = chunk.MemoryReader(); switch (chunk.Type) { case Types.FileChunk.CHARSET_SCREEN_INFO: { uint version = chunkReader.ReadUInt32(); ScreenWidth = chunkReader.ReadInt32(); ScreenHeight = chunkReader.ReadInt32(); ExternalCharset = chunkReader.ReadString(); Mode = (C64Studio.Types.CharsetMode)chunkReader.ReadInt32(); ScreenOffsetX = chunkReader.ReadInt32(); ScreenOffsetY = chunkReader.ReadInt32(); Chars = new List <ushort>(); for (int i = 0; i < ScreenWidth * ScreenHeight; ++i) { Chars.Add((ushort)0x0120); } } break; case Types.FileChunk.MULTICOLOR_DATA: Mode = (C64Studio.Types.CharsetMode)chunkReader.ReadUInt8(); BackgroundColor = chunkReader.ReadUInt8(); MultiColor1 = chunkReader.ReadUInt8(); MultiColor2 = chunkReader.ReadUInt8(); break; case Types.FileChunk.SCREEN_CHAR_DATA: for (int i = 0; i < Chars.Count; ++i) { Chars[i] = (ushort)((Chars[i] & 0xff00) | chunkReader.ReadUInt8()); } break; case Types.FileChunk.SCREEN_COLOR_DATA: for (int i = 0; i < Chars.Count; ++i) { Chars[i] = (ushort)((Chars[i] & 0x00ff) | (chunkReader.ReadUInt8() << 8)); } break; case Types.FileChunk.CHARSET_DATA: { if (!CharSet.ReadFromBuffer(chunk)) { return(false); } } break; } } memReader.Close(); return(true); }