public bool LoadFromFile(GR.Memory.ByteBuffer Data)
        {
            Characters.Clear();
            MapData.Clear();
            MapColorData.Clear();

            if ((Data == null) ||
                (Data.Length < 24) ||
                (Data.ByteAt(0) != 'C') ||
                (Data.ByteAt(1) != 'T') ||
                (Data.ByteAt(2) != 'M'))
            {
                // not a valid CTM file
                return(false);
            }
            int version = Data.ByteAt(3);

            if ((version != 4) &&
                (version != 5) &&
                (version != 6) &&
                (version != 7) &&
                (version != 8))
            {
                System.Windows.Forms.MessageBox.Show("Currently only version 4, 5, 6 or 7 of Charpad project files is supported. Sorry!", "Unsupported version " + version);
                return(false);
            }

            switch (version)
            {
            case 4:
                return(LoadVersion4(Data));

            case 5:
                return(LoadVersion5(Data));

            case 6:
                // TODO!
                return(LoadVersion5(Data));

            case 7:
                return(LoadVersion7(Data));

            case 8:
            default:
                return(LoadVersion8(Data));
            }
        }
示例#2
0
        public override bool RenameFile(GR.Memory.ByteBuffer Filename, GR.Memory.ByteBuffer NewFilename)
        {
            _LastError = "";
            int curTrack  = TRACK_DIRECTORY;
            int curSector = SECTOR_DIRECTORY;

            while (true)
            {
                Track dirTrack = Tracks[curTrack - 1];

                Sector sect = dirTrack.Sectors[curSector];
                for (int i = 0; i < 8; ++i)
                {
                    if (sect.Data.ByteAt(BYTES_PER_DIR_ENTRY * i + 2) != 0)
                    {
                        // non empty
                        bool filenameMatches = true;
                        for (int j = 0; j < 16; ++j)
                        {
                            if (Filename.ByteAt(j) != sect.Data.ByteAt(BYTES_PER_DIR_ENTRY * i + 5 + j))
                            {
                                filenameMatches = false;
                                break;
                            }
                        }

                        if (filenameMatches)
                        {
                            for (int j = 0; j < 16; ++j)
                            {
                                sect.Data.SetU8At(BYTES_PER_DIR_ENTRY * i + 5 + j, NewFilename.ByteAt(j));
                            }
                            return(true);
                        }
                    }
                }
                // find next dir sector
                if (sect.Data.ByteAt(0) == 0)
                {
                    // was last dir sector
                    _LastError = "file not found";
                    return(false);
                }
                curTrack  = sect.Data.ByteAt(0);
                curSector = sect.Data.ByteAt(1);
            }
        }
示例#3
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            Filename = Util.ToFilename(editFilename.Text);

            while ((Filename.Length > 0) &&
                   (Filename.ByteAt((int)Filename.Length - 1) == 32))
            {
                Filename.Truncate(1);
            }
            while (Filename.Length < 16)
            {
                Filename.AppendU8(0xa0);
            }

            DialogResult = DialogResult.OK;
            Close();
        }
示例#4
0
        public string DisassembleBinary(GR.Memory.ByteBuffer Data, int DataStartAddress, int ExportStartAddress, int Length, bool AddLineAddresses)
        {
            StringBuilder sb = new StringBuilder();

            int wrapSize = 8;

            while (Length >= wrapSize)
            {
                if (AddLineAddresses)
                {
                    sb.Append(ExportStartAddress.ToString("X4") + ":");
                }
                sb.Append("          !byte ");
                for (int i = 0; i < wrapSize; ++i)
                {
                    sb.Append("$" + Data.ByteAt(ExportStartAddress - DataStartAddress + i).ToString("X2"));
                    if (i + 1 < wrapSize)
                    {
                        sb.Append(",");
                    }
                }
                //Debug.Log( outputB );
                sb.Append("\r\n");
                ExportStartAddress += wrapSize;
                Length             -= wrapSize;
            }
            if (Length > 0)
            {
                if (AddLineAddresses)
                {
                    sb.Append(ExportStartAddress.ToString("X4") + ":");
                }
                sb.Append("          !byte ");
                for (int i = 0; i < Length; ++i)
                {
                    sb.Append("$" + Data.ByteAt(ExportStartAddress - DataStartAddress + i).ToString("X2"));
                    if (i + 1 < Length)
                    {
                        sb.Append(",");
                    }
                }
                //Debug.Log( outputB );
                sb.Append("\r\n");
            }
            return(sb.ToString());
        }
