From 2a9a395ec8f7adefe3b0e01d6cc7346e02dcb78c Mon Sep 17 00:00:00 2001 From: Chris Anders Date: Sat, 26 Oct 2024 07:59:20 +0200 Subject: [PATCH] feat: Wrap hex Closes #21 --- .../ViewModels/DisassemblyPopupViewModel.cs | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/MimaSim/MimaSim/ViewModels/DisassemblyPopupViewModel.cs b/src/MimaSim/MimaSim/ViewModels/DisassemblyPopupViewModel.cs index e302c73..a9aa614 100644 --- a/src/MimaSim/MimaSim/ViewModels/DisassemblyPopupViewModel.cs +++ b/src/MimaSim/MimaSim/ViewModels/DisassemblyPopupViewModel.cs @@ -1,7 +1,9 @@ -using MimaSim.Controls; +using System; +using MimaSim.Controls; using MimaSim.MIMA.Components; using ReactiveUI; using System.Linq; +using System.Text; using System.Windows.Input; using AvaloniaEdit.Highlighting; using MimaSim.Core; @@ -52,16 +54,28 @@ private static string Disassemble() private static string GetRawString() { var raw = CPU.Instance.Program; + var stringBuilder = new StringBuilder(); - return string.Join(' ', raw.Select(_ => + foreach (var item in raw) { - var result = (_).ToString("x"); + var result = item.ToString("x"); if (result.Length == 1) { result = "0" + result; } - return result; - })).ToUpper(); + stringBuilder.Append(result.ToUpper()); + + if ((stringBuilder.Length % 10) == 0) + { + stringBuilder.Append(Environment.NewLine); + } + else + { + stringBuilder.Append(' '); + } + } + + return stringBuilder.ToString().Trim(); } } \ No newline at end of file