From 7fb80514263a13266188bdeace2f608c20f40675 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Thu, 4 Apr 2019 02:17:00 +1000 Subject: [PATCH 1/4] Use string.Concat/string.Join --- BizHawk.Emulation.Cores/CPUs/68000/MC68000.cs | 14 +++++-- .../CPUs/CP1610/CP1610.Execute.cs | 32 ++++++++-------- .../CPUs/HuC6280/HuC6280.cs | 33 ++++++++-------- .../CPUs/LR35902/LR35902.cs | 38 +++++++++---------- .../CPUs/MOS 6502X/MOS6502X.cs | 19 +++++----- BizHawk.Emulation.Cores/CPUs/Z80A/Z80A.cs | 38 +++++++++---------- .../Consoles/Nintendo/NES/NES.BoardSystem.cs | 13 +++++-- .../Nintendo/QuickNES/QuickNES.ITraceable.cs | 13 +++---- .../Consoles/Sega/gpgx64/GPGX.ITraceable.cs | 3 +- 9 files changed, 105 insertions(+), 98 deletions(-) diff --git a/BizHawk.Emulation.Cores/CPUs/68000/MC68000.cs b/BizHawk.Emulation.Cores/CPUs/68000/MC68000.cs index 4d0521fc150..b851d86272b 100644 --- a/BizHawk.Emulation.Cores/CPUs/68000/MC68000.cs +++ b/BizHawk.Emulation.Cores/CPUs/68000/MC68000.cs @@ -2,6 +2,7 @@ using System.Runtime.InteropServices; using System.IO; using System.Globalization; +using System.Linq; namespace BizHawk.Emulation.Cores.Components.M68000 { @@ -163,10 +164,15 @@ public string State() { string a = Disassemble(PC).ToString().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); - 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); - string d = string.Format("SR:{0:X4} Pending {1}", SR, PendingCycles); - return a + b + c + d; + var dRegStrings = D.Select((r, i) => $"D{i}:{r.u32:X8}"); + var aRegStrings = A.Select((r, i) => $"A{i}:{r.u32:X8}"); + return a + string.Join(" ", dRegStrings + .Concat(aRegStrings) + .Concat(new[] + { + $"SR:{SR:X4}", + $"Pending {PendingCycles}" + })); } public void SaveStateText(TextWriter writer, string id) diff --git a/BizHawk.Emulation.Cores/CPUs/CP1610/CP1610.Execute.cs b/BizHawk.Emulation.Cores/CPUs/CP1610/CP1610.Execute.cs index c30c140bff5..6b5180a254f 100644 --- a/BizHawk.Emulation.Cores/CPUs/CP1610/CP1610.Execute.cs +++ b/BizHawk.Emulation.Cores/CPUs/CP1610/CP1610.Execute.cs @@ -1,4 +1,6 @@ using System; +using System.Linq; + using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Components.CP1610 @@ -27,23 +29,19 @@ public TraceInfo CP1610State(bool disassemble = true) RegisterPC-1, opcode, disassemble ? Disassemble((ushort)(RegisterPC-1), out notused) : "---").PadRight(26), - RegisterInfo = string.Format( - "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}", - TotalExecutedCycles, - FlagS ? "S" : "s", - FlagC ? "C" : "c", - FlagZ ? "Z" : "z", - FlagO ? "O" : "o", - FlagI ? "I" : "i", - FlagD ? "D" : "d", - Register[0], - Register[1], - Register[2], - Register[3], - Register[4], - Register[5], - Register[6], - Register[7]) + RegisterInfo = string.Join(" ", + new[] + { + $"Cy:{TotalExecutedCycles}", + string.Concat( + FlagS ? "S" : "s", + FlagC ? "C" : "c", + FlagZ ? "Z" : "z", + FlagO ? "O" : "o", + FlagI ? "I" : "i", + FlagD ? "D" : "d") + } + .Concat(Register.Select((r, i) => $"R{i}:{4:X4}"))) }; } diff --git a/BizHawk.Emulation.Cores/CPUs/HuC6280/HuC6280.cs b/BizHawk.Emulation.Cores/CPUs/HuC6280/HuC6280.cs index 27a93c5d2d5..919413ee809 100644 --- a/BizHawk.Emulation.Cores/CPUs/HuC6280/HuC6280.cs +++ b/BizHawk.Emulation.Cores/CPUs/HuC6280/HuC6280.cs @@ -278,23 +278,22 @@ public TraceInfo State() PC, ReadMemory(PC), Disassemble(PC, out notused), MPR[PC >> 13]).PadRight(30), - RegisterInfo = string.Format( - "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, - X, - Y, - P, - S, - TotalExecutedCycles, - FlagN ? "N" : "n", - FlagV ? "V" : "v", - FlagT ? "T" : "t", - FlagB ? "B" : "b", - FlagD ? "D" : "d", - FlagI ? "I" : "i", - FlagZ ? "Z" : "z", - FlagC ? "C" : "c" - ) + RegisterInfo = string.Join(" ", + $"A:{A:X2}", + $"X:{X:X2}", + $"Y:{Y:X2}", + $"P:{P:X2}", + $"SP:{S:X2}", + $"Cy:{TotalExecutedCycles}", + string.Concat( + FlagN ? "N" : "n", + FlagV ? "V" : "v", + FlagT ? "T" : "t", + FlagB ? "B" : "b", + FlagD ? "D" : "d", + FlagI ? "I" : "i", + FlagZ ? "Z" : "z", + FlagC ? "C" : "c")) }; } diff --git a/BizHawk.Emulation.Cores/CPUs/LR35902/LR35902.cs b/BizHawk.Emulation.Cores/CPUs/LR35902/LR35902.cs index a4e26f5a7c5..ce37346b389 100644 --- a/BizHawk.Emulation.Cores/CPUs/LR35902/LR35902.cs +++ b/BizHawk.Emulation.Cores/CPUs/LR35902/LR35902.cs @@ -566,25 +566,25 @@ public TraceInfo State(bool disassemble = true) Disassembly = string.Format( "{0} ", disassemble ? Disassemble(RegPC, ReadMemory, out notused) : "---").PadRight(40), - RegisterInfo = string.Format( - "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}", - Regs[A], - Regs[F], - Regs[B], - Regs[C], - Regs[D], - Regs[E], - Regs[H], - Regs[L], - Regs[SPl] | (Regs[SPh] << 8), - TotalExecutedCycles, - LY, - FlagZ ? "Z" : "z", - FlagN ? "N" : "n", - FlagH ? "H" : "h", - FlagC ? "C" : "c", - FlagI ? "I" : "i", - interrupts_enabled ? "E" : "e") + RegisterInfo = string.Join(" ", + $"A:{Regs[A]:X2}", + $"F:{Regs[F]:X2}", + $"B:{Regs[B]:X2}", + $"C:{Regs[C]:X2}", + $"D:{Regs[D]:X2}", + $"E:{Regs[E]:X2}", + $"H:{Regs[H]:X2}", + $"L:{Regs[L]:X2}", + $"SP:{Regs[SPl] | (Regs[SPh] << 8):X2}", + $"Cy:{TotalExecutedCycles}", + $"LY:{LY}", + string.Concat( + FlagZ ? "Z" : "z", + FlagN ? "N" : "n", + FlagH ? "H" : "h", + FlagC ? "C" : "c", + FlagI ? "I" : "i", + interrupts_enabled ? "E" : "e")) }; } // State Save/Load diff --git a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs index 5fc328f146d..046d2fe8081 100644 --- a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs +++ b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs @@ -74,16 +74,17 @@ public TraceInfo State(bool disassemble = true) "{0:X4}: {1,-9} {2} ", PC, rawbytes, disasm).PadRight(32), 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, - FlagN ? "N" : "n", - FlagV ? "V" : "v", - FlagT ? "T" : "t", - FlagB ? "B" : "b", - FlagD ? "D" : "d", - FlagI ? "I" : "i", - FlagZ ? "Z" : "z", - FlagC ? "C" : "c", + string.Concat( + FlagN ? "N" : "n", + FlagV ? "V" : "v", + FlagT ? "T" : "t", + FlagB ? "B" : "b", + FlagD ? "D" : "d", + FlagI ? "I" : "i", + FlagZ ? "Z" : "z", + FlagC ? "C" : "c"), !RDY ? "R" : "r", ext_ppu_cycle) }; diff --git a/BizHawk.Emulation.Cores/CPUs/Z80A/Z80A.cs b/BizHawk.Emulation.Cores/CPUs/Z80A/Z80A.cs index 8560300319c..880d26908bc 100644 --- a/BizHawk.Emulation.Cores/CPUs/Z80A/Z80A.cs +++ b/BizHawk.Emulation.Cores/CPUs/Z80A/Z80A.cs @@ -761,25 +761,25 @@ public TraceInfo State(bool disassemble = true) RegPC, byte_code.PadRight(12), disasm.PadRight(26)), - RegisterInfo = string.Format( - "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}", - (Regs[A] << 8) + Regs[F], - (Regs[B] << 8) + Regs[C], - (Regs[D] << 8) + Regs[E], - (Regs[H] << 8) + Regs[L], - (Regs[Ixh] << 8) + Regs[Ixl], - (Regs[Iyh] << 8) + Regs[Iyl], - Regs[SPl] | (Regs[SPh] << 8), - TotalExecutedCycles, - FlagC ? "C" : "c", - FlagN ? "N" : "n", - FlagP ? "P" : "p", - Flag3 ? "3" : "-", - FlagH ? "H" : "h", - Flag5 ? "5" : "-", - FlagZ ? "Z" : "z", - FlagS ? "S" : "s", - FlagI ? "E" : "e") + RegisterInfo = string.Join(" ", + $"AF:{(Regs[A] << 8) + Regs[F]:X4}", + $"BC:{(Regs[B] << 8) + Regs[C]:X4}", + $"DE:{(Regs[D] << 8) + Regs[E]:X4}", + $"HL:{(Regs[H] << 8) + Regs[L]:X4}", + $"IX:{(Regs[Ixh] << 8) + Regs[Ixl]:X4}", + $"IY:{(Regs[Iyh] << 8) + Regs[Iyl]:X4}", + $"SP:{Regs[SPl] | (Regs[SPh] << 8):X4}", + $"Cy:{TotalExecutedCycles}", + string.Concat( + FlagC ? "C" : "c", + FlagN ? "N" : "n", + FlagP ? "P" : "p", + Flag3 ? "3" : "-", + FlagH ? "H" : "h", + Flag5 ? "5" : "-", + FlagZ ? "Z" : "z", + FlagS ? "S" : "s", + FlagI ? "E" : "e")) }; } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.BoardSystem.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.BoardSystem.cs index ba665367f75..7c36202e546 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.BoardSystem.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.BoardSystem.cs @@ -459,10 +459,15 @@ public class CartInfo public string palette; // Palette override for VS system public byte vs_security; // for VS system games that do a ppu dheck - public override string ToString() - { - 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); - } + public override string ToString() => string.Join(",", + $"pr={prg_size}", + $"ch={chr_size}", + $"wr={wram_size}", + $"vr={vram_size}", + $"ba={(wram_battery ? 1 : 0)}", + $"pa={pad_h}|{pad_v}", + $"brd={board_type}", + $"sys={system}"); } /// diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.ITraceable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.ITraceable.cs index 1798056a315..1e2bfa3e355 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.ITraceable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.ITraceable.cs @@ -34,13 +34,12 @@ private void MakeTrace(IntPtr data) Tracer.Put(new TraceInfo { Disassembly = string.Format("{0:X4}: {1}", pc, opcodeStr).PadRight(26), - RegisterInfo = string.Format( - "A:{1:X2} X:{3:X2} Y:{4:X2} P:{2:X2} SP:{0:X2}", - sp, - a, - p, - x, - y) + RegisterInfo = string.Join(" ", + $"A:{a:X2}", + $"X:{x:X2}", + $"Y:{y:X2}", + $"P:{p:X2}", + $"SP:{sp:X2}") }); } diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ITraceable.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ITraceable.cs index c8d8dab662f..fecbfeeb4aa 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ITraceable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ITraceable.cs @@ -49,8 +49,7 @@ protected override void TraceFromCallback() } } var sr = regs["M68K SR"].Value; - sb.Append( - string.Format("{0}{1}{2}{3}{4}", + sb.Append(string.Concat( (sr & 16) > 0 ? "X" : "x", (sr & 8) > 0 ? "N" : "n", (sr & 4) > 0 ? "Z" : "z", From 9af93be0d3e1d567c423e5ce8045bc96c3f97026 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Thu, 4 Apr 2019 02:41:18 +1000 Subject: [PATCH 2/4] Use string interpolation --- .../CPUs/68000/Diassembler.cs | 5 +- .../CPUs/68000/Instructions/BitArithemetic.cs | 48 +- .../CPUs/68000/Instructions/DataMovement.cs | 6 +- .../CPUs/68000/Instructions/IntegerMath.cs | 16 +- .../CPUs/68000/Instructions/ProgramFlow.cs | 30 +- .../CPUs/68000/Instructions/Supervisor.cs | 2 +- BizHawk.Emulation.Cores/CPUs/68000/MC68000.cs | 9 +- BizHawk.Emulation.Cores/CPUs/68000/Memory.cs | 30 +- .../CPUs/CP1610/CP1610.Disassembler.cs | 20 +- .../CPUs/CP1610/CP1610.Execute.cs | 6 +- .../CPUs/HuC6280/Disassembler.cs | 760 +++++++++--------- .../CPUs/HuC6280/HuC6280.cs | 6 +- .../CPUs/LR35902/LR35902.cs | 4 +- .../CPUs/LR35902/NewDisassembler.cs | 14 +- BizHawk.Emulation.Cores/CPUs/MC6809/MC6809.cs | 4 +- .../CPUs/MC6809/NewDisassembler.cs | 14 +- .../CPUs/MOS 6502X/Disassembler.cs | 290 +++---- .../CPUs/MOS 6502X/MOS6502X.cs | 6 +- .../CPUs/W65816/Disassembler.cs | 58 +- BizHawk.Emulation.Cores/CPUs/Z80A/Z80A.cs | 6 +- .../CPUs/x86/Disassembler.cs | 73 +- BizHawk.Emulation.Cores/CPUs/x86/x86.cs | 5 +- .../AmstradCPC/Media/Tape/CDT/CdtConverter.cs | 8 +- .../Media/Tape/TAP/TapConverter.cs | 8 +- .../Media/Tape/TZX/TzxConverter.cs | 8 +- .../Media/Tape/WAV/WavHeader.cs | 4 +- .../Media/Tape/WAV/WavStreamReader.cs | 10 +- .../Consoles/Nintendo/GBA/VBANext.cs | 2 +- .../Consoles/Nintendo/N64/N64.ITraceable.cs | 16 +- .../N64/NativeApi/mupen64plusCoreApi.cs | 4 +- .../Nintendo/NES/Boards/DatachBarcode.cs | 2 +- .../Consoles/Nintendo/NES/Boards/VRC2_4.cs | 2 +- .../Consoles/Nintendo/NES/NES.iNES.cs | 4 +- .../Consoles/Nintendo/NES/Unif.cs | 6 +- .../Nintendo/QuickNES/QuickNES.ITraceable.cs | 2 +- .../Consoles/Nintendo/QuickNES/QuickNES.cs | 2 +- .../Nintendo/SNES/SNESGraphicsDecoder.cs | 5 +- .../Consoles/PC Engine/PCEngine.cs | 2 +- .../Sega/gpgx64/GPGX.IDisassembler.cs | 2 +- .../Consoles/Sega/gpgx64/GPGX.ISettable.cs | 4 +- .../Consoles/Sega/gpgx64/GPGX.ITraceable.cs | 7 +- .../Sega/gpgx64/GPGXControlConverter.cs | 16 +- .../Consoles/Sega/gpgx64/GenDbgHlp.cs | 5 +- .../Consoles/Sony/PSP/PSP.cs | 2 +- .../Consoles/Sony/PSX/Octoshock.ITraceable.cs | 7 +- BizHawk.Emulation.Cores/CoreInventory.cs | 4 +- .../Libretro/LibretroCore_Description.cs | 5 +- .../Libretro/LibretroCore_InputCallbacks.cs | 20 +- BizHawk.Emulation.Cores/Waterbox/ElfRunner.cs | 2 +- BizHawk.Emulation.Cores/Waterbox/Heap.cs | 16 +- BizHawk.Emulation.Cores/Waterbox/PeRunner.cs | 2 +- 51 files changed, 768 insertions(+), 821 deletions(-) diff --git a/BizHawk.Emulation.Cores/CPUs/68000/Diassembler.cs b/BizHawk.Emulation.Cores/CPUs/68000/Diassembler.cs index cc16656ac73..9b5ff406e80 100644 --- a/BizHawk.Emulation.Cores/CPUs/68000/Diassembler.cs +++ b/BizHawk.Emulation.Cores/CPUs/68000/Diassembler.cs @@ -10,10 +10,7 @@ public sealed class DisassemblyInfo public string RawBytes; public int Length; - public override string ToString() - { - return string.Format("{0:X6}: {1,-20} {2,-8} {3}", PC, RawBytes, Mnemonic, Args); - } + public override string ToString() => $"{PC:X6}: {RawBytes,-20} {Mnemonic,-8} {Args}"; } partial class MC68000 diff --git a/BizHawk.Emulation.Cores/CPUs/68000/Instructions/BitArithemetic.cs b/BizHawk.Emulation.Cores/CPUs/68000/Instructions/BitArithemetic.cs index 53572b3b9f0..df3e3608e46 100644 --- a/BizHawk.Emulation.Cores/CPUs/68000/Instructions/BitArithemetic.cs +++ b/BizHawk.Emulation.Cores/CPUs/68000/Instructions/BitArithemetic.cs @@ -51,15 +51,15 @@ void AND0_Disasm(DisassemblyInfo info) { case 0: // Byte info.Mnemonic = "and.b"; - info.Args = string.Format("{0}, D{1}", DisassembleValue(srcMode, srcReg, 1, ref pc), dstReg); + info.Args = $"{DisassembleValue(srcMode, srcReg, 1, ref pc)}, D{dstReg}"; break; case 1: // Word info.Mnemonic = "and.w"; - info.Args = string.Format("{0}, D{1}", DisassembleValue(srcMode, srcReg, 2, ref pc), dstReg); + info.Args = $"{DisassembleValue(srcMode, srcReg, 2, ref pc)}, D{dstReg}"; break; case 2: // Long info.Mnemonic = "and.l"; - info.Args = string.Format("{0}, D{1}", DisassembleValue(srcMode, srcReg, 4, ref pc), dstReg); + info.Args = $"{DisassembleValue(srcMode, srcReg, 4, ref pc)}, D{dstReg}"; break; } @@ -124,15 +124,15 @@ void AND1_Disasm(DisassemblyInfo info) { case 0: // Byte info.Mnemonic = "and.b"; - info.Args = string.Format("D{0}, {1}", srcReg, DisassembleValue(dstMode, dstReg, 1, ref pc)); + info.Args = $"D{srcReg}, {DisassembleValue(dstMode, dstReg, 1, ref pc)}"; break; case 1: // Word info.Mnemonic = "and.w"; - info.Args = string.Format("D{0}, {1}", srcReg, DisassembleValue(dstMode, dstReg, 2, ref pc)); + info.Args = $"D{srcReg}, {DisassembleValue(dstMode, dstReg, 2, ref pc)}"; break; case 2: // Long info.Mnemonic = "and.l"; - info.Args = string.Format("D{0}, {1}", srcReg, DisassembleValue(dstMode, dstReg, 4, ref pc)); + info.Args = $"D{srcReg}, {DisassembleValue(dstMode, dstReg, 4, ref pc)}"; break; } @@ -200,7 +200,7 @@ void ANDI_Disasm(DisassemblyInfo info) { info.Mnemonic = "andi.b"; sbyte imm = (sbyte)ReadWord(pc); pc += 2; - info.Args = string.Format("#${0:X}, ", imm); + info.Args = $"#${imm:X}, "; info.Args += DisassembleValue(dstMode, dstReg, 1, ref pc); break; } @@ -208,7 +208,7 @@ void ANDI_Disasm(DisassemblyInfo info) { info.Mnemonic = "andi.w"; short imm = ReadWord(pc); pc += 2; - info.Args = string.Format("#${0:X}, ", imm); + info.Args = $"#${imm:X}, "; info.Args += DisassembleValue(dstMode, dstReg, 2, ref pc); break; } @@ -216,7 +216,7 @@ void ANDI_Disasm(DisassemblyInfo info) { info.Mnemonic = "andi.l"; int imm = ReadLong(pc); pc += 4; - info.Args = string.Format("#${0:X}, ", imm); + info.Args = $"#${imm:X}, "; info.Args += DisassembleValue(dstMode, dstReg, 4, ref pc); break; } @@ -283,15 +283,15 @@ void EOR_Disasm(DisassemblyInfo info) { case 0: // Byte info.Mnemonic = "eor.b"; - info.Args = string.Format("D{0}, {1}", srcReg, DisassembleValue(dstMode, dstReg, 1, ref pc)); + info.Args = $"D{srcReg}, {DisassembleValue(dstMode, dstReg, 1, ref pc)}"; break; case 1: // Word info.Mnemonic = "eor.w"; - info.Args = string.Format("D{0}, {1}", srcReg, DisassembleValue(dstMode, dstReg, 2, ref pc)); + info.Args = $"D{srcReg}, {DisassembleValue(dstMode, dstReg, 2, ref pc)}"; break; case 2: // Long info.Mnemonic = "eor.l"; - info.Args = string.Format("D{0}, {1}", srcReg, DisassembleValue(dstMode, dstReg, 4, ref pc)); + info.Args = $"D{srcReg}, {DisassembleValue(dstMode, dstReg, 4, ref pc)}"; break; } @@ -355,21 +355,21 @@ void EORI_Disasm(DisassemblyInfo info) { info.Mnemonic = "eori.b"; sbyte immed = (sbyte)ReadWord(pc); pc += 2; - info.Args = String.Format("#${0:X}, {1}", immed, DisassembleValue(mode, reg, 1, ref pc)); + info.Args = $"#${immed:X}, {DisassembleValue(mode, reg, 1, ref pc)}"; break; } case 1: // word { info.Mnemonic = "eori.w"; short immed = ReadWord(pc); pc += 2; - info.Args = String.Format("#${0:X}, {1}", immed, DisassembleValue(mode, reg, 2, ref pc)); + info.Args = $"#${immed:X}, {DisassembleValue(mode, reg, 2, ref pc)}"; break; } case 2: // long { info.Mnemonic = "eori.l"; int immed = ReadLong(pc); pc += 4; - info.Args = String.Format("#${0:X}, {1}", immed, DisassembleValue(mode, reg, 4, ref pc)); + info.Args = $"#${immed:X}, {DisassembleValue(mode, reg, 4, ref pc)}"; break; } } @@ -423,15 +423,15 @@ void OR0_Disasm(DisassemblyInfo info) { case 0: // Byte info.Mnemonic = "or.b"; - info.Args = string.Format("{0}, D{1}", DisassembleValue(srcMode, srcReg, 1, ref pc), dstReg); + info.Args = $"{DisassembleValue(srcMode, srcReg, 1, ref pc)}, D{dstReg}"; break; case 1: // Word info.Mnemonic = "or.w"; - info.Args = string.Format("{0}, D{1}", DisassembleValue(srcMode, srcReg, 2, ref pc), dstReg); + info.Args = $"{DisassembleValue(srcMode, srcReg, 2, ref pc)}, D{dstReg}"; break; case 2: // Long info.Mnemonic = "or.l"; - info.Args = string.Format("{0}, D{1}", DisassembleValue(srcMode, srcReg, 4, ref pc), dstReg); + info.Args = $"{DisassembleValue(srcMode, srcReg, 4, ref pc)}, D{dstReg}"; break; } @@ -496,15 +496,15 @@ void OR1_Disasm(DisassemblyInfo info) { case 0: // Byte info.Mnemonic = "or.b"; - info.Args = string.Format("D{0}, {1}", srcReg, DisassembleValue(dstMode, dstReg, 1, ref pc)); + info.Args = $"D{srcReg}, {DisassembleValue(dstMode, dstReg, 1, ref pc)}"; break; case 1: // Word info.Mnemonic = "or.w"; - info.Args = string.Format("D{0}, {1}", srcReg, DisassembleValue(dstMode, dstReg, 2, ref pc)); + info.Args = $"D{srcReg}, {DisassembleValue(dstMode, dstReg, 2, ref pc)}"; break; case 2: // Long info.Mnemonic = "or.l"; - info.Args = string.Format("D{0}, {1}", srcReg, DisassembleValue(dstMode, dstReg, 4, ref pc)); + info.Args = $"D{srcReg}, {DisassembleValue(dstMode, dstReg, 4, ref pc)}"; break; } @@ -568,21 +568,21 @@ void ORI_Disasm(DisassemblyInfo info) { info.Mnemonic = "ori.b"; sbyte immed = (sbyte)ReadWord(pc); pc += 2; - info.Args = String.Format("#${0:X}, {1}", immed, DisassembleValue(mode, reg, 1, ref pc)); + info.Args = $"#${immed:X}, {DisassembleValue(mode, reg, 1, ref pc)}"; break; } case 1: // word { info.Mnemonic = "ori.w"; short immed = ReadWord(pc); pc += 2; - info.Args = String.Format("#${0:X}, {1}", immed, DisassembleValue(mode, reg, 2, ref pc)); + info.Args = $"#${immed:X}, {DisassembleValue(mode, reg, 2, ref pc)}"; break; } case 2: // long { info.Mnemonic = "ori.l"; int immed = ReadLong(pc); pc += 4; - info.Args = String.Format("#${0:X}, {1}", immed, DisassembleValue(mode, reg, 4, ref pc)); + info.Args = $"#${immed:X}, {DisassembleValue(mode, reg, 4, ref pc)}"; break; } } diff --git a/BizHawk.Emulation.Cores/CPUs/68000/Instructions/DataMovement.cs b/BizHawk.Emulation.Cores/CPUs/68000/Instructions/DataMovement.cs index 4520b26dd5b..4aaaeef58dd 100644 --- a/BizHawk.Emulation.Cores/CPUs/68000/Instructions/DataMovement.cs +++ b/BizHawk.Emulation.Cores/CPUs/68000/Instructions/DataMovement.cs @@ -166,7 +166,7 @@ void MOVEQ() void MOVEQ_Disasm(DisassemblyInfo info) { info.Mnemonic = "moveq"; - info.Args = String.Format("#{0}, D{1}", (sbyte)op, (op >> 9) & 7); + info.Args = $"#{(sbyte)op}, D{(op >> 9) & 7}"; } void MOVEM0() @@ -438,7 +438,7 @@ static string DisassembleRegisterList0(uint registers) } registers <<= 1; } - //str.Append(string.Format("[{0:X4}]", registers >> 16)); + //str.Append($"[{registers >> 16:X4}]"); return str.ToString(); } @@ -493,7 +493,7 @@ static string DisassembleRegisterList1(uint registers) } registers >>= 1; } - //str.Append(string.Format("[{0:X4}]", registers & 0xFFFF)); + //str.Append($"[{registers & 0xFFFF:X4}]"); return str.ToString(); } diff --git a/BizHawk.Emulation.Cores/CPUs/68000/Instructions/IntegerMath.cs b/BizHawk.Emulation.Cores/CPUs/68000/Instructions/IntegerMath.cs index 46dfbd7ce84..209c33d1665 100644 --- a/BizHawk.Emulation.Cores/CPUs/68000/Instructions/IntegerMath.cs +++ b/BizHawk.Emulation.Cores/CPUs/68000/Instructions/IntegerMath.cs @@ -934,7 +934,7 @@ void CMPM_Disasm(DisassemblyInfo info) case 1: info.Mnemonic = "cmpm.w"; break; case 2: info.Mnemonic = "cmpm.l"; break; } - info.Args = string.Format("(A{0})+, (A{1})+", ayReg, axReg); + info.Args = $"(A{ayReg})+, (A{axReg})+"; info.Length = pc - info.PC; } @@ -1001,17 +1001,17 @@ void CMPI_Disasm(DisassemblyInfo info) case 0: immediate = (byte)ReadWord(pc); pc += 2; info.Mnemonic = "cmpi.b"; - info.Args = String.Format("#${0:X}, {1}", immediate, DisassembleValue(mode, reg, 1, ref pc)); + info.Args = $"#${immediate:X}, {DisassembleValue(mode, reg, 1, ref pc)}"; break; case 1: immediate = ReadWord(pc); pc += 2; info.Mnemonic = "cmpi.w"; - info.Args = String.Format("#${0:X}, {1}", immediate, DisassembleValue(mode, reg, 2, ref pc)); + info.Args = $"#${immediate:X}, {DisassembleValue(mode, reg, 2, ref pc)}"; break; case 2: immediate = ReadLong(pc); pc += 4; info.Mnemonic = "cmpi.l"; - info.Args = String.Format("#${0:X}, {1}", immediate, DisassembleValue(mode, reg, 4, ref pc)); + info.Args = $"#${immediate:X}, {DisassembleValue(mode, reg, 4, ref pc)}"; break; } info.Length = pc - info.PC; @@ -1042,7 +1042,7 @@ void MULU_Disasm(DisassemblyInfo info) int pc = info.PC + 2; info.Mnemonic = "mulu"; - info.Args = String.Format("{0}, D{1}", DisassembleValue(mode, reg, 2, ref pc), dreg); + info.Args = $"{DisassembleValue(mode, reg, 2, ref pc)}, D{dreg}"; info.Length = pc - info.PC; } @@ -1071,7 +1071,7 @@ void MULS_Disasm(DisassemblyInfo info) int pc = info.PC + 2; info.Mnemonic = "muls"; - info.Args = String.Format("{0}, D{1}", DisassembleValue(mode, reg, 2, ref pc), dreg); + info.Args = $"{DisassembleValue(mode, reg, 2, ref pc)}, D{dreg}"; info.Length = pc - info.PC; } @@ -1107,7 +1107,7 @@ void DIVU_Disasm(DisassemblyInfo info) int pc = info.PC + 2; info.Mnemonic = "divu"; - info.Args = String.Format("{0}, D{1}", DisassembleValue(mode, reg, 2, ref pc), dreg); + info.Args = $"{DisassembleValue(mode, reg, 2, ref pc)}, D{dreg}"; info.Length = pc - info.PC; } @@ -1143,7 +1143,7 @@ void DIVS_Disasm(DisassemblyInfo info) int pc = info.PC + 2; info.Mnemonic = "divs"; - info.Args = String.Format("{0}, D{1}", DisassembleValue(mode, reg, 2, ref pc), dreg); + info.Args = $"{DisassembleValue(mode, reg, 2, ref pc)}, D{dreg}"; info.Length = pc - info.PC; } } diff --git a/BizHawk.Emulation.Cores/CPUs/68000/Instructions/ProgramFlow.cs b/BizHawk.Emulation.Cores/CPUs/68000/Instructions/ProgramFlow.cs index 6d72cf0a6ee..67edcfecdd2 100644 --- a/BizHawk.Emulation.Cores/CPUs/68000/Instructions/ProgramFlow.cs +++ b/BizHawk.Emulation.Cores/CPUs/68000/Instructions/ProgramFlow.cs @@ -94,11 +94,11 @@ void Bcc_Disasm(DisassemblyInfo info) info.Mnemonic = "b" + DisassembleCondition(cond); if (displacement8 != 0) { - info.Args = string.Format("${0:X}", pc + displacement8); + info.Args = $"${pc + displacement8:X}"; } else { - info.Args = string.Format("${0:X}", pc + ReadWord(pc)); + info.Args = $"${pc + ReadWord(pc):X}"; pc += 2; } info.Length = pc - info.PC; @@ -122,10 +122,10 @@ void BRA_Disasm(DisassemblyInfo info) sbyte displacement8 = (sbyte)op; if (displacement8 != 0) - info.Args = String.Format("${0:X}", pc + displacement8); + info.Args = $"${pc + displacement8:X}"; else { - info.Args = String.Format("${0:X}", pc + ReadWord(pc)); + info.Args = $"${pc + ReadWord(pc):X}"; pc += 2; } info.Length = pc - info.PC; @@ -158,10 +158,10 @@ void BSR_Disasm(DisassemblyInfo info) sbyte displacement8 = (sbyte)op; if (displacement8 != 0) - info.Args = String.Format("${0:X}", pc + displacement8); + info.Args = $"${pc + displacement8:X}"; else { - info.Args = String.Format("${0:X}", pc + ReadWord(pc)); + info.Args = $"${pc + ReadWord(pc):X}"; pc += 2; } info.Length = pc - info.PC; @@ -201,7 +201,7 @@ void DBcc_Disasm(DisassemblyInfo info) info.Mnemonic = "db" + DisassembleCondition(cond); int pc = info.PC + 2; - info.Args = String.Format("D{0}, ${1:X}", op & 7, pc + ReadWord(pc)); + info.Args = $"D{op & 7}, ${pc + ReadWord(pc):X}"; info.Length = 4; } @@ -319,7 +319,7 @@ void BTSTi_Disasm(DisassemblyInfo info) int reg = op & 7; info.Mnemonic = "btst"; - info.Args = String.Format("#${0:X}, {1}", bit, DisassembleValue(mode, reg, 1, ref pc)); + info.Args = $"#${bit:X}, {DisassembleValue(mode, reg, 1, ref pc)}"; info.Length = pc - info.PC; } @@ -354,7 +354,7 @@ void BTSTr_Disasm(DisassemblyInfo info) int reg = op & 7; info.Mnemonic = "btst"; - info.Args = String.Format("D{0}, {1}", dReg, DisassembleValue(mode, reg, 1, ref pc)); + info.Args = $"D{dReg}, {DisassembleValue(mode, reg, 1, ref pc)}"; info.Length = pc - info.PC; } @@ -392,7 +392,7 @@ void BCHGi_Disasm(DisassemblyInfo info) int reg = op & 7; info.Mnemonic = "bchg"; - info.Args = String.Format("#${0:X}, {1}", bit, DisassembleValue(mode, reg, 1, ref pc)); + info.Args = $"#${bit:X}, {DisassembleValue(mode, reg, 1, ref pc)}"; info.Length = pc - info.PC; } @@ -431,7 +431,7 @@ void BCHGr_Disasm(DisassemblyInfo info) int reg = op & 7; info.Mnemonic = "bchg"; - info.Args = String.Format("D{0}, {1}", dReg, DisassembleValue(mode, reg, 1, ref pc)); + info.Args = $"D{dReg}, {DisassembleValue(mode, reg, 1, ref pc)}"; info.Length = pc - info.PC; } @@ -469,7 +469,7 @@ void BCLRi_Disasm(DisassemblyInfo info) int reg = op & 7; info.Mnemonic = "bclr"; - info.Args = String.Format("#${0:X}, {1}", bit, DisassembleValue(mode, reg, 1, ref pc)); + info.Args = $"#${bit:X}, {DisassembleValue(mode, reg, 1, ref pc)}"; info.Length = pc - info.PC; } @@ -508,7 +508,7 @@ void BCLRr_Disasm(DisassemblyInfo info) int reg = op & 7; info.Mnemonic = "bclr"; - info.Args = String.Format("D{0}, {1}", dReg, DisassembleValue(mode, reg, 1, ref pc)); + info.Args = $"D{dReg}, {DisassembleValue(mode, reg, 1, ref pc)}"; info.Length = pc - info.PC; } @@ -546,7 +546,7 @@ void BSETi_Disasm(DisassemblyInfo info) int reg = op & 7; info.Mnemonic = "bset"; - info.Args = String.Format("#${0:X}, {1}", bit, DisassembleValue(mode, reg, 1, ref pc)); + info.Args = $"#${bit:X}, {DisassembleValue(mode, reg, 1, ref pc)}"; info.Length = pc - info.PC; } @@ -585,7 +585,7 @@ void BSETr_Disasm(DisassemblyInfo info) int reg = op & 7; info.Mnemonic = "bset"; - info.Args = String.Format("D{0}, {1}", dReg, DisassembleValue(mode, reg, 1, ref pc)); + info.Args = $"D{dReg}, {DisassembleValue(mode, reg, 1, ref pc)}"; info.Length = pc - info.PC; } diff --git a/BizHawk.Emulation.Cores/CPUs/68000/Instructions/Supervisor.cs b/BizHawk.Emulation.Cores/CPUs/68000/Instructions/Supervisor.cs index a23c514dc68..4ef1185b938 100644 --- a/BizHawk.Emulation.Cores/CPUs/68000/Instructions/Supervisor.cs +++ b/BizHawk.Emulation.Cores/CPUs/68000/Instructions/Supervisor.cs @@ -146,7 +146,7 @@ void TRAP() void TRAP_Disasm(DisassemblyInfo info) { info.Mnemonic = "trap"; - info.Args = string.Format("#${0:X}", op & 0xF); + info.Args = $"#${op & 0xF:X}"; } void TrapVector(int vector) diff --git a/BizHawk.Emulation.Cores/CPUs/68000/MC68000.cs b/BizHawk.Emulation.Cores/CPUs/68000/MC68000.cs index b851d86272b..a854aed6128 100644 --- a/BizHawk.Emulation.Cores/CPUs/68000/MC68000.cs +++ b/BizHawk.Emulation.Cores/CPUs/68000/MC68000.cs @@ -152,7 +152,7 @@ public void ExecuteCycles(int cycles) int prevCycles = PendingCycles; //Log.Note("CPU", State()); op = (ushort)ReadWord(PC); - if (Opcodes[op] == null) throw new Exception(string.Format("unhandled opcode at pc={0:X6}", PC)); + if (Opcodes[op] == null) throw new Exception($"unhandled opcode at pc={PC:X6}"); PC += 2; Opcodes[op](); int delta = prevCycles - PendingCycles; @@ -163,7 +163,7 @@ public void ExecuteCycles(int cycles) public string State() { string a = Disassemble(PC).ToString().PadRight(64); - //string a = string.Format("{0:X6}: {1:X4}", PC, ReadWord(PC)).PadRight(64); + //string a = $"{PC:X6}: {ReadWord(PC):X4}".PadRight(64); var dRegStrings = D.Select((r, i) => $"D{i}:{r.u32:X8}"); var aRegStrings = A.Select((r, i) => $"A{i}:{r.u32:X8}"); return a + string.Join(" ", dRegStrings @@ -271,9 +271,6 @@ public struct Register [FieldOffset(0)] public sbyte s8; - public override string ToString() - { - return String.Format("{0:X8}", u32); - } + public override string ToString() => $"{u32:X8}"; } } diff --git a/BizHawk.Emulation.Cores/CPUs/68000/Memory.cs b/BizHawk.Emulation.Cores/CPUs/68000/Memory.cs index b31b42b3994..5b4c228da16 100644 --- a/BizHawk.Emulation.Cores/CPUs/68000/Memory.cs +++ b/BizHawk.Emulation.Cores/CPUs/68000/Memory.cs @@ -329,21 +329,21 @@ string DisassembleValue(int mode, int reg, int size, ref int pc) case 2: return "(A" + reg + ")"; // (An) case 3: return "(A" + reg + ")+"; // (An)+ case 4: return "-(A" + reg + ")"; // -(An) - case 5: value = string.Format("(${0:X},A{1})", ReadWord(pc), reg); pc += 2; return value; // (d16,An) + case 5: value = $"(${ReadWord(pc):X},A{reg})"; pc += 2; return value; // (d16,An) case 6: addr = ReadWord(pc); pc += 2; return DisassembleIndex("A" + reg, (short)addr); // (d8,An,Xn) case 7: switch (reg) { - case 0: value = String.Format("(${0:X})", ReadWord(pc)); pc += 2; return value; // (imm).W - case 1: value = String.Format("(${0:X})", ReadLong(pc)); pc += 4; return value; // (imm).L - case 2: value = String.Format("(${0:X})", pc + ReadWord(pc)); pc += 2; return value; // (d16,PC) + case 0: value = $"(${ReadWord(pc):X})"; pc += 2; return value; // (imm).W + case 1: value = $"(${ReadLong(pc):X})"; pc += 4; return value; // (imm).L + case 2: value = $"(${pc + ReadWord(pc):X})"; pc += 2; return value; // (d16,PC) case 3: addr = ReadWord(pc); pc += 2; return DisassembleIndex("PC", (short)addr); // (d8,PC,Xn) case 4: switch (size) { - case 1: value = String.Format("${0:X}", (byte)ReadWord(pc)); pc += 2; return value; - case 2: value = String.Format("${0:X}", ReadWord(pc)); pc += 2; return value; - case 4: value = String.Format("${0:X}", ReadLong(pc)); pc += 4; return value; + case 1: value = $"${(byte)ReadWord(pc):X}"; pc += 2; return value; + case 2: value = $"${ReadWord(pc):X}"; pc += 2; return value; + case 4: value = $"${ReadLong(pc):X}"; pc += 4; return value; } break; } @@ -359,13 +359,13 @@ string DisassembleImmediate(int size, ref int pc) { case 1: immed = (byte)ReadWord(pc); pc += 2; - return String.Format("#${0:X}", immed); + return $"#${immed:X}"; case 2: immed = (ushort)ReadWord(pc); pc += 2; - return String.Format("#${0:X}", immed); + return $"#${immed:X}"; case 4: immed = ReadLong(pc); pc += 4; - return String.Format("#${0:X}", immed); + return $"#${immed:X}"; } throw new ArgumentException("Invalid size"); } @@ -380,14 +380,14 @@ string DisassembleAddress(int mode, int reg, ref int pc) case 2: return "(A" + reg + ")"; // (An) case 3: return "(A" + reg + ")+"; // (An)+ case 4: return "-(A" + reg + ")"; // -(An) - case 5: addr = ReadWord(pc); pc += 2; return String.Format("(${0:X},A{1})", addr, reg); // (d16,An) + case 5: addr = ReadWord(pc); pc += 2; return $"(${addr:X},A{reg})"; // (d16,An) case 6: addr = ReadWord(pc); pc += 2; return DisassembleIndex("A" + reg, (short)addr); // (d8,An,Xn) case 7: switch (reg) { - case 0: addr = ReadWord(pc); pc += 2; return String.Format("${0:X}.w", addr); // (imm).w - case 1: addr = ReadLong(pc); pc += 4; return String.Format("${0:X}.l", addr); // (imm).l - case 2: addr = ReadWord(pc); pc += 2; return String.Format("(${0:X},PC)", addr); // (d16,PC) + case 0: addr = ReadWord(pc); pc += 2; return $"${addr:X}.w"; // (imm).w + case 1: addr = ReadLong(pc); pc += 4; return $"${addr:X}.l"; // (imm).l + case 2: addr = ReadWord(pc); pc += 2; return $"(${addr:X},PC)"; // (d16,PC) case 3: addr = ReadWord(pc); pc += 2; return DisassembleIndex("PC", (short)addr); // (d8,PC,Xn) case 4: return "INVALID"; // immediate } @@ -620,7 +620,7 @@ string DisassembleIndex(string baseRegister, short extension) string offsetRegister = (d_a == 0) ? "D" : "A"; string sizeStr = size == 0 ? ".w" : ".l"; string displacementStr = displacement == 0 ? "" : ("," + displacement); - return string.Format("({0},{1}{2}{3}{4}{5})", baseRegister, scaleFactor, offsetRegister, reg, sizeStr, displacementStr); + return $"({baseRegister},{scaleFactor}{offsetRegister}{reg}{sizeStr}{displacementStr})"; } } } \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/CPUs/CP1610/CP1610.Disassembler.cs b/BizHawk.Emulation.Cores/CPUs/CP1610/CP1610.Disassembler.cs index d750c777a3b..deadc804ea6 100644 --- a/BizHawk.Emulation.Cores/CPUs/CP1610/CP1610.Disassembler.cs +++ b/BizHawk.Emulation.Cores/CPUs/CP1610/CP1610.Disassembler.cs @@ -52,7 +52,7 @@ public string Disassemble(ushort pc, out int addrToAdvance) { result += " R" + dest + ","; } - result += string.Format(" ${0:X4}", addr); + result += $" ${addr:X4}"; addrToAdvance = 3; return result; case 0x005: @@ -801,10 +801,10 @@ public string Disassemble(ushort pc, out int addrToAdvance) { offset = (ushort)(-offset - 1); } - result += string.Format(" ${0:X4}", offset); + result += $" ${offset:X4}"; if (ext != 0) { - result += string.Format(", ${0:X1}", opcode & 0x8); + result += $", ${opcode & 0x8:X1}"; } } addrToAdvance = 2; @@ -820,7 +820,7 @@ public string Disassemble(ushort pc, out int addrToAdvance) src = (byte)(opcode & 0x7); addr = ReadMemory((ushort)(pc + 1), true); addrToAdvance = 2; - return string.Format("MVO R{0:d}, ${1:X4}", src, addr); + return $"MVO R{src:d}, ${addr:X4}"; case 0x248: case 0x249: case 0x24A: @@ -891,7 +891,7 @@ public string Disassemble(ushort pc, out int addrToAdvance) dest = (byte)(opcode & 0x7); addr = ReadMemory((ushort)(pc + 1), true); addrToAdvance = 2; - return string.Format("MVI R{0:d}, ${1:X4}", dest, addr); + return $"MVI R{dest:d}, ${addr:X4}"; case 0x288: case 0x289: case 0x28A: @@ -962,7 +962,7 @@ public string Disassemble(ushort pc, out int addrToAdvance) dest = (byte)(opcode & 0x7); addr = ReadMemory((ushort)(pc + 1), true); addrToAdvance = 2; - return string.Format("ADD R{0:d}, ${1:X4}", dest, addr); + return $"ADD R{dest:d}, ${addr:X4}"; case 0x2C8: case 0x2C9: case 0x2CA: @@ -1033,7 +1033,7 @@ public string Disassemble(ushort pc, out int addrToAdvance) mem = (byte)(opcode & 0x7); addr = ReadMemory((ushort)(pc + 1), true); addrToAdvance = 2; - return string.Format("SUB R{0:d}, ${1:X4}", mem, addr); + return $"SUB R{mem:d}, ${addr:X4}"; case 0x308: case 0x309: case 0x30A: @@ -1104,7 +1104,7 @@ public string Disassemble(ushort pc, out int addrToAdvance) mem = (byte)(opcode & 0x7); addr = ReadMemory((ushort)(pc + 1), true); addrToAdvance = 2; - return string.Format("CMP R{0:d}, ${1:X4}", mem, addr); + return $"CMP R{mem:d}, ${addr:X4}"; case 0x348: case 0x349: case 0x34A: @@ -1175,7 +1175,7 @@ public string Disassemble(ushort pc, out int addrToAdvance) mem = (byte)(opcode & 0x7); addr = ReadMemory((ushort)(pc + 1), true); addrToAdvance = 2; - return string.Format("AND R{0:d}, ${1:X4}", mem, addr); + return $"AND R{mem:d}, ${addr:X4}"; case 0x388: case 0x389: case 0x38A: @@ -1246,7 +1246,7 @@ public string Disassemble(ushort pc, out int addrToAdvance) mem = (byte)(opcode & 0x7); addr = ReadMemory((ushort)(pc + 1), true); addrToAdvance = 2; - return string.Format("XOR R{0:d}, ${1:X4}", mem, addr); + return $"XOR R{mem:d}, ${addr:X4}"; case 0x3C8: case 0x3C9: case 0x3CA: diff --git a/BizHawk.Emulation.Cores/CPUs/CP1610/CP1610.Execute.cs b/BizHawk.Emulation.Cores/CPUs/CP1610/CP1610.Execute.cs index 6b5180a254f..d35d77ab349 100644 --- a/BizHawk.Emulation.Cores/CPUs/CP1610/CP1610.Execute.cs +++ b/BizHawk.Emulation.Cores/CPUs/CP1610/CP1610.Execute.cs @@ -24,11 +24,7 @@ public TraceInfo CP1610State(bool disassemble = true) return new TraceInfo { - Disassembly = string.Format( - "{0:X4}: {1:X2} {2} ", - RegisterPC-1, - opcode, - disassemble ? Disassemble((ushort)(RegisterPC-1), out notused) : "---").PadRight(26), + Disassembly = $"{RegisterPC - 1:X4}: {opcode:X2} {(disassemble ? Disassemble((ushort)(RegisterPC - 1), out notused) : "---")} ".PadRight(26), RegisterInfo = string.Join(" ", new[] { diff --git a/BizHawk.Emulation.Cores/CPUs/HuC6280/Disassembler.cs b/BizHawk.Emulation.Cores/CPUs/HuC6280/Disassembler.cs index e399c637807..042ba30d515 100644 --- a/BizHawk.Emulation.Cores/CPUs/HuC6280/Disassembler.cs +++ b/BizHawk.Emulation.Cores/CPUs/HuC6280/Disassembler.cs @@ -13,239 +13,239 @@ public string Disassemble(ushort pc, out int bytesToAdvance) switch (op) { case 0x00: bytesToAdvance = 1; return "BRK"; - case 0x01: bytesToAdvance = 2; return string.Format("ORA (${0:X2},X)", ReadMemory(++pc)); + case 0x01: bytesToAdvance = 2; return $"ORA (${ReadMemory(++pc):X2},X)"; case 0x02: bytesToAdvance = 1; return "SXY"; - case 0x03: bytesToAdvance = 2; return string.Format("ST0 #${0:X2}", ReadMemory(++pc)); - case 0x04: bytesToAdvance = 2; return string.Format("TSB ${0:X2}", ReadMemory(++pc)); - case 0x05: bytesToAdvance = 2; return string.Format("ORA ${0:X2}", ReadMemory(++pc)); - case 0x06: bytesToAdvance = 2; return string.Format("ASL ${0:X2}", ReadMemory(++pc)); - case 0x07: bytesToAdvance = 2; return string.Format("RMB0 ${0:X2}", ReadMemory(++pc)); + case 0x03: bytesToAdvance = 2; return $"ST0 #${ReadMemory(++pc):X2}"; + case 0x04: bytesToAdvance = 2; return $"TSB ${ReadMemory(++pc):X2}"; + case 0x05: bytesToAdvance = 2; return $"ORA ${ReadMemory(++pc):X2}"; + case 0x06: bytesToAdvance = 2; return $"ASL ${ReadMemory(++pc):X2}"; + case 0x07: bytesToAdvance = 2; return $"RMB0 ${ReadMemory(++pc):X2}"; case 0x08: bytesToAdvance = 1; return "PHP"; - case 0x09: bytesToAdvance = 2; return string.Format("ORA #${0:X2}", ReadMemory(++pc)); + case 0x09: bytesToAdvance = 2; return $"ORA #${ReadMemory(++pc):X2}"; case 0x0A: bytesToAdvance = 1; return "ASL A"; - case 0x0C: bytesToAdvance = 3; return string.Format("TSB ${0:X4}", ReadWord(++pc)); - case 0x0D: bytesToAdvance = 3; return string.Format("ORA ${0:X4}", ReadWord(++pc)); - case 0x0E: bytesToAdvance = 3; return string.Format("ASL ${0:X4}", ReadWord(++pc)); - case 0x0F: bytesToAdvance = 3; return string.Format("BBR0 ${0:X2},{1}", ReadMemory(++pc), (sbyte)ReadMemory(++pc)); - case 0x10: bytesToAdvance = 2; return string.Format("BPL {0}", (sbyte)ReadMemory(++pc)); - case 0x11: bytesToAdvance = 2; return string.Format("ORA (${0:X2}),Y", ReadMemory(++pc)); - case 0x12: bytesToAdvance = 2; return string.Format("ORA (${0:X2})", ReadMemory(++pc)); - case 0x13: bytesToAdvance = 2; return string.Format("ST1 #${0:X2}", ReadMemory(++pc)); - case 0x14: bytesToAdvance = 2; return string.Format("TRB ${0:X2}", ReadMemory(++pc)); - case 0x15: bytesToAdvance = 2; return string.Format("ORA ${0:X2},X", ReadMemory(++pc)); - case 0x16: bytesToAdvance = 2; return string.Format("ASL ${0:X2},X", ReadMemory(++pc)); - case 0x17: bytesToAdvance = 2; return string.Format("RMB1 ${0:X2}", ReadMemory(++pc)); + case 0x0C: bytesToAdvance = 3; return $"TSB ${ReadWord(++pc):X4}"; + case 0x0D: bytesToAdvance = 3; return $"ORA ${ReadWord(++pc):X4}"; + case 0x0E: bytesToAdvance = 3; return $"ASL ${ReadWord(++pc):X4}"; + case 0x0F: bytesToAdvance = 3; return $"BBR0 ${ReadMemory(++pc):X2},{(sbyte)ReadMemory(++pc)}"; + case 0x10: bytesToAdvance = 2; return $"BPL {(sbyte)ReadMemory(++pc)}"; + case 0x11: bytesToAdvance = 2; return $"ORA (${ReadMemory(++pc):X2}),Y"; + case 0x12: bytesToAdvance = 2; return $"ORA (${ReadMemory(++pc):X2})"; + case 0x13: bytesToAdvance = 2; return $"ST1 #${ReadMemory(++pc):X2}"; + case 0x14: bytesToAdvance = 2; return $"TRB ${ReadMemory(++pc):X2}"; + case 0x15: bytesToAdvance = 2; return $"ORA ${ReadMemory(++pc):X2},X"; + case 0x16: bytesToAdvance = 2; return $"ASL ${ReadMemory(++pc):X2},X"; + case 0x17: bytesToAdvance = 2; return $"RMB1 ${ReadMemory(++pc):X2}"; case 0x18: bytesToAdvance = 1; return "CLC"; - case 0x19: bytesToAdvance = 3; return string.Format("ORA ${0:X4},Y", ReadWord(++pc)); + case 0x19: bytesToAdvance = 3; return $"ORA ${ReadWord(++pc):X4},Y"; case 0x1A: bytesToAdvance = 1; return "INC A"; - case 0x1C: bytesToAdvance = 3; return string.Format("TRB ${0:X4}", ReadWord(++pc)); - case 0x1D: bytesToAdvance = 3; return string.Format("ORA ${0:X4},X", ReadWord(++pc)); - case 0x1E: bytesToAdvance = 3; return string.Format("ASL ${0:X4},X", ReadWord(++pc)); - case 0x1F: bytesToAdvance = 3; return string.Format("BBR1 ${0:X2},{1}", ReadMemory(++pc), (sbyte)ReadMemory(++pc)); - case 0x20: bytesToAdvance = 3; return string.Format("JSR ${0:X4}", ReadWord(++pc)); - case 0x21: bytesToAdvance = 2; return string.Format("AND (${0:X2},X)", ReadMemory(++pc)); + case 0x1C: bytesToAdvance = 3; return $"TRB ${ReadWord(++pc):X4}"; + case 0x1D: bytesToAdvance = 3; return $"ORA ${ReadWord(++pc):X4},X"; + case 0x1E: bytesToAdvance = 3; return $"ASL ${ReadWord(++pc):X4},X"; + case 0x1F: bytesToAdvance = 3; return $"BBR1 ${ReadMemory(++pc):X2},{(sbyte)ReadMemory(++pc)}"; + case 0x20: bytesToAdvance = 3; return $"JSR ${ReadWord(++pc):X4}"; + case 0x21: bytesToAdvance = 2; return $"AND (${ReadMemory(++pc):X2},X)"; case 0x22: bytesToAdvance = 1; return "SAX"; - case 0x23: bytesToAdvance = 2; return string.Format("ST2 #${0:X2}", ReadMemory(++pc)); - case 0x24: bytesToAdvance = 2; return string.Format("BIT ${0:X2}", ReadMemory(++pc)); - case 0x25: bytesToAdvance = 2; return string.Format("AND ${0:X2}", ReadMemory(++pc)); - case 0x26: bytesToAdvance = 2; return string.Format("ROL ${0:X2}", ReadMemory(++pc)); - case 0x27: bytesToAdvance = 2; return string.Format("RMB2 ${0:X2}", ReadMemory(++pc)); + case 0x23: bytesToAdvance = 2; return $"ST2 #${ReadMemory(++pc):X2}"; + case 0x24: bytesToAdvance = 2; return $"BIT ${ReadMemory(++pc):X2}"; + case 0x25: bytesToAdvance = 2; return $"AND ${ReadMemory(++pc):X2}"; + case 0x26: bytesToAdvance = 2; return $"ROL ${ReadMemory(++pc):X2}"; + case 0x27: bytesToAdvance = 2; return $"RMB2 ${ReadMemory(++pc):X2}"; case 0x28: bytesToAdvance = 1; return "PLP"; - case 0x29: bytesToAdvance = 2; return string.Format("AND #${0:X2}", ReadMemory(++pc)); + case 0x29: bytesToAdvance = 2; return $"AND #${ReadMemory(++pc):X2}"; case 0x2A: bytesToAdvance = 1; return "ROL A"; - case 0x2C: bytesToAdvance = 3; return string.Format("BIT ${0:X4}", ReadWord(++pc)); - case 0x2D: bytesToAdvance = 3; return string.Format("AND ${0:X4}", ReadWord(++pc)); - case 0x2E: bytesToAdvance = 3; return string.Format("ROL ${0:X4}", ReadWord(++pc)); - case 0x2F: bytesToAdvance = 3; return string.Format("BBR2 ${0:X2},{1}", ReadMemory(++pc), (sbyte)ReadMemory(++pc)); - case 0x30: bytesToAdvance = 2; return string.Format("BMI {0}", (sbyte)ReadMemory(++pc)); - case 0x31: bytesToAdvance = 2; return string.Format("AND (${0:X2}),Y", ReadMemory(++pc)); - case 0x32: bytesToAdvance = 2; return string.Format("AND (${0:X2})", ReadMemory(++pc)); - case 0x34: bytesToAdvance = 2; return string.Format("BIT ${0:X2},X", ReadMemory(++pc)); - case 0x35: bytesToAdvance = 2; return string.Format("AND ${0:X2},X", ReadMemory(++pc)); - case 0x36: bytesToAdvance = 2; return string.Format("ROL ${0:X2},X", ReadMemory(++pc)); - case 0x37: bytesToAdvance = 2; return string.Format("RMB3 ${0:X2}", ReadMemory(++pc)); + case 0x2C: bytesToAdvance = 3; return $"BIT ${ReadWord(++pc):X4}"; + case 0x2D: bytesToAdvance = 3; return $"AND ${ReadWord(++pc):X4}"; + case 0x2E: bytesToAdvance = 3; return $"ROL ${ReadWord(++pc):X4}"; + case 0x2F: bytesToAdvance = 3; return $"BBR2 ${ReadMemory(++pc):X2},{(sbyte)ReadMemory(++pc)}"; + case 0x30: bytesToAdvance = 2; return $"BMI {(sbyte)ReadMemory(++pc)}"; + case 0x31: bytesToAdvance = 2; return $"AND (${ReadMemory(++pc):X2}),Y"; + case 0x32: bytesToAdvance = 2; return $"AND (${ReadMemory(++pc):X2})"; + case 0x34: bytesToAdvance = 2; return $"BIT ${ReadMemory(++pc):X2},X"; + case 0x35: bytesToAdvance = 2; return $"AND ${ReadMemory(++pc):X2},X"; + case 0x36: bytesToAdvance = 2; return $"ROL ${ReadMemory(++pc):X2},X"; + case 0x37: bytesToAdvance = 2; return $"RMB3 ${ReadMemory(++pc):X2}"; case 0x38: bytesToAdvance = 1; return "SEC"; - case 0x39: bytesToAdvance = 3; return string.Format("AND ${0:X4},Y", ReadWord(++pc)); + case 0x39: bytesToAdvance = 3; return $"AND ${ReadWord(++pc):X4},Y"; case 0x3A: bytesToAdvance = 1; return "DEC A"; - case 0x3C: bytesToAdvance = 3; return string.Format("BIT ${0:X4},X", ReadWord(++pc)); - case 0x3D: bytesToAdvance = 3; return string.Format("AND ${0:X4},X", ReadWord(++pc)); - case 0x3E: bytesToAdvance = 3; return string.Format("ROL ${0:X4},X", ReadWord(++pc)); - case 0x3F: bytesToAdvance = 3; return string.Format("BBR3 ${0:X2},{1}", ReadMemory(++pc), (sbyte)ReadMemory(++pc)); + case 0x3C: bytesToAdvance = 3; return $"BIT ${ReadWord(++pc):X4},X"; + case 0x3D: bytesToAdvance = 3; return $"AND ${ReadWord(++pc):X4},X"; + case 0x3E: bytesToAdvance = 3; return $"ROL ${ReadWord(++pc):X4},X"; + case 0x3F: bytesToAdvance = 3; return $"BBR3 ${ReadMemory(++pc):X2},{(sbyte)ReadMemory(++pc)}"; case 0x40: bytesToAdvance = 1; return "RTI"; - case 0x41: bytesToAdvance = 2; return string.Format("EOR (${0:X2},X)", ReadMemory(++pc)); + case 0x41: bytesToAdvance = 2; return $"EOR (${ReadMemory(++pc):X2},X)"; case 0x42: bytesToAdvance = 1; return "SAY"; - case 0x43: bytesToAdvance = 2; return string.Format("TMA #${0:X2}", ReadMemory(++pc)); - case 0x44: bytesToAdvance = 2; return string.Format("BSR {0}", (sbyte)ReadMemory(++pc)); - case 0x45: bytesToAdvance = 2; return string.Format("EOR ${0:X2}", ReadMemory(++pc)); - case 0x46: bytesToAdvance = 2; return string.Format("LSR ${0:X2}", ReadMemory(++pc)); - case 0x47: bytesToAdvance = 2; return string.Format("RMB4 ${0:X2}", ReadMemory(++pc)); + case 0x43: bytesToAdvance = 2; return $"TMA #${ReadMemory(++pc):X2}"; + case 0x44: bytesToAdvance = 2; return $"BSR {(sbyte)ReadMemory(++pc)}"; + case 0x45: bytesToAdvance = 2; return $"EOR ${ReadMemory(++pc):X2}"; + case 0x46: bytesToAdvance = 2; return $"LSR ${ReadMemory(++pc):X2}"; + case 0x47: bytesToAdvance = 2; return $"RMB4 ${ReadMemory(++pc):X2}"; case 0x48: bytesToAdvance = 1; return "PHA"; - case 0x49: bytesToAdvance = 2; return string.Format("EOR #${0:X2}", ReadMemory(++pc)); + case 0x49: bytesToAdvance = 2; return $"EOR #${ReadMemory(++pc):X2}"; case 0x4A: bytesToAdvance = 1; return "LSR A"; - case 0x4C: bytesToAdvance = 3; return string.Format("JMP ${0:X4}", ReadWord(++pc)); - case 0x4D: bytesToAdvance = 3; return string.Format("EOR ${0:X4}", ReadWord(++pc)); - case 0x4E: bytesToAdvance = 3; return string.Format("LSR ${0:X4}", ReadWord(++pc)); - case 0x4F: bytesToAdvance = 3; return string.Format("BBR4 ${0:X2},{1}", ReadMemory(++pc), (sbyte)ReadMemory(++pc)); - case 0x50: bytesToAdvance = 2; return string.Format("BVC {0}", (sbyte)ReadMemory(++pc)); - case 0x51: bytesToAdvance = 2; return string.Format("EOR (${0:X2}),Y", ReadMemory(++pc)); - case 0x52: bytesToAdvance = 2; return string.Format("EOR (${0:X2})", ReadMemory(++pc)); - case 0x53: bytesToAdvance = 2; return string.Format("TAM #${0:X2}", ReadMemory(++pc)); + case 0x4C: bytesToAdvance = 3; return $"JMP ${ReadWord(++pc):X4}"; + case 0x4D: bytesToAdvance = 3; return $"EOR ${ReadWord(++pc):X4}"; + case 0x4E: bytesToAdvance = 3; return $"LSR ${ReadWord(++pc):X4}"; + case 0x4F: bytesToAdvance = 3; return $"BBR4 ${ReadMemory(++pc):X2},{(sbyte)ReadMemory(++pc)}"; + case 0x50: bytesToAdvance = 2; return $"BVC {(sbyte)ReadMemory(++pc)}"; + case 0x51: bytesToAdvance = 2; return $"EOR (${ReadMemory(++pc):X2}),Y"; + case 0x52: bytesToAdvance = 2; return $"EOR (${ReadMemory(++pc):X2})"; + case 0x53: bytesToAdvance = 2; return $"TAM #${ReadMemory(++pc):X2}"; case 0x54: bytesToAdvance = 1; return "CSL"; - case 0x55: bytesToAdvance = 2; return string.Format("EOR ${0:X2},X", ReadMemory(++pc)); - case 0x56: bytesToAdvance = 2; return string.Format("LSR ${0:X2},X", ReadMemory(++pc)); - case 0x57: bytesToAdvance = 2; return string.Format("RMB5 ${0:X2}", ReadMemory(++pc)); + case 0x55: bytesToAdvance = 2; return $"EOR ${ReadMemory(++pc):X2},X"; + case 0x56: bytesToAdvance = 2; return $"LSR ${ReadMemory(++pc):X2},X"; + case 0x57: bytesToAdvance = 2; return $"RMB5 ${ReadMemory(++pc):X2}"; case 0x58: bytesToAdvance = 1; return "CLI"; - case 0x59: bytesToAdvance = 3; return string.Format("EOR ${0:X4},Y", ReadWord(++pc)); + case 0x59: bytesToAdvance = 3; return $"EOR ${ReadWord(++pc):X4},Y"; case 0x5A: bytesToAdvance = 1; return "PHY"; - case 0x5D: bytesToAdvance = 3; return string.Format("EOR ${0:X4},X", ReadWord(++pc)); - case 0x5E: bytesToAdvance = 3; return string.Format("LSR ${0:X4},X", ReadWord(++pc)); - case 0x5F: bytesToAdvance = 3; return string.Format("BBR5 ${0:X2},{1}", ReadMemory(++pc), (sbyte)ReadMemory(++pc)); + case 0x5D: bytesToAdvance = 3; return $"EOR ${ReadWord(++pc):X4},X"; + case 0x5E: bytesToAdvance = 3; return $"LSR ${ReadWord(++pc):X4},X"; + case 0x5F: bytesToAdvance = 3; return $"BBR5 ${ReadMemory(++pc):X2},{(sbyte)ReadMemory(++pc)}"; case 0x60: bytesToAdvance = 1; return "RTS"; - case 0x61: bytesToAdvance = 2; return string.Format("ADC (${0:X2},X)", ReadMemory(++pc)); + case 0x61: bytesToAdvance = 2; return $"ADC (${ReadMemory(++pc):X2},X)"; case 0x62: bytesToAdvance = 1; return "CLA"; - case 0x64: bytesToAdvance = 2; return string.Format("STZ ${0:X2}", ReadMemory(++pc)); - case 0x65: bytesToAdvance = 2; return string.Format("ADC ${0:X2}", ReadMemory(++pc)); - case 0x66: bytesToAdvance = 2; return string.Format("ROR ${0:X2}", ReadMemory(++pc)); - case 0x67: bytesToAdvance = 2; return string.Format("RMB6 ${0:X2}", ReadMemory(++pc)); + case 0x64: bytesToAdvance = 2; return $"STZ ${ReadMemory(++pc):X2}"; + case 0x65: bytesToAdvance = 2; return $"ADC ${ReadMemory(++pc):X2}"; + case 0x66: bytesToAdvance = 2; return $"ROR ${ReadMemory(++pc):X2}"; + case 0x67: bytesToAdvance = 2; return $"RMB6 ${ReadMemory(++pc):X2}"; case 0x68: bytesToAdvance = 1; return "PLA"; - case 0x69: bytesToAdvance = 2; return string.Format("ADC #${0:X2}", ReadMemory(++pc)); + case 0x69: bytesToAdvance = 2; return $"ADC #${ReadMemory(++pc):X2}"; case 0x6A: bytesToAdvance = 1; return "ROR A"; - case 0x6C: bytesToAdvance = 3; return string.Format("JMP (${0:X4})", ReadWord(++pc)); - case 0x6D: bytesToAdvance = 3; return string.Format("ADC ${0:X4}", ReadWord(++pc)); - case 0x6E: bytesToAdvance = 3; return string.Format("ROR ${0:X4}", ReadWord(++pc)); - case 0x6F: bytesToAdvance = 3; return string.Format("BBR6 ${0:X2},{1}", ReadMemory(++pc), (sbyte)ReadMemory(++pc)); - case 0x70: bytesToAdvance = 2; return string.Format("BVS {0}", (sbyte)ReadMemory(++pc)); - case 0x71: bytesToAdvance = 2; return string.Format("ADC (${0:X2}),Y", ReadMemory(++pc)); - case 0x72: bytesToAdvance = 2; return string.Format("ADC (${0:X2})", ReadMemory(++pc)); - case 0x73: bytesToAdvance = 7; return string.Format("TII {0:X4},{1:X4},{2:X4}", ReadWord((ushort)(pc+1)),ReadWord((ushort)(pc+3)),ReadWord((ushort)(pc+5))); - case 0x74: bytesToAdvance = 2; return string.Format("STZ ${0:X2},X", ReadMemory(++pc)); - case 0x75: bytesToAdvance = 2; return string.Format("ADC ${0:X2},X", ReadMemory(++pc)); - case 0x76: bytesToAdvance = 2; return string.Format("ROR ${0:X2},X", ReadMemory(++pc)); - case 0x77: bytesToAdvance = 2; return string.Format("RMB7 ${0:X2}", ReadMemory(++pc)); + case 0x6C: bytesToAdvance = 3; return $"JMP (${ReadWord(++pc):X4})"; + case 0x6D: bytesToAdvance = 3; return $"ADC ${ReadWord(++pc):X4}"; + case 0x6E: bytesToAdvance = 3; return $"ROR ${ReadWord(++pc):X4}"; + case 0x6F: bytesToAdvance = 3; return $"BBR6 ${ReadMemory(++pc):X2},{(sbyte)ReadMemory(++pc)}"; + case 0x70: bytesToAdvance = 2; return $"BVS {(sbyte)ReadMemory(++pc)}"; + case 0x71: bytesToAdvance = 2; return $"ADC (${ReadMemory(++pc):X2}),Y"; + case 0x72: bytesToAdvance = 2; return $"ADC (${ReadMemory(++pc):X2})"; + case 0x73: bytesToAdvance = 7; return $"TII {ReadWord((ushort)(pc + 1)):X4},{ReadWord((ushort)(pc + 3)):X4},{ReadWord((ushort)(pc + 5)):X4}"; + case 0x74: bytesToAdvance = 2; return $"STZ ${ReadMemory(++pc):X2},X"; + case 0x75: bytesToAdvance = 2; return $"ADC ${ReadMemory(++pc):X2},X"; + case 0x76: bytesToAdvance = 2; return $"ROR ${ReadMemory(++pc):X2},X"; + case 0x77: bytesToAdvance = 2; return $"RMB7 ${ReadMemory(++pc):X2}"; case 0x78: bytesToAdvance = 1; return "SEI"; - case 0x79: bytesToAdvance = 3; return string.Format("ADC ${0:X4},Y", ReadWord(++pc)); + case 0x79: bytesToAdvance = 3; return $"ADC ${ReadWord(++pc):X4},Y"; case 0x7A: bytesToAdvance = 1; return "PLY"; - case 0x7C: bytesToAdvance = 3; return string.Format("JMP (${0:X4},X)", ReadWord(++pc)); - case 0x7D: bytesToAdvance = 3; return string.Format("ADC ${0:X4},X", ReadWord(++pc)); - case 0x7E: bytesToAdvance = 3; return string.Format("ROR ${0:X4},X", ReadWord(++pc)); - case 0x7F: bytesToAdvance = 3; return string.Format("BBR7 ${0:X2},{1}", ReadMemory(++pc), (sbyte)ReadMemory(++pc)); - case 0x80: bytesToAdvance = 2; return string.Format("BRA {0}", (sbyte)ReadMemory(++pc)); - case 0x81: bytesToAdvance = 2; return string.Format("STA (${0:X2},X)", ReadMemory(++pc)); + case 0x7C: bytesToAdvance = 3; return $"JMP (${ReadWord(++pc):X4},X)"; + case 0x7D: bytesToAdvance = 3; return $"ADC ${ReadWord(++pc):X4},X"; + case 0x7E: bytesToAdvance = 3; return $"ROR ${ReadWord(++pc):X4},X"; + case 0x7F: bytesToAdvance = 3; return $"BBR7 ${ReadMemory(++pc):X2},{(sbyte)ReadMemory(++pc)}"; + case 0x80: bytesToAdvance = 2; return $"BRA {(sbyte)ReadMemory(++pc)}"; + case 0x81: bytesToAdvance = 2; return $"STA (${ReadMemory(++pc):X2},X)"; case 0x82: bytesToAdvance = 1; return "CLX"; - case 0x83: bytesToAdvance = 3; return string.Format("TST #${0:X2}, ${1:X2}", ReadMemory(++pc), ReadMemory(++pc)); - case 0x84: bytesToAdvance = 2; return string.Format("STY ${0:X2}", ReadMemory(++pc)); - case 0x85: bytesToAdvance = 2; return string.Format("STA ${0:X2}", ReadMemory(++pc)); - case 0x86: bytesToAdvance = 2; return string.Format("STX ${0:X2}", ReadMemory(++pc)); - case 0x87: bytesToAdvance = 2; return string.Format("SMB0 ${0:X2}", ReadMemory(++pc)); + case 0x83: bytesToAdvance = 3; return $"TST #${ReadMemory(++pc):X2}, ${ReadMemory(++pc):X2}"; + case 0x84: bytesToAdvance = 2; return $"STY ${ReadMemory(++pc):X2}"; + case 0x85: bytesToAdvance = 2; return $"STA ${ReadMemory(++pc):X2}"; + case 0x86: bytesToAdvance = 2; return $"STX ${ReadMemory(++pc):X2}"; + case 0x87: bytesToAdvance = 2; return $"SMB0 ${ReadMemory(++pc):X2}"; case 0x88: bytesToAdvance = 1; return "DEY"; - case 0x89: bytesToAdvance = 2; return string.Format("BIT #${0:X2}", ReadMemory(++pc)); + case 0x89: bytesToAdvance = 2; return $"BIT #${ReadMemory(++pc):X2}"; case 0x8A: bytesToAdvance = 1; return "TXA"; - case 0x8C: bytesToAdvance = 3; return string.Format("STY ${0:X4}", ReadWord(++pc)); - case 0x8D: bytesToAdvance = 3; return string.Format("STA ${0:X4}", ReadWord(++pc)); - case 0x8E: bytesToAdvance = 3; return string.Format("STX ${0:X4}", ReadWord(++pc)); - case 0x8F: bytesToAdvance = 3; return string.Format("BBS0 ${0:X2},{1}", ReadMemory(++pc), (sbyte)ReadMemory(++pc)); - case 0x90: bytesToAdvance = 2; return string.Format("BCC {0}", (sbyte)ReadMemory(++pc)); - case 0x91: bytesToAdvance = 2; return string.Format("STA (${0:X2}),Y", ReadMemory(++pc)); - case 0x92: bytesToAdvance = 2; return string.Format("STA (${0:X2})", ReadMemory(++pc)); - case 0x93: bytesToAdvance = 4; return string.Format("TST #${0:X2}, ${1:X4}", ReadMemory(++pc), ReadWord(++pc)); - case 0x94: bytesToAdvance = 2; return string.Format("STY ${0:X2},X", ReadMemory(++pc)); - case 0x95: bytesToAdvance = 2; return string.Format("STA ${0:X2},X", ReadMemory(++pc)); - case 0x96: bytesToAdvance = 2; return string.Format("STX ${0:X2},Y", ReadMemory(++pc)); - case 0x97: bytesToAdvance = 2; return string.Format("SMB1 ${0:X2}", ReadMemory(++pc)); + case 0x8C: bytesToAdvance = 3; return $"STY ${ReadWord(++pc):X4}"; + case 0x8D: bytesToAdvance = 3; return $"STA ${ReadWord(++pc):X4}"; + case 0x8E: bytesToAdvance = 3; return $"STX ${ReadWord(++pc):X4}"; + case 0x8F: bytesToAdvance = 3; return $"BBS0 ${ReadMemory(++pc):X2},{(sbyte)ReadMemory(++pc)}"; + case 0x90: bytesToAdvance = 2; return $"BCC {(sbyte)ReadMemory(++pc)}"; + case 0x91: bytesToAdvance = 2; return $"STA (${ReadMemory(++pc):X2}),Y"; + case 0x92: bytesToAdvance = 2; return $"STA (${ReadMemory(++pc):X2})"; + case 0x93: bytesToAdvance = 4; return $"TST #${ReadMemory(++pc):X2}, ${ReadWord(++pc):X4}"; + case 0x94: bytesToAdvance = 2; return $"STY ${ReadMemory(++pc):X2},X"; + case 0x95: bytesToAdvance = 2; return $"STA ${ReadMemory(++pc):X2},X"; + case 0x96: bytesToAdvance = 2; return $"STX ${ReadMemory(++pc):X2},Y"; + case 0x97: bytesToAdvance = 2; return $"SMB1 ${ReadMemory(++pc):X2}"; case 0x98: bytesToAdvance = 1; return "TYA"; - case 0x99: bytesToAdvance = 3; return string.Format("STA ${0:X4},Y", ReadWord(++pc)); + case 0x99: bytesToAdvance = 3; return $"STA ${ReadWord(++pc):X4},Y"; case 0x9A: bytesToAdvance = 1; return "TXS"; - case 0x9C: bytesToAdvance = 3; return string.Format("STZ ${0:X4}", ReadWord(++pc)); - case 0x9D: bytesToAdvance = 3; return string.Format("STA ${0:X4},X", ReadWord(++pc)); - case 0x9E: bytesToAdvance = 3; return string.Format("STZ ${0:X4},X", ReadWord(++pc)); - case 0x9F: bytesToAdvance = 3; return string.Format("BBS1 ${0:X2},{1}", ReadMemory(++pc), (sbyte)ReadMemory(++pc)); - case 0xA0: bytesToAdvance = 2; return string.Format("LDY #${0:X2}", ReadMemory(++pc)); - case 0xA1: bytesToAdvance = 2; return string.Format("LDA (${0:X2},X)", ReadMemory(++pc)); - case 0xA2: bytesToAdvance = 2; return string.Format("LDX #${0:X2}", ReadMemory(++pc)); - case 0xA3: bytesToAdvance = 3; return string.Format("TST #${0:X2}, ${1:X2},X", ReadMemory(++pc), ReadMemory(++pc)); - case 0xA4: bytesToAdvance = 2; return string.Format("LDY ${0:X2}", ReadMemory(++pc)); - case 0xA5: bytesToAdvance = 2; return string.Format("LDA ${0:X2}", ReadMemory(++pc)); - case 0xA6: bytesToAdvance = 2; return string.Format("LDX ${0:X2}", ReadMemory(++pc)); - case 0xA7: bytesToAdvance = 2; return string.Format("SMB2 ${0:X2}", ReadMemory(++pc)); + case 0x9C: bytesToAdvance = 3; return $"STZ ${ReadWord(++pc):X4}"; + case 0x9D: bytesToAdvance = 3; return $"STA ${ReadWord(++pc):X4},X"; + case 0x9E: bytesToAdvance = 3; return $"STZ ${ReadWord(++pc):X4},X"; + case 0x9F: bytesToAdvance = 3; return $"BBS1 ${ReadMemory(++pc):X2},{(sbyte)ReadMemory(++pc)}"; + case 0xA0: bytesToAdvance = 2; return $"LDY #${ReadMemory(++pc):X2}"; + case 0xA1: bytesToAdvance = 2; return $"LDA (${ReadMemory(++pc):X2},X)"; + case 0xA2: bytesToAdvance = 2; return $"LDX #${ReadMemory(++pc):X2}"; + case 0xA3: bytesToAdvance = 3; return $"TST #${ReadMemory(++pc):X2}, ${ReadMemory(++pc):X2},X"; + case 0xA4: bytesToAdvance = 2; return $"LDY ${ReadMemory(++pc):X2}"; + case 0xA5: bytesToAdvance = 2; return $"LDA ${ReadMemory(++pc):X2}"; + case 0xA6: bytesToAdvance = 2; return $"LDX ${ReadMemory(++pc):X2}"; + case 0xA7: bytesToAdvance = 2; return $"SMB2 ${ReadMemory(++pc):X2}"; case 0xA8: bytesToAdvance = 1; return "TAY"; - case 0xA9: bytesToAdvance = 2; return string.Format("LDA #${0:X2}", ReadMemory(++pc)); + case 0xA9: bytesToAdvance = 2; return $"LDA #${ReadMemory(++pc):X2}"; case 0xAA: bytesToAdvance = 1; return "TAX"; - case 0xAC: bytesToAdvance = 3; return string.Format("LDY ${0:X4}", ReadWord(++pc)); - case 0xAD: bytesToAdvance = 3; return string.Format("LDA ${0:X4}", ReadWord(++pc)); - case 0xAE: bytesToAdvance = 3; return string.Format("LDX ${0:X4}", ReadWord(++pc)); - case 0xAF: bytesToAdvance = 3; return string.Format("BBS2 ${0:X2},{1}", ReadMemory(++pc), (sbyte)ReadMemory(++pc)); - case 0xB0: bytesToAdvance = 2; return string.Format("BCS {0}", (sbyte)ReadMemory(++pc)); - case 0xB1: bytesToAdvance = 2; return string.Format("LDA (${0:X2}),Y", ReadMemory(++pc)); - case 0xB2: bytesToAdvance = 2; return string.Format("LDA (${0:X2})", ReadMemory(++pc)); - case 0xB3: bytesToAdvance = 4; return string.Format("TST #${0:X2}, ${1:X4},X", ReadMemory(++pc), ReadWord(++pc)); - case 0xB4: bytesToAdvance = 2; return string.Format("LDY ${0:X2},X", ReadMemory(++pc)); - case 0xB5: bytesToAdvance = 2; return string.Format("LDA ${0:X2},X", ReadMemory(++pc)); - case 0xB6: bytesToAdvance = 2; return string.Format("LDX ${0:X2},Y", ReadMemory(++pc)); - case 0xB7: bytesToAdvance = 2; return string.Format("SMB3 ${0:X2}", ReadMemory(++pc)); + case 0xAC: bytesToAdvance = 3; return $"LDY ${ReadWord(++pc):X4}"; + case 0xAD: bytesToAdvance = 3; return $"LDA ${ReadWord(++pc):X4}"; + case 0xAE: bytesToAdvance = 3; return $"LDX ${ReadWord(++pc):X4}"; + case 0xAF: bytesToAdvance = 3; return $"BBS2 ${ReadMemory(++pc):X2},{(sbyte)ReadMemory(++pc)}"; + case 0xB0: bytesToAdvance = 2; return $"BCS {(sbyte)ReadMemory(++pc)}"; + case 0xB1: bytesToAdvance = 2; return $"LDA (${ReadMemory(++pc):X2}),Y"; + case 0xB2: bytesToAdvance = 2; return $"LDA (${ReadMemory(++pc):X2})"; + case 0xB3: bytesToAdvance = 4; return $"TST #${ReadMemory(++pc):X2}, ${ReadWord(++pc):X4},X"; + case 0xB4: bytesToAdvance = 2; return $"LDY ${ReadMemory(++pc):X2},X"; + case 0xB5: bytesToAdvance = 2; return $"LDA ${ReadMemory(++pc):X2},X"; + case 0xB6: bytesToAdvance = 2; return $"LDX ${ReadMemory(++pc):X2},Y"; + case 0xB7: bytesToAdvance = 2; return $"SMB3 ${ReadMemory(++pc):X2}"; case 0xB8: bytesToAdvance = 1; return "CLV"; - case 0xB9: bytesToAdvance = 3; return string.Format("LDA ${0:X4},Y", ReadWord(++pc)); + case 0xB9: bytesToAdvance = 3; return $"LDA ${ReadWord(++pc):X4},Y"; case 0xBA: bytesToAdvance = 1; return "TSX"; - case 0xBC: bytesToAdvance = 3; return string.Format("LDY ${0:X4},X", ReadWord(++pc)); - case 0xBD: bytesToAdvance = 3; return string.Format("LDA ${0:X4},X", ReadWord(++pc)); - case 0xBE: bytesToAdvance = 3; return string.Format("LDX ${0:X4},Y", ReadWord(++pc)); - case 0xBF: bytesToAdvance = 3; return string.Format("BBS3 ${0:X2},{1}", ReadMemory(++pc), (sbyte)ReadMemory(++pc)); - case 0xC0: bytesToAdvance = 2; return string.Format("CPY #${0:X2}", ReadMemory(++pc)); - case 0xC1: bytesToAdvance = 2; return string.Format("CMP (${0:X2},X)", ReadMemory(++pc)); + case 0xBC: bytesToAdvance = 3; return $"LDY ${ReadWord(++pc):X4},X"; + case 0xBD: bytesToAdvance = 3; return $"LDA ${ReadWord(++pc):X4},X"; + case 0xBE: bytesToAdvance = 3; return $"LDX ${ReadWord(++pc):X4},Y"; + case 0xBF: bytesToAdvance = 3; return $"BBS3 ${ReadMemory(++pc):X2},{(sbyte)ReadMemory(++pc)}"; + case 0xC0: bytesToAdvance = 2; return $"CPY #${ReadMemory(++pc):X2}"; + case 0xC1: bytesToAdvance = 2; return $"CMP (${ReadMemory(++pc):X2},X)"; case 0xC2: bytesToAdvance = 1; return "CLY"; - case 0xC3: bytesToAdvance = 7; return string.Format("TDD {0:X4},{1:X4},{2:X4}", ReadWord((ushort)(pc+1)),ReadWord((ushort)(pc+3)),ReadWord((ushort)(pc+5))); - case 0xC4: bytesToAdvance = 2; return string.Format("CPY ${0:X2}", ReadMemory(++pc)); - case 0xC5: bytesToAdvance = 2; return string.Format("CMP ${0:X2}", ReadMemory(++pc)); - case 0xC6: bytesToAdvance = 2; return string.Format("DEC ${0:X2}", ReadMemory(++pc)); - case 0xC7: bytesToAdvance = 2; return string.Format("SMB4 ${0:X2}", ReadMemory(++pc)); + case 0xC3: bytesToAdvance = 7; return $"TDD {ReadWord((ushort)(pc + 1)):X4},{ReadWord((ushort)(pc + 3)):X4},{ReadWord((ushort)(pc + 5)):X4}"; + case 0xC4: bytesToAdvance = 2; return $"CPY ${ReadMemory(++pc):X2}"; + case 0xC5: bytesToAdvance = 2; return $"CMP ${ReadMemory(++pc):X2}"; + case 0xC6: bytesToAdvance = 2; return $"DEC ${ReadMemory(++pc):X2}"; + case 0xC7: bytesToAdvance = 2; return $"SMB4 ${ReadMemory(++pc):X2}"; case 0xC8: bytesToAdvance = 1; return "INY"; - case 0xC9: bytesToAdvance = 2; return string.Format("CMP #${0:X2}", ReadMemory(++pc)); + case 0xC9: bytesToAdvance = 2; return $"CMP #${ReadMemory(++pc):X2}"; case 0xCA: bytesToAdvance = 1; return "DEX"; - case 0xCC: bytesToAdvance = 3; return string.Format("CPY ${0:X4}", ReadWord(++pc)); - case 0xCD: bytesToAdvance = 3; return string.Format("CMP ${0:X4}", ReadWord(++pc)); - case 0xCE: bytesToAdvance = 3; return string.Format("DEC ${0:X4}", ReadWord(++pc)); - case 0xCF: bytesToAdvance = 3; return string.Format("BBS4 ${0:X2},{1}", ReadMemory(++pc), (sbyte)ReadMemory(++pc)); - case 0xD0: bytesToAdvance = 2; return string.Format("BNE {0}", (sbyte)ReadMemory(++pc)); - case 0xD1: bytesToAdvance = 2; return string.Format("CMP (${0:X2}),Y", ReadMemory(++pc)); - case 0xD2: bytesToAdvance = 2; return string.Format("CMP (${0:X2})", ReadMemory(++pc)); - case 0xD3: bytesToAdvance = 7; return string.Format("TIN {0:X4},{1:X4},{2:X4}", ReadWord((ushort)(pc+1)),ReadWord((ushort)(pc+3)),ReadWord((ushort)(pc+5))); + case 0xCC: bytesToAdvance = 3; return $"CPY ${ReadWord(++pc):X4}"; + case 0xCD: bytesToAdvance = 3; return $"CMP ${ReadWord(++pc):X4}"; + case 0xCE: bytesToAdvance = 3; return $"DEC ${ReadWord(++pc):X4}"; + case 0xCF: bytesToAdvance = 3; return $"BBS4 ${ReadMemory(++pc):X2},{(sbyte)ReadMemory(++pc)}"; + case 0xD0: bytesToAdvance = 2; return $"BNE {(sbyte)ReadMemory(++pc)}"; + case 0xD1: bytesToAdvance = 2; return $"CMP (${ReadMemory(++pc):X2}),Y"; + case 0xD2: bytesToAdvance = 2; return $"CMP (${ReadMemory(++pc):X2})"; + case 0xD3: bytesToAdvance = 7; return $"TIN {ReadWord((ushort)(pc + 1)):X4},{ReadWord((ushort)(pc + 3)):X4},{ReadWord((ushort)(pc + 5)):X4}"; case 0xD4: bytesToAdvance = 1; return "CSH"; - case 0xD5: bytesToAdvance = 2; return string.Format("CMP ${0:X2},X", ReadMemory(++pc)); - case 0xD6: bytesToAdvance = 2; return string.Format("DEC ${0:X2},X", ReadMemory(++pc)); - case 0xD7: bytesToAdvance = 2; return string.Format("SMB5 ${0:X2}", ReadMemory(++pc)); + case 0xD5: bytesToAdvance = 2; return $"CMP ${ReadMemory(++pc):X2},X"; + case 0xD6: bytesToAdvance = 2; return $"DEC ${ReadMemory(++pc):X2},X"; + case 0xD7: bytesToAdvance = 2; return $"SMB5 ${ReadMemory(++pc):X2}"; case 0xD8: bytesToAdvance = 1; return "CLD"; - case 0xD9: bytesToAdvance = 3; return string.Format("CMP ${0:X4},Y", ReadWord(++pc)); + case 0xD9: bytesToAdvance = 3; return $"CMP ${ReadWord(++pc):X4},Y"; case 0xDA: bytesToAdvance = 1; return "PHX"; - case 0xDD: bytesToAdvance = 3; return string.Format("CMP ${0:X4},X", ReadWord(++pc)); - case 0xDE: bytesToAdvance = 3; return string.Format("DEC ${0:X4},X", ReadWord(++pc)); - case 0xDF: bytesToAdvance = 3; return string.Format("BBS5 ${0:X2},{1}", ReadMemory(++pc), (sbyte)ReadMemory(++pc)); - case 0xE0: bytesToAdvance = 2; return string.Format("CPX #${0:X2}", ReadMemory(++pc)); - case 0xE1: bytesToAdvance = 2; return string.Format("SBC (${0:X2},X)", ReadMemory(++pc)); - case 0xE3: bytesToAdvance = 7; return string.Format("TIA {0:X4},{1:X4},{2:X4}", ReadWord((ushort)(pc+1)),ReadWord((ushort)(pc+3)),ReadWord((ushort)(pc+5))); - case 0xE4: bytesToAdvance = 2; return string.Format("CPX ${0:X2}", ReadMemory(++pc)); - case 0xE5: bytesToAdvance = 2; return string.Format("SBC ${0:X2}", ReadMemory(++pc)); - case 0xE6: bytesToAdvance = 2; return string.Format("INC ${0:X2}", ReadMemory(++pc)); - case 0xE7: bytesToAdvance = 2; return string.Format("SMB6 ${0:X2}", ReadMemory(++pc)); + case 0xDD: bytesToAdvance = 3; return $"CMP ${ReadWord(++pc):X4},X"; + case 0xDE: bytesToAdvance = 3; return $"DEC ${ReadWord(++pc):X4},X"; + case 0xDF: bytesToAdvance = 3; return $"BBS5 ${ReadMemory(++pc):X2},{(sbyte)ReadMemory(++pc)}"; + case 0xE0: bytesToAdvance = 2; return $"CPX #${ReadMemory(++pc):X2}"; + case 0xE1: bytesToAdvance = 2; return $"SBC (${ReadMemory(++pc):X2},X)"; + case 0xE3: bytesToAdvance = 7; return $"TIA {ReadWord((ushort)(pc + 1)):X4},{ReadWord((ushort)(pc + 3)):X4},{ReadWord((ushort)(pc + 5)):X4}"; + case 0xE4: bytesToAdvance = 2; return $"CPX ${ReadMemory(++pc):X2}"; + case 0xE5: bytesToAdvance = 2; return $"SBC ${ReadMemory(++pc):X2}"; + case 0xE6: bytesToAdvance = 2; return $"INC ${ReadMemory(++pc):X2}"; + case 0xE7: bytesToAdvance = 2; return $"SMB6 ${ReadMemory(++pc):X2}"; case 0xE8: bytesToAdvance = 1; return "INX"; - case 0xE9: bytesToAdvance = 2; return string.Format("SBC #${0:X2}", ReadMemory(++pc)); + case 0xE9: bytesToAdvance = 2; return $"SBC #${ReadMemory(++pc):X2}"; case 0xEA: bytesToAdvance = 1; return "NOP"; - case 0xEC: bytesToAdvance = 3; return string.Format("CPX ${0:X4}", ReadWord(++pc)); - case 0xED: bytesToAdvance = 3; return string.Format("SBC ${0:X4}", ReadWord(++pc)); - case 0xEE: bytesToAdvance = 3; return string.Format("INC ${0:X4}", ReadWord(++pc)); - case 0xEF: bytesToAdvance = 3; return string.Format("BBS6 ${0:X2},{1}", ReadMemory(++pc), (sbyte)ReadMemory(++pc)); - case 0xF0: bytesToAdvance = 2; return string.Format("BEQ {0}", (sbyte)ReadMemory(++pc)); - case 0xF1: bytesToAdvance = 2; return string.Format("SBC (${0:X2}),Y", ReadMemory(++pc)); - case 0xF2: bytesToAdvance = 2; return string.Format("SBC (${0:X2})", ReadMemory(++pc)); - case 0xF3: bytesToAdvance = 7; return string.Format("TAI {0:X4},{1:X4},{2:X4}", ReadWord((ushort)(pc+1)),ReadWord((ushort)(pc+3)),ReadWord((ushort)(pc+5))); + case 0xEC: bytesToAdvance = 3; return $"CPX ${ReadWord(++pc):X4}"; + case 0xED: bytesToAdvance = 3; return $"SBC ${ReadWord(++pc):X4}"; + case 0xEE: bytesToAdvance = 3; return $"INC ${ReadWord(++pc):X4}"; + case 0xEF: bytesToAdvance = 3; return $"BBS6 ${ReadMemory(++pc):X2},{(sbyte)ReadMemory(++pc)}"; + case 0xF0: bytesToAdvance = 2; return $"BEQ {(sbyte)ReadMemory(++pc)}"; + case 0xF1: bytesToAdvance = 2; return $"SBC (${ReadMemory(++pc):X2}),Y"; + case 0xF2: bytesToAdvance = 2; return $"SBC (${ReadMemory(++pc):X2})"; + case 0xF3: bytesToAdvance = 7; return $"TAI {ReadWord((ushort)(pc + 1)):X4},{ReadWord((ushort)(pc + 3)):X4},{ReadWord((ushort)(pc + 5)):X4}"; case 0xF4: bytesToAdvance = 1; return "SET"; - case 0xF5: bytesToAdvance = 2; return string.Format("SBC ${0:X2},X", ReadMemory(++pc)); - case 0xF6: bytesToAdvance = 2; return string.Format("INC ${0:X2},X", ReadMemory(++pc)); - case 0xF7: bytesToAdvance = 2; return string.Format("SMB7 ${0:X2}", ReadMemory(++pc)); + case 0xF5: bytesToAdvance = 2; return $"SBC ${ReadMemory(++pc):X2},X"; + case 0xF6: bytesToAdvance = 2; return $"INC ${ReadMemory(++pc):X2},X"; + case 0xF7: bytesToAdvance = 2; return $"SMB7 ${ReadMemory(++pc):X2}"; case 0xF8: bytesToAdvance = 1; return "SED"; - case 0xF9: bytesToAdvance = 3; return string.Format("SBC ${0:X4},Y", ReadWord(++pc)); + case 0xF9: bytesToAdvance = 3; return $"SBC ${ReadWord(++pc):X4},Y"; case 0xFA: bytesToAdvance = 1; return "PLX"; - case 0xFD: bytesToAdvance = 3; return string.Format("SBC ${0:X4},X", ReadWord(++pc)); - case 0xFE: bytesToAdvance = 3; return string.Format("INC ${0:X4},X", ReadWord(++pc)); - case 0xFF: bytesToAdvance = 3; return string.Format("BBS7 ${0:X2},{1}", ReadMemory(++pc), (sbyte)ReadMemory(++pc)); + case 0xFD: bytesToAdvance = 3; return $"SBC ${ReadWord(++pc):X4},X"; + case 0xFE: bytesToAdvance = 3; return $"INC ${ReadWord(++pc):X4},X"; + case 0xFF: bytesToAdvance = 3; return $"BBS7 ${ReadMemory(++pc):X2},{(sbyte)ReadMemory(++pc)}"; } bytesToAdvance = 1; return "???"; @@ -258,239 +258,239 @@ public static string DisassembleExt(ushort pc, out int bytesToAdvance, Func> 13]).PadRight(30), + Disassembly = $"{MPR[PC >> 13]:X2}:{PC:X4}: {ReadMemory(PC):X2} {Disassemble(PC, out notused)} ".PadRight(30), RegisterInfo = string.Join(" ", $"A:{A:X2}", $"X:{X:X2}", diff --git a/BizHawk.Emulation.Cores/CPUs/LR35902/LR35902.cs b/BizHawk.Emulation.Cores/CPUs/LR35902/LR35902.cs index ce37346b389..c7e439c119f 100644 --- a/BizHawk.Emulation.Cores/CPUs/LR35902/LR35902.cs +++ b/BizHawk.Emulation.Cores/CPUs/LR35902/LR35902.cs @@ -563,9 +563,7 @@ public TraceInfo State(bool disassemble = true) return new TraceInfo { - Disassembly = string.Format( - "{0} ", - disassemble ? Disassemble(RegPC, ReadMemory, out notused) : "---").PadRight(40), + Disassembly = $"{(disassemble ? Disassemble(RegPC, ReadMemory, out notused) : "---")} ".PadRight(40), RegisterInfo = string.Join(" ", $"A:{Regs[A]:X2}", $"F:{Regs[F]:X2}", diff --git a/BizHawk.Emulation.Cores/CPUs/LR35902/NewDisassembler.cs b/BizHawk.Emulation.Cores/CPUs/LR35902/NewDisassembler.cs index 4bbb453301a..9eb33b6f852 100644 --- a/BizHawk.Emulation.Cores/CPUs/LR35902/NewDisassembler.cs +++ b/BizHawk.Emulation.Cores/CPUs/LR35902/NewDisassembler.cs @@ -540,7 +540,7 @@ public static string Disassemble(ushort addr, Func reader, out ush { byte d = reader(addr++); bytes.Add(d); - result = result.Replace("d8", string.Format("#{0:X2}h", d)); + result = result.Replace("d8", $"#{d:X2}h"); } else if (result.Contains("d16")) { @@ -548,7 +548,7 @@ public static string Disassemble(ushort addr, Func reader, out ush byte dhi = reader(addr++); bytes.Add(dlo); bytes.Add(dhi); - result = result.Replace("d16", string.Format("#{0:X2}{1:X2}h", dhi, dlo)); + result = result.Replace("d16", $"#{dhi:X2}{dlo:X2}h"); } else if (result.Contains("a16")) { @@ -556,13 +556,13 @@ public static string Disassemble(ushort addr, Func reader, out ush byte dhi = reader(addr++); bytes.Add(dlo); bytes.Add(dhi); - result = result.Replace("a16", string.Format("#{0:X2}{1:X2}h", dhi, dlo)); + result = result.Replace("a16", $"#{dhi:X2}{dlo:X2}h"); } else if (result.Contains("a8")) { byte d = reader(addr++); bytes.Add(d); - result = result.Replace("a8", string.Format("#FF{0:X2}h", d)); + result = result.Replace("a8", $"#FF{d:X2}h"); } else if (result.Contains("r8")) { @@ -571,12 +571,12 @@ public static string Disassemble(ushort addr, Func reader, out ush int offs = d; if (offs >= 128) offs -= 256; - result = result.Replace("r8", string.Format("{0:X4}h", (ushort)(addr + offs))); + result = result.Replace("r8", $"{(ushort)(addr + offs):X4}h"); } StringBuilder ret = new StringBuilder(); - ret.Append(string.Format("{0:X4}: ", origaddr)); + ret.Append($"{origaddr:X4}: "); foreach (var b in bytes) - ret.Append(string.Format("{0:X2} ", b)); + ret.Append($"{b:X2} "); while (ret.Length < 17) ret.Append(' '); ret.Append(result); diff --git a/BizHawk.Emulation.Cores/CPUs/MC6809/MC6809.cs b/BizHawk.Emulation.Cores/CPUs/MC6809/MC6809.cs index e15ad9c7c88..d6c4ec2968a 100644 --- a/BizHawk.Emulation.Cores/CPUs/MC6809/MC6809.cs +++ b/BizHawk.Emulation.Cores/CPUs/MC6809/MC6809.cs @@ -479,9 +479,7 @@ public TraceInfo State(bool disassemble = true) return new TraceInfo { - Disassembly = string.Format( - "{0} ", - disassemble ? Disassemble(PC, ReadMemory, out notused) : "---").PadRight(40), + Disassembly = $"{(disassemble ? Disassemble(PC, ReadMemory, out notused) : "---")} ".PadRight(40), RegisterInfo = string.Format( "A:{0:X2} F:{1:X2} B:{2:X2} C:{3:X2} D:{4:X2} E:{5:X2} H:{6:X2} L:{7:X2}", diff --git a/BizHawk.Emulation.Cores/CPUs/MC6809/NewDisassembler.cs b/BizHawk.Emulation.Cores/CPUs/MC6809/NewDisassembler.cs index 73302b182e5..0f9c2b0f12f 100644 --- a/BizHawk.Emulation.Cores/CPUs/MC6809/NewDisassembler.cs +++ b/BizHawk.Emulation.Cores/CPUs/MC6809/NewDisassembler.cs @@ -540,7 +540,7 @@ public static string Disassemble(ushort addr, Func reader, out ush { byte d = reader(addr++); bytes.Add(d); - result = result.Replace("d8", string.Format("#{0:X2}h", d)); + result = result.Replace("d8", $"#{d:X2}h"); } else if (result.Contains("d16")) { @@ -548,7 +548,7 @@ public static string Disassemble(ushort addr, Func reader, out ush byte dhi = reader(addr++); bytes.Add(dlo); bytes.Add(dhi); - result = result.Replace("d16", string.Format("#{0:X2}{1:X2}h", dhi, dlo)); + result = result.Replace("d16", $"#{dhi:X2}{dlo:X2}h"); } else if (result.Contains("a16")) { @@ -556,13 +556,13 @@ public static string Disassemble(ushort addr, Func reader, out ush byte dhi = reader(addr++); bytes.Add(dlo); bytes.Add(dhi); - result = result.Replace("a16", string.Format("#{0:X2}{1:X2}h", dhi, dlo)); + result = result.Replace("a16", $"#{dhi:X2}{dlo:X2}h"); } else if (result.Contains("a8")) { byte d = reader(addr++); bytes.Add(d); - result = result.Replace("a8", string.Format("#FF{0:X2}h", d)); + result = result.Replace("a8", $"#FF{d:X2}h"); } else if (result.Contains("r8")) { @@ -571,12 +571,12 @@ public static string Disassemble(ushort addr, Func reader, out ush int offs = d; if (offs >= 128) offs -= 256; - result = result.Replace("r8", string.Format("{0:X4}h", (ushort)(addr + offs))); + result = result.Replace("r8", $"{(ushort)(addr + offs):X4}h"); } StringBuilder ret = new StringBuilder(); - ret.Append(string.Format("{0:X4}: ", origaddr)); + ret.Append($"{origaddr:X4}: "); foreach (var b in bytes) - ret.Append(string.Format("{0:X2} ", b)); + ret.Append($"{b:X2} "); while (ret.Length < 17) ret.Append(' '); ret.Append(result); diff --git a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/Disassembler.cs b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/Disassembler.cs index c6eed768174..00bb78dc08a 100644 --- a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/Disassembler.cs +++ b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/Disassembler.cs @@ -63,185 +63,185 @@ public static string Disassemble(ushort pc, out int bytesToAdvance, Func peek, ref byte P, out int { // Absolute case 0x0C:case 0x0D:case 0x0E:case 0x1C:case 0x20:case 0x2C:case 0x2D:case 0x2E:case 0x4C:case 0x4D:case 0x4E:case 0x6D:case 0x6E:case 0x8C:case 0x8D:case 0x8E:case 0x9C:case 0xAC:case 0xAD:case 0xAE:case 0xCC:case 0xCD:case 0xCE:case 0xEC:case 0xED:case 0xEE: - pbuf = string.Format("${0:X4}", peek(addr + 1) + peek(addr + 2) * 256); + pbuf = $"${peek(addr + 1) + peek(addr + 2) * 256:X4}"; //sprintf(pbuf, "$%04X", mem[1] + mem[2] * 256); offset = 3; break; // Absolute Indexed Indirect case 0x7C:case 0xFC: - pbuf = string.Format("(${0:X4},X", peek(addr + 1) + peek(addr + 2) * 256); + pbuf = $"(${peek(addr + 1) + peek(addr + 2) * 256:X4},X"; //sprintf(pbuf, "($%04X,X)", mem[1] + mem[2] * 256); offset = 3; break; // Absolute Indexed, X case 0x1D:case 0x1E:case 0x3C:case 0x3D:case 0x3E:case 0x5D:case 0x5E:case 0x7D:case 0x7E:case 0x9D:case 0x9E:case 0xBC:case 0xBD:case 0xDD:case 0xDE:case 0xFD:case 0xFE: - pbuf = string.Format("${0:X4},X", peek(addr + 1) + peek(addr + 2) * 256); + pbuf = $"${peek(addr + 1) + peek(addr + 2) * 256:X4},X"; //sprintf(pbuf, "$%04X,X", mem[1] + mem[2] * 256); offset = 3; break; // Absolute Indexed, Y case 0x19:case 0x39:case 0x59:case 0x79:case 0x99:case 0xB9:case 0xBE:case 0xD9:case 0xF9: - pbuf = string.Format("${0:X4},Y", peek(addr + 1) + peek(addr + 2) * 256); + pbuf = $"${peek(addr + 1) + peek(addr + 2) * 256:X4},Y"; //sprintf(pbuf, "$%04X,Y", mem[1] + mem[2] * 256); offset = 3; break; // Absolute Indirect case 0x6C: - pbuf = string.Format("(${0:X4})", peek(addr + 1) + peek(addr + 2) * 256); + pbuf = $"(${peek(addr + 1) + peek(addr + 2) * 256:X4})"; //sprintf(pbuf, "($%04X)", mem[1] + mem[2] * 256); offset = 3; break; // Absolute Indirect Long case 0xDC: - pbuf = string.Format("[${0:X4}]", peek(addr + 1) + peek(addr + 2) * 256); + pbuf = $"[${peek(addr + 1) + peek(addr + 2) * 256:X4}]"; //sprintf(pbuf, "[$%04X]", mem[1] + mem[2] * 256); offset = 3; break; // Absolute Long case 0x0F:case 0x22:case 0x2F:case 0x4F:case 0x5C:case 0x6F:case 0x8F:case 0xAF:case 0xCF:case 0xEF: - pbuf = string.Format("${0:X6}", peek(addr + 1) + peek(addr + 2) * 256 + peek(addr + 3) * 65536); + pbuf = $"${peek(addr + 1) + peek(addr + 2) * 256 + peek(addr + 3) * 65536:X6}"; //sprintf(pbuf, "$%06X", mem[1] + mem[2] * 256 + mem[3] * 65536); offset = 4; break; // Absolute Long Indexed, X case 0x1F:case 0x3F:case 0x5F:case 0x7F:case 0x9F:case 0xBF:case 0xDF:case 0xFF: - pbuf = string.Format("${0:X6},X", peek(addr + 1) + peek(addr + 2) * 256 + peek(addr + 3) * 65536); + pbuf = $"${peek(addr + 1) + peek(addr + 2) * 256 + peek(addr + 3) * 65536:X6},X"; //sprintf(pbuf, "$%06X,X", mem[1] + mem[2] * 256 + mem[3] * 65536); offset = 4; break; @@ -315,49 +315,49 @@ public string Disassemble(uint addr, Func peek, ref byte P, out int break; // Direct Page case 0x04:case 0x05:case 0x06:case 0x14:case 0x24:case 0x25:case 0x26:case 0x45:case 0x46:case 0x64:case 0x65:case 0x66:case 0x84:case 0x85:case 0x86:case 0xA4:case 0xA5:case 0xA6:case 0xC4:case 0xC5:case 0xC6:case 0xE4:case 0xE5:case 0xE6: - pbuf = string.Format("${0:X2}", peek(addr + 1)); + pbuf = $"${peek(addr + 1):X2}"; //sprintf(pbuf, "$%02X", mem[1]); offset = 2; break; // Direct Page Indexed, X case 0x15:case 0x16:case 0x34:case 0x35:case 0x36:case 0x55:case 0x56:case 0x74:case 0x75:case 0x76:case 0x94:case 0x95:case 0xB4:case 0xB5:case 0xD5:case 0xD6:case 0xF5:case 0xF6: - pbuf = string.Format("${0:X2},X", peek(addr + 1)); + pbuf = $"${peek(addr + 1):X2},X"; //sprintf(pbuf, "$%02X,X", mem[1]); offset = 2; break; // Direct Page Indexed, Y case 0x96:case 0xB6: - pbuf = string.Format("${0:X2},Y", peek(addr + 1)); + pbuf = $"${peek(addr + 1):X2},Y"; //sprintf(pbuf, "$%02X,Y", mem[1]); offset = 2; break; // Direct Page Indirect case 0x12:case 0x32:case 0x52:case 0x72:case 0x92:case 0xB2:case 0xD2:case 0xF2: - pbuf = string.Format("(${0:X2})", peek(addr + 1)); + pbuf = $"(${peek(addr + 1):X2})"; //sprintf(pbuf, "($%02X)", mem[1]); offset = 2; break; // Direct Page Indirect Long case 0x07:case 0x27:case 0x47:case 0x67:case 0x87:case 0xA7:case 0xC7:case 0xE7: - pbuf = string.Format("[${0:X2}]", peek(addr + 1)); + pbuf = $"[${peek(addr + 1):X2}]"; //sprintf(pbuf, "[$%02X]", mem[1]); offset = 2; break; // Direct Page Indexed Indirect, X case 0x01:case 0x21:case 0x41:case 0x61:case 0x81:case 0xA1:case 0xC1:case 0xE1: - pbuf = string.Format("(${0:X2},X)", peek(addr + 1)); + pbuf = $"(${peek(addr + 1):X2},X)"; //sprintf(pbuf, "($%02X,X)", mem[1]); offset = 2; break; // Direct Page Indirect Indexed, Y case 0x11:case 0x31:case 0x51:case 0x71:case 0x91:case 0xB1:case 0xD1:case 0xF1: - pbuf = string.Format("(${0:X2},Y)", peek(addr + 1)); + pbuf = $"(${peek(addr + 1):X2},Y)"; //sprintf(pbuf, "($%02X),Y", mem[1]); offset = 2; break; // Direct Page Indirect Long Indexed, Y case 0x17:case 0x37:case 0x57:case 0x77:case 0x97:case 0xB7:case 0xD7:case 0xF7: - pbuf = string.Format("[${0:X2}],Y", peek(addr + 1)); + pbuf = $"[${peek(addr + 1):X2}],Y"; //sprintf(pbuf, "[$%02X],Y", mem[1]); offset = 2; break; @@ -382,7 +382,7 @@ public string Disassemble(uint addr, Func peek, ref byte P, out int { byte mem1 = peek(addr+1); sval = (mem1 > 127) ? (mem1 - 256) : mem1; - pbuf = string.Format("${0:X4}", (addr + sval + 2) & 0xFFFF); + pbuf = $"${(addr + sval + 2) & 0xFFFF:X4}"; //sprintf(pbuf, "$%04lX", (pos + sval + 2) & 0xFFFF); offset = 2; break; @@ -394,31 +394,31 @@ public string Disassemble(uint addr, Func peek, ref byte P, out int // Calculate the signed value of the param sval = peek(addr+1) + peek(addr+2) * 256; sval = (sval > 32767) ? (sval - 65536) : sval; - pbuf = string.Format("${0:X4}", (addr + sval + 3) & 0xFFFF); + pbuf = $"${(addr + sval + 3) & 0xFFFF:X4}"; //sprintf(pbuf, "$%04lX", (pos + sval + 3) & 0xFFFF); offset = 3; break; // Stack Relative Indirect Indexed, Y case 0x13:case 0x33:case 0x53:case 0x73:case 0x93:case 0xB3:case 0xD3:case 0xF3: - pbuf = string.Format("(${0:X4},S),Y", peek(addr + 1)); + pbuf = $"(${peek(addr + 1):X4},S),Y"; //sprintf(pbuf, "($%02X,S),Y", mem[1]); offset = 2; break; // Stack (Absolute) case 0xF4: - pbuf = string.Format("${0:X4}", peek(addr + 1) + peek(addr + 2) * 256); + pbuf = $"${peek(addr + 1) + peek(addr + 2) * 256:X4}"; //sprintf(pbuf, "$%04X", mem[1] + mem[2] * 256); offset = 3; break; // Stack (Direct Page Indirect) case 0xD4: - pbuf = string.Format("(${0:X2}", peek(addr + 1)); + pbuf = $"(${peek(addr + 1):X2}"; //sprintf(pbuf, "($%02X)", mem[1]); offset = 2; break; // Stack Relative case 0x03:case 0x23:case 0x43:case 0x63:case 0x83:case 0xA3:case 0xC3:case 0xE3: - pbuf = string.Format("${0:X2},S", peek(addr = 1)); + pbuf = $"${peek(addr = 1):X2},S"; //sprintf(pbuf, "$%02X,S", mem[1]); offset = 2; break; @@ -426,7 +426,7 @@ public string Disassemble(uint addr, Func peek, ref byte P, out int case 0x42: // Stack/Interrupt case 0x00: case 0x02: - pbuf = string.Format("${0:X2}", peek(addr + 1)); + pbuf = $"${peek(addr + 1):X2}"; //sprintf(pbuf, "$%02X", mem[1]); offset = 2; break; @@ -436,7 +436,7 @@ public string Disassemble(uint addr, Func peek, ref byte P, out int { byte mem1 = peek(addr + 1); P = (byte)(P & ~mem1); - pbuf = string.Format("#${0:X2}", peek(addr + 1)); + pbuf = $"#${peek(addr + 1):X2}"; //sprintf(pbuf, "#$%02X", mem[1]); offset = 2; break; @@ -446,7 +446,7 @@ public string Disassemble(uint addr, Func peek, ref byte P, out int { byte mem1 = peek(addr + 1); P = (byte)(P | mem1); - pbuf = string.Format("#${0:X2}", mem1); + pbuf = $"#${mem1:X2}"; //sprintf(pbuf, "#$%02X", mem[1]); offset = 2; break; @@ -455,13 +455,13 @@ public string Disassemble(uint addr, Func peek, ref byte P, out int case 0x09:case 0x29:case 0x49:case 0x69:case 0x89:case 0xA9:case 0xC9:case 0xE9: if ((P & 0x20)!=0) { - pbuf = string.Format("#${0:X2}", peek(addr + 1)); + pbuf = $"#${peek(addr + 1):X2}"; //sprintf(pbuf, "#$%02X", mem[1]); offset = 2; } else { - pbuf = string.Format("#${0:X4}", peek(addr + 1) + peek(addr+2)*256); + pbuf = $"#${peek(addr + 1) + peek(addr + 2) * 256:X4}"; offset = 3; } break; @@ -469,13 +469,13 @@ public string Disassemble(uint addr, Func peek, ref byte P, out int case 0xA0:case 0xA2:case 0xC0:case 0xE0: if ((P & 0x10)!=0) { - pbuf = string.Format("#${0:X2}", peek(addr + 1)); + pbuf = $"#${peek(addr + 1):X2}"; //sprintf(pbuf, "#$%02X", mem[1]); offset = 2; } else { - pbuf = string.Format("#${0:X4}", peek(addr + 1) + peek(addr + 2) * 256); + pbuf = $"#${peek(addr + 1) + peek(addr + 2) * 256:X4}"; //sprintf(pbuf, "#$%04X", mem[1] + mem[2] * 256); offset = 3; } diff --git a/BizHawk.Emulation.Cores/CPUs/Z80A/Z80A.cs b/BizHawk.Emulation.Cores/CPUs/Z80A/Z80A.cs index 880d26908bc..412e48a3189 100644 --- a/BizHawk.Emulation.Cores/CPUs/Z80A/Z80A.cs +++ b/BizHawk.Emulation.Cores/CPUs/Z80A/Z80A.cs @@ -756,11 +756,7 @@ public TraceInfo State(bool disassemble = true) return new TraceInfo { - Disassembly = string.Format( - "{0:X4}: {1} {2}", - RegPC, - byte_code.PadRight(12), - disasm.PadRight(26)), + Disassembly = $"{RegPC:X4}: {byte_code.PadRight(12)} {disasm.PadRight(26)}", RegisterInfo = string.Join(" ", $"AF:{(Regs[A] << 8) + Regs[F]:X4}", $"BC:{(Regs[B] << 8) + Regs[C]:X4}", diff --git a/BizHawk.Emulation.Cores/CPUs/x86/Disassembler.cs b/BizHawk.Emulation.Cores/CPUs/x86/Disassembler.cs index 27532cb37ce..e7ce9772f45 100644 --- a/BizHawk.Emulation.Cores/CPUs/x86/Disassembler.cs +++ b/BizHawk.Emulation.Cores/CPUs/x86/Disassembler.cs @@ -10,10 +10,7 @@ public class DisassemblyInfo public string RawBytes; public int Length; - public override string ToString() - { - return string.Format("{0:X6}: {3,-12} {1,-8} {2}", Addr, Mnemonic, Args, RawBytes); - } + public override string ToString() => $"{Addr:X6}: {RawBytes,-12} {Mnemonic,-8} {Args}"; } public partial class x86 where CpuType : struct, x86CpuType @@ -60,34 +57,34 @@ private string DisassembleMod(ref int addr, int mod, int m, int size) case 3: return "[BP+DI]"; case 4: return "[SI]"; case 5: return "[DI]"; - case 6: ret = string.Format("{0:X4}h", ReadWord(addr)); addr += 2; return ret; + case 6: ret = $"{ReadWord(addr):X4}h"; addr += 2; return ret; case 7: return "[BX]"; } break; case 1: switch (m) { - case 0: return string.Format("[BX+SI] + {0:X2}h", ReadMemory(addr++)); - case 1: return string.Format("[BX+DI] + {0:X2}h", ReadMemory(addr++)); - case 2: return string.Format("[BP+SI] + {0:X2}h", ReadMemory(addr++)); - case 3: return string.Format("[BP+DI] + {0:X2}h", ReadMemory(addr++)); - case 4: return string.Format("[SI] + {0:X2}h", ReadMemory(addr++)); - case 5: return string.Format("[DI] + {0:X2}h", ReadMemory(addr++)); - case 6: return string.Format("[BP] + {0:X2}h", ReadMemory(addr++)); - case 7: return string.Format("[BX] + {0:X2}h", ReadMemory(addr++)); + case 0: return $"[BX+SI] + {ReadMemory(addr++):X2}h"; + case 1: return $"[BX+DI] + {ReadMemory(addr++):X2}h"; + case 2: return $"[BP+SI] + {ReadMemory(addr++):X2}h"; + case 3: return $"[BP+DI] + {ReadMemory(addr++):X2}h"; + case 4: return $"[SI] + {ReadMemory(addr++):X2}h"; + case 5: return $"[DI] + {ReadMemory(addr++):X2}h"; + case 6: return $"[BP] + {ReadMemory(addr++):X2}h"; + case 7: return $"[BX] + {ReadMemory(addr++):X2}h"; } break; case 2: switch (m) { - case 0: ret = string.Format("[BX+SI] + {0:X4}h", ReadWord(addr)); addr += 2; return ret; - case 1: ret = string.Format("[BX+DI] + {0:X4}h", ReadWord(addr)); addr += 2; return ret; - case 2: ret = string.Format("[BP+SI] + {0:X4}h", ReadWord(addr)); addr += 2; return ret; - case 3: ret = string.Format("[BP+DI] + {0:X4}h", ReadWord(addr)); addr += 2; return ret; - case 4: ret = string.Format("[SI] + {0:X4}h", ReadWord(addr)); addr += 2; return ret; - case 5: ret = string.Format("[DI] + {0:X4}h", ReadWord(addr)); addr += 2; return ret; - case 6: ret = string.Format("[BP] + {0:X4}h", ReadWord(addr)); addr += 2; return ret; - case 7: ret = string.Format("[BX] + {0:X4}h", ReadWord(addr)); addr += 2; return ret; + case 0: ret = $"[BX+SI] + {ReadWord(addr):X4}h"; addr += 2; return ret; + case 1: ret = $"[BX+DI] + {ReadWord(addr):X4}h"; addr += 2; return ret; + case 2: ret = $"[BP+SI] + {ReadWord(addr):X4}h"; addr += 2; return ret; + case 3: ret = $"[BP+DI] + {ReadWord(addr):X4}h"; addr += 2; return ret; + case 4: ret = $"[SI] + {ReadWord(addr):X4}h"; addr += 2; return ret; + case 5: ret = $"[DI] + {ReadWord(addr):X4}h"; addr += 2; return ret; + case 6: ret = $"[BP] + {ReadWord(addr):X4}h"; addr += 2; return ret; + case 7: ret = $"[BX] + {ReadWord(addr):X4}h"; addr += 2; return ret; } break; case 3: @@ -119,71 +116,71 @@ public DisassemblyInfo Disassemble(int addr) break; case 0xB0: // MOV AL, immed info.Mnemonic = "MOV"; - info.Args = string.Format("AL, {0:X2}h", ReadMemory(addr++)); + info.Args = $"AL, {ReadMemory(addr++):X2}h"; break; case 0xB1: // MOV CL, immed info.Mnemonic = "MOV"; - info.Args = string.Format("CL, {0:X2}h", ReadMemory(addr++)); + info.Args = $"CL, {ReadMemory(addr++):X2}h"; break; case 0xB2: // MOV DL, immed info.Mnemonic = "MOV"; - info.Args = string.Format("DL, {0:X2}h", ReadMemory(addr++)); + info.Args = $"DL, {ReadMemory(addr++):X2}h"; break; case 0xB3: // MOV BL, immed info.Mnemonic = "MOV"; - info.Args = string.Format("BL, {0:X2}h", ReadMemory(addr++)); + info.Args = $"BL, {ReadMemory(addr++):X2}h"; break; case 0xB4: // MOV AH, immed info.Mnemonic = "MOV"; - info.Args = string.Format("AH, {0:X2}h", ReadMemory(addr++)); + info.Args = $"AH, {ReadMemory(addr++):X2}h"; break; case 0xB5: // MOV CH, immed info.Mnemonic = "MOV"; - info.Args = string.Format("CH, {0:X2}h", ReadMemory(addr++)); + info.Args = $"CH, {ReadMemory(addr++):X2}h"; break; case 0xB6: // MOV DH, immed info.Mnemonic = "MOV"; - info.Args = string.Format("DH, {0:X2}h", ReadMemory(addr++)); + info.Args = $"DH, {ReadMemory(addr++):X2}h"; break; case 0xB7: // MOV BH, immed info.Mnemonic = "MOV"; - info.Args = string.Format("BH, {0:X2}h", ReadMemory(addr++)); + info.Args = $"BH, {ReadMemory(addr++):X2}h"; break; case 0xB8: // MOV AX, immed info.Mnemonic = "MOV"; - info.Args = string.Format("AX, {0:X4}h", ReadWord(addr)); addr += 2; + info.Args = $"AX, {ReadWord(addr):X4}h"; addr += 2; break; case 0xB9: // MOV CX, immed info.Mnemonic = "MOV"; - info.Args = string.Format("CX, {0:X4}h", ReadWord(addr)); addr += 2; + info.Args = $"CX, {ReadWord(addr):X4}h"; addr += 2; break; case 0xBA: // MOV DX, immed info.Mnemonic = "MOV"; - info.Args = string.Format("DX, {0:X4}h", ReadWord(addr)); addr += 2; + info.Args = $"DX, {ReadWord(addr):X4}h"; addr += 2; break; case 0xBB: // MOV BX, immed info.Mnemonic = "MOV"; - info.Args = string.Format("BX, {0:X4}h", ReadWord(addr)); addr += 2; + info.Args = $"BX, {ReadWord(addr):X4}h"; addr += 2; break; case 0xBC: // MOV SP, immed info.Mnemonic = "MOV"; - info.Args = string.Format("SP, {0:X4}h", ReadWord(addr)); addr += 2; + info.Args = $"SP, {ReadWord(addr):X4}h"; addr += 2; break; case 0xBD: // MOV BP, immed info.Mnemonic = "MOV"; - info.Args = string.Format("BP, {0:X4}h", ReadWord(addr)); addr += 2; + info.Args = $"BP, {ReadWord(addr):X4}h"; addr += 2; break; case 0xBE: // MOV SI, immed info.Mnemonic = "MOV"; - info.Args = string.Format("SI, {0:X4}h", ReadWord(addr)); addr += 2; + info.Args = $"SI, {ReadWord(addr):X4}h"; addr += 2; break; case 0xBF: // MOV DI, immed info.Mnemonic = "MOV"; - info.Args = string.Format("DI, {0:X4}h", ReadWord(addr)); addr += 2; + info.Args = $"DI, {ReadWord(addr):X4}h"; addr += 2; break; default: info.Mnemonic = "DB"; - info.Args = string.Format("{0:X2}h", op1); + info.Args = $"{op1:X2}h"; break; } diff --git a/BizHawk.Emulation.Cores/CPUs/x86/x86.cs b/BizHawk.Emulation.Cores/CPUs/x86/x86.cs index a966781142f..278e3f27fdd 100644 --- a/BizHawk.Emulation.Cores/CPUs/x86/x86.cs +++ b/BizHawk.Emulation.Cores/CPUs/x86/x86.cs @@ -92,9 +92,6 @@ public struct Register16 [FieldOffset(1)] public byte High; - public override string ToString() - { - return String.Format("{0:X4}", Word); - } + public override string ToString() => $"{Word:X4}"; } } \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Tape/CDT/CdtConverter.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Tape/CDT/CdtConverter.cs index 3361d961261..0eb08e3ad6a 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Tape/CDT/CdtConverter.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Tape/CDT/CdtConverter.cs @@ -1754,8 +1754,8 @@ A SCREEN$ file is regarded as a Code file with start address 16384 and length 69 else { // some other type (turbo data etc..) - description = string.Format("#{0} block, {1} bytes", blockdata[0].ToString("X2"), blockSize); - //description += string.Format(", crc {0}", ((crc != 0) ? string.Format("bad (#{0:X2}!=#{1:X2})", crcFile, crcValue) : "ok")); + description = $"#{blockdata[0].ToString("X2")} block, {blockSize} bytes"; + //description += (crc != 0) ? $", crc bad (#{crcFile:X2}!=#{crcValue:X2})" : ", crc ok"; block.AddMetaData(BlockDescriptorTitle.Undefined, description); } /* @@ -1797,8 +1797,8 @@ A SCREEN$ file is regarded as a Code file with start address 16384 and length 69 else { // other type - description = string.Format("#{0} block, {1} bytes", blockdata[0].ToString("X2"), blockSize); - //description += string.Format(", crc {0}", ((crc != 0) ? string.Format("bad (#{0:X2}!=#{1:X2})", crcFile, crcValue) : "ok")); + description = $"#{blockdata[0]:X2} block, {blockSize} bytes"; + //description += (crc != 0) ? $", crc bad (#{crcFile:X2}!=#{crcValue:X2})" : ", crc ok"; block.AddMetaData(BlockDescriptorTitle.Undefined, description); } */ diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TAP/TapConverter.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TAP/TapConverter.cs index a9ab6a895ac..168602013ad 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TAP/TapConverter.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TAP/TapConverter.cs @@ -228,8 +228,8 @@ A SCREEN$ file is regarded as a Code file with start address 16384 and length 69 else { // some other type (turbo data etc..) - description = string.Format("#{0} block, {1} bytes", blockdata[0].ToString("X2"), blockSize); - //description += string.Format(", crc {0}", ((crc != 0) ? string.Format("bad (#{0:X2}!=#{1:X2})", crcFile, crcValue) : "ok")); + description = $"#{blockdata[0].ToString("X2")} block, {blockSize} bytes"; + //description += (crc != 0) ? $", crc bad (#{crcFile:X2}!=#{crcValue:X2})" : ", crc ok"; tdb.AddMetaData(BlockDescriptorTitle.Undefined, description); } /* @@ -270,8 +270,8 @@ A SCREEN$ file is regarded as a Code file with start address 16384 and length 69 else { // other type - description = string.Format("#{0} block, {1} bytes", blockdata[0].ToString("X2"), blockSize - 2); - description += string.Format(", crc {0}", ((crc != 0) ? string.Format("bad (#{0:X2}!=#{1:X2})", crcFile, crcValue) : "ok")); + description = $"#{blockdata[0]:X2} block, {blockSize - 2} bytes"; + description += (crc != 0) ? $", crc bad (#{crcFile:X2}!=#{crcValue:X2})" : ", crc ok"; } */ diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TZX/TzxConverter.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TZX/TzxConverter.cs index 1eca78ec5ad..b88ea6d4b07 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TZX/TzxConverter.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TZX/TzxConverter.cs @@ -1693,8 +1693,8 @@ A SCREEN$ file is regarded as a Code file with start address 16384 and length 69 else { // some other type (turbo data etc..) - description = string.Format("#{0} block, {1} bytes", blockdata[0].ToString("X2"), blockSize); - //description += string.Format(", crc {0}", ((crc != 0) ? string.Format("bad (#{0:X2}!=#{1:X2})", crcFile, crcValue) : "ok")); + description = $"#{blockdata[0].ToString("X2")} block, {blockSize} bytes"; + //description += (crc != 0) ? $", crc bad (#{crcFile:X2}!=#{crcValue:X2})" : ", crc ok"; block.AddMetaData(BlockDescriptorTitle.Undefined, description); } /* @@ -1736,8 +1736,8 @@ A SCREEN$ file is regarded as a Code file with start address 16384 and length 69 else { // other type - description = string.Format("#{0} block, {1} bytes", blockdata[0].ToString("X2"), blockSize); - //description += string.Format(", crc {0}", ((crc != 0) ? string.Format("bad (#{0:X2}!=#{1:X2})", crcFile, crcValue) : "ok")); + description = $"#{blockdata[0]:X2} block, {blockSize} bytes"; + //description += (crc != 0) ? $", crc bad (#{crcFile:X2}!=#{crcValue:X2})" : ", crc ok"; block.AddMetaData(BlockDescriptorTitle.Undefined, description); } */ diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/WAV/WavHeader.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/WAV/WavHeader.cs index 8a19b53ed91..270ecf35ec9 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/WAV/WavHeader.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/WAV/WavHeader.cs @@ -44,9 +44,7 @@ public void Deserialize(Stream stream) } if (riffType != BitConverter.ToInt32(Encoding.ASCII.GetBytes("WAVE"), 0)) { - throw new FormatException(string.Format( - "Not supported RIFF type: '{0}'", - Encoding.ASCII.GetString(BitConverter.GetBytes(riffType)))); + throw new FormatException($"Not supported RIFF type: '{Encoding.ASCII.GetString(BitConverter.GetBytes(riffType))}'"); } Int32 chunkId; Int32 chunkSize; diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/WAV/WavStreamReader.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/WAV/WavStreamReader.cs index 042b276c7e9..15b1d064939 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/WAV/WavStreamReader.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/WAV/WavStreamReader.cs @@ -27,10 +27,7 @@ public Int32 ReadNext() if (m_header.fmtCode != WAVE_FORMAT_PCM && m_header.fmtCode != WAVE_FORMAT_IEEE_FLOAT) { - throw new FormatException(string.Format( - "Not supported audio format: fmtCode={0}, bitDepth={1}", - m_header.fmtCode, - m_header.bitDepth)); + throw new FormatException($"Not supported audio format: fmtCode={m_header.fmtCode}, bitDepth={m_header.bitDepth}"); } byte[] data = new byte[m_header.fmtBlockAlign]; m_stream.Read(data, 0, data.Length); @@ -54,10 +51,7 @@ public Int32 ReadNext() if (m_header.bitDepth == 64) return getSampleFloat64(data, 0, 0); } - throw new NotSupportedException(string.Format( - "Not supported audio format ({0}/{1} bit)", - m_header.fmtCode == WAVE_FORMAT_PCM ? "PCM" : "FLOAT", - m_header.bitDepth)); + throw new NotSupportedException($"Not supported audio format ({(m_header.fmtCode == WAVE_FORMAT_PCM ? "PCM" : "FLOAT")}/{m_header.bitDepth} bit)"); } private Int32 getSamplePcm8(byte[] bufferRaw, int offset, int channel) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs index 72cb7af7caa..c9bec3f41ca 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs @@ -160,7 +160,7 @@ TraceInfo Trace(uint addr, uint opcode) { return new TraceInfo { - Disassembly = string.Format("{2:X8}: {0:X8} {1}", opcode, Darm.DisassembleStuff(addr, opcode), addr).PadRight(54), + Disassembly = $"{addr:X8}: {opcode:X8} {Darm.DisassembleStuff(addr, opcode)}".PadRight(54), RegisterInfo = regs.TraceString() }; } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.ITraceable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.ITraceable.cs index ee887c2dbd4..7fa36ce9440 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.ITraceable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.ITraceable.cs @@ -23,7 +23,7 @@ public void MakeTrace() var traceInfo = new TraceInfo { - Disassembly = string.Format("{0:X}: {1}", pc, disasm.PadRight(32)) + Disassembly = $"{pc:X}: {disasm.PadRight(32)}" }; var sb = new StringBuilder(); @@ -32,19 +32,19 @@ public void MakeTrace() { UInt64 val = (regs[GPRnames[i] + "_hi"].Value << 32) | regs[GPRnames[i] + "_lo"].Value; string name = GPRnames[i]; - sb.Append(string.Format("{0}:{1:X16} ", name, val)); + sb.Append($"{name}:{val:X16} "); } - sb.Append(string.Format("LL:{0:X8} ", regs["LL"].Value)); - sb.Append(string.Format("LO:{0:X8}{1:X8} ", regs["LO_hi"].Value, regs["LO_lo"].Value)); - sb.Append(string.Format("HI:{0:X8}{1:X8} ", regs["HI_hi"].Value, regs["HI_lo"].Value)); - sb.Append(string.Format("FCR0:{0:X8} ", regs["FCR0"].Value)); - sb.Append(string.Format("FCR31:{0:X8} ", regs["FCR31"].Value)); + sb.Append($"LL:{regs["LL"].Value:X8} "); + sb.Append($"LO:{regs["LO_hi"].Value:X8}{regs["LO_lo"].Value:X8} "); + sb.Append($"HI:{regs["HI_hi"].Value:X8}{regs["HI_lo"].Value:X8} "); + sb.Append($"FCR0:{regs["FCR0"].Value:X8} "); + sb.Append($"FCR31:{regs["FCR31"].Value:X8} "); for (int i = 0; i < 32; i++) // r0 is always zero { UInt64 val = (regs["CP1 FGR REG" + i + "_hi"].Value << 32) | regs["CP1 FGR REG" + i + "_lo"].Value; - sb.Append(string.Format("f{0}:{1:X16} ", i, val)); + sb.Append($"f{i}:{val:X16} "); } // drop MMU co-processor regs for now diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusCoreApi.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusCoreApi.cs index c499855ae51..c43dba1a8c5 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusCoreApi.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusCoreApi.cs @@ -499,7 +499,7 @@ public mupen64plusApi(N64 bizhawkCore, byte[] rom, VideoPluginSettings video_set CoreDll = libLoader.LoadPlatformSpecific("mupen64plus"); if (CoreDll == IntPtr.Zero) - throw new InvalidOperationException(string.Format("Failed to load mupen64plus.dll")); + throw new InvalidOperationException("Failed to load mupen64plus.dll"); connectFunctionPointers(); @@ -954,7 +954,7 @@ public IntPtr AttachPlugin(m64p_plugin_type type, string PluginName) if (result != m64p_error.M64ERR_SUCCESS) { libLoader.FreePlatformSpecific(plugin.dllHandle); - throw new InvalidOperationException(string.Format("Error during attaching plugin {0}", PluginName)); + throw new InvalidOperationException($"Error during attaching plugin {PluginName}"); } plugins.Add(type, plugin); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/DatachBarcode.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/DatachBarcode.cs index 59dddf8770c..1b4427b22c7 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/DatachBarcode.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/DatachBarcode.cs @@ -94,7 +94,7 @@ public static bool ValidString(string s, out string why) throw new ArgumentNullException(nameof(s)); if (!s.Length.In(MIN_DIGITS, MAX_DIGITS)) { - why = string.Format("String must be {0} or {1} digits long!", MIN_DIGITS, MAX_DIGITS); + why = $"String must be {MIN_DIGITS} or {MAX_DIGITS} digits long!"; return false; } foreach (char c in s) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC2_4.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC2_4.cs index caf0c2e99b9..a0a78a49cd6 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC2_4.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC2_4.cs @@ -253,7 +253,7 @@ public override bool Configure(NES.EDetectionOrigin origin) remap = AddrA1A0; break; default: - throw new Exception(string.Format("Unknown PCB type for VRC2: \"{0}\"", Cart.pcb)); + throw new Exception($"Unknown PCB type for VRC2: \"{Cart.pcb}\""); } break; default: diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.iNES.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.iNES.cs index b960e8a541a..9f4ba79467d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.iNES.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.iNES.cs @@ -48,7 +48,7 @@ public static bool DetectFromINES(byte[] data, out CartInfo Cart, out CartInfo C int mapper = data[6] >> 4 | data[7] & 0xf0 | data[8] << 8 & 0xf00; int submapper = data[8] >> 4; - CartV2.board_type = string.Format("MAPPER{0:d4}-{1:d2}", mapper, submapper); + CartV2.board_type = $"MAPPER{mapper:d4}-{submapper:d2}"; int vrambat = iNES2Wram(data[11] >> 4); int vramnon = iNES2Wram(data[11] & 15); @@ -97,7 +97,7 @@ public static bool DetectFromINES(byte[] data, out CartInfo Cart, out CartInfo C { int mapper = data[6] >> 4 | data[7] & 0xf0; - Cart.board_type = string.Format("MAPPER{0:d3}", mapper); + Cart.board_type = $"MAPPER{mapper:d3}"; } Cart.vram_size = Cart.chr_size > 0 ? 0 : 8; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Unif.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Unif.cs index 5c2059bba52..fb8d69ecdab 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Unif.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Unif.cs @@ -37,7 +37,7 @@ public Unif(Stream s) throw new Exception("Missing \"UNIF\" header mark!"); int ver = br.ReadInt32(); //if (ver != 7) - // throw new Exception(string.Format("Unknown UNIF version {0}!", ver)); + // throw new Exception($"Unknown UNIF version {ver}!"); Console.WriteLine("Processing Version {0} UNIF...", ver); br.ReadBytes(32 - 4 - 4); @@ -53,8 +53,8 @@ public Unif(Stream s) MemoryStream chrs = new MemoryStream(); for (int i = 0; i < 16; i++) { - TryAdd(prgs, string.Format("PRG{0:X1}", i)); - TryAdd(chrs, string.Format("CHR{0:X1}", i)); + TryAdd(prgs, $"PRG{i:X1}"); + TryAdd(chrs, $"CHR{i:X1}"); } prgs.Close(); chrs.Close(); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.ITraceable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.ITraceable.cs index 1e2bfa3e355..409540ec4e7 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.ITraceable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.ITraceable.cs @@ -33,7 +33,7 @@ private void MakeTrace(IntPtr data) Tracer.Put(new TraceInfo { - Disassembly = string.Format("{0:X4}: {1}", pc, opcodeStr).PadRight(26), + Disassembly = $"{pc:X4}: {opcodeStr}".PadRight(26), RegisterInfo = string.Join(" ", $"A:{a:X2}", $"X:{x:X2}", diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs index dc60a866f18..d016460ffa4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs @@ -138,7 +138,7 @@ public PadEnt(string Name, int Mask) private static PadEnt[] GetPadList(int player) { - string prefix = string.Format("P{0} ", player); + string prefix = $"P{player} "; return PadNames.Zip(PadMasks, (s, i) => new PadEnt(prefix + s, i)).ToArray(); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/SNESGraphicsDecoder.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/SNESGraphicsDecoder.cs index 41fbc650f46..653195e5aa6 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/SNESGraphicsDecoder.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/SNESGraphicsDecoder.cs @@ -31,10 +31,7 @@ public struct Dimensions { public Dimensions(int w, int h) { Width = w; Height = h; } public int Width, Height; - public override string ToString() - { - return string.Format("{0}x{1}", Width, Height); - } + public override string ToString() => $"{Width}x{Height}"; } public enum ScreenSize diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs index 918bb5699b9..450b024ca8f 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs @@ -101,7 +101,7 @@ public PCEngine(CoreComm comm, GameInfo game, Disc disc, object Settings, object Init(game, rom); // the default RomStatusDetails don't do anything with Disc - CoreComm.RomStatusDetails = string.Format("{0}\r\nDisk partial hash:{1}", game.Name, new DiscSystem.DiscHasher(disc).OldHash()); + CoreComm.RomStatusDetails = $"{game.Name}\r\nDisk partial hash:{new DiscSystem.DiscHasher(disc).OldHash()}"; _controllerDeck = new PceControllerDeck( _syncSettings.Port1, diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IDisassembler.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IDisassembler.cs index 4f6f6a177e9..dd7c1a7d443 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IDisassembler.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IDisassembler.cs @@ -36,7 +36,7 @@ public string Disassemble(MemoryDomain m, uint addr, out int length) length = info.Length; - return string.Format("{0:X4} {1,-7} {2}", info.RawBytes.Substring(0, 4), info.Mnemonic, info.Args); + return $"{info.RawBytes.Substring(0, 4):X4} {info.Mnemonic,-7} {info.Args}"; } // TODO: refactor MC6800's disassembler to be a static call diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ISettable.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ISettable.cs index e5ef0463c27..2fb22f0e7ba 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ISettable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ISettable.cs @@ -66,7 +66,7 @@ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo cul { if (destinationType == typeof(string) && value.GetType() == typeof(uint)) { - return string.Format("0x{0:x8}", value); + return $"0x{value:x8}"; } else { @@ -122,7 +122,7 @@ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo cul { if (destinationType == typeof(string) && value.GetType() == typeof(ushort)) { - return string.Format("0x{0:x4}", value); + return $"0x{value:x4}"; } else { diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ITraceable.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ITraceable.cs index fecbfeeb4aa..55290c989d3 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ITraceable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.ITraceable.cs @@ -28,7 +28,7 @@ protected override void TraceFromCallback() var traceInfo = new TraceInfo { - Disassembly = string.Format("{0:X6}: {1}", pc, disasm).PadRight(50) + Disassembly = $"{pc:X6}: {disasm}".PadRight(50) }; var sb = new StringBuilder(); @@ -41,10 +41,7 @@ protected override void TraceFromCallback() r.Key != "M68K PC" && // already present in every line start r.Key != "M68K IR") // copy of last opcode, already shown in raw bytes { - sb.Append( - string.Format("{0}:{1} ", - r.Key.Replace("M68K", "").Trim(), - r.Value.Value.ToHexString(r.Value.BitSize / 4))); + sb.Append($"{r.Key.Replace("M68K", "").Trim()}:{r.Value.Value.ToHexString(r.Value.BitSize / 4)} "); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGXControlConverter.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGXControlConverter.cs index 99a7a7745bd..cf49ad8d4a5 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGXControlConverter.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGXControlConverter.cs @@ -114,7 +114,7 @@ void AddToController(int idx, int player, IEnumerable Buttons) { foreach (var Button in Buttons) { - string Name = string.Format("P{0} {1}", player, Button.Name); + string Name = $"P{player} {Button.Name}"; ControllerDef.BoolButtons.Add(Name); var ButtonFlag = Button.Key; Converts.Add(delegate() @@ -127,8 +127,8 @@ void AddToController(int idx, int player, IEnumerable Buttons) void DoMouseAnalog(int idx, int player) { - string NX = string.Format("P{0} Mouse X", player); - string NY = string.Format("P{0} Mouse Y", player); + string NX = $"P{player} Mouse X"; + string NY = $"P{player} Mouse Y"; ControllerDef.FloatControls.Add(NX); ControllerDef.FloatControls.Add(NY); ControllerDef.FloatRanges.Add(MouseRange); @@ -142,8 +142,8 @@ void DoMouseAnalog(int idx, int player) void DoLightgunAnalog(int idx, int player) { - string NX = string.Format("P{0} Lightgun X", player); - string NY = string.Format("P{0} Lightgun Y", player); + string NX = $"P{player} Lightgun X"; + string NY = $"P{player} Lightgun Y"; ControllerDef.FloatControls.Add(NX); ControllerDef.FloatControls.Add(NY); ControllerDef.FloatRanges.Add(LightgunRange); @@ -157,9 +157,9 @@ void DoLightgunAnalog(int idx, int player) void DoXEA1PAnalog(int idx, int player) { - string NX = string.Format("P{0} Stick X", player); - string NY = string.Format("P{0} Stick Y", player); - string NZ = string.Format("P{0} Stick Z", player); + string NX = $"P{player} Stick X"; + string NY = $"P{player} Stick Y"; + string NZ = $"P{player} Stick Z"; ControllerDef.FloatControls.Add(NX); ControllerDef.FloatControls.Add(NY); ControllerDef.FloatControls.Add(NZ); diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GenDbgHlp.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GenDbgHlp.cs index 39487cfc7d7..115a5fdc7a2 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GenDbgHlp.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GenDbgHlp.cs @@ -203,10 +203,7 @@ public int CompareTo(Symbol other) return (int)this.addr - (int)other.addr; } - public override string ToString() - { - return string.Format("0x{0:X8} {1} ({2})", (int)addr, name, section); - } + public override string ToString() => $"0x{(int)addr:X8} {name} ({section})"; } diff --git a/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs b/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs index 55157f7abef..327518e6672 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs @@ -73,7 +73,7 @@ public PSP(CoreComm comm, string isopath) void LogCallbackFunc(char type, string message) { - debugmsgs.Enqueue(string.Format("PSP: {0} {1}", type, message)); + debugmsgs.Enqueue($"PSP: {type} {message}"); } void LogFlush() { diff --git a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.ITraceable.cs b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.ITraceable.cs index 00d0fc8e26c..c29e954164d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.ITraceable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.ITraceable.cs @@ -24,15 +24,12 @@ public void ShockTraceCallback(IntPtr opaque, uint PC, uint inst, string dis) foreach (var r in regs) { if (r.Key != "pc") - sb.Append( - string.Format("{0}:{1} ", - r.Key, - r.Value.Value.ToHexString(r.Value.BitSize / 4))); + sb.Append($"{r.Key}:{r.Value.Value.ToHexString(r.Value.BitSize / 4)} "); } Tracer.Put(new TraceInfo { - Disassembly = string.Format("{0:X8}: {1:X8} {2}", PC, inst, dis.PadRight(30)), + Disassembly = $"{PC:X8}: {inst:X8} {dis.PadRight(30)}", RegisterInfo = sb.ToString().Trim() }); } diff --git a/BizHawk.Emulation.Cores/CoreInventory.cs b/BizHawk.Emulation.Cores/CoreInventory.cs index 9f5a5aa9055..3d3fb53257c 100644 --- a/BizHawk.Emulation.Cores/CoreInventory.cs +++ b/BizHawk.Emulation.Cores/CoreInventory.cs @@ -32,12 +32,12 @@ public Core(string Name, Type Type, ConstructorInfo CTor) string pname = p.Name.ToLowerInvariant(); Type expectedtype; if (!paramtypes.TryGetValue(pname, out expectedtype)) - throw new InvalidOperationException(string.Format("Unexpected parameter name {0} in constructor for {1}", p.Name, Type)); + throw new InvalidOperationException($"Unexpected parameter name {p.Name} in constructor for {Type}"); // disabling the typecheck here doesn't really hurt anything, because the Invoke call will still catch any forbidden casts // it does allow us to write "MySettingsType settings" instead of "object settings" // if (expectedtype != p.ParameterType) - // throw new InvalidOperationException(string.Format("Unexpected type mismatch in parameter {0} in constructor for {1}", p.Name, Type)); + // throw new InvalidOperationException($"Unexpected type mismatch in parameter {p.Name} in constructor for {Type}"); parammap.Add(pname, i); } } diff --git a/BizHawk.Emulation.Cores/Libretro/LibretroCore_Description.cs b/BizHawk.Emulation.Cores/Libretro/LibretroCore_Description.cs index 1ea0cb00164..8c7adf477c9 100644 --- a/BizHawk.Emulation.Cores/Libretro/LibretroCore_Description.cs +++ b/BizHawk.Emulation.Cores/Libretro/LibretroCore_Description.cs @@ -48,9 +48,6 @@ public class VariableDescription public string[] Options; public string DefaultOption { get { return Options[0]; } } - public override string ToString() - { - return string.Format("{0} ({1}) = ({2})", Name, Description, string.Join("|", Options)); - } + public override string ToString() => $"{Name} ({Description}) = ({string.Join("|", Options)})"; } } \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/Libretro/LibretroCore_InputCallbacks.cs b/BizHawk.Emulation.Cores/Libretro/LibretroCore_InputCallbacks.cs index 5f9ded0a896..45e3dbca7a6 100644 --- a/BizHawk.Emulation.Cores/Libretro/LibretroCore_InputCallbacks.cs +++ b/BizHawk.Emulation.Cores/Libretro/LibretroCore_InputCallbacks.cs @@ -216,16 +216,16 @@ public short CB_InputState(uint port, uint device, uint index, uint id) } } - private bool GetButton(uint pnum, string type, string button) - { - string key = string.Format("P{0} {1} {2}", pnum, type, button); - bool b = _controller.IsPressed(key); - if (b == true) - { - return true; //debugging placeholder - } - else return false; - } + private bool GetButton(uint pnum, string type, string button) + { + string key = $"P{pnum} {type} {button}"; + bool b = _controller.IsPressed(key); + if (b == true) + { + return true; //debugging placeholder + } + else return false; + } } } diff --git a/BizHawk.Emulation.Cores/Waterbox/ElfRunner.cs b/BizHawk.Emulation.Cores/Waterbox/ElfRunner.cs index 000d7629951..2cc89ec24f5 100644 --- a/BizHawk.Emulation.Cores/Waterbox/ElfRunner.cs +++ b/BizHawk.Emulation.Cores/Waterbox/ElfRunner.cs @@ -170,7 +170,7 @@ private void PrintTopSavableSymbols() .Where(s => s.PointedSection != null && (s.PointedSection.Flags & SectionFlags.Writable) != 0) .OrderByDescending(s => s.Size) .Take(30) - .Select(s => string.Format("{0} size {1}", s.Name, s.Size))) + .Select(s => $"{s.Name} size {s.Size}")) { Console.WriteLine(text); } diff --git a/BizHawk.Emulation.Cores/Waterbox/Heap.cs b/BizHawk.Emulation.Cores/Waterbox/Heap.cs index 26eb9529727..eb7a09c22ed 100644 --- a/BizHawk.Emulation.Cores/Waterbox/Heap.cs +++ b/BizHawk.Emulation.Cores/Waterbox/Heap.cs @@ -45,7 +45,7 @@ private ulong EnsureAlignment(int align) ulong newused = ((Used - 1) | (ulong)(align - 1)) + 1; if (newused > Memory.Size) { - throw new InvalidOperationException(string.Format("Failed to meet alignment {0} on heap {1}", align, Name)); + throw new InvalidOperationException($"Failed to meet alignment {align} on heap {Name}"); } return newused; } @@ -55,13 +55,13 @@ private ulong EnsureAlignment(int align) public ulong Allocate(ulong size, int align) { if (Sealed) - throw new InvalidOperationException(string.Format("Attempt made to allocate from sealed heap {0}", Name)); + throw new InvalidOperationException($"Attempt made to allocate from sealed heap {Name}"); ulong allocstart = EnsureAlignment(align); ulong newused = allocstart + size; if (newused > Memory.Size) { - throw new InvalidOperationException(string.Format("Failed to allocate {0} bytes from heap {1}", size, Name)); + throw new InvalidOperationException($"Failed to allocate {size} bytes from heap {Name}"); } ulong ret = Memory.Start + allocstart; Memory.Protect(Memory.Start + Used, newused - Used, MemoryBlock.Protection.RW); @@ -80,7 +80,7 @@ public void Seal() } else { - throw new InvalidOperationException(string.Format("Attempt to reseal heap {0}", Name)); + throw new InvalidOperationException($"Attempt to reseal heap {Name}"); } } @@ -105,16 +105,16 @@ public void LoadStateBinary(BinaryReader br) var name = br.ReadString(); if (name != Name) // probable cause: internal error - throw new InvalidOperationException(string.Format("Name did not match for heap {0}", Name)); + throw new InvalidOperationException($"Name did not match for heap {Name}"); var used = br.ReadUInt64(); if (used > Memory.Size) - throw new InvalidOperationException(string.Format("Heap {0} used {1} larger than available {2}", Name, used, Memory.Size)); + throw new InvalidOperationException($"Heap {Name} used {used} larger than available {Memory.Size}"); if (!Sealed) { var hash = br.ReadBytes(Memory.XorHash.Length); if (!hash.SequenceEqual(Memory.XorHash)) { - throw new InvalidOperationException(string.Format("Hash did not match for heap {0}. Is this the same rom with the same SyncSettings?", Name)); + throw new InvalidOperationException($"Hash did not match for heap {Name}. Is this the same rom with the same SyncSettings?"); } var usedAligned = WaterboxUtils.AlignUp(used); @@ -129,7 +129,7 @@ public void LoadStateBinary(BinaryReader br) var hash = br.ReadBytes(_hash.Length); if (!hash.SequenceEqual(_hash)) { - throw new InvalidOperationException(string.Format("Hash did not match for heap {0}. Is this the same rom with the same SyncSettings?", Name)); + throw new InvalidOperationException($"Hash did not match for heap {Name}. Is this the same rom with the same SyncSettings?"); } } } diff --git a/BizHawk.Emulation.Cores/Waterbox/PeRunner.cs b/BizHawk.Emulation.Cores/Waterbox/PeRunner.cs index d81aac84be3..0fe94e85b1a 100644 --- a/BizHawk.Emulation.Cores/Waterbox/PeRunner.cs +++ b/BizHawk.Emulation.Cores/Waterbox/PeRunner.cs @@ -100,7 +100,7 @@ private void PopulateVtable(string moduleName, ICollection entries, IntP var ptr = imports.Resolve(e); if (ptr == IntPtr.Zero) { - var s = string.Format("Trapped on unimplemented function {0}:{1}", moduleName, e); + var s = $"Trapped on unimplemented function {moduleName}:{e}"; Action del = () => { Console.WriteLine(s); From b37ced84cba6546f4b2a670f59136cab28b75623 Mon Sep 17 00:00:00 2001 From: James Groom Date: Thu, 4 Apr 2019 11:57:36 +1000 Subject: [PATCH 3/4] Use string.Join --- .../CPUs/MOS 6502X/MOS6502X.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs index 35aef41ce4b..842724dfe6e 100644 --- a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs +++ b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs @@ -71,9 +71,12 @@ public TraceInfo State(bool disassemble = true) return new TraceInfo { Disassembly = $"{PC:X4}: {rawbytes,-9} {disasm} ".PadRight(32), - RegisterInfo = string.Format( - "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, + RegisterInfo = string.Join(" ", + $"A:{A:X2}", + $"X:{X:X2}", + $"Y:{Y:X2}", + $"SP:{S:X2}", + $"P:{P:X2}", string.Concat( FlagN ? "N" : "n", FlagV ? "V" : "v", @@ -82,9 +85,11 @@ public TraceInfo State(bool disassemble = true) FlagD ? "D" : "d", FlagI ? "I" : "i", FlagZ ? "Z" : "z", - FlagC ? "C" : "c"), - !RDY ? "R" : "r", - ext_ppu_cycle) + FlagC ? "C" : "c", +// !RDY ? "R" : "r", + ), + $"Cy:{TotalExecutedCycles}", + $"PPU-Cy:{ext_ppu_cycle}") }; } From 8f5ecdf15754c8d08109a0031d86453e902a482a Mon Sep 17 00:00:00 2001 From: James Groom Date: Thu, 4 Apr 2019 12:00:13 +1000 Subject: [PATCH 4/4] Remove trailing comma in vararg --- BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs index 842724dfe6e..ea9be7b972f 100644 --- a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs +++ b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs @@ -85,8 +85,8 @@ public TraceInfo State(bool disassemble = true) FlagD ? "D" : "d", FlagI ? "I" : "i", FlagZ ? "Z" : "z", - FlagC ? "C" : "c", -// !RDY ? "R" : "r", + FlagC ? "C" : "c" +// !RDY ? "R" : "r" ), $"Cy:{TotalExecutedCycles}", $"PPU-Cy:{ext_ppu_cycle}")