示例#5
0
        public override void ApplyDisplayDetails(GR.Memory.ByteBuffer Buffer)
        {
            GR.IO.MemoryReader memIn = Buffer.MemoryReader();

            int numColumns = memIn.ReadInt32();

            for (int i = 0; i < numColumns; ++i)
            {
                if (i < listResults.Columns.Count)
                {
                    listResults.Columns[i].Width = memIn.ReadInt32();
                }
            }

            listResultsSortColumn = memIn.ReadInt32();
            listResults.Sorting   = (SortOrder)memIn.ReadInt32();
        }
示例#6
0
文件: Tap.cs 项目: wowjinxy/C64Studio
 public override Types.FileInfo LoadFile(GR.Memory.ByteBuffer Filename)
 {
     _LastError = "";
     Types.FileInfo fileInfo = new C64Studio.Types.FileInfo();
     foreach (FileEntry file in TapFiles)
     {
         if (file.Filename.Compare(Filename) == 0)
         {
             fileInfo.Filename = new GR.Memory.ByteBuffer(file.Filename);
             fileInfo.Data     = file.Data;
             fileInfo.Type     = C64Studio.Types.FileType.PRG;
             return(fileInfo);
         }
     }
     _LastError = "file not found";
     return(null);
 }
示例#7
0
        public GR.Memory.ByteBuffer Save()
        {
            GR.Memory.ByteBuffer bufferProject = new GR.Memory.ByteBuffer();

            GR.IO.FileChunk chunkProject = new GR.IO.FileChunk(Types.FileChunk.PROJECT);

            // version 2 -> has adjusted debug start address (to get rid of 2049)
            chunkProject.AppendU32(2);
            chunkProject.AppendString(Settings.Name);
            chunkProject.AppendString(Settings.Filename);
            chunkProject.AppendU16(Settings.DebugPort);
            chunkProject.AppendU16(0);// obsolete Settings.DebugStartAddress
            chunkProject.AppendString(Settings.BuildTool);
            chunkProject.AppendString(Settings.RunTool);
            chunkProject.AppendString(Settings.MainDocument);
            chunkProject.AppendString(Settings.CurrentConfig.Name);
            if (Core.MainForm.ActiveElement != null)
            {
                chunkProject.AppendString(Core.MainForm.ActiveElement.Filename);
            }
            else
            {
                chunkProject.AppendString("");
            }

            bufferProject.Append(chunkProject.ToBuffer());

            foreach (System.Windows.Forms.TreeNode node in Node.Nodes)
            {
                ProjectElement element = (ProjectElement)node.Tag;

                bufferProject.Append(ElementToBuffer(element));
            }

            foreach (ProjectConfig config in Settings.GetConfigurations())
            {
                bufferProject.Append(config.Save());
            }

            foreach (var watch in Core.MainForm.m_DebugWatch.m_WatchEntries)
            {
                bufferProject.Append(watch.Save());
            }

            return(bufferProject);
        }
