Use string.Concat/string.Join

This commit is contained in:
YoshiRulz 2019-04-04 02:17:00 +10:00
parent 7655e5194e
commit 7fb8051426
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
9 changed files with 105 additions and 98 deletions

View File

@ -2,6 +2,7 @@
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.IO; using System.IO;
using System.Globalization; using System.Globalization;
using System.Linq;
namespace BizHawk.Emulation.Cores.Components.M68000 namespace BizHawk.Emulation.Cores.Components.M68000
{ {
@ -163,10 +164,15 @@ namespace BizHawk.Emulation.Cores.Components.M68000
{ {
string a = Disassemble(PC).ToString().PadRight(64); string a = Disassemble(PC).ToString().PadRight(64);
//string a = string.Format("{0:X6}: {1:X4}", PC, ReadWord(PC)).PadRight(64); //string a = string.Format("{0:X6}: {1:X4}", PC, ReadWord(PC)).PadRight(64);
string b = string.Format("D0:{0:X8} D1:{1:X8} D2:{2:X8} D3:{3:X8} D4:{4:X8} D5:{5:X8} D6:{6:X8} D7:{7:X8} ", D[0].u32, D[1].u32, D[2].u32, D[3].u32, D[4].u32, D[5].u32, D[6].u32, D[7].u32); var dRegStrings = D.Select((r, i) => $"D{i}:{r.u32:X8}");
string c = string.Format("A0:{0:X8} A1:{1:X8} A2:{2:X8} A3:{3:X8} A4:{4:X8} A5:{5:X8} A6:{6:X8} A7:{7:X8} ", A[0].u32, A[1].u32, A[2].u32, A[3].u32, A[4].u32, A[5].u32, A[6].u32, A[7].u32); var aRegStrings = A.Select((r, i) => $"A{i}:{r.u32:X8}");
string d = string.Format("SR:{0:X4} Pending {1}", SR, PendingCycles); return a + string.Join(" ", dRegStrings
return a + b + c + d; .Concat(aRegStrings)
.Concat(new[]
{
$"SR:{SR:X4}",
$"Pending {PendingCycles}"
}));
} }
public void SaveStateText(TextWriter writer, string id) public void SaveStateText(TextWriter writer, string id)

View File

@ -1,4 +1,6 @@
using System; using System;
using System.Linq;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Components.CP1610 namespace BizHawk.Emulation.Cores.Components.CP1610
@ -27,23 +29,19 @@ namespace BizHawk.Emulation.Cores.Components.CP1610
RegisterPC-1, RegisterPC-1,
opcode, opcode,
disassemble ? Disassemble((ushort)(RegisterPC-1), out notused) : "---").PadRight(26), disassemble ? Disassemble((ushort)(RegisterPC-1), out notused) : "---").PadRight(26),
RegisterInfo = string.Format( RegisterInfo = string.Join(" ",
"Cy:{0} {1}{2}{3}{4}{5}{6} R0:{7:X4} R1:{8:X4} R2:{9:X4} R3:{10:X4} R4:{11:X4} R5:{12:X4} R6:{13:X4} R7:{14:X4}", new[]
TotalExecutedCycles, {
FlagS ? "S" : "s", $"Cy:{TotalExecutedCycles}",
FlagC ? "C" : "c", string.Concat(
FlagZ ? "Z" : "z", FlagS ? "S" : "s",
FlagO ? "O" : "o", FlagC ? "C" : "c",
FlagI ? "I" : "i", FlagZ ? "Z" : "z",
FlagD ? "D" : "d", FlagO ? "O" : "o",
Register[0], FlagI ? "I" : "i",
Register[1], FlagD ? "D" : "d")
Register[2], }
Register[3], .Concat(Register.Select((r, i) => $"R{i}:{4:X4}")))
Register[4],
Register[5],
Register[6],
Register[7])
}; };
} }

View File

