public void Configuration(string ConfigName, ProjectConfig Config) { if (Configs.ContainsKey(ConfigName)) { Configs[ConfigName] = Config; return; } Configs.Add(ConfigName, Config); }
public void AddVirtualBreakpoints(Types.ASM.FileInfo ASMFileInfo) { if (ASMFileInfo == null) { return; } foreach (var virtualBP in ASMFileInfo.VirtualBreakpoints.Values) { virtualBP.IsVirtual = true; int globalLineIndex = -1; if (!ASMFileInfo.FindGlobalLineIndex(virtualBP.LineIndex, virtualBP.DocumentFilename, out globalLineIndex)) { Core.AddToOutput("Cannot assign breakpoint for line " + virtualBP.LineIndex + ", no address found" + System.Environment.NewLine); continue; } int address = ASMFileInfo.FindLineAddress(globalLineIndex); if (address != -1) { var existingBP = BreakpointAtAddress(address); if (existingBP == null) { C64Studio.Types.Breakpoint bp = new C64Studio.Types.Breakpoint(); bp.LineIndex = virtualBP.LineIndex; bp.Address = address; bp.TriggerOnExec = true; bp.IsVirtual = true; bp.DocumentFilename = virtualBP.DocumentFilename; bp.Virtual.Add(virtualBP); virtualBP.Address = address; // we just need any key (as null is not allowed) if (!BreakPoints.ContainsKey("C64Studio.DebugBreakpoints")) { BreakPoints.Add("C64Studio.DebugBreakpoints", new List <C64Studio.Types.Breakpoint>()); } BreakPoints["C64Studio.DebugBreakpoints"].Add(bp); //AddBreakpoint( bp ); Debug.Log("Add virtual bp for $" + address.ToString("X4")); } else { // merge with existing existingBP.TriggerOnExec = true; existingBP.Virtual.Add(virtualBP); } } else { Core.AddToOutput("Cannot assign breakpoint for line " + virtualBP.LineIndex + ", no address found" + System.Environment.NewLine); } } }
public int ImageToMCBitmapData(Dictionary <int, List <ColorMappingTarget> > ForceBitPattern, List <Formats.CharData> Chars, bool[,] ErrornousBlocks, int CharX, int CharY, int WidthChars, int HeightChars, out GR.Memory.ByteBuffer bitmapData, out GR.Memory.ByteBuffer screenChar, out GR.Memory.ByteBuffer screenColor) { int numErrors = 0; ColorMappingTarget[] bitPattern = new ColorMappingTarget[3] { ColorMappingTarget.BITS_01, ColorMappingTarget.BITS_10, ColorMappingTarget.BITS_11 }; var usedBitPattern = new GR.Collections.Set <ColorMappingTarget>(); Dictionary <int, GR.Collections.Set <ColorMappingTarget> > usedPatterns = new Dictionary <int, GR.Collections.Set <ColorMappingTarget> >(); screenChar = new GR.Memory.ByteBuffer((uint)(WidthChars * HeightChars)); screenColor = new GR.Memory.ByteBuffer((uint)(WidthChars * HeightChars)); bitmapData = new GR.Memory.ByteBuffer((uint)(8 * WidthChars * HeightChars)); GR.Collections.Map <byte, ColorMappingTarget> usedColors = new GR.Collections.Map <byte, ColorMappingTarget>(); for (int y = 0; y < HeightChars; ++y) { for (int x = 0; x < WidthChars; ++x) { // ein zeichen-block usedColors.Clear(); usedBitPattern.Clear(); if (ErrornousBlocks != null) { ErrornousBlocks[x, y] = false; } for (int charY = 0; charY < 8; ++charY) { for (int charX = 0; charX < 4; ++charX) { byte colorIndex = (byte)Image.GetPixel(x * 8 + charX * 2, y * 8 + charY); if (colorIndex >= 16) { if (Chars != null) { Chars[x + y * BlockWidth].Error = "Color index >= 16 (" + colorIndex + ") at " + (x * 8 + charX * 2).ToString() + ", " + (y * 8 + charY).ToString() + " (" + charX + "," + charY + ")"; } if (ErrornousBlocks != null) { ErrornousBlocks[x, y] = true; } ++numErrors; } if (colorIndex != Colors.BackgroundColor) { // remember used color usedColors.Add(colorIndex, 0); } } } // more than 3 colors? if (usedColors.Count > 3) { if (Chars != null) { Chars[x + y * BlockWidth].Error = "Too many colors used"; } if (ErrornousBlocks != null) { ErrornousBlocks[x, y] = true; } ++numErrors; } else { if (usedColors.Count > 0) { int colorTarget = 0; List <byte> keys = new List <byte>(usedColors.Keys); // check for overlaps - two colors are used that would map to the same target pattern? Dictionary <int, ColorMappingTarget> recommendedPattern = new Dictionary <int, ColorMappingTarget>(); numErrors += DetermineBestMapping(keys, x, y, ForceBitPattern, recommendedPattern, ErrornousBlocks); foreach (byte colorIndex in keys) { if (recommendedPattern.ContainsKey(colorIndex)) { usedColors[colorIndex] = recommendedPattern[colorIndex]; if (!usedPatterns.ContainsKey(colorIndex)) { usedPatterns.Add(colorIndex, new GR.Collections.Set <ColorMappingTarget>()); } usedPatterns[colorIndex].Add(recommendedPattern[colorIndex]); usedBitPattern.Add(recommendedPattern[colorIndex]); switch (recommendedPattern[colorIndex]) { case ColorMappingTarget.BITS_01: { // upper screen char nibble byte value = screenChar.ByteAt(x + y * WidthChars); value &= 0x0f; value |= (byte)(colorIndex << 4); screenChar.SetU8At(x + y * WidthChars, value); } break; case ColorMappingTarget.BITS_10: { // lower nibble in screen char byte value = screenChar.ByteAt(x + y * WidthChars); value &= 0xf0; value |= (byte)(colorIndex); screenChar.SetU8At(x + y * WidthChars, value); } break; case ColorMappingTarget.BITS_11: // color ram screenColor.SetU8At(x + y * WidthChars, colorIndex); break; } continue; } if (!usedPatterns.ContainsKey(colorIndex)) { usedPatterns.Add(colorIndex, new GR.Collections.Set <ColorMappingTarget>()); } usedPatterns[colorIndex].Add(bitPattern[colorTarget]); colorTarget = 0; while ((colorTarget < 3) && (usedBitPattern.ContainsValue(bitPattern[colorTarget]))) { ++colorTarget; } usedBitPattern.Add(bitPattern[colorTarget]); if (colorTarget == 0) { // upper screen char nibble byte value = screenChar.ByteAt(x + y * WidthChars); value &= 0x0f; value |= (byte)(colorIndex << 4); screenChar.SetU8At(x + y * WidthChars, value); usedColors[colorIndex] = ColorMappingTarget.BITS_01; } else if (colorTarget == 1) { // lower nibble in screen char byte value = screenChar.ByteAt(x + y * WidthChars); value &= 0xf0; value |= (byte)(colorIndex); screenChar.SetU8At(x + y * WidthChars, value); usedColors[colorIndex] = ColorMappingTarget.BITS_10; } else if (colorTarget == 2) { // color ram screenColor.SetU8At(x + y * WidthChars, colorIndex); usedColors[colorIndex] = ColorMappingTarget.BITS_11; } ++colorTarget; } } // write out bits /* * Debug.Log( "For Char " + x + "," + y ); * foreach ( var usedColor in usedColors ) * { * Debug.Log( " Color " + usedColor.Key + " = " + usedColor.Value ); * }*/ for (int charY = 0; charY < 8; ++charY) { for (int charX = 0; charX < 4; ++charX) { byte colorIndex = (byte)Image.GetPixel(x * 8 + charX * 2, y * 8 + charY); if (colorIndex != Colors.BackgroundColor) { // other color byte colorValue = 0; switch (usedColors[colorIndex]) { case ColorMappingTarget.BITS_01: colorValue = 0x01; break; case ColorMappingTarget.BITS_10: colorValue = 0x02; break; case ColorMappingTarget.BITS_11: colorValue = 0x03; break; } int bitmapIndex = x * 8 + y * 8 * WidthChars + charY; byte value = bitmapData.ByteAt(bitmapIndex); if (charX == 0) { value &= 0x3f; value |= (byte)(colorValue << 6); } else if (charX == 1) { value &= 0xcf; value |= (byte)(colorValue << 4); } else if (charX == 2) { value &= 0xf3; value |= (byte)(colorValue << 2); } else { value &= 0xfc; value |= colorValue; } bitmapData.SetU8At(bitmapIndex, value); } } } } } } /* * Debug.Log( "Used patterns:" ); * foreach ( var entry in usedPatterns ) * { * Debug.Log( "Index " + entry.Key ); * foreach ( var pattern in entry.Value ) * { * Debug.Log( " used " + pattern ); * } * }*/ return(numErrors); }
public int ImageToHiresBitmapData(Dictionary <int, List <ColorMappingTarget> > ForceBitPattern, List <Formats.CharData> Chars, bool[,] ErrornousBlocks, int CharX, int CharY, int WidthChars, int HeightChars, out GR.Memory.ByteBuffer bitmapData, out GR.Memory.ByteBuffer screenChar, out GR.Memory.ByteBuffer screenColor) { screenChar = null; screenColor = null; bitmapData = null; if ((CharX < 0) || (CharX >= BlockWidth) || (CharY < 0) || (CharY >= BlockHeight) || (WidthChars < 0) || (HeightChars < 0) || (CharX + WidthChars > BlockWidth) || (CharY + HeightChars > BlockHeight)) { return(1); } int numErrors = 0; screenChar = new GR.Memory.ByteBuffer((uint)(WidthChars * HeightChars)); screenColor = new GR.Memory.ByteBuffer((uint)(WidthChars * HeightChars)); bitmapData = new GR.Memory.ByteBuffer((uint)(8 * WidthChars * HeightChars)); GR.Collections.Map <byte, byte> usedColors = new GR.Collections.Map <byte, byte>(); for (int y = CharY; y < HeightChars; ++y) { for (int x = CharX; x < WidthChars; ++x) { // ein zeichen-block usedColors.Clear(); if (ErrornousBlocks != null) { ErrornousBlocks[x, y] = false; } for (int charY = 0; charY < 8; ++charY) { for (int charX = 0; charX < 8; ++charX) { byte colorIndex = (byte)Image.GetPixel(x * 8 + charX, y * 8 + charY); if (colorIndex >= 16) { if (Chars != null) { Chars[x + y * BlockWidth].Error = "Color index >= 16 (" + colorIndex + ") at " + (x * 8 + charX).ToString() + ", " + (y * 8 + charY).ToString() + " (" + charX + "," + charY + ")"; } if (ErrornousBlocks != null) { ErrornousBlocks[x, y] = true; } ++numErrors; } //if ( colorIndex != Colors.BackgroundColor ) { // remember used color usedColors.Add(colorIndex, 0); } } } // more than 2 colors? if (usedColors.Count > 2) { if (Chars != null) { Chars[x + y * BlockWidth].Error = "Too many colors used"; } if (ErrornousBlocks != null) { ErrornousBlocks[x, y] = true; } ++numErrors; } else { int firstColorIndex = -1; if (usedColors.Count > 0) { int colorTarget = 0; List <byte> keys = new List <byte>(usedColors.Keys); /* * // only one color, that means, the other was background -> force the same bit pattern * if ( ( usedColors.Count == 1 ) * && ( usedColors[0] != Colors.BackgroundColor ) ) * { * colorTarget = 1; * firstColorIndex = Colors.BackgroundColor; * }*/ // check for overlaps - two colors are used that would map to the same target pattern? Dictionary <int, ColorMappingTarget> recommendedPattern = new Dictionary <int, ColorMappingTarget>(); numErrors += DetermineBestMapping(keys, x, y, ForceBitPattern, recommendedPattern, ErrornousBlocks); foreach (byte colorIndex in keys) { if (recommendedPattern.ContainsKey(colorIndex)) { if (recommendedPattern[colorIndex] == ColorMappingTarget.COLOR_1) { colorTarget = 0; } else if (recommendedPattern[colorIndex] == ColorMappingTarget.COLOR_2) { colorTarget = 1; } } if (colorTarget == 0) { // upper screen char nibble byte value = screenChar.ByteAt(x + y * WidthChars); value &= 0x0f; value |= (byte)(colorIndex << 4); screenChar.SetU8At(x + y * WidthChars, value); usedColors[colorIndex] = 1; firstColorIndex = colorIndex; } else if (colorTarget == 1) { // lower nibble in screen char byte value = screenChar.ByteAt(x + y * WidthChars); value &= 0xf0; value |= (byte)(colorIndex); screenChar.SetU8At(x + y * WidthChars, value); usedColors[colorIndex] = 2; } if (recommendedPattern.ContainsKey(colorIndex)) { if (recommendedPattern[colorIndex] == ColorMappingTarget.COLOR_2) { firstColorIndex = colorIndex; } } ++colorTarget; } } // write out bits for (int charY = 0; charY < 8; ++charY) { for (int charX = 0; charX < 8; ++charX) { byte colorIndex = (byte)Image.GetPixel(x * 8 + charX, y * 8 + charY); if (colorIndex == firstColorIndex) { // other color byte colorValue = usedColors[colorIndex]; int bitmapIndex = x * 8 + y * WidthChars * 8 + charY; byte value = bitmapData.ByteAt(bitmapIndex); int mask = (1 << (7 - charX)); value &= (byte)(0xff ^ mask); value |= (byte)mask; bitmapData.SetU8At(bitmapIndex, value); } } } } } } return(numErrors); }
public int ImageToHiresBitmapData(List <Formats.CharData> Chars, bool[,] ErrornousBlocks, out GR.Memory.ByteBuffer bitmapData, out GR.Memory.ByteBuffer screenChar, out GR.Memory.ByteBuffer screenColor) { int numErrors = 0; screenChar = new GR.Memory.ByteBuffer((uint)(BlockWidth * BlockHeight)); screenColor = new GR.Memory.ByteBuffer((uint)(BlockWidth * BlockHeight)); bitmapData = new GR.Memory.ByteBuffer((uint)(8 * BlockWidth * BlockHeight)); GR.Collections.Map <byte, byte> usedColors = new GR.Collections.Map <byte, byte>(); for (int y = 0; y < BlockHeight; ++y) { for (int x = 0; x < BlockWidth; ++x) { // ein zeichen-block usedColors.Clear(); if (ErrornousBlocks != null) { ErrornousBlocks[x, y] = false; } for (int charY = 0; charY < 8; ++charY) { for (int charX = 0; charX < 8; ++charX) { byte colorIndex = (byte)Image.GetPixel(x * 8 + charX, y * 8 + charY); if (colorIndex >= 16) { if (Chars != null) { Chars[x + y * BlockWidth].Error = "Color index >= 16 (" + colorIndex + ") at " + (x * 8 + charX).ToString() + ", " + (y * 8 + charY).ToString() + " (" + charX + "," + charY + ")"; } if (ErrornousBlocks != null) { ErrornousBlocks[x, y] = true; } ++numErrors; } if (colorIndex != BackgroundColor) { // remember used color usedColors.Add(colorIndex, 0); } } } // more than 2 colors? if (usedColors.Count > 2) { if (Chars != null) { Chars[x + y * BlockWidth].Error = "Too many colors used"; } if (ErrornousBlocks != null) { ErrornousBlocks[x, y] = true; } ++numErrors; } else { int firstColorIndex = -1; if (usedColors.Count > 0) { int colorTarget = 0; List <byte> keys = new List <byte>(usedColors.Keys); foreach (byte colorIndex in keys) { if (colorTarget == 0) { // upper screen char nibble byte value = screenChar.ByteAt(x + y * BlockWidth); value &= 0x0f; value |= (byte)(colorIndex << 4); screenChar.SetU8At(x + y * BlockWidth, value); usedColors[colorIndex] = 1; firstColorIndex = colorIndex; } else if (colorTarget == 1) { // lower nibble in screen char byte value = screenChar.ByteAt(x + y * BlockWidth); value &= 0xf0; value |= (byte)(colorIndex); screenChar.SetU8At(x + y * BlockWidth, value); usedColors[colorIndex] = 2; } ++colorTarget; } } // write out bits for (int charY = 0; charY < 8; ++charY) { for (int charX = 0; charX < 8; ++charX) { byte colorIndex = (byte)Image.GetPixel(x * 8 + charX, y * 8 + charY); if (colorIndex == firstColorIndex) { // other color byte colorValue = usedColors[colorIndex]; int bitmapIndex = x * 8 + y * BlockWidth * 8 + charY; byte value = bitmapData.ByteAt(bitmapIndex); int mask = (1 << (7 - charX)); value &= (byte)(0xff ^ mask); value |= (byte)mask; bitmapData.SetU8At(bitmapIndex, value); } } } } } } return(numErrors); }
public StudioSettings() { m_deserializeDockContent = new DeserializeDockContent(GetContentFromPersistString); // known functions // functions from editing Functions.Add(C64Studio.Types.Function.BUILD, new C64Studio.Types.FunctionInfo(C64Studio.Types.Function.BUILD, "Build", C64Studio.Types.FunctionStudioState.NORMAL)); Functions.Add(C64Studio.Types.Function.BUILD_AND_DEBUG, new C64Studio.Types.FunctionInfo(C64Studio.Types.Function.BUILD_AND_DEBUG, "Build and Debug", C64Studio.Types.FunctionStudioState.NORMAL)); Functions.Add(C64Studio.Types.Function.BUILD_AND_RUN, new C64Studio.Types.FunctionInfo(C64Studio.Types.Function.BUILD_AND_RUN, "Build and Run", C64Studio.Types.FunctionStudioState.NORMAL)); Functions.Add(C64Studio.Types.Function.COMPILE, new C64Studio.Types.FunctionInfo(C64Studio.Types.Function.COMPILE, "Compile", C64Studio.Types.FunctionStudioState.NORMAL)); Functions.Add(C64Studio.Types.Function.REBUILD, new C64Studio.Types.FunctionInfo(C64Studio.Types.Function.REBUILD, "Rebuild", C64Studio.Types.FunctionStudioState.NORMAL)); // functions for any state Functions.Add(C64Studio.Types.Function.CENTER_ON_CURSOR, new C64Studio.Types.FunctionInfo(C64Studio.Types.Function.CENTER_ON_CURSOR, "Center on Cursor", C64Studio.Types.FunctionStudioState.ANY)); Functions.Add(C64Studio.Types.Function.DELETE_LINE, new C64Studio.Types.FunctionInfo(C64Studio.Types.Function.DELETE_LINE, "Delete Line", C64Studio.Types.FunctionStudioState.ANY)); Functions.Add(C64Studio.Types.Function.FIND, new C64Studio.Types.FunctionInfo(C64Studio.Types.Function.FIND, "Find", C64Studio.Types.FunctionStudioState.ANY)); Functions.Add(C64Studio.Types.Function.FIND_IN_PROJECT, new C64Studio.Types.FunctionInfo(C64Studio.Types.Function.FIND_IN_PROJECT, "Find in Project", C64Studio.Types.FunctionStudioState.ANY)); Functions.Add(C64Studio.Types.Function.FIND_NEXT, new C64Studio.Types.FunctionInfo(C64Studio.Types.Function.FIND_NEXT, "Find Next", C64Studio.Types.FunctionStudioState.ANY)); Functions.Add(C64Studio.Types.Function.FIND_REPLACE, new C64Studio.Types.FunctionInfo(C64Studio.Types.Function.FIND_REPLACE, "Replace", C64Studio.Types.FunctionStudioState.ANY)); Functions.Add(C64Studio.Types.Function.GO_TO_DECLARATION, new C64Studio.Types.FunctionInfo(C64Studio.Types.Function.GO_TO_DECLARATION, "Go To Declaration", C64Studio.Types.FunctionStudioState.ANY)); Functions.Add(C64Studio.Types.Function.HELP, new C64Studio.Types.FunctionInfo(C64Studio.Types.Function.HELP, "Help", C64Studio.Types.FunctionStudioState.ANY)); Functions.Add(C64Studio.Types.Function.PRINT, new C64Studio.Types.FunctionInfo(C64Studio.Types.Function.PRINT, "Print", C64Studio.Types.FunctionStudioState.ANY)); Functions.Add(C64Studio.Types.Function.REPLACE_IN_PROJECT, new C64Studio.Types.FunctionInfo(C64Studio.Types.Function.REPLACE_IN_PROJECT, "Replace in Project", C64Studio.Types.FunctionStudioState.ANY)); Functions.Add(C64Studio.Types.Function.SAVE_ALL, new C64Studio.Types.FunctionInfo(C64Studio.Types.Function.SAVE_ALL, "Save All", C64Studio.Types.FunctionStudioState.ANY)); Functions.Add(C64Studio.Types.Function.SAVE_DOCUMENT, new C64Studio.Types.FunctionInfo(C64Studio.Types.Function.SAVE_DOCUMENT, "Save Document", C64Studio.Types.FunctionStudioState.ANY)); Functions.Add(C64Studio.Types.Function.SAVE_DOCUMENT_AS, new C64Studio.Types.FunctionInfo(C64Studio.Types.Function.SAVE_DOCUMENT_AS, "Save Document As", C64Studio.Types.FunctionStudioState.ANY)); Functions.Add(C64Studio.Types.Function.MOVE_LINE_UP, new C64Studio.Types.FunctionInfo(C64Studio.Types.Function.MOVE_LINE_UP, "Move Line Up", C64Studio.Types.FunctionStudioState.ANY)); Functions.Add(C64Studio.Types.Function.MOVE_LINE_DOWN, new C64Studio.Types.FunctionInfo(C64Studio.Types.Function.MOVE_LINE_DOWN, "Move Line Down", C64Studio.Types.FunctionStudioState.ANY)); Functions.Add(C64Studio.Types.Function.COPY_LINE_UP, new C64Studio.Types.FunctionInfo(C64Studio.Types.Function.COPY_LINE_UP, "Copy Line Up", C64Studio.Types.FunctionStudioState.ANY)); Functions.Add(C64Studio.Types.Function.COPY_LINE_DOWN, new C64Studio.Types.FunctionInfo(C64Studio.Types.Function.COPY_LINE_DOWN, "Copy Line Down", C64Studio.Types.FunctionStudioState.ANY)); // functions for running debugger Functions.Add(C64Studio.Types.Function.DEBUG_BREAK, new C64Studio.Types.FunctionInfo(C64Studio.Types.Function.DEBUG_BREAK, "Break into Debugger", C64Studio.Types.FunctionStudioState.DEBUGGER_RUNNING)); // functions for broken debugger Functions.Add(C64Studio.Types.Function.DEBUG_GO, new C64Studio.Types.FunctionInfo(C64Studio.Types.Function.DEBUG_GO, "Debug Go", C64Studio.Types.FunctionStudioState.DEBUGGER_BROKEN)); Functions.Add(C64Studio.Types.Function.DEBUG_STEP, new C64Studio.Types.FunctionInfo(C64Studio.Types.Function.DEBUG_STEP, "Debug Step", C64Studio.Types.FunctionStudioState.DEBUGGER_BROKEN)); Functions.Add(C64Studio.Types.Function.DEBUG_STEP_OUT, new C64Studio.Types.FunctionInfo(C64Studio.Types.Function.DEBUG_STEP_OUT, "Debug Step Out", C64Studio.Types.FunctionStudioState.DEBUGGER_BROKEN)); Functions.Add(C64Studio.Types.Function.DEBUG_STEP_OVER, new C64Studio.Types.FunctionInfo(C64Studio.Types.Function.DEBUG_STEP_OVER, "Debug Step Over", C64Studio.Types.FunctionStudioState.DEBUGGER_BROKEN)); // functions for running/broken debugger Functions.Add(C64Studio.Types.Function.DEBUG_STOP, new C64Studio.Types.FunctionInfo(C64Studio.Types.Function.DEBUG_STOP, "Stop Debugging", C64Studio.Types.FunctionStudioState.DEBUGGER_BROKEN | C64Studio.Types.FunctionStudioState.DEBUGGER_RUNNING)); // functions for broken debugger/editing Functions.Add(C64Studio.Types.Function.DEBUG_RUN_TO, new C64Studio.Types.FunctionInfo(C64Studio.Types.Function.DEBUG_RUN_TO, "Run to Cursor", C64Studio.Types.FunctionStudioState.DEBUGGER_BROKEN | C64Studio.Types.FunctionStudioState.NORMAL)); Functions.Add(C64Studio.Types.Function.TOGGLE_BREAKPOINT, new C64Studio.Types.FunctionInfo(C64Studio.Types.Function.TOGGLE_BREAKPOINT, "Toggle Breakpoint", C64Studio.Types.FunctionStudioState.DEBUGGER_BROKEN | C64Studio.Types.FunctionStudioState.NORMAL)); }
public bool ReadFromBuffer(GR.Memory.ByteBuffer SettingsData) { IgnoredWarnings.Clear(); GR.IO.BinaryReader binReader = new GR.IO.BinaryReader(SettingsData.MemoryStream()); GR.IO.FileChunk chunkData = new GR.IO.FileChunk(); while (chunkData.ReadFromStream(binReader)) { switch (chunkData.Type) { case Types.FileChunk.SETTINGS_TOOL: { ToolInfo tool = new ToolInfo(); tool.FromChunk(chunkData); // sanitize args tool.CartArguments = tool.CartArguments.Replace("$(BuildTargetFilename)", "$(RunFilename)"); tool.PRGArguments = tool.PRGArguments.Replace("$(BuildTargetFilename)", "$(RunFilename)"); tool.WorkPath = tool.WorkPath.Replace("$(FilePath)", "$(RunPath)"); if (string.IsNullOrEmpty(tool.TrueDriveOnArguments)) { tool.TrueDriveOnArguments = "-truedrive +virtualdev"; tool.TrueDriveOffArguments = "+truedrive -virtualdev"; } if (tool.PRGArguments.Contains("-truedrive ")) { tool.PRGArguments = tool.PRGArguments.Replace("-truedrive ", ""); } if (tool.PRGArguments.Contains(" -truedrive")) { tool.PRGArguments = tool.PRGArguments.Replace(" -truedrive", ""); } ToolInfos.AddLast(tool); } break; case Types.FileChunk.SETTINGS_ACCELERATOR: { AcceleratorKey key = new AcceleratorKey(); key.FromChunk(chunkData); Accelerators.Add(key.Key, key); } break; case Types.FileChunk.SETTINGS_DPS_LAYOUT: { GR.IO.IReader binIn = chunkData.MemoryReader(); uint size = binIn.ReadUInt32(); GR.Memory.ByteBuffer tempData = new GR.Memory.ByteBuffer(); binIn.ReadBlock(tempData, size); SetLayoutFromData(tempData); } break; case Types.FileChunk.SETTINGS_SOUND: { GR.IO.IReader binIn = chunkData.MemoryReader(); PlaySoundOnSuccessfulBuild = (binIn.ReadUInt8() != 0); PlaySoundOnBuildFailure = (binIn.ReadUInt8() != 0); PlaySoundOnSearchFoundNoItem = (binIn.ReadUInt8() != 0); } break; case Types.FileChunk.SETTINGS_WINDOW: { GR.IO.IReader binIn = chunkData.MemoryReader(); MainWindowPlacement = binIn.ReadString(); } break; case Types.FileChunk.SETTINGS_TABS: { GR.IO.IReader binIn = chunkData.MemoryReader(); TabSize = binIn.ReadInt32(); if ((TabSize <= 0) || (TabSize >= 100)) { TabSize = 2; } AllowTabs = (binIn.ReadUInt8() != 0); TabConvertToSpaces = (binIn.ReadUInt8() != 0); } break; case Types.FileChunk.SETTINGS_FONT: { GR.IO.IReader binIn = chunkData.MemoryReader(); SourceFontFamily = binIn.ReadString(); SourceFontSize = (float)binIn.ReadInt32(); BASICUseNonC64Font = (binIn.ReadUInt8() != 0); BASICSourceFontFamily = binIn.ReadString(); BASICSourceFontSize = (float)binIn.ReadInt32(); if (BASICSourceFontSize <= 0) { BASICSourceFontSize = 9.0f; } } break; case Types.FileChunk.SETTINGS_SYNTAX_COLORING: { GR.IO.IReader binIn = chunkData.MemoryReader(); Types.SyntaxElement element = (C64Studio.Types.SyntaxElement)binIn.ReadUInt32(); Types.SyntaxColor color = new C64Studio.Types.SyntaxColor(GR.EnumHelper.GetDescription(element)); color.FGColor = binIn.ReadUInt32(); color.BGColor = binIn.ReadUInt32(); color.BGColorAuto = (binIn.ReadUInt32() != 0); SyntaxColoring.Add(element, color); } break; case Types.FileChunk.SETTINGS_UI: { GR.IO.IReader binIn = chunkData.MemoryReader(); ToolbarActiveMain = (binIn.ReadUInt8() == 1); ToolbarActiveDebugger = (binIn.ReadUInt8() == 1); } break; case Types.FileChunk.SETTINGS_RUN_EMULATOR: { GR.IO.IReader binIn = chunkData.MemoryReader(); TrueDriveEnabled = (binIn.ReadUInt8() != 0); } break; case Types.FileChunk.SETTINGS_DEFAULTS: { GR.IO.IReader binIn = chunkData.MemoryReader(); DefaultProjectBasePath = binIn.ReadString(); } break; case Types.FileChunk.SETTINGS_FIND_REPLACE: { GR.IO.IReader binIn = chunkData.MemoryReader(); LastFindIgnoreCase = (binIn.ReadUInt8() == 1); LastFindWholeWord = (binIn.ReadUInt8() == 1); LastFindRegexp = (binIn.ReadUInt8() == 1); LastFindWrap = (binIn.ReadUInt8() == 1); LastFindTarget = binIn.ReadUInt8(); int numFindArguments = binIn.ReadInt32(); for (int i = 0; i < numFindArguments; ++i) { FindArguments.Add(binIn.ReadString()); } int numReplaceArguments = binIn.ReadInt32(); for (int i = 0; i < numReplaceArguments; ++i) { ReplaceArguments.Add(binIn.ReadString()); } } break; case Types.FileChunk.SETTINGS_IGNORED_WARNINGS: { GR.IO.IReader binIn = chunkData.MemoryReader(); int numIgnoredWarnings = binIn.ReadInt32(); for (int i = 0; i < numIgnoredWarnings; ++i) { IgnoredWarnings.Add((C64Studio.Types.ErrorCode)binIn.ReadInt32()); } } break; case Types.FileChunk.SETTINGS_PANEL_DISPLAY_DETAILS: { GR.IO.IReader binIn = chunkData.MemoryReader(); string toolName = binIn.ReadString(); if (GenericTools.ContainsKey(toolName)) { uint length = binIn.ReadUInt32(); GR.Memory.ByteBuffer data = new GR.Memory.ByteBuffer(); binIn.ReadBlock(data, length); GenericTools[toolName].ApplyDisplayDetails(data); } } break; case Types.FileChunk.SETTINGS_BASIC_KEYMAP: { GR.IO.IReader binIn = chunkData.MemoryReader(); int numEntries = binIn.ReadInt32(); uint neutralLang = (uint)(System.Globalization.CultureInfo.CurrentCulture.KeyboardLayoutId & 0xff); if ((neutralLang != 7) && (neutralLang != 9)) { neutralLang = 9; } for (int i = 0; i < numEntries; ++i) { Keys key = (Keys)binIn.ReadUInt32(); Types.KeyboardKey cmdKey = (C64Studio.Types.KeyboardKey)binIn.ReadInt32(); var keyMapEntry = new KeymapEntry(); foreach (var entry in BASICKeyMap.DefaultKeymaps[neutralLang]) { if (entry.Value.KeyboardKey == cmdKey) { BASICKeyMap.Keymap[key] = entry.Value; break; } } } } break; case Types.FileChunk.SETTINGS_ASSEMBLER_EDITOR: { GR.IO.IReader binIn = chunkData.MemoryReader(); ASMHideLineNumbers = (binIn.ReadUInt8() != 0); } break; case Types.FileChunk.SETTINGS_BASIC_PARSER: { GR.IO.IReader binIn = chunkData.MemoryReader(); BASICStripSpaces = (binIn.ReadUInt8() != 0); } break; case Types.FileChunk.SETTINGS_ENVIRONMENT: { GR.IO.IReader binIn = chunkData.MemoryReader(); AutoOpenLastSolution = (binIn.ReadUInt8() != 0); } break; } } return(true); }