示例#8
0
        public GR.Memory.ByteBuffer SaveToBuffer()
        {
            GR.Memory.ByteBuffer projectFile = new GR.Memory.ByteBuffer();

            GR.IO.FileChunk chunkScreenInfo = new GR.IO.FileChunk(Types.FileChunk.CHARSET_SCREEN_INFO);
            // version
            chunkScreenInfo.AppendU32(0);
            // width
            chunkScreenInfo.AppendI32(ScreenWidth);
            // height
            chunkScreenInfo.AppendI32(ScreenHeight);
            chunkScreenInfo.AppendString("");
            chunkScreenInfo.AppendI32((int)Mode);
            chunkScreenInfo.AppendI32(ScreenOffsetX);
            chunkScreenInfo.AppendI32(ScreenOffsetY);

            projectFile.Append(chunkScreenInfo.ToBuffer());

            GR.IO.FileChunk chunkCharSet = new GR.IO.FileChunk(Types.FileChunk.CHARSET_DATA);
            chunkCharSet.Append(CharSet.SaveToBuffer());
            projectFile.Append(chunkCharSet.ToBuffer());

            GR.IO.FileChunk chunkScreenMultiColorData = new GR.IO.FileChunk(Types.FileChunk.MULTICOLOR_DATA);
            chunkScreenMultiColorData.AppendU8((byte)Mode);
            chunkScreenMultiColorData.AppendU8((byte)BackgroundColor);
            chunkScreenMultiColorData.AppendU8((byte)MultiColor1);
            chunkScreenMultiColorData.AppendU8((byte)MultiColor2);
            projectFile.Append(chunkScreenMultiColorData.ToBuffer());

            GR.IO.FileChunk chunkScreenCharData = new GR.IO.FileChunk(Types.FileChunk.SCREEN_CHAR_DATA);
            for (int i = 0; i < Chars.Count; ++i)
            {
                chunkScreenCharData.AppendU8((byte)(Chars[i] & 0xff));
            }
            projectFile.Append(chunkScreenCharData.ToBuffer());

            GR.IO.FileChunk chunkScreenColorData = new GR.IO.FileChunk(Types.FileChunk.SCREEN_COLOR_DATA);
            for (int i = 0; i < Chars.Count; ++i)
            {
                chunkScreenColorData.AppendU8((byte)(Chars[i] >> 8));
            }
            projectFile.Append(chunkScreenColorData.ToBuffer());

            return(projectFile);
        }
示例#9
0
            public override UInt32 ReadBlock(GR.Memory.ByteBuffer BufferTarget, UInt32 BytesToRead)
            {
                if (m_Stream == null)
                {
                    return(0);
                }

                int bytesInCache = (int)m_Cache.Length - m_CacheBytesUsed;

                // full in cache
                if (BytesToRead <= bytesInCache)
                {
                    BufferTarget.Resize(BytesToRead);
                    m_Cache.CopyTo(BufferTarget, m_CacheBytesUsed, (int)BytesToRead);
                    m_CacheBytesUsed += (int)BytesToRead;
                    return(BytesToRead);
                }

                UInt32 bytesRead = 0;

                // partially in cache
                BufferTarget.Resize((uint)bytesInCache);
                m_Cache.CopyTo(BufferTarget, m_CacheBytesUsed, bytesInCache);
                m_CacheBytesUsed += bytesInCache;
                BytesToRead      -= (uint)bytesInCache;

                bytesRead = (UInt32)bytesInCache;


                UInt32 BytesToReadNow = BytesToRead;

                if (m_Stream.Position + BytesToRead > m_Stream.Length)
                {
                    BytesToReadNow = (UInt32)(m_Stream.Length - m_Stream.Position);
                }
                UInt32 OriginalLength = (UInt32)BufferTarget.Length;

                BufferTarget.Resize((UInt32)(BufferTarget.Length + BytesToReadNow));

                m_Stream.Read(BufferTarget.Data(), (int)OriginalLength, (int)BytesToReadNow);

                bytesRead += BytesToReadNow;

                return(bytesRead);
            }
        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);
        }
示例#11
0
        private bool DoSave(string Filename)
        {
            try
            {
                DisableFileWatcher();

                GR.Memory.ByteBuffer data = DataFromHex();
                GR.IO.File.WriteAllBytes(Filename, data);
            }
            catch (System.IO.IOException ex)
            {
                System.Windows.Forms.MessageBox.Show("Could not save file " + Filename + ".\r\n" + ex.ToString(), "Could not save file");
                EnableFileWatcher();
                return(false);
            }
            EnableFileWatcher();
            return(true);
        }