@ -278,23 +278,22 @@ namespace BizHawk.Emulation.Cores.Components.H6280
PC, PC,
ReadMemory(PC), ReadMemory(PC),
Disassemble(PC, out notused), MPR[PC >> 13]).PadRight(30), Disassemble(PC, out notused), MPR[PC >> 13]).PadRight(30),
RegisterInfo = string.Format( RegisterInfo = string.Join(" ",
"A:{0:X2} X:{1:X2} Y:{2:X2} P:{3:X2} SP:{4:X2} Cy:{5} {6}{7}{8}{9}{10}{11}{12}{13}", $"A:{A:X2}",
A, $"X:{X:X2}",
X, $"Y:{Y:X2}",
Y, $"P:{P:X2}",
P, $"SP:{S:X2}",
S, $"Cy:{TotalExecutedCycles}",
TotalExecutedCycles, string.Concat(
FlagN ? "N" : "n", FlagN ? "N" : "n",
FlagV ? "V" : "v", FlagV ? "V" : "v",
FlagT ? "T" : "t", FlagT ? "T" : "t",
FlagB ? "B" : "b", FlagB ? "B" : "b",
FlagD ? "D" : "d", FlagD ? "D" : "d",
FlagI ? "I" : "i", FlagI ? "I" : "i",
FlagZ ? "Z" : "z", FlagZ ? "Z" : "z",
FlagC ? "C" : "c" FlagC ? "C" : "c"))
)
}; };
} }

View File

@ -566,25 +566,25 @@ namespace BizHawk.Emulation.Common.Components.LR35902
Disassembly = string.Format( Disassembly = string.Format(
"{0} ", "{0} ",
disassemble ? Disassemble(RegPC, ReadMemory, out notused) : "---").PadRight(40), disassemble ? Disassemble(RegPC, ReadMemory, out notused) : "---").PadRight(40),
RegisterInfo = string.Format( RegisterInfo = string.Join(" ",
"A:{0:X2} F:{1:X2} B:{2:X2} C:{3:X2} D:{4:X2} E:{5:X2} H:{6:X2} L:{7:X2} SP:{8:X2} Cy:{9} LY:{10} {11}{12}{13}{14}{15}{16}", $"A:{Regs[A]:X2}",
Regs[A], $"F:{Regs[F]:X2}",
Regs[F], $"B:{Regs[B]:X2}",
Regs[B], $"C:{Regs[C]:X2}",
Regs[C], $"D:{Regs[D]:X2}",
Regs[D], $"E:{Regs[E]:X2}",
Regs[E], $"H:{Regs[H]:X2}",
Regs[H], $"L:{Regs[L]:X2}",
Regs[L], $"SP:{Regs[SPl] | (Regs[SPh] << 8):X2}",
Regs[SPl] | (Regs[SPh] << 8), $"Cy:{TotalExecutedCycles}",
TotalExecutedCycles, $"LY:{LY}",
LY, string.Concat(
FlagZ ? "Z" : "z", FlagZ ? "Z" : "z",
FlagN ? "N" : "n", FlagN ? "N" : "n",
FlagH ? "H" : "h", FlagH ? "H" : "h",
FlagC ? "C" : "c", FlagC ? "C" : "c",
FlagI ? "I" : "i", FlagI ? "I" : "i",
interrupts_enabled ? "E" : "e") interrupts_enabled ? "E" : "e"))
}; };
} }
// State Save/Load // State Save/Load

View File

@ -74,16 +74,17 @@ namespace BizHawk.Emulation.Cores.Components.M6502
"{0:X4}: {1,-9} {2} ", "{0:X4}: {1,-9} {2} ",
PC, rawbytes, disasm).PadRight(32), PC, rawbytes, disasm).PadRight(32),
RegisterInfo = string.Format( RegisterInfo = string.Format(
"A:{0:X2} X:{1:X2} Y:{2:X2} SP:{4:X2} P:{3:X2} {6}{7}{8}{9}{10}{11}{12}{13} Cy:{5} PPU-Cy:{15}", "A:{0:X2} X:{1:X2} Y:{2:X2} SP:{4:X2} P:{3:X2} {6} Cy:{5} PPU-Cy:{8}",
A, X, Y, P, S, TotalExecutedCycles, A, X, Y, P, S, TotalExecutedCycles,
FlagN ? "N" : "n", string.Concat(
FlagV ? "V" : "v", FlagN ? "N" : "n",
FlagT ? "T" : "t", FlagV ? "V" : "v",
FlagB ? "B" : "b", FlagT ? "T" : "t",
FlagD ? "D" : "d", FlagB ? "B" : "b",
FlagI ? "I" : "i", FlagD ? "D" : "d",
FlagZ ? "Z" : "z", FlagI ? "I" : "i",
FlagC ? "C" : "c", FlagZ ? "Z" : "z",
FlagC ? "C" : "c"),
!RDY ? "R" : "r", !RDY ? "R" : "r",
ext_ppu_cycle) ext_ppu_cycle)
}; };

