private void btnExportCharset_Click(object sender, EventArgs e) { System.Windows.Forms.SaveFileDialog saveDlg = new System.Windows.Forms.SaveFileDialog(); saveDlg.FileName = m_Charset.ExportFilename; saveDlg.Title = "Export Charset to"; saveDlg.Filter = "Charset|*.chr|All Files|*.*"; if (DocumentInfo.Project != null) { saveDlg.InitialDirectory = DocumentInfo.Project.Settings.BasePath; } if (saveDlg.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } if (m_Charset.ExportFilename != saveDlg.FileName) { m_Charset.ExportFilename = saveDlg.FileName; Modified = true; } GR.Memory.ByteBuffer charSet = new GR.Memory.ByteBuffer(); List <int> exportIndices = ListOfExportIndices(); foreach (int i in exportIndices) { charSet.Append(m_Charset.Characters[i].Data); } GR.IO.File.WriteAllBytes(m_Charset.ExportFilename, charSet); }
private void btnFromHex_Click(object sender, EventArgs e) { string binaryText = textBinaryData.Text.Replace(" ", "").Replace("\r", "").Replace("\n", ""); GR.Memory.ByteBuffer data = new GR.Memory.ByteBuffer(binaryText); SetHexData(data); }
private int HandleMapProject(GR.Text.ArgumentParser ArgParser) { if (!ValidateExportType("map project file", ArgParser.Parameter("TYPE"), new string[] { "MAPDATA", "MAPDATAASM" })) { return(1); } GR.Memory.ByteBuffer data = GR.IO.File.ReadAllBytes(ArgParser.Parameter("MAPPROJECT")); if (data == null) { System.Console.WriteLine("Couldn't read binary char file " + ArgParser.Parameter("MAPPROJECT")); return(1); } var mapProject = new RetroDevStudio.Formats.MapProject(); if (!mapProject.ReadFromBuffer(data)) { System.Console.WriteLine("Couldn't read map project from file " + ArgParser.Parameter("MAPPROJECT")); return(1); } GR.Memory.ByteBuffer resultingData = new GR.Memory.ByteBuffer(); if (ArgParser.Parameter("TYPE").Contains("MAPDATAASM")) { foreach (var map in mapProject.Maps) { var mapData = new ByteBuffer((uint)(map.Tiles.Width * map.Tiles.Height)); for (int j = 0; j < 0 + map.Tiles.Height; ++j) { for (int i = 0; i < 0 + map.Tiles.Width; ++i) { mapData.SetU8At(i + j * map.Tiles.Width, (byte)map.Tiles[i, j]); } } resultingData.Append(Encoding.ASCII.GetBytes("MAP_" + map.Name + "\n!hex \"" + mapData.ToString() + "\"\n")); } } else if (ArgParser.Parameter("TYPE").Contains("MAPDATA")) { foreach (var map in mapProject.Maps) { for (int j = 0; j < 0 + map.Tiles.Height; ++j) { for (int i = 0; i < 0 + map.Tiles.Width; ++i) { resultingData.AppendU8((byte)map.Tiles[i, j]); } } } } if (!GR.IO.File.WriteAllBytes(ArgParser.Parameter("EXPORT"), resultingData)) { Console.WriteLine("Could not write to file " + ArgParser.Parameter("EXPORT")); return(1); } return(0); }
internal static ByteBuffer FromBASICHex(string Text) { string[] lines = Text.Split(new char[] { '\n' }); GR.Memory.ByteBuffer resultData = new GR.Memory.ByteBuffer(); for (int i = 0; i < lines.Length; ++i) { string cleanLine = lines[i].Trim().ToUpper(); int dataPos = cleanLine.IndexOf("DATA"); if (dataPos != -1) { int commaPos = -1; int byteStartPos = dataPos + 4; do { commaPos = cleanLine.IndexOf(',', byteStartPos); if (commaPos == -1) { commaPos = cleanLine.Length; } int value = GR.Convert.ToI32(cleanLine.Substring(byteStartPos, commaPos - byteStartPos).Trim(), 16); resultData.AppendU8((byte)value); byteStartPos = commaPos + 1; }while (commaPos < cleanLine.Length); } } return(resultData); }
public static GR.Memory.ByteBuffer ToFilename(string Name) { GR.Memory.ByteBuffer bufName = new GR.Memory.ByteBuffer(); for (int i = 0; i < 16; ++i) { if (i < Name.Length) { /* * if ( ConstantData.PETSCII.ContainsKey( Name[i] ) ) * { * bufName.AppendU8( ConstantData.PETSCII[Name[i]] ); * }*/ var potChar = ConstantData.PetSCIIToChar.Values.FirstOrDefault(v => v.CharValue == Name[i]); if (potChar != null) { bufName.AppendU8(potChar.PetSCIIValue); } else { bufName.AppendU8((byte)Name[i]); } } else { bufName.AppendU8(0xa0); } } return(bufName); }
public void UpdateMemory(VICERemoteDebugger.RequestData Request, GR.Memory.ByteBuffer Data) { int Offset = Request.Parameter1; for (int i = 0; i < Data.Length; ++i) { byte ramByte = Data.ByteAt(i); if (Request.Reason != VICERemoteDebugger.RequestReason.MEMORY_FETCH) { /* * if ( ramByte != Core.Debugging.ActiveMemory.RAM.ByteAt( Offset + i ) ) * { * Core.Debugging.ActiveMemory.RAMChanged[Offset + i] = true; * * hexView.SelectedByteProvider.SetByteSelectionState( Offset + i, true ); * } * else * { * Core.Debugging.ActiveMemory.RAMChanged[Offset + i] = false; * * hexView.SelectedByteProvider.SetByteSelectionState( Offset + i, false ); * }*/ hexView.SelectedByteProvider.SetByteSelectionState(Offset + i, Core.Debugging.ActiveMemory.RAMChanged[Offset + i]); } //Core.Debugging.ActiveMemory.RAM.SetU8At( Offset + i, ramByte ); hexView.ByteProvider.WriteByte(Offset + i, ramByte); } //ValidateMemory( Offset, (int)Data.Length ); hexView.Invalidate(); }
public void FromBuffer(GR.Memory.ByteBuffer Data) { if (Data == null) { return; } GR.IO.MemoryReader memIn = Data.MemoryReader(); int w = memIn.ReadInt32(); int h = memIn.ReadInt32(); var pf = (GR.Drawing.PixelFormat)memIn.ReadUInt32(); Create(w, h, pf); int numEntries = memIn.ReadInt32(); for (int i = 0; i < numEntries; ++i) { byte r = memIn.ReadUInt8(); byte g = memIn.ReadUInt8(); byte b = memIn.ReadUInt8(); SetPaletteColor(i, r, g, b); } }
private void btnExportCharsetToBASICHex_Click(object sender, EventArgs e) { int startLine = GR.Convert.ToI32(editExportBASICLineNo.Text); if ((startLine < 0) || (startLine > 63999)) { startLine = 10; } int lineOffset = GR.Convert.ToI32(editExportBASICLineOffset.Text); if ((lineOffset < 0) || (lineOffset > 63999)) { startLine = 10; } List <int> exportIndices = ListOfExportIndices(); GR.Memory.ByteBuffer charSet = new GR.Memory.ByteBuffer(); foreach (int index in exportIndices) { charSet.Append(m_Charset.Characters[index].Data); } string resultText = Util.ToBASICHexData(charSet, startLine, lineOffset); editDataExport.Text = resultText; }
public override bool Load() { if (DocumentInfo.DocumentFilename == null) { return(false); } try { GR.Memory.ByteBuffer data = GR.IO.File.ReadAllBytes(DocumentInfo.FullPath); if (data != null) { SetHexData(data); } } catch (System.Exception ex) { System.Windows.Forms.MessageBox.Show("Could not load binary file " + DocumentInfo.FullPath + ".\r\n" + ex.Message, "Could not load file"); return(false); } SetUnmodified(); if (string.IsNullOrEmpty(m_FileWatcher.Path)) { SetupWatcher(); EnableFileWatcher(); } return(true); }
private void btnFromBASIC_Click(object sender, EventArgs e) { string[] lines = textBinaryData.Text.Split(new char[] { '\n' }); GR.Memory.ByteBuffer resultData = new GR.Memory.ByteBuffer(); for (int i = 0; i < lines.Length; ++i) { string cleanLine = lines[i].Trim().ToUpper(); int dataPos = cleanLine.IndexOf("DATA"); if (dataPos != -1) { int commaPos = -1; int byteStartPos = dataPos + 4; do { commaPos = cleanLine.IndexOf(',', byteStartPos); if (commaPos == -1) { commaPos = cleanLine.Length; } int value = GR.Convert.ToI32(cleanLine.Substring(byteStartPos, commaPos - byteStartPos).Trim()); resultData.AppendU8((byte)value); byteStartPos = commaPos + 1; }while (commaPos < cleanLine.Length); } } SetHexData(resultData); }
public override bool Load() { if (string.IsNullOrEmpty(DocumentInfo.DocumentFilename)) { return(false); } try { if (IsBinaryFile()) { GR.Memory.ByteBuffer charData = GR.IO.File.ReadAllBytes(DocumentInfo.FullPath); ImportFromData(charData); } else { OpenProject(DocumentInfo.FullPath); } } catch (System.IO.IOException ex) { System.Windows.Forms.MessageBox.Show("Could not load charset project file " + DocumentInfo.FullPath + ".\r\n" + ex.Message, "Could not load file"); return(false); } SetUnmodified(); return(true); }
public override bool HandleExport(ExportSpriteInfo Info, TextBox EditOutput, DocumentInfo DocInfo) { System.Windows.Forms.SaveFileDialog saveDlg = new System.Windows.Forms.SaveFileDialog(); saveDlg.FileName = Info.Project.ExportFilename; saveDlg.Title = "Export Sprites to"; saveDlg.Filter = "Sprites|*.spr|All Files|*.*"; if (DocInfo.Project != null) { saveDlg.InitialDirectory = DocInfo.Project.Settings.BasePath; } if (saveDlg.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return(false); } GR.Memory.ByteBuffer exportData = Info.ExportData; if (checkPrefixLoadAddress.Checked) { ushort address = GR.Convert.ToU16(editPrefixLoadAddress.Text, 16); var addressData = new ByteBuffer(); addressData.AppendU16(address); exportData = addressData + exportData; } GR.IO.File.WriteAllBytes(saveDlg.FileName, exportData); return(true); }
public BinaryDisplay(StudioCore Core, GR.Memory.ByteBuffer WorkData, bool AllowEditing, bool FixedWidth) { this.Core = Core; DocumentInfo.UndoManager.MainForm = Core.MainForm; InitializeComponent(); DPIHandler.ResizeControlsForDPI(this); if (WorkData == null) { SetHexData(new GR.Memory.ByteBuffer()); } else { SetHexData(WorkData); } this.AllowEditing = AllowEditing; this.FixedWidth = FixedWidth; hexView.ByteProvider.Changed += new EventHandler(ByteProvider_Changed); // modify context menu hexView.ContextMenuStrip.Items.Add("-"); m_MenuItemChangeOffset = new ToolStripMenuItem("Offset Displayed Address"); m_MenuItemChangeOffset.Click += OnMenuItemChangeOffsetClick; hexView.ContextMenuStrip.Items.Add(m_MenuItemChangeOffset); }
private GR.Memory.ByteBuffer DataFromHex() { Be.Windows.Forms.DynamicByteProvider dynProvider = (Be.Windows.Forms.DynamicByteProvider)hexView.ByteProvider; List <byte> dataBytes = dynProvider.Bytes; if (dataBytes.Count == 0) { return(new GR.Memory.ByteBuffer()); } long dataStart = hexView.SelectionStart; long dataLength = hexView.SelectionLength; if (hexView.SelectionLength == 0) { dataStart = 0; dataLength = hexView.ByteProvider.Length; } GR.Memory.ByteBuffer data = new GR.Memory.ByteBuffer((uint)dataLength); for (int i = 0; i < dataLength; ++i) { data.SetU8At(i, dataBytes[(int)dataStart + i]); } return(data); }
public override bool HandleExport(ExportCharsetInfo Info, TextBox EditOutput, DocumentInfo DocInfo) { System.Windows.Forms.SaveFileDialog saveDlg = new System.Windows.Forms.SaveFileDialog(); saveDlg.FileName = Info.Charset.ExportFilename; saveDlg.Title = "Export Charset to"; saveDlg.Filter = "Charset|*.chr|All Files|*.*"; if (DocInfo.Project != null) { saveDlg.InitialDirectory = DocInfo.Project.Settings.BasePath; } if (saveDlg.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return(false); } GR.Memory.ByteBuffer charSet = new GR.Memory.ByteBuffer(); List <int> exportIndices = Info.ExportIndices; foreach (int i in exportIndices) { charSet.Append(Info.Charset.Characters[i].Tile.Data); } if (checkPrefixLoadAddress.Checked) { ushort address = GR.Convert.ToU16(editPrefixLoadAddress.Text, 16); var addressData = new ByteBuffer(); addressData.AppendU16(address); charSet = addressData + charSet; } GR.IO.File.WriteAllBytes(saveDlg.FileName, charSet); return(true); }
private void RenderFullImage(Tiny64.Machine machine, GR.Image.MemoryImage img) { // render image bool vicActive = ((machine.VIC.ReadByte(0x11) & 0x10) != 0); if (vicActive) { int vicBank = (machine.CIA2.ReadByte(0) & 0x03) ^ 0x03; int screenPos = ((machine.VIC.ReadByte(0x18) & 0xf0) >> 4) * 1024 + vicBank * 16384; int localCharDataPos = (machine.VIC.ReadByte(0x18) & 0x0e) * 1024; int charDataPos = localCharDataPos + vicBank * 16384; byte bgColor = (byte)(machine.VIC.ReadByte(0x21) & 0x0f); GR.Memory.ByteBuffer charData = null; if (((vicBank == 0) || (vicBank == 2)) && (localCharDataPos == 0x1000)) { // use default upper case chars charData = new GR.Memory.ByteBuffer(); charData.Append(Machine.Memory.CharacterROM, 0, 2048); } else if (((vicBank == 0) || (vicBank == 2)) && (localCharDataPos == 0x2000)) { // use default lower case chars charData = new GR.Memory.ByteBuffer(); charData.Append(Machine.Memory.CharacterROM, 2048, 2048); } else { // use RAM charData = new GR.Memory.ByteBuffer(machine.Memory.RAM); charData = charData.SubBuffer(charDataPos, 2048); } for (int y = 0; y < 25; ++y) { for (int x = 0; x < 40; ++x) { byte charIndex = machine.Memory.RAM[screenPos + x + y * 40]; byte charColor = machine.Memory.ColorRAM[x + y * 40]; //CharacterDisplayer.DisplayHiResChar( charData.SubBuffer( charIndex * 8, 8 ), bgColor, charColor, img, x * 8, y * 8 ); } } /* * DataObject dataObj = new DataObject(); * * GR.Memory.ByteBuffer dibData = img.CreateHDIBAsBuffer(); * * System.IO.MemoryStream ms = dibData.MemoryStream(); * * // WTF - SetData requires streams, NOT global data (HGLOBAL) * dataObj.SetData( "DeviceIndependentBitmap", ms ); * Clipboard.SetDataObject( dataObj, true );*/ } }
public void OpenProject(GR.Memory.ByteBuffer ProjectData) { if (!m_Charset.ReadFromBuffer(ProjectData)) { return; } CharsetWasImported(); }
public void SetHexData(GR.Memory.ByteBuffer Data) { if (Data == null) { return; } hexView.ByteProvider = new Be.Windows.Forms.DynamicByteProvider(Data.Data()); hexView.ByteProvider.Changed += new EventHandler(ByteProvider_Changed); }
public bool SetData(GR.Memory.ByteBuffer ImageData) { if (ImageData.Length != m_ImageData.Length) { return(false); } ImageData.CopyTo(m_ImageData); return(true); }
private void btnExportToBASICData_Click(object sender, EventArgs e) { GR.Memory.ByteBuffer exportData = GetValueData(); int lineDelta = GR.Convert.ToI32(editExportBASICLineOffset.Text); int curLineNumber = GR.Convert.ToI32(editExportBASICLineNo.Text); editDataExport.Text = Util.ToBASICData(exportData, curLineNumber, lineDelta); }
public void SetHexData(GR.Memory.ByteBuffer Data) { long oldOffset = hexView.VScrollPos; hexView.ByteProvider = new Be.Windows.Forms.DynamicByteProvider(Data.Data()); Debug.Log("DebugMemory::SetHexData called with " + oldOffset + ", setting " + Data.Length + " bytes"); hexView.PerformScrollToLine(oldOffset); }
private void btnImportFromFile_Click(object sender, EventArgs e) { string filename; if (OpenFile("Open binary data", Constants.FILEFILTER_BINARY_FILES + Constants.FILEFILTER_ALL, out filename)) { GR.Memory.ByteBuffer data = GR.IO.File.ReadAllBytes(filename); ImportFromData(data, checkImportSwizzle.Checked, checkImportColorsSorted.Checked); } }
public static string PETSCIIToUnicode(GR.Memory.ByteBuffer Filename) { string filename = ""; for (int i = 0; i < Filename.Length; ++i) { byte petscii = Filename.ByteAt(i); filename += (char)ConstantData.PETSCIIToUnicode[petscii]; } return(filename); }
private bool SaveProject(bool SaveAs) { string saveFilename = DocumentInfo.FullPath; if ((String.IsNullOrEmpty(DocumentInfo.DocumentFilename)) || (SaveAs)) { System.Windows.Forms.SaveFileDialog saveDlg = new System.Windows.Forms.SaveFileDialog(); saveDlg.Title = "Save Charset Project as"; saveDlg.Filter = "Charset Projects|*.charsetproject|All Files|*.*"; if (DocumentInfo.Project != null) { saveDlg.InitialDirectory = DocumentInfo.Project.Settings.BasePath; } if (saveDlg.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return(false); } if (SaveAs) { saveFilename = saveDlg.FileName; } else { DocumentInfo.DocumentFilename = saveDlg.FileName; if (DocumentInfo.Element != null) { if (string.IsNullOrEmpty(DocumentInfo.Project.Settings.BasePath)) { DocumentInfo.DocumentFilename = saveDlg.FileName; } else { DocumentInfo.DocumentFilename = GR.Path.RelativePathTo(saveDlg.FileName, false, System.IO.Path.GetFullPath(DocumentInfo.Project.Settings.BasePath), true); } DocumentInfo.Element.Name = System.IO.Path.GetFileNameWithoutExtension(DocumentInfo.DocumentFilename); DocumentInfo.Element.Node.Text = System.IO.Path.GetFileName(DocumentInfo.DocumentFilename); DocumentInfo.Element.Filename = DocumentInfo.DocumentFilename; } saveFilename = DocumentInfo.FullPath; } } if (!SaveAs) { m_Charset.Name = DocumentInfo.DocumentFilename; m_Charset.UsedTiles = GR.Convert.ToU32(editCharactersFrom.Text); } GR.Memory.ByteBuffer projectFile = SaveToBuffer(); return(SaveDocumentData(saveFilename, projectFile, SaveAs)); }
private void Import() { string filename; if (OpenFile("Open Binary File", C64Studio.Types.Constants.FILEFILTER_ALL, out filename)) { GR.Memory.ByteBuffer data = GR.IO.File.ReadAllBytes(filename); if (data != null) { SetHexData(data); } } }
private void btnToText_Click(object sender, EventArgs e) { GR.Memory.ByteBuffer data = DataFromHex(); int wrapCount = GR.Convert.ToI32(editWrapCount.Text); if (wrapCount <= 0) { wrapCount = 40; } textBinaryData.Text = Util.ToASMData(data, wrapCount > 0, wrapCount, "!byte "); }
public bool SaveToFile(string Filename) { GR.Memory.ByteBuffer dataToSave = SaveToBuffer(); if (dataToSave == null) { return(false); } if (!GR.IO.File.WriteAllBytes(Filename, dataToSave)) { return(false); } return(true); }
private void btnImportFromHex_Click(object sender, EventArgs e) { string binaryText = editDataExport.Text.Replace(" ", "").Replace("\r", "").Replace("\n", ""); GR.Memory.ByteBuffer data = new GR.Memory.ByteBuffer(binaryText); m_Project.ValueTable.Values.Clear(); m_Project.ValueTable.Data = data; for (int i = 0; i < data.Length; ++i) { m_Project.ValueTable.Values.Add(data.ByteAt(i).ToString()); } SetModified(); }
public void OpenProject(string Filename) { DisableFileWatcher(); Clear(); GR.Memory.ByteBuffer projectFile = GR.IO.File.ReadAllBytes(Filename); DocumentInfo.DocumentFilename = Filename; OpenProject(projectFile); EnableFileWatcher(); }
private void btnUpsize_Click(object sender, EventArgs e) { var data = DataFromHex(); GR.Memory.ByteBuffer newData = new GR.Memory.ByteBuffer(data.Length * 2); for (int i = 0; i < data.Length; ++i) { byte value = data.ByteAt(i); newData.SetU16At(i * 2, value); } SetHexData(newData); }