示例#12
0
        public BinaryDisplay(StudioCore Core, GR.Memory.ByteBuffer WorkData, bool AllowEditing, bool FixedWidth)
        {
            this.Core = Core;
            DocumentInfo.UndoManager.MainForm = Core.MainForm;
            InitializeComponent();
            if (WorkData == null)
            {
                SetHexData(new GR.Memory.ByteBuffer());
            }
            else
            {
                SetHexData(WorkData);
            }
            this.AllowEditing = AllowEditing;
            this.FixedWidth   = FixedWidth;

            hexView.ByteProvider.Changed += new EventHandler(ByteProvider_Changed);
        }
        public override bool HandleExport(ExportCharsetInfo Info, TextBox EditOutput, DocumentInfo DocInfo)
        {
            var sb = new StringBuilder();

            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))
            {
                lineOffset = 10;
            }

            int  wrapByteCount = GetExportWrapCount();
            bool asHex         = checkExportHex.Checked;
            int  wrapCharCount = GetExportCharCount();

            List <int> exportIndices = Info.ExportIndices;

            GR.Memory.ByteBuffer charSet = new GR.Memory.ByteBuffer();
            foreach (int index in exportIndices)
            {
                charSet.Append(Info.Charset.Characters[index].Tile.Data);
            }

            if (asHex)
            {
                sb.Append(Util.ToBASICHexData(charSet, startLine, lineOffset, wrapByteCount, wrapCharCount));
            }
            else
            {
                sb.Append(Util.ToBASICData(charSet, startLine, lineOffset, wrapByteCount, wrapCharCount));
            }

            EditOutput.Font = new System.Drawing.Font(Core.MainForm.m_FontC64.Families[0], 16, System.Drawing.GraphicsUnit.Pixel);
            EditOutput.Text = sb.ToString();
            return(true);
        }
示例#14
0
        public static void DisplayMultiColorChar(GR.Memory.ByteBuffer Data, int BGColor, int MColor1, int MColor2, int CharColor, CustomDrawControlContext Context)
        {
            // multicolor
            if (CharColor < 8)
            {
                DisplayHiResChar(Data, BGColor, CharColor, Context);
                return;
            }

            // single color
            int charColor = CharColor - 8;

            for (int j = 0; j < 8; ++j)
            {
                for (int i = 0; i < 4; ++i)
                {
                    int pixelValue = (Data.ByteAt(j) & (3 << ((3 - i) * 2))) >> ((3 - i) * 2);

                    switch (pixelValue)
                    {
                    case 0:
                        pixelValue = BGColor;
                        break;

                    case 1:
                        pixelValue = MColor1;
                        break;

                    case 2:
                        pixelValue = MColor2;
                        break;

                    case 3:
                        pixelValue = charColor;
                        break;
                    }
                    Context.Graphics.FillRectangle(Types.ConstantData.Palette.ColorBrushes[pixelValue],
                                                   (i * Context.Bounds.Width) / 4,
                                                   (j * Context.Bounds.Height) / 8,
                                                   ((i + 1) * Context.Bounds.Width) / 4 - (i * Context.Bounds.Width) / 4,
                                                   ((j + 1) * Context.Bounds.Height) / 8 - (j * Context.Bounds.Height) / 8);
                }
            }
        }
示例#15
0
        public static void DisplayVIC20Char(GR.Memory.ByteBuffer Data, Palette Palette, int BGColor, int MColor1, int MColor2, int CharColor, GR.Image.IImage TargetImage, int X, int Y)
        {
            // multicolor
            if (CharColor < 8)
            {
                DisplayHiResChar(Data, Palette, BGColor, CharColor, TargetImage, X, Y);
                return;
            }

            int charColor = CharColor - 8;

            for (int j = 0; j < 8; ++j)
            {
                for (int i = 0; i < 4; ++i)
                {
                    int pixelValue = (Data.ByteAt(j) & (3 << ((3 - i) * 2))) >> ((3 - i) * 2);

                    switch (pixelValue)
                    {
                    case 0:
                        pixelValue = BGColor;
                        break;

                    case 1:
                        // border color(!)
                        pixelValue = MColor1;
                        break;

                    case 2:
                        pixelValue = charColor;
                        break;

                    case 3:
                        pixelValue = MColor2;
                        break;
                    }

                    uint color = Palette.ColorValues[pixelValue];
                    TargetImage.SetPixel(X + i * 2, Y + j, color);
                    TargetImage.SetPixel(X + i * 2 + 1, Y + j, color);
                }
            }
        }