View File

@ -761,25 +761,25 @@ namespace BizHawk.Emulation.Cores.Components.Z80A
RegPC, RegPC,
byte_code.PadRight(12), byte_code.PadRight(12),
disasm.PadRight(26)), disasm.PadRight(26)),
RegisterInfo = string.Format( RegisterInfo = string.Join(" ",
"AF:{0:X4} BC:{1:X4} DE:{2:X4} HL:{3:X4} IX:{4:X4} IY:{5:X4} SP:{6:X4} Cy:{7} {8}{9}{10}{11}{12}{13}{14}{15}{16}", $"AF:{(Regs[A] << 8) + Regs[F]:X4}",
(Regs[A] << 8) + Regs[F], $"BC:{(Regs[B] << 8) + Regs[C]:X4}",
(Regs[B] << 8) + Regs[C], $"DE:{(Regs[D] << 8) + Regs[E]:X4}",
(Regs[D] << 8) + Regs[E], $"HL:{(Regs[H] << 8) + Regs[L]:X4}",
(Regs[H] << 8) + Regs[L], $"IX:{(Regs[Ixh] << 8) + Regs[Ixl]:X4}",
(Regs[Ixh] << 8) + Regs[Ixl], $"IY:{(Regs[Iyh] << 8) + Regs[Iyl]:X4}",
(Regs[Iyh] << 8) + Regs[Iyl], $"SP:{Regs[SPl] | (Regs[SPh] << 8):X4}",
Regs[SPl] | (Regs[SPh] << 8), $"Cy:{TotalExecutedCycles}",
TotalExecutedCycles, string.Concat(
FlagC ? "C" : "c", FlagC ? "C" : "c",
FlagN ? "N" : "n", FlagN ? "N" : "n",
FlagP ? "P" : "p", FlagP ? "P" : "p",
Flag3 ? "3" : "-", Flag3 ? "3" : "-",
FlagH ? "H" : "h", FlagH ? "H" : "h",
Flag5 ? "5" : "-", Flag5 ? "5" : "-",
FlagZ ? "Z" : "z", FlagZ ? "Z" : "z",
FlagS ? "S" : "s", FlagS ? "S" : "s",
FlagI ? "E" : "e") FlagI ? "E" : "e"))
}; };
} }

View File

@ -459,10 +459,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public string palette; // Palette override for VS system public string palette; // Palette override for VS system
public byte vs_security; // for VS system games that do a ppu dheck public byte vs_security; // for VS system games that do a ppu dheck
public override string ToString() public override string ToString() => string.Join(",",
{ $"pr={prg_size}",
return string.Format("pr={1},ch={2},wr={3},vr={4},ba={5},pa={6}|{7},brd={8},sys={9}", board_type, prg_size, chr_size, wram_size, vram_size, wram_battery ? 1 : 0, pad_h, pad_v, board_type, system); $"ch={chr_size}",
} $"wr={wram_size}",
$"vr={vram_size}",
$"ba={(wram_battery ? 1 : 0)}",
$"pa={pad_h}|{pad_v}",
$"brd={board_type}",
$"sys={system}");
} }
/// <summary> /// <summary>

View File

@ -34,13 +34,12 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
Tracer.Put(new TraceInfo Tracer.Put(new TraceInfo
{ {
Disassembly = string.Format("{0:X4}: {1}", pc, opcodeStr).PadRight(26), Disassembly = string.Format("{0:X4}: {1}", pc, opcodeStr).PadRight(26),
RegisterInfo = string.Format( RegisterInfo = string.Join(" ",
"A:{1:X2} X:{3:X2} Y:{4:X2} P:{2:X2} SP:{0:X2}", $"A:{a:X2}",
sp, $"X:{x:X2}",
a, $"Y:{y:X2}",
p, $"P:{p:X2}",
x, $"SP:{sp:X2}")
y)
}); });
} }

View File

@ -49,8 +49,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
} }
} }
var sr = regs["M68K SR"].Value; var sr = regs["M68K SR"].Value;
sb.Append( sb.Append(string.Concat(
string.Format("{0}{1}{2}{3}{4}",
(sr & 16) > 0 ? "X" : "x", (sr & 16) > 0 ? "X" : "x",
(sr & 8) > 0 ? "N" : "n", (sr & 8) > 0 ? "N" : "n",
(sr & 4) > 0 ? "Z" : "z", (sr & 4) > 0 ? "Z" : "z",