示例#16
0
        private void Export()
        {
            System.Windows.Forms.SaveFileDialog saveDlg = new System.Windows.Forms.SaveFileDialog();

            saveDlg.FileName = DocumentFilename;
            saveDlg.Title    = "Export binary data to";
            saveDlg.Filter   = "All Files|*.*";
            if (DocumentInfo.Project != null)
            {
                saveDlg.InitialDirectory = DocumentInfo.Project.Settings.BasePath;
            }
            if (saveDlg.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }
            GR.Memory.ByteBuffer data = DataFromHex();

            GR.IO.File.WriteAllBytes(saveDlg.FileName, data);
        }
示例#17
0
        private void btnOpenBinary_Click(object sender, EventArgs e)
        {
            OpenFileDialog openDialog = new OpenFileDialog();

            openDialog.Title = "Choose binary file";
            if (openDialog.ShowDialog() == DialogResult.OK)
            {
                m_OpenedFilename = openDialog.FileName;

                GR.Memory.ByteBuffer data = GR.IO.File.ReadAllBytes(openDialog.FileName);
                if (data != null)
                {
                    ushort loadAddress = 0x801;

                    if (System.IO.Path.GetExtension(openDialog.FileName).ToUpper() == ".PRG")
                    {
                        // treat first two bytes as load address
                        loadAddress = data.UInt16At(0);

                        data = data.SubBuffer(2);
                    }
                    m_Disassembler.SetData(data);
                    m_DisassemblyProject.Data = data;

                    editStartAddress.Text = "$" + loadAddress.ToString("X4");

                    int sysAddress = -1;

                    if (m_Disassembler.HasBASICJumpAddress(loadAddress, out sysAddress))
                    {
                        m_DisassemblyProject.JumpedAtAddresses.Add(sysAddress);

                        ListViewItem item = new ListViewItem();
                        FillItemFromAddress(item, sysAddress);
                        listJumpedAtAddresses.Items.Add(item);
                    }

                    SetHexData(data);

                    UpdateDisassembly();
                }
            }
        }
示例#18
0
 public static void DisplayMega65FCMChar(GR.Memory.ByteBuffer Data, int BGColor, int CharColor, CustomDrawControlContext Context)
 {
     // single color
     for (int j = 0; j < 8; ++j)
     {
         for (int i = 0; i < 8; ++i)
         {
             int colorIndex = Data.ByteAt(i + j * 8);
             if (colorIndex < Context.Palette.ColorBrushes.Length)
             {
                 Context.Graphics.FillRectangle(Context.Palette.ColorBrushes[colorIndex],
                                                (i * Context.Bounds.Width) / 8,
                                                (j * Context.Bounds.Height) / 8,
                                                ((i + 1) * Context.Bounds.Width) / 8 - (i * Context.Bounds.Width) / 8,
                                                ((j + 1) * Context.Bounds.Height) / 8 - (j * Context.Bounds.Height) / 8);
             }
         }
     }
 }
示例#19
0
    public void AddWatchEntry( WatchEntry Watch )
    {
      ListViewItem  item = new ListViewItem();

      item.Text = Watch.Name;
      if ( Watch.IndexedX )
      {
        item.Text += ",x";
      }
      if ( Watch.IndexedY )
      {
        item.Text += ",y";
      }
      item.SubItems.Add( TypeToString( Watch ) );
      if ( Watch.DisplayMemory )
      {
        item.SubItems.Add( "(unread)" );
        m_WatchEntries.Add( Watch );
      }
      else if ( !Watch.DisplayMemory )
      {
        if ( Watch.SizeInBytes == 1 )
        {
          GR.Memory.ByteBuffer data = new GR.Memory.ByteBuffer( Watch.Address.ToString( "x02" ) );
          Watch.CurrentValue = data;
          item.SubItems.Add( data.ToString() );
        }
        else if ( Watch.SizeInBytes == 2 )
        {
          GR.Memory.ByteBuffer data = new GR.Memory.ByteBuffer( Watch.Address.ToString( "x04" ) );
          Watch.CurrentValue = data;
          item.SubItems.Add( data.ToString() );
        }
      }
      else
      {
        item.SubItems.Add( "(unread)" );
        m_WatchEntries.Add( Watch );
      }
      item.Tag = Watch;

      listWatch.Items.Add( item );
    }
示例#20
0
        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 Value Table Project as";
                saveDlg.Filter = "Value Table Projects|*.valuetableproject|All Files|*.*";
                if (DocumentInfo.Project != null)
                {
                    saveDlg.InitialDirectory = DocumentInfo.Project.Settings.BasePath;
                }
                if (saveDlg.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    return(false);
                }
                saveFilename = saveDlg.FileName;
                if (!SaveAs)
                {
                    DocumentInfo.DocumentFilename = saveDlg.FileName;
                    if (DocumentInfo.Element != null)
                    {
                        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;
                }
            }

            GR.Memory.ByteBuffer dataToSave = SaveToBuffer();
            if (!GR.IO.File.WriteAllBytes(saveFilename, dataToSave))
            {
                return(false);
            }
            Modified = false;
            return(true);
        }
示例#21
0
        public bool FromBuffer(GR.Memory.ByteBuffer SolutionData, string FromFile)
        {
            GR.IO.MemoryReader memIn = new GR.IO.MemoryReader(SolutionData);

            GR.IO.FileChunk chunk = new GR.IO.FileChunk();

            while (chunk.ReadFromStream(memIn))
            {
                if (chunk.Type != Types.FileChunk.SOLUTION)
                {
                    return(false);
                }
                GR.IO.MemoryReader memChunk = chunk.MemoryReader();

                GR.IO.FileChunk subChunk = new GR.IO.FileChunk();

                while (subChunk.ReadFromStream(memChunk))
                {
                    GR.IO.MemoryReader memSubChunk = subChunk.MemoryReader();

                    switch (subChunk.Type)
                    {
                    case Types.FileChunk.SOLUTION_INFO:
                        Name     = memSubChunk.ReadString();
                        Filename = memSubChunk.ReadString();
                        Filename = FromFile;
                        break;

                    case Types.FileChunk.SOLUTION_PROJECT:
                    {
                        string filename = memSubChunk.ReadString();

                        filename = GR.Path.Normalize(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Filename), filename), false);

                        Project project = MainForm.OpenProject(filename);
                    }
                    break;
                    }
                }
            }
            return(true);
        }
示例#22
0
        private void btnToBASICHex_Click(object sender, EventArgs e)
        {
            GR.Memory.ByteBuffer data = DataFromHex();

            int lineDelta = GR.Convert.ToI32(editToBASICLineDelta.Text);

            if (lineDelta <= 0)
            {
                lineDelta = 1;
            }

            int curLineNumber = GR.Convert.ToI32(editToBASICStartLine.Text);

            if (curLineNumber < 0)
            {
                curLineNumber = 0;
            }

            textBinaryData.Text = Util.ToBASICHexData(data, curLineNumber, lineDelta);
        }
示例#23
0
 public override bool Load(string Filename)
 {
     _LastError = "";
     Clear();
     GR.Memory.ByteBuffer data = GR.IO.File.ReadAllBytes(Filename);
     if (data == null)
     {
         _LastError = "could not open/read file";
         return(false);
     }
     if (data.Length < 2)
     {
         _LastError = "file size is too small";
         return(false);
     }
     LoadAddress   = data.UInt16At(0);
     Data          = new GR.Memory.ByteBuffer(data);
     this.Filename = Util.ToFilename(System.IO.Path.GetFileNameWithoutExtension(Filename).ToUpper());
     return(true);
 }
示例#24
0
        private GR.Memory.ByteBuffer PadString(GR.Memory.ByteBuffer Text, int Digits, byte fillChar)
        {
            GR.Memory.ByteBuffer result = new GR.Memory.ByteBuffer();

            int useCharCount = Digits;

            if (Text.Length < useCharCount)
            {
                useCharCount = (int)Text.Length;
            }
            for (int i = 0; i < useCharCount; ++i)
            {
                result.AppendU8(Text.ByteAt(i));
            }
            while (result.Length < Digits)
            {
                result.AppendU8(fillChar);
            }
            return(result);
        }
示例#25
0
        public override bool RenameFile(GR.Memory.ByteBuffer Filename, GR.Memory.ByteBuffer NewFilename)
        {
            _LastError = "";
            int fileIndex = 0;

            foreach (FileRecord file in FileRecords)
            {
                if (file.EntryType == 1)
                {
                    if (file.Filename == Filename)
                    {
                        NewFilename.CopyTo(file.Filename, 0, 16);
                        return(true);
                    }
                }
                ++fileIndex;
            }
            _LastError = "file not found";
            return(false);
        }
        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  = 0;
            long dataLength = hexView.ByteProvider.Length;

            GR.Memory.ByteBuffer data = new GR.Memory.ByteBuffer((uint)dataLength);
            for (int i = 0; i < dataBytes.Count; ++i)
            {
                data.SetU8At(i, dataBytes[(int)dataStart + i]);
            }
            return(data);
        }
示例#27
0
        internal void ImageToClipboard(IImage Image, int X, int Y, int Width, int Height)
        {
            if (Image == null)
            {
                return;
            }
            if ((X >= Image.Width) ||
                (Width <= 0) ||
                (Height <= 0) ||
                (X + Width < X) ||
                (Y >= Image.Height) ||
                (Y + Height < Y))
            {
                return;
            }
            GR.Memory.ByteBuffer dibData2 = Image.GetImage(X, Y, Width, Height).CreateHDIBAsBuffer();

            System.IO.MemoryStream ms2 = dibData2.MemoryStream();

            System.Windows.Forms.Clipboard.SetData("DeviceIndependentBitmap", ms2);
        }
示例#28
0
        public static void DisplayHiResChar(GR.Memory.ByteBuffer Data, int BGColor, int CharColor, GR.Image.IImage TargetImage, int X, int Y)
        {
            // single color
            int colorIndex = 0;

            for (int j = 0; j < 8; ++j)
            {
                for (int i = 0; i < 8; ++i)
                {
                    if ((Data.ByteAt(j) & (1 << (7 - i))) != 0)
                    {
                        colorIndex = CharColor;
                    }
                    else
                    {
                        colorIndex = BGColor;
                    }
                    TargetImage.SetPixel(X + i, Y + j, (uint)colorIndex);
                }
            }
        }
示例#29
0
        public override bool WriteFile(GR.Memory.ByteBuffer Filename, GR.Memory.ByteBuffer Content, Types.FileType Type)
        {
            _LastError = "";

            int fileIndex = 0;

            foreach (FileRecord file in FileRecords)
            {
                if (file.EntryType == 0)
                {
                    // free slot found
                    file.EntryType   = 1;
                    file.C64FileType = Type;
                    if (Type == Types.FileType.PRG)
                    {
                        file.StartAddress = Content.UInt16At(0);
                        if (Content.Length < 2)
                        {
                            FileDatas[fileIndex] = new GR.Memory.ByteBuffer();
                        }
                        else
                        {
                            FileDatas[fileIndex] = Content.SubBuffer(2);
                        }
                    }
                    else
                    {
                        file.StartAddress    = 0x0801;
                        FileDatas[fileIndex] = new GR.Memory.ByteBuffer(Content);
                    }
                    file.EndAddress = (ushort)(file.StartAddress + Content.Length);
                    file.FileOffset = 0;
                    file.Filename   = Filename;
                    return(true);
                }
                ++fileIndex;
            }
            _LastError = "tape image is full";
            return(false);
        }
        private void btnReloadFile_Click(object sender, EventArgs e)
        {
            GR.Memory.ByteBuffer data = GR.IO.File.ReadAllBytes(m_OpenedFilename);
            if (data != null)
            {
                ushort loadAddress = 0x801;

                if (System.IO.Path.GetExtension(m_OpenedFilename).ToUpper() == ".PRG")
                {
                    // treat first two bytes as load address
                    loadAddress = data.UInt16At(0);

                    data = data.SubBuffer(2);
                }
                m_Disassembler.SetData(data);
                m_DisassemblyProject.Data = data;

                SetHexData(data);

                UpdateDisassembly();
            }
        }