diff --git a/BizHawk.Emulation.Cores/CPUs/68000/Instructions/BitArithemetic.cs b/BizHawk.Emulation.Cores/CPUs/68000/Instructions/BitArithemetic.cs index df3e3608e4..1533864d2a 100644 --- a/BizHawk.Emulation.Cores/CPUs/68000/Instructions/BitArithemetic.cs +++ b/BizHawk.Emulation.Cores/CPUs/68000/Instructions/BitArithemetic.cs @@ -1,6 +1,4 @@ -using System; - -namespace BizHawk.Emulation.Cores.Components.M68000 +namespace BizHawk.Emulation.Cores.Components.M68000 { partial class MC68000 { diff --git a/BizHawk.Emulation.Cores/CPUs/ARM/Darm.cs b/BizHawk.Emulation.Cores/CPUs/ARM/Darm.cs index 18e7a1c33d..d1d4e1da45 100644 --- a/BizHawk.Emulation.Cores/CPUs/ARM/Darm.cs +++ b/BizHawk.Emulation.Cores/CPUs/ARM/Darm.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Text; using System.Runtime.InteropServices; diff --git a/BizHawk.Emulation.Cores/CPUs/CP1610/CP1610.Execute.cs b/BizHawk.Emulation.Cores/CPUs/CP1610/CP1610.Execute.cs index f949ae3952..949c406206 100644 --- a/BizHawk.Emulation.Cores/CPUs/CP1610/CP1610.Execute.cs +++ b/BizHawk.Emulation.Cores/CPUs/CP1610/CP1610.Execute.cs @@ -181,8 +181,7 @@ namespace BizHawk.Emulation.Cores.Components.CP1610 bool FlagD_prev = FlagD; opcode = ReadMemoryWrapper(RegisterPC++, false) & 0x3FF; - if (TraceCallback != null) - TraceCallback(CP1610State()); + TraceCallback?.Invoke(CP1610State()); if (MemoryCallbacks != null) { diff --git a/BizHawk.Emulation.Cores/CPUs/CP1610/CP1610.cs b/BizHawk.Emulation.Cores/CPUs/CP1610/CP1610.cs index 70605cc81e..a23eaaf38c 100644 --- a/BizHawk.Emulation.Cores/CPUs/CP1610/CP1610.cs +++ b/BizHawk.Emulation.Cores/CPUs/CP1610/CP1610.cs @@ -26,13 +26,7 @@ namespace BizHawk.Emulation.Cores.Components.CP1610 set => Register[7] = value; } - public string TraceHeader - { - get - { - return "CP1610: PC, machine code, mnemonic, operands, flags (SCZOID)"; - } - } + public string TraceHeader => "CP1610: PC, machine code, mnemonic, operands, flags (SCZOID)"; public Action TraceCallback; public IMemoryCallbackSystem MemoryCallbacks { get; set; } diff --git a/BizHawk.Emulation.Cores/CPUs/HuC6280/CDLOpcodes.cs b/BizHawk.Emulation.Cores/CPUs/HuC6280/CDLOpcodes.cs index e8c5c59cfb..1a8d86f79f 100644 --- a/BizHawk.Emulation.Cores/CPUs/HuC6280/CDLOpcodes.cs +++ b/BizHawk.Emulation.Cores/CPUs/HuC6280/CDLOpcodes.cs @@ -1,4 +1,4 @@ -using System; + // Do not modify this file directly! This is GENERATED code. // Please open the CpuCoreGenerator solution and make your modifications there. diff --git a/BizHawk.Emulation.Cores/CPUs/HuC6280/HuC6280.cs b/BizHawk.Emulation.Cores/CPUs/HuC6280/HuC6280.cs index dee3c642a8..d5f8a3b295 100644 --- a/BizHawk.Emulation.Cores/CPUs/HuC6280/HuC6280.cs +++ b/BizHawk.Emulation.Cores/CPUs/HuC6280/HuC6280.cs @@ -1,7 +1,4 @@ using System; -using System.Globalization; -using System.IO; - using BizHawk.Common; using BizHawk.Emulation.Common; @@ -264,10 +261,7 @@ namespace BizHawk.Emulation.Cores.Components.H6280 return (ushort)(ReadMemory(address) | (ReadMemory(highAddress) << 8)); } - public string TraceHeader - { - get { return "HuC6280: PC, machine code, mnemonic, operands, registers (A, X, Y, P, SP, Cy), flags (NVTBDIZC)"; } - } + public string TraceHeader => "HuC6280: PC, machine code, mnemonic, operands, registers (A, X, Y, P, SP, Cy), flags (NVTBDIZC)"; public TraceInfo State() { diff --git a/BizHawk.Emulation.Cores/CPUs/HuC6280/HuC6280_CDL.cs b/BizHawk.Emulation.Cores/CPUs/HuC6280/HuC6280_CDL.cs index da943670ed..86430df8c2 100644 --- a/BizHawk.Emulation.Cores/CPUs/HuC6280/HuC6280_CDL.cs +++ b/BizHawk.Emulation.Cores/CPUs/HuC6280/HuC6280_CDL.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; using System.IO; using BizHawk.Emulation.Common; @@ -73,7 +71,7 @@ namespace BizHawk.Emulation.Cores.Components.H6280 public string Name; public int Offs; public int VOffs; // if non-zero, specifies a larger potential offset - public int MaxOffs { get { return Math.Max(Offs, VOffs); } } + public int MaxOffs => Math.Max(Offs, VOffs); } public MemMapping[] Mappings; // = new MemMapping[256]; diff --git a/BizHawk.Emulation.Cores/CPUs/HuC6280/IDisassemblable.cs b/BizHawk.Emulation.Cores/CPUs/HuC6280/IDisassemblable.cs index dc8d843407..c08ca33cbc 100644 --- a/BizHawk.Emulation.Cores/CPUs/HuC6280/IDisassemblable.cs +++ b/BizHawk.Emulation.Cores/CPUs/HuC6280/IDisassemblable.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Collections.Generic; using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Components.H6280 @@ -14,10 +11,7 @@ namespace BizHawk.Emulation.Cores.Components.H6280 set { } } - public string PCRegisterName - { - get { return "PC"; } - } + public string PCRegisterName => "PC"; public IEnumerable AvailableCpus { diff --git a/BizHawk.Emulation.Cores/CPUs/Intel8048/Execute.cs b/BizHawk.Emulation.Cores/CPUs/Intel8048/Execute.cs index b2d1e7f3d0..f1283adfd9 100644 --- a/BizHawk.Emulation.Cores/CPUs/Intel8048/Execute.cs +++ b/BizHawk.Emulation.Cores/CPUs/Intel8048/Execute.cs @@ -1,5 +1,3 @@ -using System; - namespace BizHawk.Emulation.Cores.Components.I8048 { public partial class I8048 diff --git a/BizHawk.Emulation.Cores/CPUs/Intel8048/I8048.cs b/BizHawk.Emulation.Cores/CPUs/Intel8048/I8048.cs index 244431faf3..7454e14f4c 100644 --- a/BizHawk.Emulation.Cores/CPUs/Intel8048/I8048.cs +++ b/BizHawk.Emulation.Cores/CPUs/Intel8048/I8048.cs @@ -160,10 +160,10 @@ namespace BizHawk.Emulation.Cores.Components.I8048 // do nothing break; case OP: - // Read the opcode of the next instruction - if (OnExecFetch != null) OnExecFetch(PC); - if (TraceCallback != null) TraceCallback(State()); - if (CDLCallback != null) CDLCallback(PC, eCDLogMemFlags.FetchFirst); + // Read the opcode of the next instruction + OnExecFetch?.Invoke(PC); + TraceCallback?.Invoke(State()); + CDLCallback?.Invoke(PC, eCDLogMemFlags.FetchFirst); FetchInstruction(ReadMemory(Regs[PC])); Regs[ALU2] = (ushort)(Regs[PC] & 0x800); Regs[PC] = (ushort)(((Regs[PC] + 1) & 0x7FF) | Regs[ALU2]); @@ -259,8 +259,8 @@ namespace BizHawk.Emulation.Cores.Components.I8048 else { Regs[reg_d_ad] = (ushort)((reg_h_ad << 8) | Regs[reg_l_ad]); - } - break; + } + break; case CLC: FlagC = false; break; @@ -437,12 +437,12 @@ namespace BizHawk.Emulation.Cores.Components.I8048 if (++irq_pntr == IRQS) { - // then regular IRQ + // then regular IRQ if (IRQPending && IntEn && INT_MSTR) { IRQPending = false; - if (TraceCallback != null) { TraceCallback(new TraceInfo { Disassembly = "====IRQ====", RegisterInfo = "" }); } + TraceCallback?.Invoke(new TraceInfo { Disassembly = "====IRQ====", RegisterInfo = "" }); IRQ_(0); IRQCallback(); @@ -452,7 +452,7 @@ namespace BizHawk.Emulation.Cores.Components.I8048 { TIRQPending = false; - if (TraceCallback != null) { TraceCallback(new TraceInfo { Disassembly = "====TIRQ====", RegisterInfo = "" }); } + TraceCallback?.Invoke(new TraceInfo { Disassembly = "====TIRQ====", RegisterInfo = "" }); IRQ_(1); IRQCallback(); @@ -511,10 +511,7 @@ namespace BizHawk.Emulation.Cores.Components.I8048 public Action TraceCallback; - public string TraceHeader - { - get { return "MC6809: PC, machine code, mnemonic, operands, registers (A, B, X, Y, US, SP, DP, CC), Cy, flags (CAFBIFTTR)"; } - } + public string TraceHeader => "MC6809: PC, machine code, mnemonic, operands, registers (A, B, X, Y, US, SP, DP, CC), Cy, flags (CAFBIFTTR)"; public TraceInfo State(bool disassemble = true) { diff --git a/BizHawk.Emulation.Cores/CPUs/Intel8048/Operations.cs b/BizHawk.Emulation.Cores/CPUs/Intel8048/Operations.cs index 7a9dd1687e..bec22ab306 100644 --- a/BizHawk.Emulation.Cores/CPUs/Intel8048/Operations.cs +++ b/BizHawk.Emulation.Cores/CPUs/Intel8048/Operations.cs @@ -1,5 +1,4 @@ -using System; -using BizHawk.Common.NumberExtensions; +using BizHawk.Common.NumberExtensions; namespace BizHawk.Emulation.Cores.Components.I8048 { @@ -17,7 +16,7 @@ namespace BizHawk.Emulation.Cores.Components.I8048 public void Write_Func(ushort dest, ushort src) { - if (CDLCallback != null) CDLCallback(Regs[dest], eCDLogMemFlags.Write | eCDLogMemFlags.Data); + CDLCallback?.Invoke(Regs[dest], eCDLogMemFlags.Write | eCDLogMemFlags.Data); WriteMemory(Regs[dest], (byte)Regs[src]); } diff --git a/BizHawk.Emulation.Cores/CPUs/Intel8048/Registers.cs b/BizHawk.Emulation.Cores/CPUs/Intel8048/Registers.cs index 7ea2c5e9c1..19a80a5a25 100644 --- a/BizHawk.Emulation.Cores/CPUs/Intel8048/Registers.cs +++ b/BizHawk.Emulation.Cores/CPUs/Intel8048/Registers.cs @@ -1,5 +1,3 @@ -using System; - namespace BizHawk.Emulation.Cores.Components.I8048 { public partial class I8048 diff --git a/BizHawk.Emulation.Cores/CPUs/LR35902/Execute.cs b/BizHawk.Emulation.Cores/CPUs/LR35902/Execute.cs index e728986aab..0dd55e28cd 100644 --- a/BizHawk.Emulation.Cores/CPUs/LR35902/Execute.cs +++ b/BizHawk.Emulation.Cores/CPUs/LR35902/Execute.cs @@ -1,5 +1,3 @@ -using System; - namespace BizHawk.Emulation.Cores.Components.LR35902 { public partial class LR35902 diff --git a/BizHawk.Emulation.Cores/CPUs/LR35902/Interrupts.cs b/BizHawk.Emulation.Cores/CPUs/LR35902/Interrupts.cs index 8390dad785..55c0f7a661 100644 --- a/BizHawk.Emulation.Cores/CPUs/LR35902/Interrupts.cs +++ b/BizHawk.Emulation.Cores/CPUs/LR35902/Interrupts.cs @@ -1,5 +1,3 @@ -using System; - namespace BizHawk.Emulation.Cores.Components.LR35902 { public partial class LR35902 diff --git a/BizHawk.Emulation.Cores/CPUs/LR35902/LR35902.cs b/BizHawk.Emulation.Cores/CPUs/LR35902/LR35902.cs index f004385440..427b12779e 100644 --- a/BizHawk.Emulation.Cores/CPUs/LR35902/LR35902.cs +++ b/BizHawk.Emulation.Cores/CPUs/LR35902/LR35902.cs @@ -1,7 +1,4 @@ using System; -using System.Globalization; -using System.IO; - using BizHawk.Common; using BizHawk.Emulation.Common; using BizHawk.Common.NumberExtensions; @@ -145,14 +142,11 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 { interrupts_enabled = false; - if (TraceCallback != null) + TraceCallback?.Invoke(new TraceInfo { - TraceCallback(new TraceInfo - { - Disassembly = "====IRQ====", - RegisterInfo = "" - }); - } + Disassembly = "====IRQ====", + RegisterInfo = "" + }); // call interrupt processor // lowest bit set is highest priority @@ -160,9 +154,9 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 } else { - if (OnExecFetch != null) OnExecFetch(RegPC); + OnExecFetch?.Invoke(RegPC); if (TraceCallback != null && !CB_prefix) TraceCallback(State()); - if (CDLCallback != null) CDLCallback(RegPC, eCDLogMemFlags.FetchFirst); + CDLCallback?.Invoke(RegPC, eCDLogMemFlags.FetchFirst); FetchInstruction(ReadMemory(RegPC++)); } instr_pntr = 0; @@ -296,14 +290,11 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 { interrupts_enabled = false; - if (TraceCallback != null) + TraceCallback?.Invoke(new TraceInfo { - TraceCallback(new TraceInfo - { - Disassembly = "====IRQ====", - RegisterInfo = "" - }); - } + Disassembly = "====IRQ====", + RegisterInfo = "" + }); halted = false; if (is_GBC) @@ -321,23 +312,20 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 } } else - { + { // call interrupt processor INTERRUPT_(); Halt_bug_3 = false; - } + } } else if (temp) { // even if interrupt servicing is disabled, any interrupt flag raised still resumes execution - if (TraceCallback != null) + TraceCallback?.Invoke(new TraceInfo { - TraceCallback(new TraceInfo - { - Disassembly = "====un-halted====", - RegisterInfo = "" - }); - } + Disassembly = "====un-halted====", + RegisterInfo = "" + }); halted = false; if (is_GBC) @@ -345,9 +333,9 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 // extra 4 cycles for GBC if (Halt_bug_3) { - if (OnExecFetch != null) OnExecFetch(RegPC); + OnExecFetch?.Invoke(RegPC); if (TraceCallback != null && !CB_prefix) TraceCallback(State()); - if (CDLCallback != null) CDLCallback(RegPC, eCDLogMemFlags.FetchFirst); + CDLCallback?.Invoke(RegPC, eCDLogMemFlags.FetchFirst); RegPC++; FetchInstruction(ReadMemory(RegPC)); @@ -356,18 +344,20 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 } else { - cur_instr = new ushort[] - {IDLE, - IDLE, - IDLE, - OP }; + cur_instr = new[] + { + IDLE, + IDLE, + IDLE, + OP + }; } } else { - if (OnExecFetch != null) OnExecFetch(RegPC); + OnExecFetch?.Invoke(RegPC); if (TraceCallback != null && !CB_prefix) TraceCallback(State()); - if (CDLCallback != null) CDLCallback(RegPC, eCDLogMemFlags.FetchFirst); + CDLCallback?.Invoke(RegPC, eCDLogMemFlags.FetchFirst); if (Halt_bug_3) { @@ -379,8 +369,8 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 else { FetchInstruction(ReadMemory(RegPC++)); - } - } + } + } } else { @@ -431,19 +421,16 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 stop_time--; if (stop_time == 0) { - if (TraceCallback != null) + TraceCallback?.Invoke(new TraceInfo { - TraceCallback(new TraceInfo - { - Disassembly = "====un-stop====", - RegisterInfo = "" - }); - } + Disassembly = "====un-stop====", + RegisterInfo = "" + }); stopped = false; - if (OnExecFetch != null) OnExecFetch(RegPC); + OnExecFetch?.Invoke(RegPC); if (TraceCallback != null && !CB_prefix) TraceCallback(State()); - if (CDLCallback != null) CDLCallback(RegPC, eCDLogMemFlags.FetchFirst); + CDLCallback?.Invoke(RegPC, eCDLogMemFlags.FetchFirst); FetchInstruction(ReadMemory(RegPC++)); instr_pntr = 0; @@ -461,19 +448,16 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 } else if (interrupt_src.Bit(4)) // button pressed, not actually an interrupt though { - if (TraceCallback != null) + TraceCallback?.Invoke(new TraceInfo { - TraceCallback(new TraceInfo - { - Disassembly = "====un-stop====", - RegisterInfo = "" - }); - } + Disassembly = "====un-stop====", + RegisterInfo = "" + }); stopped = false; - if (OnExecFetch != null) OnExecFetch(RegPC); + OnExecFetch?.Invoke(RegPC); if (TraceCallback != null && !CB_prefix) TraceCallback(State()); - if (CDLCallback != null) CDLCallback(RegPC, eCDLogMemFlags.FetchFirst); + CDLCallback?.Invoke(RegPC, eCDLogMemFlags.FetchFirst); FetchInstruction(ReadMemory(RegPC++)); instr_pntr = 0; @@ -482,11 +466,13 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 else { instr_pntr = 0; - cur_instr = new ushort[] - {IDLE, - IDLE, - IDLE, - STOP }; + cur_instr = new[] + { + IDLE, + IDLE, + IDLE, + STOP + }; } break; case PREFIX: @@ -499,9 +485,9 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 ADDS_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++], cur_instr[instr_pntr++], cur_instr[instr_pntr++]); break; case OP_G: - if (OnExecFetch != null) OnExecFetch(RegPC); - if (TraceCallback != null) TraceCallback(State()); - if (CDLCallback != null) CDLCallback(RegPC, eCDLogMemFlags.FetchFirst); + OnExecFetch?.Invoke(RegPC); + TraceCallback?.Invoke(State()); + CDLCallback?.Invoke(RegPC, eCDLogMemFlags.FetchFirst); FetchInstruction(ReadMemory(RegPC)); // note no increment @@ -557,10 +543,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 public Action TraceCallback; - public string TraceHeader - { - get { return "LR35902: PC, machine code, mnemonic, operands, registers (A, F, B, C, D, E, H, L, SP), Cy, flags (ZNHCI)"; } - } + public string TraceHeader => "LR35902: PC, machine code, mnemonic, operands, registers (A, F, B, C, D, E, H, L, SP), Cy, flags (ZNHCI)"; public TraceInfo State(bool disassemble = true) { diff --git a/BizHawk.Emulation.Cores/CPUs/LR35902/NewDisassembler.cs b/BizHawk.Emulation.Cores/CPUs/LR35902/NewDisassembler.cs index e13ec667fb..03db38e01c 100644 --- a/BizHawk.Emulation.Cores/CPUs/LR35902/NewDisassembler.cs +++ b/BizHawk.Emulation.Cores/CPUs/LR35902/NewDisassembler.cs @@ -526,8 +526,10 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 public static string Disassemble(ushort addr, Func reader, out ushort size) { ushort origaddr = addr; - List bytes = new List(); - bytes.Add(reader(addr++)); + var bytes = new List + { + reader(addr++) + }; string result = table[bytes[0]]; if (bytes[0] == 0xcb) @@ -573,7 +575,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 offs -= 256; result = result.Replace("r8", $"{(ushort)(addr + offs):X4}h"); } - StringBuilder ret = new StringBuilder(); + var ret = new StringBuilder(); ret.Append($"{origaddr:X4}: "); foreach (var b in bytes) ret.Append($"{b:X2} "); diff --git a/BizHawk.Emulation.Cores/CPUs/LR35902/Operations.cs b/BizHawk.Emulation.Cores/CPUs/LR35902/Operations.cs index de12d12826..aeb84545d0 100644 --- a/BizHawk.Emulation.Cores/CPUs/LR35902/Operations.cs +++ b/BizHawk.Emulation.Cores/CPUs/LR35902/Operations.cs @@ -1,5 +1,4 @@ using BizHawk.Common.NumberExtensions; -using System; namespace BizHawk.Emulation.Cores.Components.LR35902 { @@ -16,7 +15,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 Regs[dest] = ReadMemory(addr); } - // speical read for POP AF that always clears the lower 4 bits of F + // special read for POP AF that always clears the lower 4 bits of F public void Read_Func_F(ushort dest, ushort src_l, ushort src_h) { Regs[dest] = (ushort)(ReadMemory((ushort)(Regs[src_l] | (Regs[src_h]) << 8)) & 0xF0); @@ -25,7 +24,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 public void Write_Func(ushort dest_l, ushort dest_h, ushort src) { ushort addr = (ushort)(Regs[dest_l] | (Regs[dest_h]) << 8); - if (CDLCallback != null) CDLCallback(addr, eCDLogMemFlags.Write | eCDLogMemFlags.Data); + CDLCallback?.Invoke(addr, eCDLogMemFlags.Write | eCDLogMemFlags.Data); WriteMemory(addr, (byte)Regs[src]); } @@ -141,7 +140,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 FlagZ = Regs[src] == 0; FlagH = false; - FlagN = false; + FlagN = false; } public void SRA_Func(ushort src) diff --git a/BizHawk.Emulation.Cores/CPUs/LR35902/Registers.cs b/BizHawk.Emulation.Cores/CPUs/LR35902/Registers.cs index b89a3cad14..3692dedeff 100644 --- a/BizHawk.Emulation.Cores/CPUs/LR35902/Registers.cs +++ b/BizHawk.Emulation.Cores/CPUs/LR35902/Registers.cs @@ -1,6 +1,3 @@ -using System.Runtime.InteropServices; -using System; - namespace BizHawk.Emulation.Cores.Components.LR35902 { public partial class LR35902 diff --git a/BizHawk.Emulation.Cores/CPUs/LR35902/Tables_Direct.cs b/BizHawk.Emulation.Cores/CPUs/LR35902/Tables_Direct.cs index c70c745211..07a1bd8ee7 100644 --- a/BizHawk.Emulation.Cores/CPUs/LR35902/Tables_Direct.cs +++ b/BizHawk.Emulation.Cores/CPUs/LR35902/Tables_Direct.cs @@ -1,51 +1,58 @@ -using System; - namespace BizHawk.Emulation.Cores.Components.LR35902 { public partial class LR35902 { - // this contains the vectors of instrcution operations + // this contains the vectors of instruction operations // NOTE: This list is NOT confirmed accurate for each individual cycle private void NOP_() { - cur_instr = new ushort[] - {IDLE, - IDLE, - HALT_CHK, - OP }; + cur_instr = new[] + { + IDLE, + IDLE, + HALT_CHK, + OP + }; } - private void INC_16(ushort src_l, ushort src_h) + private void INC_16(ushort srcL, ushort srcH) { - cur_instr = new ushort[] - {IDLE, - IDLE, - IDLE, - INC16, src_l, src_h, - IDLE, - IDLE, - HALT_CHK, - OP }; + cur_instr = new[] + { + IDLE, + IDLE, + IDLE, + INC16, + srcL, + srcH, + IDLE, + IDLE, + HALT_CHK, + OP + }; } - private void DEC_16(ushort src_l, ushort src_h) { - cur_instr = new ushort[] - {IDLE, - IDLE, - IDLE, - DEC16, src_l, src_h, - IDLE, - IDLE, - HALT_CHK, - OP }; + cur_instr = new[] + { + IDLE, + IDLE, + IDLE, + DEC16, + src_l, + src_h, + IDLE, + IDLE, + HALT_CHK, + OP + }; } private void ADD_16(ushort dest_l, ushort dest_h, ushort src_l, ushort src_h) { - cur_instr = new ushort[] + cur_instr = new[] {IDLE, IDLE, IDLE, @@ -58,7 +65,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 private void REG_OP(ushort operation, ushort dest, ushort src) { - cur_instr = new ushort[] + cur_instr = new[] {operation, dest, src, IDLE, HALT_CHK, @@ -67,7 +74,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 private void STOP_() { - cur_instr = new ushort[] + cur_instr = new[] {RD, Z, PCl, PCh, INC16, PCl, PCh, IDLE, @@ -82,7 +89,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 { // in GBC mode, the HALT bug is worked around by simply adding a NOP // so it just takes 4 cycles longer to reach the next instruction - cur_instr = new ushort[] + cur_instr = new[] {IDLE, IDLE, IDLE, @@ -92,7 +99,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 { // if interrupts are disabled, // a glitchy decrement to the program counter happens { - cur_instr = new ushort[] + cur_instr = new[] {IDLE, IDLE, IDLE, @@ -104,7 +111,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 { cur_instr = new ushort[] { - IDLE, + IDLE, HALT_CHK, IDLE, HALT, 0 }; @@ -139,7 +146,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 } else { - cur_instr = new ushort[] + cur_instr = new[] {IDLE, IDLE, IDLE, @@ -155,7 +162,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 { if (cond) { - cur_instr = new ushort[] + cur_instr = new[] {IDLE, IDLE, IDLE, @@ -175,7 +182,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 } else { - cur_instr = new ushort[] + cur_instr = new[] {IDLE, IDLE, IDLE, @@ -193,7 +200,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 private void RET_() { - cur_instr = new ushort[] + cur_instr = new[] {IDLE, IDLE, IDLE, @@ -214,7 +221,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 private void RETI_() { - cur_instr = new ushort[] + cur_instr = new[] {IDLE, IDLE, IDLE, @@ -238,7 +245,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 { if (cond) { - cur_instr = new ushort[] + cur_instr = new[] {IDLE, IDLE, IDLE, @@ -262,7 +269,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 } else { - cur_instr = new ushort[] + cur_instr = new[] {IDLE, IDLE, IDLE, @@ -278,7 +285,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 { if (cond) { - cur_instr = new ushort[] + cur_instr = new[] {IDLE, IDLE, IDLE, @@ -306,7 +313,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 } else { - cur_instr = new ushort[] + cur_instr = new[] {IDLE, IDLE, IDLE, @@ -324,7 +331,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 private void INT_OP(ushort operation, ushort src) { - cur_instr = new ushort[] + cur_instr = new[] {operation, src, IDLE, HALT_CHK, @@ -333,7 +340,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 private void BIT_OP(ushort operation, ushort bit, ushort src) { - cur_instr = new ushort[] + cur_instr = new[] {operation, bit, src, IDLE, HALT_CHK, @@ -342,7 +349,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 private void PUSH_(ushort src_l, ushort src_h) { - cur_instr = new ushort[] + cur_instr = new[] {IDLE, IDLE, IDLE, @@ -368,7 +375,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 { if (src_l != F) { - cur_instr = new ushort[] + cur_instr = new[] {IDLE, IDLE, IDLE, @@ -384,7 +391,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 } else { - cur_instr = new ushort[] + cur_instr = new[] {IDLE, IDLE, IDLE, @@ -423,7 +430,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 private void PREFIX_() { - cur_instr = new ushort[] + cur_instr = new[] {PREFIX, IDLE, IDLE, @@ -432,7 +439,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 private void DI_() { - cur_instr = new ushort[] + cur_instr = new[] {DI, IDLE, HALT_CHK, @@ -441,7 +448,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 private void EI_() { - cur_instr = new ushort[] + cur_instr = new[] {EI, IDLE, HALT_CHK, @@ -450,7 +457,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 private void JP_HL() { - cur_instr = new ushort[] + cur_instr = new[] {TR, PCl, L, TR, PCh, H, HALT_CHK, @@ -480,7 +487,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 private void LD_SP_HL() { - cur_instr = new ushort[] + cur_instr = new[] {IDLE, IDLE, IDLE, @@ -510,7 +517,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902 private void JAM_() { - cur_instr = new ushort[] + cur_instr = new[] {JAM, IDLE, IDLE, diff --git a/BizHawk.Emulation.Cores/CPUs/MC6800/Execute.cs b/BizHawk.Emulation.Cores/CPUs/MC6800/Execute.cs index 69f8c8cd93..5b00ff3098 100644 --- a/BizHawk.Emulation.Cores/CPUs/MC6800/Execute.cs +++ b/BizHawk.Emulation.Cores/CPUs/MC6800/Execute.cs @@ -1,5 +1,3 @@ -using System; - namespace BizHawk.Emulation.Cores.Components.MC6800 { public partial class MC6800 diff --git a/BizHawk.Emulation.Cores/CPUs/MC6800/Indexed_Modes.cs b/BizHawk.Emulation.Cores/CPUs/MC6800/Indexed_Modes.cs index efa5c9b045..91892ef5f5 100644 --- a/BizHawk.Emulation.Cores/CPUs/MC6800/Indexed_Modes.cs +++ b/BizHawk.Emulation.Cores/CPUs/MC6800/Indexed_Modes.cs @@ -1,5 +1,3 @@ -using System; - namespace BizHawk.Emulation.Cores.Components.MC6800 { public partial class MC6800 diff --git a/BizHawk.Emulation.Cores/CPUs/MC6800/MC6800.cs b/BizHawk.Emulation.Cores/CPUs/MC6800/MC6800.cs index f30c0312c6..3535d5cedc 100644 --- a/BizHawk.Emulation.Cores/CPUs/MC6800/MC6800.cs +++ b/BizHawk.Emulation.Cores/CPUs/MC6800/MC6800.cs @@ -153,10 +153,10 @@ namespace BizHawk.Emulation.Cores.Components.MC6800 // do nothing break; case OP: - // Read the opcode of the next instruction - if (OnExecFetch != null) OnExecFetch(PC); - if (TraceCallback != null) TraceCallback(State()); - if (CDLCallback != null) CDLCallback(PC, eCDLogMemFlags.FetchFirst); + // Read the opcode of the next instruction + OnExecFetch?.Invoke(PC); + TraceCallback?.Invoke(State()); + CDLCallback?.Invoke(PC, eCDLogMemFlags.FetchFirst); FetchInstruction(ReadMemory(Regs[PC]++)); instr_pntr = 0; irq_pntr = -1; @@ -433,7 +433,7 @@ namespace BizHawk.Emulation.Cores.Components.MC6800 irq_pntr = -1; IRQS = 3; - if (TraceCallback != null) { TraceCallback(new TraceInfo { Disassembly = "====CWAI NMI====", RegisterInfo = "" }); } + TraceCallback?.Invoke(new TraceInfo { Disassembly = "====CWAI NMI====", RegisterInfo = "" }); } else if (IRQPending && !FlagI) { @@ -446,7 +446,7 @@ namespace BizHawk.Emulation.Cores.Components.MC6800 irq_pntr = -1; IRQS = 3; - if (TraceCallback != null) { TraceCallback(new TraceInfo { Disassembly = "====CWAI IRQ====", RegisterInfo = "" }); } + TraceCallback?.Invoke(new TraceInfo { Disassembly = "====CWAI IRQ====", RegisterInfo = "" }); } else { @@ -465,23 +465,23 @@ namespace BizHawk.Emulation.Cores.Components.MC6800 { NMIPending = false; - if (TraceCallback != null) { TraceCallback(new TraceInfo { Disassembly = "====NMI====", RegisterInfo = "" }); } + TraceCallback?.Invoke(new TraceInfo { Disassembly = "====NMI====", RegisterInfo = "" }); NMI_(); NMICallback(); instr_pntr = irq_pntr = 0; } - // then regular IRQ + // then regular IRQ else if (IRQPending && !FlagI) { IRQPending = false; - if (TraceCallback != null) { TraceCallback(new TraceInfo { Disassembly = "====IRQ====", RegisterInfo = "" }); } + TraceCallback?.Invoke(new TraceInfo { Disassembly = "====IRQ====", RegisterInfo = "" }); IRQ_(); IRQCallback(); instr_pntr = irq_pntr = 0; - } + } // otherwise start the next instruction else { @@ -498,10 +498,7 @@ namespace BizHawk.Emulation.Cores.Components.MC6800 public Action TraceCallback; - public string TraceHeader - { - get { return "MC6809: PC, machine code, mnemonic, operands, registers (A, B, X, SP, CC), Cy, flags (EHINZVC)"; } - } + public string TraceHeader => "MC6809: PC, machine code, mnemonic, operands, registers (A, B, X, SP, CC), Cy, flags (EHINZVC)"; public TraceInfo State(bool disassemble = true) { @@ -523,7 +520,7 @@ namespace BizHawk.Emulation.Cores.Components.MC6800 FlagN ? "N" : "n", FlagZ ? "Z" : "z", FlagV ? "V" : "v", - FlagC ? "C" : "c" + FlagC ? "C" : "c" ) }; } diff --git a/BizHawk.Emulation.Cores/CPUs/MC6800/OP_Tables.cs b/BizHawk.Emulation.Cores/CPUs/MC6800/OP_Tables.cs index 3df5ca9277..177e8a7257 100644 --- a/BizHawk.Emulation.Cores/CPUs/MC6800/OP_Tables.cs +++ b/BizHawk.Emulation.Cores/CPUs/MC6800/OP_Tables.cs @@ -1,6 +1,3 @@ -using System; -using BizHawk.Common.NumberExtensions; - namespace BizHawk.Emulation.Cores.Components.MC6800 { public partial class MC6800 diff --git a/BizHawk.Emulation.Cores/CPUs/MC6800/Operations.cs b/BizHawk.Emulation.Cores/CPUs/MC6800/Operations.cs index ad345c2f73..ea74430924 100644 --- a/BizHawk.Emulation.Cores/CPUs/MC6800/Operations.cs +++ b/BizHawk.Emulation.Cores/CPUs/MC6800/Operations.cs @@ -1,5 +1,4 @@ -using System; -using BizHawk.Common.NumberExtensions; +using BizHawk.Common.NumberExtensions; namespace BizHawk.Emulation.Cores.Components.MC6800 { @@ -31,33 +30,33 @@ namespace BizHawk.Emulation.Cores.Components.MC6800 public void Write_Func(ushort dest, ushort src) { - if (CDLCallback != null) CDLCallback(Regs[dest], eCDLogMemFlags.Write | eCDLogMemFlags.Data); + CDLCallback?.Invoke(Regs[dest], eCDLogMemFlags.Write | eCDLogMemFlags.Data); WriteMemory(Regs[dest], (byte)Regs[src]); } public void Write_Dec_Lo_Func(ushort dest, ushort src) { - if (CDLCallback != null) CDLCallback(Regs[dest], eCDLogMemFlags.Write | eCDLogMemFlags.Data); + CDLCallback?.Invoke(Regs[dest], eCDLogMemFlags.Write | eCDLogMemFlags.Data); WriteMemory(Regs[dest], (byte)Regs[src]); Regs[dest] -= 1; } public void Write_Dec_HI_Func(ushort dest, ushort src) { - if (CDLCallback != null) CDLCallback(Regs[dest], eCDLogMemFlags.Write | eCDLogMemFlags.Data); + CDLCallback?.Invoke(Regs[dest], eCDLogMemFlags.Write | eCDLogMemFlags.Data); WriteMemory(Regs[dest], (byte)(Regs[src] >> 8)); Regs[dest] -= 1; } public void Write_Hi_Func(ushort dest, ushort src) { - if (CDLCallback != null) CDLCallback(Regs[dest], eCDLogMemFlags.Write | eCDLogMemFlags.Data); + CDLCallback?.Invoke(Regs[dest], eCDLogMemFlags.Write | eCDLogMemFlags.Data); WriteMemory(Regs[dest], (byte)(Regs[src] >> 8)); } public void Write_Hi_Inc_Func(ushort dest, ushort src) { - if (CDLCallback != null) CDLCallback(Regs[dest], eCDLogMemFlags.Write | eCDLogMemFlags.Data); + CDLCallback?.Invoke(Regs[dest], eCDLogMemFlags.Write | eCDLogMemFlags.Data); WriteMemory(Regs[dest], (byte)(Regs[src] >> 8)); Regs[dest]++; } diff --git a/BizHawk.Emulation.Cores/CPUs/MC6800/Registers.cs b/BizHawk.Emulation.Cores/CPUs/MC6800/Registers.cs index 7bad8ec25e..6c598ca7f5 100644 --- a/BizHawk.Emulation.Cores/CPUs/MC6800/Registers.cs +++ b/BizHawk.Emulation.Cores/CPUs/MC6800/Registers.cs @@ -1,5 +1,3 @@ -using System; - namespace BizHawk.Emulation.Cores.Components.MC6800 { public partial class MC6800 diff --git a/BizHawk.Emulation.Cores/CPUs/MC6809/Execute.cs b/BizHawk.Emulation.Cores/CPUs/MC6809/Execute.cs index 021443fa10..fd70853604 100644 --- a/BizHawk.Emulation.Cores/CPUs/MC6809/Execute.cs +++ b/BizHawk.Emulation.Cores/CPUs/MC6809/Execute.cs @@ -1,5 +1,3 @@ -using System; - namespace BizHawk.Emulation.Cores.Components.MC6809 { public partial class MC6809 diff --git a/BizHawk.Emulation.Cores/CPUs/MC6809/Indexed_Modes.cs b/BizHawk.Emulation.Cores/CPUs/MC6809/Indexed_Modes.cs index 8d33c383da..f64ac8d9bb 100644 --- a/BizHawk.Emulation.Cores/CPUs/MC6809/Indexed_Modes.cs +++ b/BizHawk.Emulation.Cores/CPUs/MC6809/Indexed_Modes.cs @@ -1,5 +1,3 @@ -using System; - namespace BizHawk.Emulation.Cores.Components.MC6809 { public partial class MC6809 diff --git a/BizHawk.Emulation.Cores/CPUs/MC6809/MC6809.cs b/BizHawk.Emulation.Cores/CPUs/MC6809/MC6809.cs index 325a3479f2..3c81f73097 100644 --- a/BizHawk.Emulation.Cores/CPUs/MC6809/MC6809.cs +++ b/BizHawk.Emulation.Cores/CPUs/MC6809/MC6809.cs @@ -162,10 +162,10 @@ namespace BizHawk.Emulation.Cores.Components.MC6809 // do nothing break; case OP: - // Read the opcode of the next instruction - if (OnExecFetch != null) OnExecFetch(PC); - if (TraceCallback != null) TraceCallback(State()); - if (CDLCallback != null) CDLCallback(PC, eCDLogMemFlags.FetchFirst); + // Read the opcode of the next instruction + OnExecFetch?.Invoke(PC); + TraceCallback?.Invoke(State()); + CDLCallback?.Invoke(PC, eCDLogMemFlags.FetchFirst); FetchInstruction(ReadMemory(Regs[PC]++)); instr_pntr = 0; irq_pntr = -1; @@ -473,7 +473,7 @@ namespace BizHawk.Emulation.Cores.Components.MC6809 irq_pntr = -1; IRQS = 3; - if (TraceCallback != null) { TraceCallback(new TraceInfo { Disassembly = "====CWAI NMI====", RegisterInfo = "" }); } + TraceCallback?.Invoke(new TraceInfo { Disassembly = "====CWAI NMI====", RegisterInfo = "" }); } else if (FIRQPending && !FlagF) { @@ -486,7 +486,7 @@ namespace BizHawk.Emulation.Cores.Components.MC6809 irq_pntr = -1; IRQS = 3; - if (TraceCallback != null) { TraceCallback(new TraceInfo { Disassembly = "====CWAI FIRQ====", RegisterInfo = "" }); } + TraceCallback?.Invoke(new TraceInfo { Disassembly = "====CWAI FIRQ====", RegisterInfo = "" }); } else if (IRQPending && !FlagI) { @@ -499,7 +499,7 @@ namespace BizHawk.Emulation.Cores.Components.MC6809 irq_pntr = -1; IRQS = 3; - if (TraceCallback != null) { TraceCallback(new TraceInfo { Disassembly = "====CWAI IRQ====", RegisterInfo = "" }); } + TraceCallback?.Invoke(new TraceInfo { Disassembly = "====CWAI IRQ====", RegisterInfo = "" }); } else { @@ -522,7 +522,7 @@ namespace BizHawk.Emulation.Cores.Components.MC6809 irq_pntr = -1; IRQS = 3; - if (TraceCallback != null) { TraceCallback(new TraceInfo { Disassembly = "====SYNC NMI====", RegisterInfo = "" }); } + TraceCallback?.Invoke(new TraceInfo { Disassembly = "====SYNC NMI====", RegisterInfo = "" }); } else if (FIRQPending) { @@ -537,11 +537,11 @@ namespace BizHawk.Emulation.Cores.Components.MC6809 irq_pntr = -1; IRQS = 3; - if (TraceCallback != null) { TraceCallback(new TraceInfo { Disassembly = "====SYNC FIRQ====", RegisterInfo = "" }); } + TraceCallback?.Invoke(new TraceInfo { Disassembly = "====SYNC FIRQ====", RegisterInfo = "" }); } else { - FIRQPending = false; + FIRQPending = false; IN_SYNC = false; IRQS = 2; instr_pntr = irq_pntr = 0; @@ -563,7 +563,7 @@ namespace BizHawk.Emulation.Cores.Components.MC6809 irq_pntr = -1; IRQS = 3; - if (TraceCallback != null) { TraceCallback(new TraceInfo { Disassembly = "====SYNC IRQ====", RegisterInfo = "" }); } + TraceCallback?.Invoke(new TraceInfo { Disassembly = "====SYNC IRQ====", RegisterInfo = "" }); } else { @@ -593,7 +593,7 @@ namespace BizHawk.Emulation.Cores.Components.MC6809 { NMIPending = false; - if (TraceCallback != null) { TraceCallback(new TraceInfo { Disassembly = "====NMI====", RegisterInfo = "" }); } + TraceCallback?.Invoke(new TraceInfo { Disassembly = "====NMI====", RegisterInfo = "" }); NMI_(); NMICallback(); @@ -604,23 +604,22 @@ namespace BizHawk.Emulation.Cores.Components.MC6809 { FIRQPending = false; - if (TraceCallback != null) { TraceCallback(new TraceInfo { Disassembly = "====FIRQ====", RegisterInfo = "" }); } + TraceCallback?.Invoke(new TraceInfo { Disassembly = "====FIRQ====", RegisterInfo = "" }); FIRQ_(); FIRQCallback(); instr_pntr = irq_pntr = 0; } - // then regular IRQ + // then regular IRQ else if (IRQPending && !FlagI) { IRQPending = false; - if (TraceCallback != null) { TraceCallback(new TraceInfo { Disassembly = "====IRQ====", RegisterInfo = "" }); } - + TraceCallback?.Invoke(new TraceInfo { Disassembly = "====IRQ====", RegisterInfo = "" }); IRQ_(); IRQCallback(); instr_pntr = irq_pntr = 0; - } + } // otherwise start the next instruction else { @@ -637,10 +636,7 @@ namespace BizHawk.Emulation.Cores.Components.MC6809 public Action TraceCallback; - public string TraceHeader - { - get { return "MC6809: PC, machine code, mnemonic, operands, registers (A, B, X, Y, US, SP, DP, CC), Cy, flags (EFHINZVC)"; } - } + public string TraceHeader => "MC6809: PC, machine code, mnemonic, operands, registers (A, B, X, Y, US, SP, DP, CC), Cy, flags (EFHINZVC)"; public TraceInfo State(bool disassemble = true) { @@ -667,7 +663,7 @@ namespace BizHawk.Emulation.Cores.Components.MC6809 FlagN ? "N" : "n", FlagZ ? "Z" : "z", FlagV ? "V" : "v", - FlagC ? "C" : "c" + FlagC ? "C" : "c" ) }; } diff --git a/BizHawk.Emulation.Cores/CPUs/MC6809/OP_Tables.cs b/BizHawk.Emulation.Cores/CPUs/MC6809/OP_Tables.cs index 404ef05039..519758f904 100644 --- a/BizHawk.Emulation.Cores/CPUs/MC6809/OP_Tables.cs +++ b/BizHawk.Emulation.Cores/CPUs/MC6809/OP_Tables.cs @@ -1,4 +1,3 @@ -using System; using BizHawk.Common.NumberExtensions; namespace BizHawk.Emulation.Cores.Components.MC6809 diff --git a/BizHawk.Emulation.Cores/CPUs/MC6809/Operations.cs b/BizHawk.Emulation.Cores/CPUs/MC6809/Operations.cs index e731ee336d..2a03682fc9 100644 --- a/BizHawk.Emulation.Cores/CPUs/MC6809/Operations.cs +++ b/BizHawk.Emulation.Cores/CPUs/MC6809/Operations.cs @@ -1,5 +1,4 @@ -using System; -using BizHawk.Common.NumberExtensions; +using BizHawk.Common.NumberExtensions; namespace BizHawk.Emulation.Cores.Components.MC6809 { @@ -31,40 +30,40 @@ namespace BizHawk.Emulation.Cores.Components.MC6809 public void Write_Func(ushort dest, ushort src) { - if (CDLCallback != null) CDLCallback(Regs[dest], eCDLogMemFlags.Write | eCDLogMemFlags.Data); + CDLCallback?.Invoke(Regs[dest], eCDLogMemFlags.Write | eCDLogMemFlags.Data); WriteMemory(Regs[dest], (byte)Regs[src]); } public void Write_Dec_Lo_Func(ushort dest, ushort src) { - if (CDLCallback != null) CDLCallback(Regs[dest], eCDLogMemFlags.Write | eCDLogMemFlags.Data); + CDLCallback?.Invoke(Regs[dest], eCDLogMemFlags.Write | eCDLogMemFlags.Data); WriteMemory(Regs[dest], (byte)Regs[src]); Regs[dest] -= 1; } public void Write_Dec_HI_Func(ushort dest, ushort src) { - if (CDLCallback != null) CDLCallback(Regs[dest], eCDLogMemFlags.Write | eCDLogMemFlags.Data); + CDLCallback?.Invoke(Regs[dest], eCDLogMemFlags.Write | eCDLogMemFlags.Data); WriteMemory(Regs[dest], (byte)(Regs[src] >> 8)); Regs[dest] -= 1; } public void Write_Hi_Func(ushort dest, ushort src) { - if (CDLCallback != null) CDLCallback(Regs[dest], eCDLogMemFlags.Write | eCDLogMemFlags.Data); + CDLCallback?.Invoke(Regs[dest], eCDLogMemFlags.Write | eCDLogMemFlags.Data); WriteMemory(Regs[dest], (byte)(Regs[src] >> 8)); } public void Write_Hi_Inc_Func(ushort dest, ushort src) { - if (CDLCallback != null) CDLCallback(Regs[dest], eCDLogMemFlags.Write | eCDLogMemFlags.Data); + CDLCallback?.Invoke(Regs[dest], eCDLogMemFlags.Write | eCDLogMemFlags.Data); WriteMemory(Regs[dest], (byte)(Regs[src] >> 8)); Regs[dest]++; } public void Write_Lo_Inc_Func(ushort dest, ushort src) { - if (CDLCallback != null) CDLCallback(Regs[dest], eCDLogMemFlags.Write | eCDLogMemFlags.Data); + CDLCallback?.Invoke(Regs[dest], eCDLogMemFlags.Write | eCDLogMemFlags.Data); WriteMemory(Regs[dest], (byte)Regs[src]); Regs[dest]++; } @@ -126,7 +125,7 @@ namespace BizHawk.Emulation.Cores.Components.MC6809 FlagZ = Regs[dest] == 0; FlagV = false; - FlagN = Regs[dest] > 0x7FFF; + FlagN = Regs[dest] > 0x7FFF; } // for LEAX/Y, zero flag can be effected, but not for U/S @@ -134,7 +133,7 @@ namespace BizHawk.Emulation.Cores.Components.MC6809 { Regs[dest] = Regs[src]; - if ((dest == X) || (dest == Y)) + if (dest == X || dest == Y) { FlagZ = Regs[dest] == 0; } diff --git a/BizHawk.Emulation.Cores/CPUs/MC6809/Registers.cs b/BizHawk.Emulation.Cores/CPUs/MC6809/Registers.cs index 6d82219e93..0184e17ef5 100644 --- a/BizHawk.Emulation.Cores/CPUs/MC6809/Registers.cs +++ b/BizHawk.Emulation.Cores/CPUs/MC6809/Registers.cs @@ -1,5 +1,3 @@ -using System; - namespace BizHawk.Emulation.Cores.Components.MC6809 { public partial class MC6809 diff --git a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/Disassembler.cs b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/Disassembler.cs index 00bb78dc08..929c2a6108 100644 --- a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/Disassembler.cs +++ b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/Disassembler.cs @@ -20,19 +20,13 @@ namespace BizHawk.Emulation.Cores.Components.M6502 public string Cpu { - get - { - return "6502"; - } + get => "6502"; set { } } - public string PCRegisterName - { - get { return "PC"; } - } + public string PCRegisterName => "PC"; public IEnumerable AvailableCpus { diff --git a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/Execute.cs b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/Execute.cs index d0cd3cab16..4cd7c8e69a 100644 --- a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/Execute.cs +++ b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/Execute.cs @@ -1,7 +1,6 @@ //http://nesdev.parodius.com/6502_cpu.txt using System; -using BizHawk.Common; using BizHawk.Common.NumberExtensions; using BizHawk.Emulation.Common; @@ -561,14 +560,11 @@ namespace BizHawk.Emulation.Cores.Components.M6502 interrupt_pending = false; if (NMI) { - if (TraceCallback != null) + TraceCallback?.Invoke(new TraceInfo { - TraceCallback(new TraceInfo - { - Disassembly = "====NMI====", - RegisterInfo = "" - }); - } + Disassembly = "====NMI====", + RegisterInfo = "" + }); ea = NMIVector; opcode = VOP_NMI; @@ -577,16 +573,14 @@ namespace BizHawk.Emulation.Cores.Components.M6502 ExecuteOneRetry(); return; } - else if (IRQ && !my_iflag) + + if (IRQ && !my_iflag) { - if (TraceCallback != null) + TraceCallback?.Invoke(new TraceInfo { - TraceCallback(new TraceInfo - { - Disassembly = "====IRQ====", - RegisterInfo = "" - }); - } + Disassembly = "====IRQ====", + RegisterInfo = "" + }); ea = IRQVector; opcode = VOP_IRQ; mi = 0; @@ -606,8 +600,7 @@ namespace BizHawk.Emulation.Cores.Components.M6502 if (debug) Console.WriteLine(State()); branch_irq_hack = false; _link.OnExecFetch(PC); - if (TraceCallback != null) - TraceCallback(State()); + TraceCallback?.Invoke(State()); opcode = _link.ReadMemory(PC++); mi = -1; } diff --git a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs index da33d3c1dc..c70228b197 100644 --- a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs +++ b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs @@ -138,7 +138,7 @@ namespace BizHawk.Emulation.Cores.Components.M6502 }; } - public bool AtStart { get { return opcode == VOP_Fetch1 || Microcode[opcode][mi] >= Uop.End; } } + public bool AtStart => opcode == VOP_Fetch1 || Microcode[opcode][mi] >= Uop.End; public TraceInfo TraceState() { diff --git a/BizHawk.Emulation.Cores/CPUs/W65816/Disassembler.cs b/BizHawk.Emulation.Cores/CPUs/W65816/Disassembler.cs index e2f9e2e905..2c8810d971 100644 --- a/BizHawk.Emulation.Cores/CPUs/W65816/Disassembler.cs +++ b/BizHawk.Emulation.Cores/CPUs/W65816/Disassembler.cs @@ -28,18 +28,13 @@ namespace BizHawk.Emulation.Cores.Components.W65816 get { yield return "W65816"; } } - - public string PCRegisterName - { - get { return "PC"; } - } + public string PCRegisterName => "PC"; public string Disassemble(MemoryDomain m, uint addr, out int length) { byte P = 0; //TODO - user preferences somehow... return disassemblerCpu.Disassemble(addr, m.PeekByte, ref P, out length); } - } class W65816 diff --git a/BizHawk.Emulation.Cores/CPUs/Z80A/Execute.cs b/BizHawk.Emulation.Cores/CPUs/Z80A/Execute.cs index edc4823150..891de7fa79 100644 --- a/BizHawk.Emulation.Cores/CPUs/Z80A/Execute.cs +++ b/BizHawk.Emulation.Cores/CPUs/Z80A/Execute.cs @@ -1,5 +1,3 @@ -using System; - namespace BizHawk.Emulation.Cores.Components.Z80A { public partial class Z80A @@ -8,7 +6,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80A private int EI_pending; // ZXHawk needs to be able to read this for zx-state snapshot export - public int EIPending { get { return EI_pending; } } + public int EIPending => EI_pending; public const ushort CBpre = 0; public const ushort EXTDpre = 1; diff --git a/BizHawk.Emulation.Cores/CPUs/Z80A/NewDisassembler.cs b/BizHawk.Emulation.Cores/CPUs/Z80A/NewDisassembler.cs index 0bb629cbee..8903621584 100644 --- a/BizHawk.Emulation.Cores/CPUs/Z80A/NewDisassembler.cs +++ b/BizHawk.Emulation.Cores/CPUs/Z80A/NewDisassembler.cs @@ -26,7 +26,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80A return format; } - static readonly string[] mnemonics = new string[] + static readonly string[] mnemonics = { "NOP", "LD BC, nn", "LD (BC), A", "INC BC", //0x04 "INC B", "DEC B", "LD B, n", "RLCA", //0x08 @@ -94,7 +94,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80A "CALL M, nn", "[FD]", "CP n", "RST $38", //0x100 }; - static readonly string[] mnemonicsDD = new string[] + static readonly string[] mnemonicsDD = { "NOP", "LD BC, nn", "LD (BC), A", "INC BC", //0x04 "INC B", "DEC B", "LD B, n", "RLCA", //0x08 @@ -162,7 +162,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80A "CALL M, nn", "[!!DD FD!!]", "CP n", "RST $38", //0x100 }; - static readonly string[] mnemonicsFD = new string[] + static readonly string[] mnemonicsFD = { "NOP", "LD BC, nn", "LD (BC), A", "INC BC", //0x04 "INC B", "DEC B", "LD B, n", "RLCA", //0x08 @@ -230,7 +230,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80A "CALL M, nn", "[!FD FD!]", "CP n", "RST $38", //0x100 }; - static readonly string[] mnemonicsDDCB = new string[] + static readonly string[] mnemonicsDDCB = { "RLC (IX+d)->B", "RLC (IX+d)->C", "RLC (IX+d)->D", "RLC (IX+d)->E", "RLC (IX+d)->H", "RLC (IX+d)->L", "RLC (IX+d)", "RLC (IX+d)->A", "RRC (IX+d)->B", "RRC (IX+d)->C", "RRC (IX+d)->D", "RRC (IX+d)->E", "RRC (IX+d)->H", "RRC (IX+d)->L", "RRC (IX+d)", "RRC (IX+d)->A", @@ -266,7 +266,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80A "SET 7 (IX+d)->B", "SET 7 (IX+d)->C", "SET 7 (IX+d)->D", "SET 7 (IX+d)->E", "SET 7 (IX+d)->H", "SET 7 (IX+d)->L", "SET 7 (IX+d)", "SET 7 (IX+d)->A", }; - static readonly string[] mnemonicsFDCB = new string[] + static readonly string[] mnemonicsFDCB = { "RLC (IY+d)->B", "RLC (IY+d)->C", "RLC (IY+d)->D", "RLC (IY+d)->E", "RLC (IY+d)->H", "RLC (IY+d)->L", "RLC (IY+d)", "RLC (IY+d)->A", "RRC (IY+d)->B", "RRC (IY+d)->C", "RRC (IY+d)->D", "RRC (IY+d)->E", "RRC (IY+d)->H", "RRC (IY+d)->L", "RRC (IY+d)", "RRC (IY+d)->A", @@ -302,7 +302,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80A "SET 7 (IY+d)->B", "SET 7 (IY+d)->C", "SET 7 (IY+d)->D", "SET 7 (IY+d)->E", "SET 7 (IY+d)->H", "SET 7 (IY+d)->L", "SET 7 (IY+d)", "SET 7 (IY+d)->A", }; - static readonly string[] mnemonicsCB = new string[] + static readonly string[] mnemonicsCB = { "RLC B", "RLC C", "RLC D", "RLC E", "RLC H", "RLC L", "RLC (HL)", "RLC A", "RRC B", "RRC C", "RRC D", "RRC E", "RRC H", "RRC L", "RRC (HL)", "RRC A", @@ -338,7 +338,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80A "SET 7, B", "SET 7, C", "SET 7, D", "SET 7, E", "SET 7, H", "SET 7, L", "SET 7, (HL)", "SET 7, A", }; - static readonly string[] mnemonicsED = new string[] + static readonly string[] mnemonicsED = { "NOP", "NOP", "NOP", "NOP", "NOP", "NOP", "NOP", "NOP", "NOP", "NOP", "NOP", "NOP", "NOP", "NOP", "NOP", "NOP", "NOP", "NOP", "NOP", "NOP", "NOP", "NOP", "NOP", "NOP", "NOP", "NOP", "NOP", "NOP", "NOP", "NOP", "NOP", "NOP", @@ -439,10 +439,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80A set { } } - public string PCRegisterName - { - get { return "PC"; } - } + public string PCRegisterName => "PC"; public IEnumerable AvailableCpus { diff --git a/BizHawk.Emulation.Cores/CPUs/Z80A/Operations.cs b/BizHawk.Emulation.Cores/CPUs/Z80A/Operations.cs index e2a6280737..f4b0752520 100644 --- a/BizHawk.Emulation.Cores/CPUs/Z80A/Operations.cs +++ b/BizHawk.Emulation.Cores/CPUs/Z80A/Operations.cs @@ -1,5 +1,4 @@ using BizHawk.Common.NumberExtensions; -using System; namespace BizHawk.Emulation.Cores.Components.Z80A { diff --git a/BizHawk.Emulation.Cores/CPUs/Z80A/Registers.cs b/BizHawk.Emulation.Cores/CPUs/Z80A/Registers.cs index 24b3a49915..e6d50db681 100644 --- a/BizHawk.Emulation.Cores/CPUs/Z80A/Registers.cs +++ b/BizHawk.Emulation.Cores/CPUs/Z80A/Registers.cs @@ -1,6 +1,3 @@ -using System.Runtime.InteropServices; -using System; - namespace BizHawk.Emulation.Cores.Components.Z80A { public partial class Z80A diff --git a/BizHawk.Emulation.Cores/CPUs/Z80A/Tables_Direct.cs b/BizHawk.Emulation.Cores/CPUs/Z80A/Tables_Direct.cs index d8ea27b445..af2cf4187f 100644 --- a/BizHawk.Emulation.Cores/CPUs/Z80A/Tables_Direct.cs +++ b/BizHawk.Emulation.Cores/CPUs/Z80A/Tables_Direct.cs @@ -1,5 +1,3 @@ -using System; - namespace BizHawk.Emulation.Cores.Components.Z80A { public partial class Z80A diff --git a/BizHawk.Emulation.Cores/CPUs/Z80A/Z80A.cs b/BizHawk.Emulation.Cores/CPUs/Z80A/Z80A.cs index 7912aae0f3..8f7cc33938 100644 --- a/BizHawk.Emulation.Cores/CPUs/Z80A/Z80A.cs +++ b/BizHawk.Emulation.Cores/CPUs/Z80A/Z80A.cs @@ -1,8 +1,5 @@ using System; using System.Collections.Generic; -using System.Globalization; -using System.IO; - using BizHawk.Common; using BizHawk.Emulation.Common; using BizHawk.Common.NumberExtensions; @@ -306,8 +303,8 @@ namespace BizHawk.Emulation.Cores.Components.Z80A break; case OP_F: // Read the opcode of the next instruction - if (OnExecFetch != null) OnExecFetch(RegPC); - if (TraceCallback != null) TraceCallback(State()); + OnExecFetch?.Invoke(RegPC); + TraceCallback?.Invoke(State()); opcode = FetchMemory(RegPC++); FetchInstruction(); @@ -778,10 +775,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80A { nonMaskableInterruptPending = false; - if (TraceCallback != null) - { - TraceCallback(new TraceInfo { Disassembly = "====NMI====", RegisterInfo = "" }); - } + TraceCallback?.Invoke(new TraceInfo { Disassembly = "====NMI====", RegisterInfo = "" }); iff2 = iff1; iff1 = false; @@ -802,10 +796,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80A iff1 = iff2 = false; EI_pending = 0; - if (TraceCallback != null) - { - TraceCallback(new TraceInfo { Disassembly = "====IRQ====", RegisterInfo = "" }); - } + TraceCallback?.Invoke(new TraceInfo { Disassembly = "====IRQ====", RegisterInfo = "" }); switch (interruptMode) { @@ -858,10 +849,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80A // tracer stuff public Action TraceCallback; - public string TraceHeader - { - get { return "Z80A: PC, machine code, mnemonic, operands, registers (AF, BC, DE, HL, IX, IY, SP, Cy), flags (CNP3H5ZS)"; } - } + public string TraceHeader => "Z80A: PC, machine code, mnemonic, operands, registers (AF, BC, DE, HL, IX, IY, SP, Cy), flags (CNP3H5ZS)"; public TraceInfo State(bool disassemble = true) { @@ -906,7 +894,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80A /// /// Optimization method to set BUSRQ - /// + /// private void PopulateBUSRQ(ushort d0 = 0, ushort d1 = 0, ushort d2 = 0, ushort d3 = 0, ushort d4 = 0, ushort d5 = 0, ushort d6 = 0, ushort d7 = 0, ushort d8 = 0, ushort d9 = 0, ushort d10 = 0, ushort d11 = 0, ushort d12 = 0, ushort d13 = 0, ushort d14 = 0, ushort d15 = 0, ushort d16 = 0, ushort d17 = 0, ushort d18 = 0) { @@ -921,7 +909,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80A /// /// Optimization method to set MEMRQ - /// + /// private void PopulateMEMRQ(ushort d0 = 0, ushort d1 = 0, ushort d2 = 0, ushort d3 = 0, ushort d4 = 0, ushort d5 = 0, ushort d6 = 0, ushort d7 = 0, ushort d8 = 0, ushort d9 = 0, ushort d10 = 0, ushort d11 = 0, ushort d12 = 0, ushort d13 = 0, ushort d14 = 0, ushort d15 = 0, ushort d16 = 0, ushort d17 = 0, ushort d18 = 0) { diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.Controllers.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.Controllers.cs index dae5ccb5ed..dfceefa720 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.Controllers.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.Controllers.cs @@ -16,14 +16,16 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC { get { - ControllerDefinition definition = new ControllerDefinition(); - definition.Name = "AmstradCPC Controller"; + var definition = new ControllerDefinition + { + Name = "AmstradCPC Controller" + }; // joysticks - List joys1 = new List + var joys1 = new List { - // P1 Joystick - "P1 Up", "P1 Down", "P1 Left", "P1 Right", "P1 Fire1", "P1 Fire2", "P1 Fire3" + // P1 Joystick + "P1 Up", "P1 Down", "P1 Left", "P1 Right", "P1 Fire1", "P1 Fire2", "P1 Fire3" }; foreach (var s in joys1) @@ -32,10 +34,10 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC definition.CategoryLabels[s] = "J1"; } - List joys2 = new List + var joys2 = new List { - // P2 Joystick - "P2 Up", "P2 Down", "P2 Left", "P2 Right", "P2 Fire", + // P2 Joystick + "P2 Up", "P2 Down", "P2 Left", "P2 Right", "P2 Fire", }; foreach (var s in joys2) @@ -45,25 +47,25 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC } // keyboard - List keys = new List + var keys = new List { - // http://www.cpcwiki.eu/index.php/Programming:Keyboard_scanning - // http://www.cpcwiki.eu/index.php/File:Grimware_cpc464_version3_case_top.jpg - - // Keyboard - row 1 - "Key ESC", "Key 1", "Key 2", "Key 3", "Key 4", "Key 5", "Key 6", "Key 7", "Key 8", "Key 9", "Key 0", "Key Dash", "Key Hat", "Key CLR", "Key DEL", - // Keyboard - row 2 - "Key TAB", "Key Q", "Key W", "Key E", "Key R", "Key T", "Key Y", "Key U", "Key I", "Key O", "Key P", "Key @", "Key LeftBracket", "Key RETURN", - // Keyboard - row 3 - "Key CAPSLOCK", "Key A", "Key S", "Key D", "Key F", "Key G", "Key H", "Key J", "Key K", "Key L", "Key Colon", "Key SemiColon", "Key RightBracket", - // Keyboard - row 4 - "Key SHIFT", "Key Z", "Key X", "Key C", "Key V", "Key B", "Key N", "Key M", "Key Comma", "Key Period", "Key ForwardSlash", "Key BackSlash", - // Keyboard - row 5 - "Key SPACE", "Key CONTROL", - // Keyboard - Cursor - "Key CURUP", "Key CURDOWN", "Key CURLEFT", "Key CURRIGHT", "Key COPY", - // Keyboard - Numpad - "Key NUM0", "Key NUM1", "Key NUM2", "Key NUM3", "Key NUM4", "Key NUM5", "Key NUM6", "Key NUM7", "Key NUM8", "Key NUM9", "Key NUMPERIOD", "KEY ENTER" + // http://www.cpcwiki.eu/index.php/Programming:Keyboard_scanning + // http://www.cpcwiki.eu/index.php/File:Grimware_cpc464_version3_case_top.jpg + + // Keyboard - row 1 + "Key ESC", "Key 1", "Key 2", "Key 3", "Key 4", "Key 5", "Key 6", "Key 7", "Key 8", "Key 9", "Key 0", "Key Dash", "Key Hat", "Key CLR", "Key DEL", + // Keyboard - row 2 + "Key TAB", "Key Q", "Key W", "Key E", "Key R", "Key T", "Key Y", "Key U", "Key I", "Key O", "Key P", "Key @", "Key LeftBracket", "Key RETURN", + // Keyboard - row 3 + "Key CAPSLOCK", "Key A", "Key S", "Key D", "Key F", "Key G", "Key H", "Key J", "Key K", "Key L", "Key Colon", "Key SemiColon", "Key RightBracket", + // Keyboard - row 4 + "Key SHIFT", "Key Z", "Key X", "Key C", "Key V", "Key B", "Key N", "Key M", "Key Comma", "Key Period", "Key ForwardSlash", "Key BackSlash", + // Keyboard - row 5 + "Key SPACE", "Key CONTROL", + // Keyboard - Cursor + "Key CURUP", "Key CURDOWN", "Key CURLEFT", "Key CURRIGHT", "Key COPY", + // Keyboard - Numpad + "Key NUM0", "Key NUM1", "Key NUM2", "Key NUM3", "Key NUM4", "Key NUM5", "Key NUM6", "Key NUM7", "Key NUM8", "Key NUM9", "Key NUMPERIOD", "KEY ENTER" }; foreach (var s in keys) @@ -73,10 +75,10 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC } // Power functions - List power = new List + var power = new List { - // Power functions - "Reset", "Power" + // Power functions + "Reset", "Power" }; foreach (var s in power) @@ -86,10 +88,10 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC } // Datacorder (tape device) - List tape = new List + var tape = new List { - // Tape functions - "Play Tape", "Stop Tape", "RTZ Tape", "Record Tape", "Insert Next Tape", + // Tape functions + "Play Tape", "Stop Tape", "RTZ Tape", "Record Tape", "Insert Next Tape", "Insert Previous Tape", "Next Tape Block", "Prev Tape Block", "Get Tape Status" }; @@ -100,10 +102,10 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC } // Datacorder (tape device) - List disk = new List + var disk = new List { - // Tape functions - "Insert Next Disk", "Insert Previous Disk", /*"Eject Current Disk",*/ "Get Disk Status" + // Tape functions + "Insert Next Disk", "Insert Previous Disk", /*"Eject Current Disk",*/ "Get Disk Status" }; foreach (var s in disk) diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.IEmulator.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.IEmulator.cs index 4b7bf3cb9e..419d113678 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.IEmulator.cs @@ -46,24 +46,11 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC return true; } - public int Frame - { - get - { - if (_machine == null) - return 0; - else - return _machine.FrameCount; - } - } + public int Frame => _machine?.FrameCount ?? 0; public string SystemId => "AmstradCPC"; - private bool deterministicEmulation; - public bool DeterministicEmulation - { - get { return deterministicEmulation; } - } + public bool DeterministicEmulation { get; } public void ResetCounters() { diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.IStatable.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.IStatable.cs index 11a5976645..a676469a48 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.IStatable.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.IStatable.cs @@ -39,9 +39,9 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC if (tmpM != _machineType && _machineType.ToString() != "72") { string msg = "SAVESTATE FAILED TO LOAD!!\n\n"; - msg += "Current Configuration: " + tmpM.ToString(); + msg += "Current Configuration: " + tmpM; msg += "\n"; - msg += "Saved Configuration: " + _machineType.ToString(); + msg += "Saved Configuration: " + _machineType; msg += "\n\n"; msg += "If you wish to load this SaveState ensure that you have the correct machine configuration selected, reboot the core, then try again."; CoreComm.ShowMessage(msg); diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.InputPollable.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.InputPollable.cs index d723fe0dcb..179f05e790 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.InputPollable.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.InputPollable.cs @@ -1,5 +1,4 @@ -using System; -using BizHawk.Emulation.Common; +using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Computers.AmstradCPC { diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.Messaging.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.Messaging.cs index 0619635535..0f18c8a2fc 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.Messaging.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.Messaging.cs @@ -1,5 +1,4 @@ -using System; -using System.Linq; +using System.Linq; using System.Text; namespace BizHawk.Emulation.Cores.Computers.AmstradCPC diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.cs index d55a325c70..52c0acb33a 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.cs @@ -39,18 +39,18 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC PutSyncSettings((AmstradCPCSyncSettings)syncSettings ?? new AmstradCPCSyncSettings()); PutSettings((AmstradCPCSettings)settings ?? new AmstradCPCSettings()); - deterministicEmulation = ((AmstradCPCSyncSettings)syncSettings as AmstradCPCSyncSettings).DeterministicEmulation; + DeterministicEmulation = ((AmstradCPCSyncSettings)syncSettings).DeterministicEmulation; switch (SyncSettings.MachineType) { case MachineType.CPC464: ControllerDefinition = AmstradCPCControllerDefinition; - Init(MachineType.CPC464, _files, ((AmstradCPCSyncSettings)syncSettings as AmstradCPCSyncSettings).AutoStartStopTape, - ((AmstradCPCSyncSettings)syncSettings as AmstradCPCSyncSettings).BorderType); + Init(MachineType.CPC464, _files, ((AmstradCPCSyncSettings)syncSettings).AutoStartStopTape, + ((AmstradCPCSyncSettings)syncSettings).BorderType); break; case MachineType.CPC6128: ControllerDefinition = AmstradCPCControllerDefinition; - Init(MachineType.CPC6128, _files, ((AmstradCPCSyncSettings)syncSettings as AmstradCPCSyncSettings).AutoStartStopTape, ((AmstradCPCSyncSettings)syncSettings as AmstradCPCSyncSettings).BorderType); + Init(MachineType.CPC6128, _files, ((AmstradCPCSyncSettings)syncSettings).AutoStartStopTape, ((AmstradCPCSyncSettings)syncSettings).BorderType); break; default: throw new InvalidOperationException("Machine not yet emulated"); @@ -194,13 +194,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC #region IDriveLight - public bool DriveLightEnabled - { - get - { - return true; - } - } + public bool DriveLightEnabled => true; public bool DriveLightOn { diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Abstraction/IBeeperDevice.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Abstraction/IBeeperDevice.cs index 0572218c95..de19bfe9a2 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Abstraction/IBeeperDevice.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Abstraction/IBeeperDevice.cs @@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC public interface IBeeperDevice { /// - /// Initialisation + /// Initialization /// void Init(int sampleRate, int tStatesPerFrame); diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Abstraction/IFDDHost.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Abstraction/IFDDHost.cs index 3bea240dee..7ae645b750 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Abstraction/IFDDHost.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Abstraction/IFDDHost.cs @@ -7,7 +7,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC public interface IFDDHost { /// - /// The currently inserted diskimage + /// The currently inserted disk image /// FloppyDisk Disk { get; set; } @@ -23,7 +23,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC /// /// Signs whether the current active drive has a disk inserted - /// + /// bool FDD_IsDiskLoaded { get; } } } diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Abstraction/IPSG.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Abstraction/IPSG.cs index f272899598..dcc1826a9f 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Abstraction/IPSG.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Abstraction/IPSG.cs @@ -9,7 +9,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC public interface IPSG : ISoundProvider { /// - /// Initlization routine + /// Initialization routine /// void Init(int sampleRate, int tStatesPerFrame); diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Datacorder/DatacorderDevice.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Datacorder/DatacorderDevice.cs index 4b897adf18..8762b15d37 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Datacorder/DatacorderDevice.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Datacorder/DatacorderDevice.cs @@ -87,8 +87,12 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC { get { - if (_dataBlocks.Count() > 0) { return _currentDataBlockIndex; } - else { return -1; } + if (_dataBlocks.Any()) + { + return _currentDataBlockIndex; + } + + return -1; } set { @@ -105,23 +109,13 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC /// The current position within the current data block /// private int _position = 0; - public int Position - { - get - { - if (_position >= _dataBlocks[_currentDataBlockIndex].DataPeriods.Count) { return 0; } - else { return _position; } - } - } + public int Position => _position >= _dataBlocks[_currentDataBlockIndex].DataPeriods.Count ? 0 : _position; /// /// Signs whether the tape is currently playing or not /// private bool _tapeIsPlaying = false; - public bool TapeIsPlaying - { - get { return _tapeIsPlaying; } - } + public bool TapeIsPlaying => _tapeIsPlaying; /// /// A list of the currently loaded data blocks @@ -811,7 +805,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC #region State Serialization /// - /// Bizhawk state serialization + /// BizHawk state serialization /// public void SyncState(Serializer ser) { diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.FDC.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.FDC.cs index 4f49615b4f..90adce2c70 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.FDC.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.FDC.cs @@ -372,22 +372,13 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC switch (ActiveCommandParams.SectorSize) { case 1: - if (CMD_FLAG_MF) - maxTransferCap = 6656; - else - maxTransferCap = 3840; + maxTransferCap = CMD_FLAG_MF ? 6656 : 3840; break; case 2: - if (CMD_FLAG_MF) - maxTransferCap = 7680; - else - maxTransferCap = 4096; + maxTransferCap = CMD_FLAG_MF ? 7680 : 4096; break; case 3: - if (CMD_FLAG_MF) - maxTransferCap = 8192; - else - maxTransferCap = 4096; + maxTransferCap = CMD_FLAG_MF ? 8192 : 4096; break; } @@ -397,7 +388,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC var mtc = maxTransferCap; // get the current track - var track = ActiveDrive.Disk.DiskTracks.Where(a => a.TrackNumber == ActiveDrive.CurrentTrackID).FirstOrDefault(); + var track = ActiveDrive.Disk.DiskTracks.FirstOrDefault(a => a.TrackNumber == ActiveDrive.CurrentTrackID); if (track == null || track.NumberOfSectors <= 0) { @@ -704,7 +695,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC } // get the current track - var track = ActiveDrive.Disk.DiskTracks.Where(a => a.TrackNumber == ActiveDrive.CurrentTrackID).FirstOrDefault(); + var track = ActiveDrive.Disk.DiskTracks.FirstOrDefault(a => a.TrackNumber == ActiveDrive.CurrentTrackID); if (track == null || track.NumberOfSectors <= 0) { @@ -754,7 +745,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC Status1 = sector.Status1; Status2 = sector.Status2; - // we dont need EN + // we don't need EN UnSetBit(SR1_EN, ref Status1); // invert CM for read deleted data command @@ -994,22 +985,13 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC switch (ActiveCommandParams.SectorSize) { case 1: - if (CMD_FLAG_MF) - maxTransferCap = 6656; - else - maxTransferCap = 3840; + maxTransferCap = CMD_FLAG_MF ? 6656 : 3840; break; case 2: - if (CMD_FLAG_MF) - maxTransferCap = 7680; - else - maxTransferCap = 4096; + maxTransferCap = CMD_FLAG_MF ? 7680 : 4096; break; case 3: - if (CMD_FLAG_MF) - maxTransferCap = 8192; - else - maxTransferCap = 4096; + maxTransferCap = CMD_FLAG_MF ? 8192 : 4096; break; } @@ -1017,7 +999,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC } // get the current track - var track = ActiveDrive.Disk.DiskTracks.Where(a => a.TrackNumber == ActiveDrive.CurrentTrackID).FirstOrDefault(); + var track = ActiveDrive.Disk.DiskTracks.FirstOrDefault(a => a.TrackNumber == ActiveDrive.CurrentTrackID); if (track == null || track.NumberOfSectors <= 0) { @@ -1209,7 +1191,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC break; } - var track = ActiveDrive.Disk.DiskTracks.Where(a => a.TrackNumber == ActiveDrive.CurrentTrackID).FirstOrDefault(); + var track = ActiveDrive.Disk.DiskTracks.FirstOrDefault(a => a.TrackNumber == ActiveDrive.CurrentTrackID); if (track != null && track.NumberOfSectors > 0 && track.TrackNumber != 0xff) { @@ -2539,7 +2521,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC cmdByte = cByte; // lookup the command - var cmd = CommandList.Where(a => a.CommandCode == cmdByte).FirstOrDefault(); + var cmd = CommandList.FirstOrDefault(a => a.CommandCode == cmdByte); if (cmd == null) { diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.FDD.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.FDD.cs index 331ec2a500..a1ec95fdba 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.FDD.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Disk/NECUPD765.FDD.cs @@ -171,18 +171,12 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC /// /// Signs whether the current active drive has a disk inserted /// - public bool FDD_IsDiskLoaded - { - get { return DriveStates[DiskDriveIndex].FDD_IsDiskLoaded; } - } + public bool FDD_IsDiskLoaded => DriveStates[DiskDriveIndex].FDD_IsDiskLoaded; /// /// Returns the disk object from drive 0 /// - public FloppyDisk DiskPointer - { - get { return DriveStates[0].Disk; } - } + public FloppyDisk DiskPointer => DriveStates[0].Disk; public FloppyDisk Disk { get; set; } diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/AmstradGateArray.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/AmstradGateArray.cs index 2aede39139..f12028334b 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/AmstradGateArray.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/AmstradGateArray.cs @@ -6,8 +6,6 @@ using System; using System.Collections; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace BizHawk.Emulation.Cores.Computers.AmstradCPC { @@ -986,10 +984,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC private int _bufferWidth; private int _bufferHeight; - public int BackgroundColor - { - get { return CPCHardwarePalette[0]; } - } + public int BackgroundColor => CPCHardwarePalette[0]; public int VirtualWidth { @@ -1024,10 +1019,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC set { } } - public int VsyncDenominator - { - get { return Z80ClockSpeed; } - } + public int VsyncDenominator => Z80ClockSpeed; public int[] GetVideoBuffer() { @@ -1313,10 +1305,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC Phases.Add(phase); } - public int PhaseCount - { - get { return Phases.Count(); } - } + public int PhaseCount => Phases.Count(); public void Clear(int screenMode) { diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/CRCT_6845.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/CRCT_6845.cs index 61119c3748..3b6b17370e 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/CRCT_6845.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/CRCT_6845.cs @@ -1,7 +1,5 @@ using BizHawk.Common; using BizHawk.Common.NumberExtensions; -using System; -using System.Collections; namespace BizHawk.Emulation.Cores.Computers.AmstradCPC { @@ -98,123 +96,57 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC /// /// The total frame width (in characters) /// - public int FrameWidth - { - get - { - return (int)Regs[HOR_TOTAL] + 1; - } - } + public int FrameWidth => (int)Regs[HOR_TOTAL] + 1; /// /// The total frame height (in scanlines) /// - public int FrameHeight - { - get - { - return ((int)Regs[VER_TOTAL] + 1) * ((int)Regs[MAX_RASTER_ADDR] + 1); - } - } + public int FrameHeight => ((int)Regs[VER_TOTAL] + 1) * ((int)Regs[MAX_RASTER_ADDR] + 1); /// /// The total frame height (in scanlines) /// - public int FrameHeightInChars - { - get - { - return ((int)Regs[VER_TOTAL] + 1); - } - } + public int FrameHeightInChars => ((int)Regs[VER_TOTAL] + 1); /// /// The width of the display area (in characters) /// - public int DisplayWidth - { - get - { - return (int)Regs[HOR_DISPLAYED]; - } - } + public int DisplayWidth => (int)Regs[HOR_DISPLAYED]; /// /// The width of the display area (in scanlines) /// - public int DisplayHeight - { - get - { - return (int)Regs[VER_DISPLAYED] * ((int)Regs[MAX_RASTER_ADDR] + 1); - } - } + public int DisplayHeight => (int)Regs[VER_DISPLAYED] * ((int)Regs[MAX_RASTER_ADDR] + 1); /// /// The width of the display area (in scanlines) /// - public int DisplayHeightInChars - { - get - { - return (int)Regs[VER_DISPLAYED]; - } - } + public int DisplayHeightInChars => (int)Regs[VER_DISPLAYED]; /// /// The character at which to start HSYNC /// - public int HorizontalSyncPos - { - get - { - return (int)Regs[HOR_SYNC_POS]; - } - } + public int HorizontalSyncPos => (int)Regs[HOR_SYNC_POS]; /// /// Width (in characters) of the HSYNC /// - public int HorizontalSyncWidth - { - get - { - return HSYNCWidth; - } - } + public int HorizontalSyncWidth => HSYNCWidth; /// /// The vertical scanline at which to start VSYNC /// - public int VerticalSyncPos - { - get - { - return (int)Regs[VER_SYNC_POS] * ((int)Regs[MAX_RASTER_ADDR] + 1); - } - } + public int VerticalSyncPos => (int)Regs[VER_SYNC_POS] * ((int)Regs[MAX_RASTER_ADDR] + 1); /// /// Height (in scanlines) of the VSYNC /// - public int VerticalSyncHeight - { - get - { - return VSYNCWidth; // * ((int)Regs[MAX_RASTER_ADDR] + 1); - } - } + public int VerticalSyncHeight => VSYNCWidth; // * ((int)Regs[MAX_RASTER_ADDR] + 1); /// /// The number of scanlines in one character (MAXRASTER) /// - public int ScanlinesPerCharacter - { - get - { - return (int)Regs[MAX_RASTER_ADDR] + 1; - } - } + public int ScanlinesPerCharacter => (int)Regs[MAX_RASTER_ADDR] + 1; /// /// Returns the starting video page address as specified within R12 @@ -236,11 +168,9 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC } } - public int DStartHigh - { get { return Regs[DISP_START_ADDR_H]; } } + public int DStartHigh => Regs[DISP_START_ADDR_H]; - public int DStartLow - { get { return Regs[DISP_START_ADDR_L]; } } + public int DStartLow => Regs[DISP_START_ADDR_L]; /// /// Returns the video buffer size as specified within R12 @@ -456,14 +386,14 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC /// http://www.cantrell.org.uk/david/tech/cpc/cpc-firmware/firmware.pdf /// (The defaults values given here are those programmed by the firmware ROM after a cold/warm boot of the CPC/Plus) /// - private byte[] RegDefaults = new byte[] { 63, 40, 46, 112, 38, 0, 25, 30, 0, 7, 0, 0, 48, 0, 192, 7, 0, 0 }; + private byte[] RegDefaults = { 63, 40, 46, 112, 38, 0, 25, 30, 0, 7, 0, 0, 48, 0, 192, 7, 0, 0 }; /// /// Register masks /// 0 = WRITE /// 1 = READ /// - private byte[] CPCMask = new byte[] { 255, 255, 255, 255, 127, 31, 127, 126, 3, 31, 31, 31, 63, 255, 63, 255, 63, 255 }; + private byte[] CPCMask = { 255, 255, 255, 255, 127, 31, 127, 126, 3, 31, 31, 31, 63, 255, 63, 255, 63, 255 }; /// /// Horizontal Character Count diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/CRTC6845.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/CRTC6845.cs index 60e733e38f..5b1a82041e 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/CRTC6845.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/CRTC6845.cs @@ -1,7 +1,6 @@ -using BizHawk.Common; +using System.Collections; +using BizHawk.Common; using BizHawk.Common.NumberExtensions; -using System; -using System.Collections; namespace BizHawk.Emulation.Cores.Computers.AmstradCPC { @@ -62,7 +61,8 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC /// An external dot counter is used to derive this signal which is usually the character rate in an alphanumeric CRT. /// The active transition is high-to-low /// - public bool CLK { get { return _CLK; } } + public bool CLK => _CLK; + private bool _CLK; /// /// The RES input is used to Reset the CRTC. An input low level on RES forces CRTC into following status: @@ -74,13 +74,15 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC /// (At least 1 cycle CLK signal is necessary for reset.) /// (C) The CRTC starts the Display operation immediately after the release of RES signal. /// - public bool RESET { get { return _RESET; } } + public bool RESET => _RESET; + private bool _RESET; /// /// Light Pen Strobe (LPSTR) - This high impedance TTLIMOS compatible input latches the cu rrent Refresh Addresses in the Register File. /// Latching is on the low to high edge and is synchronized internally to character clock. /// - public bool LPSTB { get { return _LPSTB; } } + public bool LPSTB => _LPSTB; + private bool _LPSTB; #endregion @@ -92,23 +94,27 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC /// This TTL compatible output is an active high signal which drives the monitor directly or is fed to Video Processing Logic for composite generation. /// This signal determines the vertical position of the displayed text. /// - public bool VSYNC { get { return _VSYNC; } } + public bool VSYNC => _VSYNC; + private bool _VSYNC; /// /// This TTL compatible output is an active high signal which drives the monitor directly or is fed to Video Processing Logic for composite generation. /// This signal determines the horizontal position of the displayed text. /// - public bool HSYNC { get { return _HSYNC; } } + public bool HSYNC => _HSYNC; + private bool _HSYNC; /// /// This TTL compatible output is an active high signal which indicates the CRTC is providing addressing in the active Display Area. /// - public bool DISPTMG { get { return _DISPTMG; } } + public bool DISPTMG => _DISPTMG; + private bool _DISPTMG; /// /// This TTL compatible output indicates Cursor Display to external Video Processing Logic.Active high signal. /// - public bool CUDISP { get { return _CUDISP; } } + public bool CUDISP => _CUDISP; + private bool _CUDISP; // Refresh memory addresses @@ -117,31 +123,31 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC data located within a 16K block of refresh memory. These outputs drive a TTL load and 30pF. A high level on MAO-MA 13 is a logical "1." */ - public bool MA0 { get { return LinearAddress.Bit(0); } } - public bool MA1 { get { return LinearAddress.Bit(1); } } - public bool MA2 { get { return LinearAddress.Bit(2); } } - public bool MA3 { get { return LinearAddress.Bit(3); } } - public bool MA4 { get { return LinearAddress.Bit(4); } } - public bool MA5 { get { return LinearAddress.Bit(5); } } - public bool MA6 { get { return LinearAddress.Bit(6); } } - public bool MA7 { get { return LinearAddress.Bit(7); } } - public bool MA8 { get { return LinearAddress.Bit(8); } } - public bool MA9 { get { return LinearAddress.Bit(9); } } - public bool MA10 { get { return LinearAddress.Bit(10); } } // cpcwiki would suggest that this isnt connected in the CPC range - public bool MA11 { get { return LinearAddress.Bit(11); } } // cpcwiki would suggest that this isnt connected in the CPC range - public bool MA12 { get { return LinearAddress.Bit(12); } } // cpcwiki would suggest that this is connected in the CPC range but not used - public bool MA13 { get { return LinearAddress.Bit(13); } } // cpcwiki would suggest that this is connected in the CPC range but not used + public bool MA0 => LinearAddress.Bit(0); + public bool MA1 => LinearAddress.Bit(1); + public bool MA2 => LinearAddress.Bit(2); + public bool MA3 => LinearAddress.Bit(3); + public bool MA4 => LinearAddress.Bit(4); + public bool MA5 => LinearAddress.Bit(5); + public bool MA6 => LinearAddress.Bit(6); + public bool MA7 => LinearAddress.Bit(7); + public bool MA8 => LinearAddress.Bit(8); + public bool MA9 => LinearAddress.Bit(9); + public bool MA10 => LinearAddress.Bit(10); // cpcwiki would suggest that this isnt connected in the CPC range + public bool MA11 => LinearAddress.Bit(11); // cpcwiki would suggest that this isnt connected in the CPC range + public bool MA12 => LinearAddress.Bit(12); // cpcwiki would suggest that this is connected in the CPC range but not used + public bool MA13 => LinearAddress.Bit(13); // cpcwiki would suggest that this is connected in the CPC range but not used // Row addresses for character generators /* Raster Addresses (RAO-RA4) - These 5 outputs from the internal Raster Counter address the Character ROM for the row of a character. These outputs drive a TTL load and 30pF. A high level (on RAO-RA4) is a logical "1." */ - public bool RA0 { get { return RowSelects.Bit(0); } } - public bool RA1 { get { return RowSelects.Bit(1); } } - public bool RA2 { get { return RowSelects.Bit(2); } } - public bool RA3 { get { return RowSelects.Bit(3); } } // cpcwiki would suggest that this isnt connected in the CPC range - public bool RA4 { get { return RowSelects.Bit(4); } } // cpcwiki would suggest that this isnt connected in the CPC range + public bool RA0 => RowSelects.Bit(0); + public bool RA1 => RowSelects.Bit(1); + public bool RA2 => RowSelects.Bit(2); + public bool RA3 => RowSelects.Bit(3); // cpcwiki would suggest that this isnt connected in the CPC range + public bool RA4 => RowSelects.Bit(4); // cpcwiki would suggest that this isnt connected in the CPC range /// /// This 16-bit property emulates how the Amstrad CPC Gate Array is connected up to the CRTC @@ -682,15 +688,9 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC /// /// Current programmed HSYNC width for Type 0 (HD6845S & UM6845) & Type 1 (UM6845R) /// - private int HSYNCWidth_Type0_1 - { - get - { - // Bits 3..0 define Horizontal Sync Width. - // If 0 is programmed no HSYNC is generated. - return (Register[SYNC_WIDTHS] >> 0) & 0x0F; - } - } + // Bits 3..0 define Horizontal Sync Width. + // If 0 is programmed no HSYNC is generated. + private int HSYNCWidth_Type0_1 => (Register[SYNC_WIDTHS] >> 0) & 0x0F; /// /// Current programmed HSYNC width for Type 2 (MC6845), 3 (AMS40489) & 4 (pre-ASIC) @@ -727,15 +727,9 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC /// /// Current programmed VSYNC width for Type 1 (UM6845R) & 2 (MC6845) /// - private int VSYNCWidth_Type1_2 - { - get - { - // Bits 7..4 are ignored. - // Vertical Sync is fixed at 16 lines. - return 16; - } - } + // Bits 7..4 are ignored. + // Vertical Sync is fixed at 16 lines. + private int VSYNCWidth_Type1_2 => 16; #endregion diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/CRTDevice.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/CRTDevice.cs index 475dee756d..c2fbc88dcb 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/CRTDevice.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/Display/CRTDevice.cs @@ -2,10 +2,6 @@ using BizHawk.Common.NumberExtensions; using BizHawk.Emulation.Common; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace BizHawk.Emulation.Cores.Computers.AmstradCPC { @@ -188,10 +184,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC private int _bufferWidth; private int _bufferHeight; - public int BackgroundColor - { - get { return CPCHardwarePalette[0]; } - } + public int BackgroundColor => CPCHardwarePalette[0]; public int VirtualWidth { @@ -223,15 +216,9 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC set { } } - public int VsyncDenominator - { - get { return GateArray.Z80ClockSpeed; } - } + public int VsyncDenominator => GateArray.Z80ClockSpeed; - public int[] GetVideoBuffer() - { - return ProcessVideoBuffer(); - } + public int[] GetVideoBuffer() => ProcessVideoBuffer(); public void SetupScreenSize() { diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/PPI/PPI_8255.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/PPI/PPI_8255.cs index cfc69b6744..7570ce10c8 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/PPI/PPI_8255.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Hardware/PPI/PPI_8255.cs @@ -1,7 +1,6 @@ -using BizHawk.Common; +using System.Collections; +using BizHawk.Common; using BizHawk.Common.NumberExtensions; -using System; -using System.Collections; namespace BizHawk.Emulation.Cores.Computers.AmstradCPC { @@ -38,18 +37,12 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC /// /// BDIR Line connected to PSG /// - public bool BDIR - { - get { return Regs[PORT_C].Bit(7); } - } + public bool BDIR => Regs[PORT_C].Bit(7); /// /// BC1 Line connected to PSG /// - public bool BC1 - { - get { return Regs[PORT_C].Bit(6); } - } + public bool BC1 => Regs[PORT_C].Bit(6); /* Port Constants */ private const int PORT_A = 0; @@ -65,34 +58,22 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC /// /// Returns the currently latched port direction for Port A /// - private PortDirection DirPortA - { - get { return Regs[PORT_CONTROL].Bit(4) ? PortDirection.Input : PortDirection.Output; } - } + private PortDirection DirPortA => Regs[PORT_CONTROL].Bit(4) ? PortDirection.Input : PortDirection.Output; /// /// Returns the currently latched port direction for Port B /// - private PortDirection DirPortB - { - get { return Regs[PORT_CONTROL].Bit(1) ? PortDirection.Input : PortDirection.Output; } - } + private PortDirection DirPortB => Regs[PORT_CONTROL].Bit(1) ? PortDirection.Input : PortDirection.Output; /// /// Returns the currently latched port direction for Port C (lower half) /// - private PortDirection DirPortCL - { - get { return Regs[PORT_CONTROL].Bit(0) ? PortDirection.Input : PortDirection.Output; } - } + private PortDirection DirPortCL => Regs[PORT_CONTROL].Bit(0) ? PortDirection.Input : PortDirection.Output; /// /// Returns the currently latched port direction for Port C (upper half) /// - private PortDirection DirPortCU - { - get { return Regs[PORT_CONTROL].Bit(3) ? PortDirection.Input : PortDirection.Output; } - } + private PortDirection DirPortCU => Regs[PORT_CONTROL].Bit(3) ? PortDirection.Input : PortDirection.Output; #region OUT Methods diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPC464/CPC464.Memory.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPC464/CPC464.Memory.cs index 62dc8b29a3..d15d22e3a5 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPC464/CPC464.Memory.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPC464/CPC464.Memory.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BizHawk.Emulation.Cores.Computers.AmstradCPC +namespace BizHawk.Emulation.Cores.Computers.AmstradCPC { /// /// CPC464 diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPC464/CPC464.Port.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPC464/CPC464.Port.cs index 6f7a2cae3d..9d2d10e321 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPC464/CPC464.Port.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPC464/CPC464.Port.cs @@ -1,9 +1,5 @@ using System; using System.Collections; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace BizHawk.Emulation.Cores.Computers.AmstradCPC { diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPC464/CPC464.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPC464/CPC464.cs index 3deca82750..98f100afbb 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPC464/CPC464.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPC464/CPC464.cs @@ -1,5 +1,4 @@ using BizHawk.Emulation.Cores.Components.Z80A; -using System; using System.Collections.Generic; namespace BizHawk.Emulation.Cores.Computers.AmstradCPC diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPC6128/CPC6128.Memory.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPC6128/CPC6128.Memory.cs index 731fe3cd4d..e64b0621ea 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPC6128/CPC6128.Memory.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPC6128/CPC6128.Memory.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BizHawk.Emulation.Cores.Computers.AmstradCPC +namespace BizHawk.Emulation.Cores.Computers.AmstradCPC { /// /// CPC6128 diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPC6128/CPC6128.Port.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPC6128/CPC6128.Port.cs index 80138015c3..6cd4c5706c 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPC6128/CPC6128.Port.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPC6128/CPC6128.Port.cs @@ -1,10 +1,6 @@ using BizHawk.Common.NumberExtensions; using System; using System.Collections; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace BizHawk.Emulation.Cores.Computers.AmstradCPC { diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPC6128/CPC6128.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPC6128/CPC6128.cs index fee955f0f9..2128e34ca6 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPC6128/CPC6128.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPC6128/CPC6128.cs @@ -1,5 +1,4 @@ using BizHawk.Emulation.Cores.Components.Z80A; -using System; using System.Collections.Generic; namespace BizHawk.Emulation.Cores.Computers.AmstradCPC diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPCBase.Input.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPCBase.Input.cs index 6d8e35d3a1..fb43e7602b 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPCBase.Input.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPCBase.Input.cs @@ -1,7 +1,4 @@ -using System.Collections.Generic; -using System.Linq; - -namespace BizHawk.Emulation.Cores.Computers.AmstradCPC +namespace BizHawk.Emulation.Cores.Computers.AmstradCPC { /// /// The abstract class that all emulated models will inherit from diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPCBase.Memory.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPCBase.Memory.cs index b4e3badeb8..1485ab1e56 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPCBase.Memory.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPCBase.Memory.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; - -namespace BizHawk.Emulation.Cores.Computers.AmstradCPC +namespace BizHawk.Emulation.Cores.Computers.AmstradCPC { /// /// The abstract class that all emulated models will inherit from diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPCBase.Port.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPCBase.Port.cs index 73fc120790..d70afd9101 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPCBase.Port.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPCBase.Port.cs @@ -1,6 +1,5 @@  using BizHawk.Common.NumberExtensions; -using System; using System.Collections.Generic; namespace BizHawk.Emulation.Cores.Computers.AmstradCPC diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPCBase.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPCBase.cs index 89e7d94216..0e9d9427d9 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPCBase.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/CPCBase.cs @@ -172,8 +172,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC // we have reached the end of a frame LastFrameStartCPUTick = CPU.TotalExecutedCycles; // - OverFlow; - if (AYDevice != null) - AYDevice.EndFrame(); + AYDevice?.EndFrame(); FrameCount++; @@ -185,7 +184,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC // is this a lag frame? CPC.IsLagFrame = !InputRead; - // FDC debug + // FDC debug if (UPDDiskDevice != null && UPDDiskDevice.writeDebug) { // only write UPD log every second @@ -360,10 +359,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC if (ser.IsReader) DiskMediaIndex = diskMediaIndex; - if (UPDDiskDevice != null) - { - UPDDiskDevice.SyncState(ser); - } + UPDDiskDevice?.SyncState(ser); ser.EndSection(); } diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/GateArrayBase.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/GateArrayBase.cs index 46a47809a2..219dd075d8 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/GateArrayBase.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Machine/GateArrayBase.cs @@ -3,10 +3,6 @@ using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Components.Z80A; using System; using System.Collections; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace BizHawk.Emulation.Cores.Computers.AmstradCPC { @@ -452,10 +448,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC private int _bufferWidth; private int _bufferHeight; - public int BackgroundColor - { - get { return CPCHardwarePalette[16]; } - } + public int BackgroundColor => CPCHardwarePalette[16]; public int VirtualWidth { @@ -487,15 +480,9 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC set { } } - public int VsyncDenominator - { - get { return Z80ClockSpeed; } - } + public int VsyncDenominator => Z80ClockSpeed; - public int[] GetVideoBuffer() - { - return ScreenBuffer; - } + public int[] GetVideoBuffer() => ScreenBuffer; protected void SetupScreenSize() { diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/CPCExtendedFloppyDisk.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/CPCExtendedFloppyDisk.cs index 688e5b45a1..f045be5df5 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/CPCExtendedFloppyDisk.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/CPCExtendedFloppyDisk.cs @@ -68,8 +68,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC // check for unformatted track if (DiskHeader.TrackSizes[i] == 0) { - DiskTracks[i] = new Track(); - DiskTracks[i].Sectors = new Sector[0]; + DiskTracks[i] = new Track { Sectors = new Sector[0] }; continue; } @@ -94,15 +93,16 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC DiskTracks[i].Sectors = new Sector[DiskTracks[i].NumberOfSectors]; for (int s = 0; s < DiskTracks[i].NumberOfSectors; s++) { - DiskTracks[i].Sectors[s] = new Sector(); - - DiskTracks[i].Sectors[s].TrackNumber = data[p++]; - DiskTracks[i].Sectors[s].SideNumber = data[p++]; - DiskTracks[i].Sectors[s].SectorID = data[p++]; - DiskTracks[i].Sectors[s].SectorSize = data[p++]; - DiskTracks[i].Sectors[s].Status1 = data[p++]; - DiskTracks[i].Sectors[s].Status2 = data[p++]; - DiskTracks[i].Sectors[s].ActualDataByteLength = MediaConverter.GetWordValue(data, p); + DiskTracks[i].Sectors[s] = new Sector + { + TrackNumber = data[p++], + SideNumber = data[p++], + SectorID = data[p++], + SectorSize = data[p++], + Status1 = data[p++], + Status2 = data[p++], + ActualDataByteLength = MediaConverter.GetWordValue(data, p) + }; p += 2; // sector data - begins at 0x100 offset from the start of the track info block (in this case dpos) diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/CPCFloppyDisk.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/CPCFloppyDisk.cs index 69df07745f..214c0fced0 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/CPCFloppyDisk.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/CPCFloppyDisk.cs @@ -69,8 +69,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC // check for unformatted track if (DiskHeader.TrackSizes[i] == 0) { - DiskTracks[i] = new Track(); - DiskTracks[i].Sectors = new Sector[0]; + DiskTracks[i] = new Track { Sectors = new Sector[0] }; continue; } @@ -94,15 +93,17 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC DiskTracks[i].Sectors = new Sector[DiskTracks[i].NumberOfSectors]; for (int s = 0; s < DiskTracks[i].NumberOfSectors; s++) { - DiskTracks[i].Sectors[s] = new Sector(); + DiskTracks[i].Sectors[s] = new Sector + { + TrackNumber = data[p++], + SideNumber = data[p++], + SectorID = data[p++], + SectorSize = data[p++], + Status1 = data[p++], + Status2 = data[p++], + ActualDataByteLength = MediaConverter.GetWordValue(data, p) + }; - DiskTracks[i].Sectors[s].TrackNumber = data[p++]; - DiskTracks[i].Sectors[s].SideNumber = data[p++]; - DiskTracks[i].Sectors[s].SectorID = data[p++]; - DiskTracks[i].Sectors[s].SectorSize = data[p++]; - DiskTracks[i].Sectors[s].Status1 = data[p++]; - DiskTracks[i].Sectors[s].Status2 = data[p++]; - DiskTracks[i].Sectors[s].ActualDataByteLength = MediaConverter.GetWordValue(data, p); p += 2; // actualdatabytelength value is calculated now diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/DiskHandler.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/DiskHandler.cs index b7f7a26520..ce5217d0e8 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/DiskHandler.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/DiskHandler.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BizHawk.Emulation.Cores.Computers.AmstradCPC +namespace BizHawk.Emulation.Cores.Computers.AmstradCPC { /// /// This is called first when importing disk images diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/FloppyDisk.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/FloppyDisk.cs index aaa143cac6..b9a78e7804 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/FloppyDisk.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/FloppyDisk.cs @@ -700,21 +700,16 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC } } - public CHRN SectorIDInfo - { - get + public CHRN SectorIDInfo => + new CHRN { - return new CHRN - { - C = TrackNumber, - H = SideNumber, - R = SectorID, - N = SectorSize, - Flag1 = Status1, - Flag2 = Status2, - }; - } - } + C = TrackNumber, + H = SideNumber, + R = SectorID, + N = SectorSize, + Flag1 = Status1, + Flag2 = Status2, + }; } } diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/MediaConverter.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/MediaConverter.cs index effd75ba8a..39ae1db445 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/MediaConverter.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/MediaConverter.cs @@ -17,31 +17,19 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC /// /// Signs whether this class can be used to read the data format /// - public virtual bool IsReader - { - get - { - return false; - } - } + public virtual bool IsReader => false; /// /// Signs whether this class can be used to write the data format /// - public virtual bool IsWriter - { - get - { - return false; - } - } + public virtual bool IsWriter => false; /// /// Serialization method /// public virtual void Read(byte[] data) { - throw new NotImplementedException(this.GetType().ToString() + + throw new NotImplementedException(this.GetType() + "Read operation is not implemented for this converter"); } @@ -50,7 +38,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC /// public virtual void Write(byte[] data) { - throw new NotImplementedException(this.GetType().ToString() + + throw new NotImplementedException(this.GetType() + "Write operation is not implemented for this converter"); } 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 741b178d34..a19a7996dd 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Tape/CDT/CdtConverter.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Tape/CDT/CdtConverter.cs @@ -6,7 +6,7 @@ using System.Text; namespace BizHawk.Emulation.Cores.Computers.AmstradCPC { /// - /// Reponsible for TZX format serializaton + /// Responsible for TZX format serialization /// public class CdtConverter : MediaConverter { @@ -14,23 +14,17 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC /// The type of serializer /// private MediaConverterType _formatType = MediaConverterType.CDT; - public override MediaConverterType FormatType - { - get - { - return _formatType; - } - } + public override MediaConverterType FormatType => _formatType; /// /// Signs whether this class can be used to read the data format /// - public override bool IsReader { get { return true; } } + public override bool IsReader => true; /// /// Signs whether this class can be used to write the data format /// - public override bool IsWriter { get { return false; } } + public override bool IsWriter => false; /// /// Working list of generated tape data blocks @@ -65,14 +59,16 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC /// private TapeDataBlock ConvertClock(TapeDataBlock db) { - TapeDataBlock tb = new TapeDataBlock(); - tb.BlockDescription = db.BlockDescription; - tb.BlockID = db.BlockID; - tb.Command = db.Command; - tb.DataPeriods = new List(); - tb.InitialPulseLevel = db.InitialPulseLevel; - tb.MetaData = db.MetaData; - tb.PauseInMS = db.PauseInMS; + var tb = new TapeDataBlock + { + BlockDescription = db.BlockDescription, + BlockID = db.BlockID, + Command = db.Command, + DataPeriods = new List(), + InitialPulseLevel = db.InitialPulseLevel, + MetaData = db.MetaData, + PauseInMS = db.PauseInMS + }; double multiplier = 8.0 / 7.0; //double cycleScale = ((40 << 16) / 35); @@ -172,7 +168,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC if (ident != "ZXTape!" || eotm != 0x1A) { // this is not a valid TZX format file - throw new Exception(this.GetType().ToString() + + throw new Exception(this.GetType() + "This is not a valid TZX format file"); } @@ -180,7 +176,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC _position = 10; while (_position < data.Length) { - // block ID is the first byte in a new block + // block ID is the first byte in a new block int ID = data[_position++]; // process the data @@ -347,10 +343,12 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC for custom loading routines that use the same timings as ROM ones do. */ private void ProcessBlockID10(byte[] data) { - TapeDataBlock t = new TapeDataBlock(); - t.BlockID = 0x10; - t.BlockDescription = BlockType.Standard_Speed_Data_Block; - t.DataPeriods = new List(); + var t = new TapeDataBlock + { + BlockID = 0x10, + BlockDescription = BlockType.Standard_Speed_Data_Block, + DataPeriods = new List() + }; int pauseLen = GetWordValue(data, _position); if (pauseLen == 0) @@ -399,10 +397,12 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC sync or pilot tones (i.e. all sorts of protection schemes) then use the next three blocks to describe it.*/ private void ProcessBlockID11(byte[] data) { - TapeDataBlock t = new TapeDataBlock(); - t.BlockID = 0x11; - t.BlockDescription = BlockType.Turbo_Speed_Data_Block; - t.DataPeriods = new List(); + var t = new TapeDataBlock + { + BlockID = 0x11, + BlockDescription = BlockType.Turbo_Speed_Data_Block, + DataPeriods = new List() + }; int pilotPL = GetWordValue(data, _position); int sync1P = GetWordValue(data, _position + 2); @@ -450,17 +450,18 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC { int blockLen = 4; - TapeDataBlock t = new TapeDataBlock(); - t.BlockID = 0x12; - t.BlockDescription = BlockType.Pure_Tone; - t.DataPeriods = new List(); - t.PauseInMS = 0; + var t = new TapeDataBlock + { + BlockID = 0x12, + BlockDescription = BlockType.Pure_Tone, + DataPeriods = new List(), PauseInMS = 0 + }; // get values int pulseLength = GetWordValue(data, _position); int pulseCount = GetWordValue(data, _position + 2); - t.AddMetaData(BlockDescriptorTitle.Pulse_Length, pulseLength.ToString() + " T-States"); + t.AddMetaData(BlockDescriptorTitle.Pulse_Length, pulseLength + " T-States"); t.AddMetaData(BlockDescriptorTitle.Pulse_Count, pulseCount.ToString()); // build period information @@ -487,14 +488,15 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC sync tones used by some protection schemes. */ private void ProcessBlockID13(byte[] data) { - TapeDataBlock t = new TapeDataBlock(); - t.BlockID = 0x13; - t.BlockDescription = BlockType.Pulse_Sequence; - t.DataPeriods = new List(); + TapeDataBlock t = new TapeDataBlock + { + BlockID = 0x13, + BlockDescription = BlockType.Pulse_Sequence, + DataPeriods = new List(), + PauseInMS = 0 + }; - t.PauseInMS = 0; - - // get pulse count + // get pulse count int pulseCount = data[_position]; t.AddMetaData(BlockDescriptorTitle.Pulse_Count, pulseCount.ToString()); _position++; @@ -504,7 +506,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC { // get pulse length int pulseLength = GetWordValue(data, _position); - t.AddMetaData(BlockDescriptorTitle.Needs_Parsing, "Pulse " + p + " Length\t" + pulseLength.ToString() + " T-States"); + t.AddMetaData(BlockDescriptorTitle.Needs_Parsing, "Pulse " + p + " Length\t" + pulseLength + " T-States"); t.DataPeriods.Add(pulseLength); } @@ -528,10 +530,12 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC This is the same as in the turbo loading data block, except that it has no pilot or sync pulses. */ private void ProcessBlockID14(byte[] data) { - TapeDataBlock t = new TapeDataBlock(); - t.BlockID = 0x14; - t.BlockDescription = BlockType.Pure_Data_Block; - t.DataPeriods = new List(); + TapeDataBlock t = new TapeDataBlock + { + BlockID = 0x14, + BlockDescription = BlockType.Pure_Data_Block, + DataPeriods = new List() + }; int pilotPL = 0; int sync1P = 0; @@ -583,10 +587,12 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC Please use this block only if you cannot use any other block. */ private void ProcessBlockID15(byte[] data) { - TapeDataBlock t = new TapeDataBlock(); - t.BlockID = 0x15; - t.BlockDescription = BlockType.Direct_Recording; - t.DataPeriods = new List(); + var t = new TapeDataBlock + { + BlockID = 0x15, + BlockDescription = BlockType.Direct_Recording, + DataPeriods = new List() + }; // get values int samLen = GetInt32(data, _position + 5); @@ -632,7 +638,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC } } - // incrememt position + // increment position _position++; } @@ -680,15 +686,17 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC 0x01: RLE 0x02: Z-RLE 0x0A - DWORD Number of stored pulses (after decompression, for validation purposes) - 0x0E - BYTE[N] CSW data, encoded according to the CSW file format specification. + 0x0E - BYTE[N] CSW data, encoded according to the CSW file format specification. This block contains a sequence of raw pulses encoded in CSW format v2 (Compressed Square Wave). */ private void ProcessBlockID18(byte[] data) { - TapeDataBlock t = new TapeDataBlock(); - t.BlockID = 0x18; - t.BlockDescription = BlockType.CSW_Recording; - t.DataPeriods = new List(); + TapeDataBlock t = new TapeDataBlock + { + BlockID = 0x18, + BlockDescription = BlockType.CSW_Recording, + DataPeriods = new List() + }; int blockLen = GetInt32(data, _position); _position += 4; @@ -710,7 +718,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC byte[] dest = new byte[pulses + 1]; // process the CSW data - BizHawk.Emulation.Cores.Computers.SinclairSpectrum.CswConverter.ProcessCSWV2(src, ref dest, compType, pulses); + SinclairSpectrum.CswConverter.ProcessCSWV2(src, ref dest, compType, pulses); // create the periods var rate = (69888 * 50) / sampleRate; @@ -804,11 +812,12 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC private void ProcessBlockID19(byte[] data) { // not currently implemented properly - - TapeDataBlock t = new TapeDataBlock(); - t.BlockID = 0x19; - t.BlockDescription = BlockType.Generalized_Data_Block; - t.DataPeriods = new List(); + var t = new TapeDataBlock + { + BlockID = 0x19, + BlockDescription = BlockType.Generalized_Data_Block, + DataPeriods = new List() + }; int blockLen = GetInt32(data, _position); _position += 4; @@ -841,16 +850,18 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC #region ID 20 - Pause (silence) or 'Stop the Tape' command /* length: 02 Offset Value Type Description - 0x00 - WORD Pause duration (ms.) + 0x00 - WORD Pause duration (ms.) This will make a silence (low amplitude level (0)) for a given time in milliseconds. If the value is 0 then the emulator or utility should (in effect) STOP THE TAPE, i.e. should not continue loading until the user or emulator requests it. */ private void ProcessBlockID20(byte[] data) { - TapeDataBlock t = new TapeDataBlock(); - t.BlockID = 0x20; - t.DataPeriods = new List(); - t.BlockDescription = BlockType.Pause_or_Stop_the_Tape; + TapeDataBlock t = new TapeDataBlock + { + BlockID = 0x20, + DataPeriods = new List(), + BlockDescription = BlockType.Pause_or_Stop_the_Tape + }; int pauseDuration = GetWordValue(data, _position); if (pauseDuration != 0) @@ -907,10 +918,12 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC For each group start block, there must be a group end block. Nesting of groups is not allowed. */ private void ProcessBlockID21(byte[] data) { - TapeDataBlock t = new TapeDataBlock(); - t.BlockID = 0x21; - t.DataPeriods = new List(); - t.BlockDescription = BlockType.Group_Start; + var t = new TapeDataBlock + { + BlockID = 0x21, + DataPeriods = new List(), + BlockDescription = BlockType.Group_Start + }; int nameLength = data[_position]; _position++; @@ -935,13 +948,14 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC This indicates the end of a group. This block has no body. */ private void ProcessBlockID22(byte[] data) { - TapeDataBlock t = new TapeDataBlock(); - t.BlockID = 0x22; - t.DataPeriods = new List(); - t.BlockDescription = BlockType.Group_End; - t.Command = TapeCommand.END_GROUP; - - t.PauseInMS = 0; + TapeDataBlock t = new TapeDataBlock + { + BlockID = 0x22, + DataPeriods = new List(), + BlockDescription = BlockType.Group_End, + Command = TapeCommand.END_GROUP, + PauseInMS = 0 + }; // add to tape _datacorder.DataBlocks.Add(t); @@ -963,11 +977,12 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC private void ProcessBlockID23(byte[] data) { // not implemented properly - - TapeDataBlock t = new TapeDataBlock(); - t.BlockID = 0x23; - t.DataPeriods = new List(); - t.BlockDescription = BlockType.Jump_to_Block; + var t = new TapeDataBlock + { + BlockID = 0x23, + DataPeriods = new List(), + BlockDescription = BlockType.Jump_to_Block + }; int relativeJumpValue = GetWordValue(data, _position); string result = string.Empty; @@ -1010,10 +1025,12 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC For simplicity reasons don't nest loop blocks! */ private void ProcessBlockID24(byte[] data) { - TapeDataBlock t = new TapeDataBlock(); - t.BlockID = 0x24; - t.DataPeriods = new List(); - t.BlockDescription = BlockType.Loop_Start; + var t = new TapeDataBlock + { + BlockID = 0x24, + DataPeriods = new List(), + BlockDescription = BlockType.Loop_Start + }; // loop should start from the next block int loopStart = _datacorder.DataBlocks.Count() + 1; @@ -1047,10 +1064,12 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC This block has no body. */ private void ProcessBlockID25(byte[] data) { - TapeDataBlock t = new TapeDataBlock(); - t.BlockID = 0x25; - t.DataPeriods = new List(); - t.BlockDescription = BlockType.Loop_End; + var t = new TapeDataBlock + { + BlockID = 0x25, + DataPeriods = new List(), + BlockDescription = BlockType.Loop_End + }; // get the most recent loop info var loop = _loopCounter.LastOrDefault(); @@ -1100,10 +1119,12 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC private void ProcessBlockID26(byte[] data) { // block processing not implemented for this - just gets added for informational purposes only - TapeDataBlock t = new TapeDataBlock(); - t.BlockID = 0x26; - t.DataPeriods = new List(); - t.BlockDescription = BlockType.Call_Sequence; + var t = new TapeDataBlock + { + BlockID = 0x26, + DataPeriods = new List(), + BlockDescription = BlockType.Call_Sequence + }; int blockSize = 2 + 2 * GetWordValue(data, _position); t.PauseInMS = 0; @@ -1126,12 +1147,13 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC private void ProcessBlockID27(byte[] data) { // block processing not implemented for this - just gets added for informational purposes only - TapeDataBlock t = new TapeDataBlock(); - t.BlockID = 0x27; - t.DataPeriods = new List(); - t.BlockDescription = BlockType.Return_From_Sequence; - t.PauseInMS = 0; - + var t = new TapeDataBlock + { + BlockID = 0x27, + DataPeriods = new List(), + BlockDescription = BlockType.Return_From_Sequence, + PauseInMS = 0 + }; // add to tape _datacorder.DataBlocks.Add(t); @@ -1160,10 +1182,12 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC private void ProcessBlockID28(byte[] data) { // block processing not implemented for this - just gets added for informational purposes only - TapeDataBlock t = new TapeDataBlock(); - t.BlockID = 0x28; - t.DataPeriods = new List(); - t.BlockDescription = BlockType.Select_Block; + var t = new TapeDataBlock + { + BlockID = 0x28, + DataPeriods = new List(), + BlockDescription = BlockType.Select_Block + }; int blockSize = 2 + GetWordValue(data, _position); @@ -1187,11 +1211,13 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC This block has no body of its own, but follows the extension rule. */ private void ProcessBlockID2A(byte[] data) { - TapeDataBlock t = new TapeDataBlock(); - t.BlockID = 0x2A; - t.DataPeriods = new List(); - t.BlockDescription = BlockType.Stop_the_Tape_48K; - t.Command = TapeCommand.STOP_THE_TAPE_48K; + var t = new TapeDataBlock + { + BlockID = 0x2A, + DataPeriods = new List(), + BlockDescription = BlockType.Stop_the_Tape_48K, + Command = TapeCommand.STOP_THE_TAPE_48K + }; int blockSize = 4 + GetWordValue(data, _position); @@ -1215,12 +1241,13 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC ambiguities, e.g. with custom loaders which are level-sensitive. */ private void ProcessBlockID2B(byte[] data) { - TapeDataBlock t = new TapeDataBlock(); - t.BlockID = 0x2B; - t.DataPeriods = new List(); - t.BlockDescription = BlockType.Set_Signal_Level; - - t.PauseInMS = 0; + var t = new TapeDataBlock + { + BlockID = 0x2B, + DataPeriods = new List(), + BlockDescription = BlockType.Set_Signal_Level, + PauseInMS = 0 + }; // add to tape _datacorder.DataBlocks.Add(t); @@ -1244,10 +1271,12 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC Please use 'Archive Info' block for title, authors, publisher, etc. */ private void ProcessBlockID30(byte[] data) { - TapeDataBlock t = new TapeDataBlock(); - t.BlockID = 0x30; - t.DataPeriods = new List(); - t.BlockDescription = BlockType.Text_Description; + var t = new TapeDataBlock + { + BlockID = 0x30, + DataPeriods = new List(), + BlockDescription = BlockType.Text_Description + }; int textLen = data[_position]; _position++; @@ -1283,11 +1312,12 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC private void ProcessBlockID31(byte[] data) { // currently not implemented properly in ZXHawk - - TapeDataBlock t = new TapeDataBlock(); - t.BlockID = 0x31; - t.DataPeriods = new List(); - t.BlockDescription = BlockType.Message_Block; + var t = new TapeDataBlock + { + BlockID = 0x31, + DataPeriods = new List(), + BlockDescription = BlockType.Message_Block + }; _position++; @@ -1344,10 +1374,12 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC The information about what hardware the tape uses is in the 'Hardware Type' block, so no need for it here. */ private void ProcessBlockID32(byte[] data) { - TapeDataBlock t = new TapeDataBlock(); - t.BlockID = 0x32; - t.DataPeriods = new List(); - t.BlockDescription = BlockType.Archive_Info; + var t = new TapeDataBlock + { + BlockID = 0x32, + DataPeriods = new List(), + BlockDescription = BlockType.Archive_Info + }; int blockLen = GetWordValue(data, _position); _position += 2; @@ -1397,8 +1429,6 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC case 0xFF: title = "Comment(s): "; break; - default: - break; } // add title to description @@ -1451,12 +1481,13 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC { // currently not implemented properly in ZXHawk - TapeDataBlock t = new TapeDataBlock(); - t.BlockID = 0x33; - t.DataPeriods = new List(); - t.BlockDescription = BlockType.Hardware_Type; - - t.PauseInMS = 0; + TapeDataBlock t = new TapeDataBlock + { + BlockID = 0x33, + DataPeriods = new List(), + BlockDescription = BlockType.Hardware_Type, + PauseInMS = 0 + }; // first byte contains number of HWINFOs int infos = data[_position]; @@ -1485,12 +1516,13 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC extra settings required by a particular emulator, or even poke data. */ private void ProcessBlockID35(byte[] data) { - TapeDataBlock t = new TapeDataBlock(); - t.BlockID = 0x35; - t.DataPeriods = new List(); - t.BlockDescription = BlockType.Custom_Info_Block; - - t.PauseInMS = 0; + var t = new TapeDataBlock + { + BlockID = 0x35, + DataPeriods = new List(), + BlockDescription = BlockType.Custom_Info_Block, + PauseInMS = 0 + }; string info = Encoding.ASCII.GetString(data, _position, 0x10); //t.BlockDescription = "[CUSTOM INFO: " + info + "]"; @@ -1520,12 +1552,13 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC ensure that they are both of the higher version number. */ private void ProcessBlockID5A(byte[] data) { - TapeDataBlock t = new TapeDataBlock(); - t.BlockID = 0x5A; - t.DataPeriods = new List(); - t.BlockDescription = BlockType.Glue_Block; - - t.PauseInMS = 0; + var t = new TapeDataBlock + { + BlockID = 0x5A, + DataPeriods = new List(), + BlockDescription = BlockType.Glue_Block, + PauseInMS = 0 + }; // add to tape _datacorder.DataBlocks.Add(t); @@ -1539,10 +1572,12 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC private void ProcessUnidentifiedBlock(byte[] data) { - TapeDataBlock t = new TapeDataBlock(); - t.BlockID = -2; - t.DataPeriods = new List(); - t.BlockDescription = BlockType.Unsupported; + var t = new TapeDataBlock + { + BlockID = -2, + DataPeriods = new List(), + BlockDescription = BlockType.Unsupported + }; //t.BlockDescription = "[UNSUPPORTED - 0x" + data[_position - 1] + "]"; _position += GetInt32(data, _position) & 0xFFFFFF; @@ -1564,12 +1599,13 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC private void ProcessBlockID16(byte[] data) { // zxhawk will not implement this block. it will however handle it so subsequent blocks can be parsed - TapeDataBlock t = new TapeDataBlock(); - t.BlockID = 0x16; - t.DataPeriods = new List(); - t.BlockDescription = BlockType.C64_ROM_Type_Data_Block; - - t.PauseInMS = 0; + TapeDataBlock t = new TapeDataBlock + { + BlockID = 0x16, + DataPeriods = new List(), + BlockDescription = BlockType.C64_ROM_Type_Data_Block, + PauseInMS = 0 + }; // add to tape _datacorder.DataBlocks.Add(t); @@ -1584,12 +1620,13 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC private void ProcessBlockID17(byte[] data) { // zxhawk will not implement this block. it will however handle it so subsequent blocks can be parsed - TapeDataBlock t = new TapeDataBlock(); - t.BlockID = 0x17; - t.DataPeriods = new List(); - t.BlockDescription = BlockType.C64_Turbo_Tape_Data_Block; - - t.PauseInMS = 0; + var t = new TapeDataBlock + { + BlockID = 0x17, + DataPeriods = new List(), + BlockDescription = BlockType.C64_Turbo_Tape_Data_Block, + PauseInMS = 0 + }; // add to tape _datacorder.DataBlocks.Add(t); @@ -1604,11 +1641,12 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC private void ProcessBlockID34(byte[] data) { // currently not implemented properly in ZXHawk - - TapeDataBlock t = new TapeDataBlock(); - t.BlockID = 0x34; - t.DataPeriods = new List(); - t.BlockDescription = BlockType.Emulation_Info; + var t = new TapeDataBlock + { + BlockID = 0x34, + DataPeriods = new List(), + BlockDescription = BlockType.Emulation_Info + }; // add to tape _datacorder.DataBlocks.Add(t); @@ -1635,10 +1673,12 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC { // currently not implemented properly in ZXHawk - TapeDataBlock t = new TapeDataBlock(); - t.BlockID = 0x40; - t.DataPeriods = new List(); - t.BlockDescription = BlockType.Snapshot_Block; + TapeDataBlock t = new TapeDataBlock + { + BlockID = 0x40, + DataPeriods = new List(), + BlockDescription = BlockType.Snapshot_Block + }; _position++; @@ -1735,7 +1775,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC { // data block description = "Data Block " + (blockSize - 2) + "bytes"; - block.AddMetaData(BlockDescriptorTitle.Data_Bytes, (blockSize - 2).ToString() + " Bytes"); + block.AddMetaData(BlockDescriptorTitle.Data_Bytes, (blockSize - 2) + " Bytes"); } else { @@ -1801,10 +1841,10 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC if (dataBlockType == DataBlockType.Turbo) block.BlockDescription = BlockType.Turbo_Speed_Data_Block; - block.AddMetaData(BlockDescriptorTitle.Pilot_Pulse_Length, pilotToneLength.ToString() + " T-States"); - block.AddMetaData(BlockDescriptorTitle.Pilot_Pulse_Count, pilotCount.ToString() + " Pulses"); - block.AddMetaData(BlockDescriptorTitle.First_Sync_Length, sync1PulseLength.ToString() + " T-States"); - block.AddMetaData(BlockDescriptorTitle.Second_Sync_Length, sync2PulseLength.ToString() + " T-States"); + block.AddMetaData(BlockDescriptorTitle.Pilot_Pulse_Length, pilotToneLength + " T-States"); + block.AddMetaData(BlockDescriptorTitle.Pilot_Pulse_Count, pilotCount + " Pulses"); + block.AddMetaData(BlockDescriptorTitle.First_Sync_Length, sync1PulseLength + " T-States"); + block.AddMetaData(BlockDescriptorTitle.Second_Sync_Length, sync2PulseLength + " T-States"); break; case DataBlockType.Pure: @@ -1812,11 +1852,11 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC break; } - block.AddMetaData(BlockDescriptorTitle.Zero_Bit_Length, bit0PulseLength.ToString() + " T-States"); - block.AddMetaData(BlockDescriptorTitle.One_Bit_Length, bit1PulseLength.ToString() + " T-States"); - block.AddMetaData(BlockDescriptorTitle.Data_Length, blockSize.ToString() + " Bytes"); - block.AddMetaData(BlockDescriptorTitle.Bits_In_Last_Byte, bitsInLastByte.ToString() + " Bits"); - block.AddMetaData(BlockDescriptorTitle.Pause_After_Data, pauseAfterBlock.ToString() + " ms"); + block.AddMetaData(BlockDescriptorTitle.Zero_Bit_Length, bit0PulseLength + " T-States"); + block.AddMetaData(BlockDescriptorTitle.One_Bit_Length, bit1PulseLength + " T-States"); + block.AddMetaData(BlockDescriptorTitle.Data_Length, blockSize + " Bytes"); + block.AddMetaData(BlockDescriptorTitle.Bits_In_Last_Byte, bitsInLastByte + " Bits"); + block.AddMetaData(BlockDescriptorTitle.Pause_After_Data, pauseAfterBlock + " ms"); // calculate period information List dataPeriods = new List(); @@ -1937,19 +1977,21 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC #region Pause Block Creator /// - /// If neccessary a seperate PAUSE block will be created + /// If necessary a separate PAUSE block will be created /// private void CreatePauseBlock(TapeDataBlock original) { if (original.PauseInMS > 0) { - TapeDataBlock pBlock = new TapeDataBlock(); - pBlock.DataPeriods = new List(); - pBlock.BlockDescription = BlockType.PAUSE_BLOCK; - pBlock.PauseInMS = 0; + var pBlock = new TapeDataBlock + { + DataPeriods = new List(), + BlockDescription = BlockType.PAUSE_BLOCK, + PauseInMS = 0 + }; var pauseInTStates = TranslatePause(original.PauseInMS); - pBlock.AddMetaData(BlockDescriptorTitle.Block_ID, pauseInTStates.ToString() + " cycles"); + pBlock.AddMetaData(BlockDescriptorTitle.Block_ID, pauseInTStates + " cycles"); int by1000 = pauseInTStates / 70000; int rem1000 = pauseInTStates % 70000; diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Tape/TapeDataBlock.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Tape/TapeDataBlock.cs index ddd42ce708..75dcc3995c 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Tape/TapeDataBlock.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Tape/TapeDataBlock.cs @@ -1,7 +1,6 @@ using BizHawk.Common; using System.Collections.Generic; using System.Linq; -using System.Text; namespace BizHawk.Emulation.Cores.Computers.AmstradCPC { diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/ROM/RomData.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/ROM/RomData.cs index 3743639d84..62ffb71c30 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/ROM/RomData.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/ROM/RomData.cs @@ -37,8 +37,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC /// public static RomData InitROM(MachineType machineType, byte[] rom, ROMChipType type, int romPosition = 0) { - RomData RD = new RomData(); - RD.RomBytes = new byte[rom.Length]; + RomData RD = new RomData { RomBytes = new byte[rom.Length] }; RD.RomBytes = rom; RD.ROMType = type; diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.MotherboardInterface.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.MotherboardInterface.cs index cfb9b5534d..6db624e968 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.MotherboardInterface.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.MotherboardInterface.cs @@ -1,6 +1,4 @@ -using System; - -namespace BizHawk.Emulation.Cores.Computers.Commodore64 +namespace BizHawk.Emulation.Cores.Computers.Commodore64 { public sealed partial class Motherboard { diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/CartridgeDevice.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/CartridgeDevice.cs index 595ef0e204..04ec6bc6ae 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/CartridgeDevice.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/CartridgeDevice.cs @@ -13,113 +13,111 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge public static CartridgeDevice Load(byte[] crtFile) { - using (var mem = new MemoryStream(crtFile)) + using var mem = new MemoryStream(crtFile); + var reader = new BinaryReader(mem); + + if (new string(reader.ReadChars(16)) != "C64 CARTRIDGE ") { - var reader = new BinaryReader(mem); - - if (new string(reader.ReadChars(16)) != "C64 CARTRIDGE ") - { - return null; - } - - var chipAddress = new List(); - var chipBank = new List(); - var chipData = new List(); - var chipType = new List(); - - var headerLength = ReadCRTInt(reader); - var version = ReadCRTShort(reader); - var mapper = ReadCRTShort(reader); - var exrom = reader.ReadByte() != 0; - var game = reader.ReadByte() != 0; - - // reserved - reader.ReadBytes(6); - - // cartridge name - reader.ReadBytes(0x20); - - // skip extra header bytes - if (headerLength > 0x40) - { - reader.ReadBytes(headerLength - 0x40); - } - - // read chips - while (reader.PeekChar() >= 0) - { - if (new string(reader.ReadChars(4)) != "CHIP") - { - break; - } - - var chipLength = ReadCRTInt(reader); - chipType.Add(ReadCRTShort(reader)); - chipBank.Add(ReadCRTShort(reader)); - chipAddress.Add(ReadCRTShort(reader)); - var chipDataLength = ReadCRTShort(reader); - chipData.Add(reader.ReadBytes(chipDataLength).Select(x => (int)x).ToArray()); - chipLength -= chipDataLength + 0x10; - if (chipLength > 0) - { - reader.ReadBytes(chipLength); - } - } - - if (chipData.Count <= 0) - { - return null; - } - - CartridgeDevice result; - switch (mapper) - { - case 0x0000: // Standard Cartridge - result = new Mapper0000(chipAddress, chipData, game, exrom); - break; - case 0x0001: // Action Replay (4.2 and up) - result = new Mapper0001(chipAddress, chipBank, chipData); - break; - case 0x0005: // Ocean - result = new Mapper0005(chipAddress, chipBank, chipData); - break; - case 0x0007: // Fun Play - result = new Mapper0007(chipData, game, exrom); - break; - case 0x0008: // SuperGame - result = new Mapper0008(chipData); - break; - case 0x000A: // Epyx FastLoad - result = new Mapper000A(chipData); - break; - case 0x000B: // Westermann Learning - result = new Mapper000B(chipAddress, chipData); - break; - case 0x000F: // C64 Game System / System 3 - result = new Mapper000F(chipAddress, chipBank, chipData); - break; - case 0x0011: // Dinamic - result = new Mapper0011(chipAddress, chipBank, chipData); - break; - case 0x0012: // Zaxxon / Super Zaxxon - result = new Mapper0012(chipAddress, chipBank, chipData); - break; - case 0x0013: // Domark - result = new Mapper0013(chipAddress, chipBank, chipData); - break; - case 0x0020: // EasyFlash - result = new Mapper0020(chipAddress, chipBank, chipData); - break; - case 0x002B: // Prophet 64 - result = new Mapper002B(chipAddress, chipBank, chipData); - break; - default: - throw new Exception("This cartridge file uses an unrecognized mapper: " + mapper); - } - result.HardReset(); - - return result; + return null; } + + var chipAddress = new List(); + var chipBank = new List(); + var chipData = new List(); + var chipType = new List(); + + var headerLength = ReadCRTInt(reader); + var version = ReadCRTShort(reader); + var mapper = ReadCRTShort(reader); + var exrom = reader.ReadByte() != 0; + var game = reader.ReadByte() != 0; + + // reserved + reader.ReadBytes(6); + + // cartridge name + reader.ReadBytes(0x20); + + // skip extra header bytes + if (headerLength > 0x40) + { + reader.ReadBytes(headerLength - 0x40); + } + + // read chips + while (reader.PeekChar() >= 0) + { + if (new string(reader.ReadChars(4)) != "CHIP") + { + break; + } + + var chipLength = ReadCRTInt(reader); + chipType.Add(ReadCRTShort(reader)); + chipBank.Add(ReadCRTShort(reader)); + chipAddress.Add(ReadCRTShort(reader)); + var chipDataLength = ReadCRTShort(reader); + chipData.Add(reader.ReadBytes(chipDataLength).Select(x => (int)x).ToArray()); + chipLength -= chipDataLength + 0x10; + if (chipLength > 0) + { + reader.ReadBytes(chipLength); + } + } + + if (chipData.Count <= 0) + { + return null; + } + + CartridgeDevice result; + switch (mapper) + { + case 0x0000: // Standard Cartridge + result = new Mapper0000(chipAddress, chipData, game, exrom); + break; + case 0x0001: // Action Replay (4.2 and up) + result = new Mapper0001(chipAddress, chipBank, chipData); + break; + case 0x0005: // Ocean + result = new Mapper0005(chipAddress, chipBank, chipData); + break; + case 0x0007: // Fun Play + result = new Mapper0007(chipData, game, exrom); + break; + case 0x0008: // SuperGame + result = new Mapper0008(chipData); + break; + case 0x000A: // Epyx FastLoad + result = new Mapper000A(chipData); + break; + case 0x000B: // Westermann Learning + result = new Mapper000B(chipAddress, chipData); + break; + case 0x000F: // C64 Game System / System 3 + result = new Mapper000F(chipAddress, chipBank, chipData); + break; + case 0x0011: // Dinamic + result = new Mapper0011(chipAddress, chipBank, chipData); + break; + case 0x0012: // Zaxxon / Super Zaxxon + result = new Mapper0012(chipAddress, chipBank, chipData); + break; + case 0x0013: // Domark + result = new Mapper0013(chipAddress, chipBank, chipData); + break; + case 0x0020: // EasyFlash + result = new Mapper0020(chipAddress, chipBank, chipData); + break; + case 0x002B: // Prophet 64 + result = new Mapper002B(chipAddress, chipBank, chipData); + break; + default: + throw new Exception("This cartridge file uses an unrecognized mapper: " + mapper); + } + result.HardReset(); + + return result; } private static int ReadCRTShort(BinaryReader reader) diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Cassette/CassettePort.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Cassette/CassettePort.cs index 32e873f7d6..9e7be9a88f 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Cassette/CassettePort.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/Cassette/CassettePort.cs @@ -41,10 +41,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cassette public void SyncState(Serializer ser) { ser.Sync("Connected", ref _connected); - if (_device != null) - { - _device.SyncState(ser); - } + _device?.SyncState(ser); } public void Connect(CassettePortDevice device) diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Cassette/TapeDrive.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Cassette/TapeDrive.cs index f41258ce44..97c30f9fe0 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Cassette/TapeDrive.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/Cassette/TapeDrive.cs @@ -32,8 +32,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cassette public override void SyncState(Serializer ser) { - - if (_tape != null) { _tape.SyncState(ser); } + _tape?.SyncState(ser); } public void Insert(Tape tape) @@ -47,19 +46,6 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cassette } // Exposed for memory domains, should not be used for actual emulation implementation - public override byte[] TapeDataDomain - { - get - { - if (_tape != null) - { - return _tape.TapeDataDomain; - } - else - { - return null; - } - } - } + public override byte[] TapeDataDomain => _tape?.TapeDataDomain; } } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip6510.IDisassemblable.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip6510.IDisassemblable.cs index ccacc83988..6ccfc9f3f7 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip6510.IDisassemblable.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip6510.IDisassemblable.cs @@ -13,11 +13,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS public string Cpu { - get - { - return "6510"; - } - + get => "6510"; set { } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Cia.Registers.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Cia.Registers.cs index af5ed166fc..8d435bfdf2 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Cia.Registers.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Cia.Registers.cs @@ -1,7 +1,4 @@ -using BizHawk.Common.NumberExtensions; -using System; - -namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS +namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS { public sealed partial class Cia { diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.Envelope.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.Envelope.cs index e011908307..fc6d9ee5aa 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.Envelope.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.Envelope.cs @@ -146,10 +146,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS public int Attack { - get - { - return _attack; - } + get => _attack; set { _attack = value & 0xF; @@ -160,10 +157,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS public int Decay { - get - { - return _decay; - } + get => _decay; set { _decay = value & 0xF; @@ -174,10 +168,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS public bool Gate { - get - { - return _gate; - } + get => _gate; set { var nextGate = value; @@ -197,20 +188,11 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS } } - public int Level - { - get - { - return _envCounter; - } - } + public int Level => _envCounter; public int Release { - get - { - return _release; - } + get => _release; set { _release = value & 0xF; @@ -221,14 +203,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS public int Sustain { - get - { - return _sustain; - } - set - { - _sustain = value & 0xF; - } + get => _sustain; + set => _sustain = value & 0xF; } // ------------------------------------ diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.Voice.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.Voice.cs index d6e943f9e2..c6a6f2c826 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.Voice.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.Voice.cs @@ -179,10 +179,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS public int FrequencyLo { - get - { - return _frequency & 0xFF; - } + get => _frequency & 0xFF; set { _frequency &= 0xFF00; @@ -192,10 +189,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS public int FrequencyHi { - get - { - return _frequency >> 8; - } + get => _frequency >> 8; set { _frequency &= 0x00FF; @@ -205,37 +199,30 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS public int Output(Voice ringModSource) { - + if (_waveform != 0) { - if (_waveform != 0) + _waveformIndex = (_accumulator ^ (ringModSource._accumulator & _ringMsbMask)) >> 12; + _output = _wave[_waveformIndex] & (_noPulse | _pulse) & _noNoiseOrNoise; + if (_waveform > 8) { - _waveformIndex = (_accumulator ^ (ringModSource._accumulator & _ringMsbMask)) >> 12; - _output = _wave[_waveformIndex] & (_noPulse | _pulse) & _noNoiseOrNoise; - if (_waveform > 8) - { - WriteShiftReg(); - } + WriteShiftReg(); } - else - { - if (_floatOutputTtl != 0 && --_floatOutputTtl == 0) - { - _output = 0x000; - } - } - - _pulse = _accumulator >> 12 >= _pulseWidth ? 0xFFF : 0x000; - return _output; } + else + { + if (_floatOutputTtl != 0 && --_floatOutputTtl == 0) + { + _output = 0x000; + } + } + + _pulse = _accumulator >> 12 >= _pulseWidth ? 0xFFF : 0x000; + return _output; } public int PulseWidthLo { - get - { - return _pulseWidth & 0xFF; - } - + get => _pulseWidth & 0xFF; set { _pulseWidth &= 0x0F00; @@ -245,11 +232,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS public int PulseWidthHi { - get - { - return _pulseWidth >> 8; - } - + get => _pulseWidth >> 8; set { _pulseWidth &= 0x00FF; @@ -304,6 +287,5 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS _wave = _waveTable[_waveform & 0x07]; } } - } } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Media/D64.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Media/D64.cs index fc24a083d8..42fdfe16a1 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Media/D64.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/Media/D64.cs @@ -102,40 +102,38 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Media private static byte[] ConvertSectorToGcr(byte[] source, byte sectorNo, byte trackNo, byte formatA, byte formatB, int gapLength, ErrorType errorType, out int bitsWritten) { - using (var mem = new MemoryStream()) + using var mem = new MemoryStream(); + using var writer = new BinaryWriter(mem); + + if (errorType == ErrorType.IdMismatch) { - var writer = new BinaryWriter(mem); - - if (errorType == ErrorType.IdMismatch) - { - formatA ^= 0xFF; - formatB ^= 0xFF; - } - - var headerChecksum = (byte)(sectorNo ^ trackNo ^ formatA ^ formatB ^ (errorType == ErrorType.HeaderChecksumError ? 0xFF : 0x00)); - - // assemble written data for GCR encoding - var writtenData = new byte[260]; - var syncBytes40 = Enumerable.Repeat((byte) (errorType == ErrorType.NoSyncSequence ? 0x00 : 0xFF), 5).ToArray(); - - Array.Copy(source, 0, writtenData, 1, 256); - writtenData[0] = (byte)(errorType == ErrorType.HeaderNotFound ? 0x00 : 0x07); - writtenData[0x101] = (byte)(Checksum(source) ^ (errorType == ErrorType.DataChecksumError ? 0xFF : 0x00)); - writtenData[0x102] = 0x00; - writtenData[0x103] = 0x00; - - writer.Write(syncBytes40); // sync - writer.Write(EncodeGcr(new byte[] { (byte)(errorType == ErrorType.DataNotFound ? 0x00 : 0x08), headerChecksum, sectorNo, trackNo, formatA, formatB, 0x0F, 0x0F })); // header - writer.Write(new byte[] { 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55 }); // gap - writer.Write(syncBytes40); // sync - writer.Write(EncodeGcr(writtenData)); // data - writer.Write(Enumerable.Repeat((byte)0x55, gapLength).ToArray()); // gap - - bitsWritten = (int)mem.Length * 8; - - writer.Flush(); - return mem.ToArray(); + formatA ^= 0xFF; + formatB ^= 0xFF; } + + var headerChecksum = (byte)(sectorNo ^ trackNo ^ formatA ^ formatB ^ (errorType == ErrorType.HeaderChecksumError ? 0xFF : 0x00)); + + // assemble written data for GCR encoding + var writtenData = new byte[260]; + var syncBytes40 = Enumerable.Repeat((byte) (errorType == ErrorType.NoSyncSequence ? 0x00 : 0xFF), 5).ToArray(); + + Array.Copy(source, 0, writtenData, 1, 256); + writtenData[0] = (byte)(errorType == ErrorType.HeaderNotFound ? 0x00 : 0x07); + writtenData[0x101] = (byte)(Checksum(source) ^ (errorType == ErrorType.DataChecksumError ? 0xFF : 0x00)); + writtenData[0x102] = 0x00; + writtenData[0x103] = 0x00; + + writer.Write(syncBytes40); // sync + writer.Write(EncodeGcr(new byte[] { (byte)(errorType == ErrorType.DataNotFound ? 0x00 : 0x08), headerChecksum, sectorNo, trackNo, formatA, formatB, 0x0F, 0x0F })); // header + writer.Write(new byte[] { 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55 }); // gap + writer.Write(syncBytes40); // sync + writer.Write(EncodeGcr(writtenData)); // data + writer.Write(Enumerable.Repeat((byte)0x55, gapLength).ToArray()); // gap + + bitsWritten = (int)mem.Length * 8; + + writer.Flush(); + return mem.ToArray(); } private static byte[] EncodeGcr(byte[] source) @@ -144,39 +142,37 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Media var gcr = new int[8]; var data = new byte[4]; var count = source.Length; - using (var mem = new MemoryStream()) + using var mem = new MemoryStream(); + var writer = new BinaryWriter(mem); + + for (var i = 0; i < count; i += 4) { - var writer = new BinaryWriter(mem); + Array.Copy(source, i, data, 0, 4); + gcr[0] = GcrEncodeTable[data[0] >> 4]; + gcr[1] = GcrEncodeTable[data[0] & 0xF]; + gcr[2] = GcrEncodeTable[data[1] >> 4]; + gcr[3] = GcrEncodeTable[data[1] & 0xF]; + gcr[4] = GcrEncodeTable[data[2] >> 4]; + gcr[5] = GcrEncodeTable[data[2] & 0xF]; + gcr[6] = GcrEncodeTable[data[3] >> 4]; + gcr[7] = GcrEncodeTable[data[3] & 0xF]; - for (var i = 0; i < count; i += 4) - { - Array.Copy(source, i, data, 0, 4); - gcr[0] = GcrEncodeTable[data[0] >> 4]; - gcr[1] = GcrEncodeTable[data[0] & 0xF]; - gcr[2] = GcrEncodeTable[data[1] >> 4]; - gcr[3] = GcrEncodeTable[data[1] & 0xF]; - gcr[4] = GcrEncodeTable[data[2] >> 4]; - gcr[5] = GcrEncodeTable[data[2] & 0xF]; - gcr[6] = GcrEncodeTable[data[3] >> 4]; - gcr[7] = GcrEncodeTable[data[3] & 0xF]; + // -------- -------- -------- -------- -------- + // 00000111 11222223 33334444 45555566 66677777 - // -------- -------- -------- -------- -------- - // 00000111 11222223 33334444 45555566 66677777 - - var outputValue = (gcr[0] << 3) | (gcr[1] >> 2); - writer.Write((byte)(outputValue & 0xFF)); - outputValue = (gcr[1] << 6) | (gcr[2] << 1) | (gcr[3] >> 4); - writer.Write((byte)(outputValue & 0xFF)); - outputValue = (gcr[3] << 4) | (gcr[4] >> 1); - writer.Write((byte)(outputValue & 0xFF)); - outputValue = (gcr[4] << 7) | (gcr[5] << 2) | (gcr[6] >> 3); - writer.Write((byte)(outputValue & 0xFF)); - outputValue = (gcr[6] << 5) | (gcr[7]); - writer.Write((byte)(outputValue & 0xFF)); - } - writer.Flush(); - return mem.ToArray(); + var outputValue = (gcr[0] << 3) | (gcr[1] >> 2); + writer.Write((byte)(outputValue & 0xFF)); + outputValue = (gcr[1] << 6) | (gcr[2] << 1) | (gcr[3] >> 4); + writer.Write((byte)(outputValue & 0xFF)); + outputValue = (gcr[3] << 4) | (gcr[4] >> 1); + writer.Write((byte)(outputValue & 0xFF)); + outputValue = (gcr[4] << 7) | (gcr[5] << 2) | (gcr[6] >> 3); + writer.Write((byte)(outputValue & 0xFF)); + outputValue = (gcr[6] << 5) | (gcr[7]); + writer.Write((byte)(outputValue & 0xFF)); } + writer.Flush(); + return mem.ToArray(); } public static Disk Read(byte[] source) @@ -184,73 +180,69 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Media var formatB = source[D64_DISK_ID_OFFSET + 0x00]; var formatA = source[D64_DISK_ID_OFFSET + 0x01]; - using (var mem = new MemoryStream(source)) + using var mem = new MemoryStream(source); + var reader = new BinaryReader(mem); + var trackDatas = new List(); + var trackLengths = new List(); + var trackNumbers = new List(); + var trackDensities = new List(); + var errorType = ErrorType.NoError; + int trackCount; + int errorOffset = -1; + + switch (source.Length) { - var reader = new BinaryReader(mem); - var trackDatas = new List(); - var trackLengths = new List(); - var trackNumbers = new List(); - var trackDensities = new List(); - var errorType = ErrorType.NoError; - int trackCount; - int errorOffset = -1; - - switch (source.Length) - { - case 174848: // 35 tracks no errors - trackCount = 35; - break; - case 175531: // 35 tracks with errors - trackCount = 35; - errorOffset = 174848; - break; - case 196608: // 40 tracks no errors - trackCount = 40; - break; - case 197376: // 40 tracks with errors - trackCount = 40; - errorOffset = 196608; - break; - default: - throw new Exception("Not able to identify capacity of the D64 file."); - } - - for (var i = 0; i < trackCount; i++) - { - if (errorOffset >= 0) - { - errorType = (ErrorType) source[errorOffset]; - errorOffset++; - } - var sectors = SectorsPerTrack[i]; - var trackLengthBits = 0; - using (var trackMem = new MemoryStream()) - { - for (var j = 0; j < sectors; j++) - { - int bitsWritten; - var sectorData = reader.ReadBytes(256); - var diskData = ConvertSectorToGcr(sectorData, (byte)j, (byte)(i + 1), formatA, formatB, StandardSectorGapLength[DensityTable[i]], errorType, out bitsWritten); - trackMem.Write(diskData, 0, diskData.Length); - trackLengthBits += bitsWritten; - } - var density = DensityTable[i]; - - // we pad the tracks with extra gap bytes to meet MNIB standards - while (trackMem.Length < StandardTrackLengthBytes[density]) - { - trackMem.WriteByte(0x55); - } - - trackDatas.Add(trackMem.ToArray()); - trackLengths.Add(trackLengthBits); - trackNumbers.Add(i * 2); - trackDensities.Add(DensityTable[i]); - } - } - - return new Disk(trackDatas, trackNumbers, trackDensities, 84) {WriteProtected = false}; + case 174848: // 35 tracks no errors + trackCount = 35; + break; + case 175531: // 35 tracks with errors + trackCount = 35; + errorOffset = 174848; + break; + case 196608: // 40 tracks no errors + trackCount = 40; + break; + case 197376: // 40 tracks with errors + trackCount = 40; + errorOffset = 196608; + break; + default: + throw new Exception("Not able to identify capacity of the D64 file."); } + + for (var i = 0; i < trackCount; i++) + { + if (errorOffset >= 0) + { + errorType = (ErrorType) source[errorOffset]; + errorOffset++; + } + var sectors = SectorsPerTrack[i]; + var trackLengthBits = 0; + using var trackMem = new MemoryStream(); + for (var j = 0; j < sectors; j++) + { + int bitsWritten; + var sectorData = reader.ReadBytes(256); + var diskData = ConvertSectorToGcr(sectorData, (byte)j, (byte)(i + 1), formatA, formatB, StandardSectorGapLength[DensityTable[i]], errorType, out bitsWritten); + trackMem.Write(diskData, 0, diskData.Length); + trackLengthBits += bitsWritten; + } + var density = DensityTable[i]; + + // we pad the tracks with extra gap bytes to meet MNIB standards + while (trackMem.Length < StandardTrackLengthBytes[density]) + { + trackMem.WriteByte(0x55); + } + + trackDatas.Add(trackMem.ToArray()); + trackLengths.Add(trackLengthBits); + trackNumbers.Add(i * 2); + trackDensities.Add(DensityTable[i]); + } + + return new Disk(trackDatas, trackNumbers, trackDensities, 84) {WriteProtected = false}; } } } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Media/DiskBuilder.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Media/DiskBuilder.cs index dac5c39c87..778670a31f 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Media/DiskBuilder.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/Media/DiskBuilder.cs @@ -67,11 +67,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Media public bool this[int sector] { - get - { - return (Data & (1 << sector)) != 0; - } - + get => (Data & (1 << sector)) != 0; set { if (value) diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Media/G64.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Media/G64.cs index 607f1ce2ec..a6a97c3ac4 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Media/G64.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/Media/G64.cs @@ -9,59 +9,57 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Media { public static Disk Read(byte[] source) { - using (var mem = new MemoryStream(source)) + using var mem = new MemoryStream(source); + using var reader = new BinaryReader(mem); + var id = new string(reader.ReadChars(8)); + var trackDatas = new List(); + var trackLengths = new List(); + var trackNumbers = new List(); + var trackDensities = new List(); + + if (id == @"GCR-1541") { - var reader = new BinaryReader(mem); - var id = new string(reader.ReadChars(8)); - var trackDatas = new List(); - var trackLengths = new List(); - var trackNumbers = new List(); - var trackDensities = new List(); + reader.ReadByte(); // version + int trackCount = reader.ReadByte(); + reader.ReadInt16(); // max track size in bytes - if (id == @"GCR-1541") + var trackOffsetTable = new int[trackCount]; + var trackSpeedTable = new int[trackCount]; + + for (var i = 0; i < trackCount; i++) { - reader.ReadByte(); // version - int trackCount = reader.ReadByte(); - reader.ReadInt16(); // max track size in bytes - - var trackOffsetTable = new int[trackCount]; - var trackSpeedTable = new int[trackCount]; - - for (var i = 0; i < trackCount; i++) - { - trackOffsetTable[i] = reader.ReadInt32(); - } - - for (var i = 0; i < trackCount; i++) - { - trackSpeedTable[i] = reader.ReadInt32(); - } - - for (var i = 0; i < trackCount; i++) - { - if (trackOffsetTable[i] > 0) - { - mem.Position = trackOffsetTable[i]; - int trackLength = reader.ReadInt16(); - var trackData = reader.ReadBytes(trackLength); - - trackDatas.Add(trackData); - trackLengths.Add(trackLength * 8); - trackDensities.Add(trackSpeedTable[i]); - trackNumbers.Add(i); - } - } - - if (trackSpeedTable.Any(ts => ts > 3 || ts < 0)) - { - throw new Exception("Byte-level speeds are not yet supported in the G64 loader."); - } - - return new Disk(trackDatas, trackNumbers, trackDensities, 84) {WriteProtected = true}; + trackOffsetTable[i] = reader.ReadInt32(); } - return new Disk(84) {WriteProtected = false}; + for (var i = 0; i < trackCount; i++) + { + trackSpeedTable[i] = reader.ReadInt32(); + } + + for (var i = 0; i < trackCount; i++) + { + if (trackOffsetTable[i] > 0) + { + mem.Position = trackOffsetTable[i]; + int trackLength = reader.ReadInt16(); + var trackData = reader.ReadBytes(trackLength); + + trackDatas.Add(trackData); + trackLengths.Add(trackLength * 8); + trackDensities.Add(trackSpeedTable[i]); + trackNumbers.Add(i); + } + } + + if (trackSpeedTable.Any(ts => ts > 3 || ts < 0)) + { + throw new Exception("Byte-level speeds are not yet supported in the G64 loader."); + } + + return new Disk(trackDatas, trackNumbers, trackDensities, 84) {WriteProtected = true}; } + + return new Disk(84) {WriteProtected = false}; } public static byte[] Write(IList trackData, IList trackNumbers, IList trackDensities) @@ -73,70 +71,68 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Media var trackMaxLength = (ushort)Math.Max(7928, trackData.Max(d => d.Length)); - using (var mem = new MemoryStream()) + using var mem = new MemoryStream(); + using var writer = new BinaryWriter(mem); + + // header ID + writer.Write("GCR-1541".ToCharArray()); + + // version # + writer.Write(version); + + // tracks in the image + writer.Write(trackCount); + + // maximum track size in bytes + writer.Write(trackMaxLength); + + // combine track data + var offsets = new List(); + var densities = new List(); + using (var trackMem = new MemoryStream()) { - var writer = new BinaryWriter(mem); - - // header ID - writer.Write("GCR-1541".ToCharArray()); - - // version # - writer.Write(version); - - // tracks in the image - writer.Write(trackCount); - - // maximum track size in bytes - writer.Write(trackMaxLength); - - // combine track data - var offsets = new List(); - var densities = new List(); - using (var trackMem = new MemoryStream()) + var trackMemWriter = new BinaryWriter(trackMem); + for (var i = 0; i < trackCount; i++) { - var trackMemWriter = new BinaryWriter(trackMem); - for (var i = 0; i < trackCount; i++) + if (trackNumbers.Contains(i)) { - if (trackNumbers.Contains(i)) - { - var trackIndex = trackNumbers.IndexOf(i); - offsets.Add((int)trackMem.Length); - densities.Add(trackDensities[trackIndex]); + var trackIndex = trackNumbers.IndexOf(i); + offsets.Add((int)trackMem.Length); + densities.Add(trackDensities[trackIndex]); - var data = trackData[trackIndex]; - var buffer = Enumerable.Repeat(dataFillerValue, trackMaxLength).ToArray(); - var dataBytes = data.Select(d => unchecked((byte)d)).ToArray(); - Array.Copy(dataBytes, buffer, dataBytes.Length); - trackMemWriter.Write((ushort)dataBytes.Length); - trackMemWriter.Write(buffer); - } - else - { - offsets.Add(-1); - densities.Add(0); - } + var data = trackData[trackIndex]; + var buffer = Enumerable.Repeat(dataFillerValue, trackMaxLength).ToArray(); + var dataBytes = data.Select(d => unchecked((byte)d)).ToArray(); + Array.Copy(dataBytes, buffer, dataBytes.Length); + trackMemWriter.Write((ushort)dataBytes.Length); + trackMemWriter.Write(buffer); } - trackMemWriter.Flush(); - - // offset table - foreach (var offset in offsets.Select(o => o >= 0 ? o + headerLength + trackCount * 8 : 0)) + else { - writer.Write(offset); + offsets.Add(-1); + densities.Add(0); } + } + trackMemWriter.Flush(); - // speed zone data - foreach (var density in densities) - { - writer.Write(density); - } - - // track data - writer.Write(trackMem.ToArray()); + // offset table + foreach (var offset in offsets.Select(o => o >= 0 ? o + headerLength + trackCount * 8 : 0)) + { + writer.Write(offset); } - writer.Flush(); - return mem.ToArray(); + // speed zone data + foreach (var density in densities) + { + writer.Write(density); + } + + // track data + writer.Write(trackMem.ToArray()); } + + writer.Flush(); + return mem.ToArray(); } } } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Serial/Drive1541.IDisassemblable.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Serial/Drive1541.IDisassemblable.cs index d1eabbac31..c8c159933e 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Serial/Drive1541.IDisassemblable.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/Serial/Drive1541.IDisassemblable.cs @@ -12,10 +12,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Serial string IDisassemblable.Cpu { - get - { - return "Disk Drive 6502"; - } + get => "Disk Drive 6502"; set { diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Serial/Drive1541.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Serial/Drive1541.cs index 50fb387ecb..4ddfcd5404 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Serial/Drive1541.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/Serial/Drive1541.cs @@ -70,7 +70,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Serial public override void SyncState(Serializer ser) { ser.BeginSection("Disk"); - if (_disk != null) { _disk.SyncState(ser); } + _disk?.SyncState(ser); ser.EndSection(); ser.Sync("BitHistory", ref _bitHistory); diff --git a/BizHawk.Emulation.Cores/Computers/MSX/LibMSX.cs b/BizHawk.Emulation.Cores/Computers/MSX/LibMSX.cs index 715c9787fa..229bac5fe1 100644 --- a/BizHawk.Emulation.Cores/Computers/MSX/LibMSX.cs +++ b/BizHawk.Emulation.Cores/Computers/MSX/LibMSX.cs @@ -1,6 +1,5 @@ using System; using System.Runtime.InteropServices; -using BizHawk.Emulation.Common; using System.Text; namespace BizHawk.Emulation.Cores.Computers.MSX diff --git a/BizHawk.Emulation.Cores/Computers/MSX/MSX.IEmulator.cs b/BizHawk.Emulation.Cores/Computers/MSX/MSX.IEmulator.cs index d34e9c11d4..7a31221548 100644 --- a/BizHawk.Emulation.Cores/Computers/MSX/MSX.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Computers/MSX/MSX.IEmulator.cs @@ -7,13 +7,7 @@ namespace BizHawk.Emulation.Cores.Computers.MSX { public IEmulatorServiceProvider ServiceProvider { get; } - public ControllerDefinition ControllerDefinition - { - get - { - return current_controller; - } - } + public ControllerDefinition ControllerDefinition => current_controller; public bool FrameAdvance(IController controller, bool render, bool rendersound) { @@ -182,7 +176,7 @@ namespace BizHawk.Emulation.Cores.Computers.MSX const int blipbuffsize = 4500; - public bool CanProvideAsync { get { return false; } } + public bool CanProvideAsync => false; public void SetSyncMode(SyncSoundMode mode) { @@ -197,10 +191,7 @@ namespace BizHawk.Emulation.Cores.Computers.MSX throw new NotSupportedException("Async not supported"); } - public SyncSoundMode SyncMode - { - get { return SyncSoundMode.Sync; } - } + public SyncSoundMode SyncMode => SyncSoundMode.Sync; public void GetSamplesSync(out short[] samples, out int nsamp) { diff --git a/BizHawk.Emulation.Cores/Computers/MSX/MSX.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Computers/MSX/MSX.IMemoryDomains.cs index 321e15070f..8f65f4432a 100644 --- a/BizHawk.Emulation.Cores/Computers/MSX/MSX.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Computers/MSX/MSX.IMemoryDomains.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using BizHawk.Emulation.Common; diff --git a/BizHawk.Emulation.Cores/Computers/MSX/MSX.ISaveRam.cs b/BizHawk.Emulation.Cores/Computers/MSX/MSX.ISaveRam.cs index b295be6d3c..e9f89ac306 100644 --- a/BizHawk.Emulation.Cores/Computers/MSX/MSX.ISaveRam.cs +++ b/BizHawk.Emulation.Cores/Computers/MSX/MSX.ISaveRam.cs @@ -8,14 +8,7 @@ namespace BizHawk.Emulation.Cores.Computers.MSX { public byte[] CloneSaveRam() { - if (SaveRAM != null) - { - return (byte[])SaveRAM.Clone(); - } - else - { - return null; - } + return (byte[]) SaveRAM?.Clone(); } public void StoreSaveRam(byte[] data) diff --git a/BizHawk.Emulation.Cores/Computers/MSX/MSX.ISettable.cs b/BizHawk.Emulation.Cores/Computers/MSX/MSX.ISettable.cs index 9c04eca93e..b6931bf390 100644 --- a/BizHawk.Emulation.Cores/Computers/MSX/MSX.ISettable.cs +++ b/BizHawk.Emulation.Cores/Computers/MSX/MSX.ISettable.cs @@ -1,8 +1,4 @@ -using System; -using System.ComponentModel; - -using Newtonsoft.Json; - +using System.ComponentModel; using BizHawk.Common; using BizHawk.Emulation.Common; diff --git a/BizHawk.Emulation.Cores/Computers/MSX/MSX.Input.cs b/BizHawk.Emulation.Cores/Computers/MSX/MSX.Input.cs index 3d02b95164..32d52901c5 100644 --- a/BizHawk.Emulation.Cores/Computers/MSX/MSX.Input.cs +++ b/BizHawk.Emulation.Cores/Computers/MSX/MSX.Input.cs @@ -1,6 +1,4 @@ -using System; - -using BizHawk.Emulation.Common; +using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Computers.MSX { diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Datacorder/DatacorderDevice.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Datacorder/DatacorderDevice.cs index 876ba3acbb..7cc374627e 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Datacorder/DatacorderDevice.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Datacorder/DatacorderDevice.cs @@ -77,7 +77,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum get { if (_position >= _dataBlocks[_currentDataBlockIndex].DataPeriods.Count) { return 0; } - else { return _position; } + + return _position; } } @@ -85,10 +86,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum /// Signs whether the tape is currently playing or not /// private bool _tapeIsPlaying = false; - public bool TapeIsPlaying - { - get { return _tapeIsPlaying; } - } + public bool TapeIsPlaying => _tapeIsPlaying; /// /// A list of the currently loaded data blocks diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.FDC.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.FDC.cs index b672680905..4c24900408 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.FDC.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.FDC.cs @@ -5,223 +5,223 @@ using System.Linq; namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { - /// - /// FDC State and Methods - /// - #region Attribution - /* + /// + /// FDC State and Methods + /// + #region Attribution + /* Implementation based on the information contained here: http://www.cpcwiki.eu/index.php/765_FDC and here: http://www.cpcwiki.eu/imgs/f/f3/UPD765_Datasheet_OCRed.pdf */ - #endregion - public partial class NECUPD765 - { - #region Controller State + #endregion + public partial class NECUPD765 + { + #region Controller State - /// - /// Signs whether the drive is active - /// - public bool DriveLight; + /// + /// Signs whether the drive is active + /// + public bool DriveLight; - /// - /// Collection of possible commands - /// - private List CommandList; + /// + /// Collection of possible commands + /// + private List CommandList; - /// - /// State parameters relating to the Active command - /// - public CommandParameters ActiveCommandParams = new CommandParameters(); + /// + /// State parameters relating to the Active command + /// + public CommandParameters ActiveCommandParams = new CommandParameters(); - /// - /// The current active phase of the controller - /// - private Phase ActivePhase = Phase.Command; + /// + /// The current active phase of the controller + /// + private Phase ActivePhase = Phase.Command; - /// - /// The currently active interrupt - /// - private InterruptState ActiveInterrupt = InterruptState.None; - /// - /// Command buffer - /// This does not contain the initial command byte (only parameter bytes) - /// - private byte[] CommBuffer = new byte[9]; + /// + /// The currently active interrupt + /// + private InterruptState ActiveInterrupt = InterruptState.None; + /// + /// Command buffer + /// This does not contain the initial command byte (only parameter bytes) + /// + private byte[] CommBuffer = new byte[9]; - /// - /// Current index within the command buffer - /// - private int CommCounter = 0; + /// + /// Current index within the command buffer + /// + private int CommCounter = 0; - /// - /// Initial command byte flag - /// Bit7 Multi Track (continue multi-sector-function on other head) - /// - private bool CMD_FLAG_MT; + /// + /// Initial command byte flag + /// Bit7 Multi Track (continue multi-sector-function on other head) + /// + private bool CMD_FLAG_MT; - /// - /// Initial command byte flag - /// Bit6 MFM-Mode-Bit (Default 1=Double Density) - /// - private bool CMD_FLAG_MF; + /// + /// Initial command byte flag + /// Bit6 MFM-Mode-Bit (Default 1=Double Density) + /// + private bool CMD_FLAG_MF; - /// - /// Initial command byte flag - /// Bit5 Skip-Bit (set if secs with deleted DAM shall be skipped) - /// - private bool CMD_FLAG_SK; + /// + /// Initial command byte flag + /// Bit5 Skip-Bit (set if secs with deleted DAM shall be skipped) + /// + private bool CMD_FLAG_SK; - /// - /// Step Rate Time (supplied via the specify command) - /// SRT stands for the steooino rate for the FDD ( 1 to 16 ms in 1 ms increments). - /// Stepping rate applies to all drives(FH= 1ms, EH= 2ms, etc.). - /// - private int SRT; + /// + /// Step Rate Time (supplied via the specify command) + /// SRT stands for the steooino rate for the FDD ( 1 to 16 ms in 1 ms increments). + /// Stepping rate applies to all drives(FH= 1ms, EH= 2ms, etc.). + /// + private int SRT; - /// - /// Keeps track of the current SRT state - /// - private int SRT_Counter; + /// + /// Keeps track of the current SRT state + /// + private int SRT_Counter; - /// - /// Head Unload Time (supplied via the specify command) - /// HUT stands for the head unload time after a Read or Write operation has occurred - /// (16 to 240 ms in 16 ms Increments) - /// - private int HUT; + /// + /// Head Unload Time (supplied via the specify command) + /// HUT stands for the head unload time after a Read or Write operation has occurred + /// (16 to 240 ms in 16 ms Increments) + /// + private int HUT; - /// - /// Keeps track of the current HUT state - /// - private int HUT_Counter; + /// + /// Keeps track of the current HUT state + /// + private int HUT_Counter; - /// - /// Head load Time (supplied via the specify command) - /// HLT stands for the head load time in the FDD (2 to 254 ms in 2 ms Increments) - /// - private int HLT; + /// + /// Head load Time (supplied via the specify command) + /// HLT stands for the head load time in the FDD (2 to 254 ms in 2 ms Increments) + /// + private int HLT; - /// - /// Keeps track of the current HLT state - /// - private int HLT_Counter; + /// + /// Keeps track of the current HLT state + /// + private int HLT_Counter; - /// - /// Non-DMA Mode (supplied via the specify command) - /// ND stands for operation in the non-DMA mode - /// - private bool ND; + /// + /// Non-DMA Mode (supplied via the specify command) + /// ND stands for operation in the non-DMA mode + /// + private bool ND; - /// - /// In lieu of actual timing, this will count status reads in execution phase - /// where the CPU hasnt actually read any bytes - /// - private int OverrunCounter; + /// + /// In lieu of actual timing, this will count status reads in execution phase + /// where the CPU hasnt actually read any bytes + /// + private int OverrunCounter; - /// - /// Contains result bytes in result phase - /// - private byte[] ResBuffer = new byte[7]; + /// + /// Contains result bytes in result phase + /// + private byte[] ResBuffer = new byte[7]; - /// - /// Contains sector data to be written/read in execution phase - /// - private byte[] ExecBuffer = new byte[0x8000]; + /// + /// Contains sector data to be written/read in execution phase + /// + private byte[] ExecBuffer = new byte[0x8000]; - /// - /// Interrupt result buffer - /// Persists (and returns when needed) the last result data when a sense interrupt status command happens - /// - private byte[] InterruptResultBuffer = new byte[2]; + /// + /// Interrupt result buffer + /// Persists (and returns when needed) the last result data when a sense interrupt status command happens + /// + private byte[] InterruptResultBuffer = new byte[2]; - /// - /// Current index within the result buffer - /// - private int ResCounter = 0; + /// + /// Current index within the result buffer + /// + private int ResCounter = 0; - /// - /// The byte length of the currently active command - /// This may or may not be the same as the actual command resultbytes value - /// - private int ResLength = 0; + /// + /// The byte length of the currently active command + /// This may or may not be the same as the actual command resultbytes value + /// + private int ResLength = 0; - /// - /// Index for sector data within the result buffer - /// - private int ExecCounter = 0; + /// + /// Index for sector data within the result buffer + /// + private int ExecCounter = 0; - /// - /// The length of the current exec command - /// - private int ExecLength = 0; + /// + /// The length of the current exec command + /// + private int ExecLength = 0; - /// - /// The last write byte that was received during execution phase - /// - private byte LastSectorDataWriteByte = 0; + /// + /// The last write byte that was received during execution phase + /// + private byte LastSectorDataWriteByte = 0; - /// - /// The last read byte to be sent during execution phase - /// - private byte LastSectorDataReadByte = 0; + /// + /// The last read byte to be sent during execution phase + /// + private byte LastSectorDataReadByte = 0; - /// - /// The last parameter byte that was written to the FDC - /// - private byte LastByteReceived = 0; + /// + /// The last parameter byte that was written to the FDC + /// + private byte LastByteReceived = 0; - /// - /// Delay for reading sector - /// - private int SectorDelayCounter = 0; + /// + /// Delay for reading sector + /// + private int SectorDelayCounter = 0; - /// - /// The phyical sector ID - /// - private int SectorID = 0; + /// + /// The phyical sector ID + /// + private int SectorID = 0; - /// - /// Counter for index pulses - /// - private int IndexPulseCounter; + /// + /// Counter for index pulses + /// + private int IndexPulseCounter; - /// - /// Specifies the index of the currently selected command (in the CommandList) - /// - public int CMDIndex - { - get => _cmdIndex; - set - { - _cmdIndex = value; - ActiveCommand = CommandList[_cmdIndex]; - } - } - private int _cmdIndex; + /// + /// Specifies the index of the currently selected command (in the CommandList) + /// + public int CMDIndex + { + get => _cmdIndex; + set + { + _cmdIndex = value; + ActiveCommand = CommandList[_cmdIndex]; + } + } + private int _cmdIndex; - /// - /// The currently active command - /// - private Command ActiveCommand; + /// + /// The currently active command + /// + private Command ActiveCommand; - /// - /// Main status register (accessed via reads to port 0x2ffd) - /// - /* + /// + /// Main status register (accessed via reads to port 0x2ffd) + /// + /* b0..3 DB FDD0..3 Busy (seek/recalib active, until succesful sense intstat) b4 CB FDC Busy (still in command-, execution- or result-phase) b5 EXM Execution Mode (still in execution-phase, non_DMA_only) b6 DIO Data Input/Output (0=CPU->FDC, 1=FDC->CPU) (see b7) b7 RQM Request For Master (1=ready for next byte) (see b6 for direction) */ - private byte StatusMain; + private byte StatusMain; - /// - /// Status Register 0 - /// - /* + /// + /// Status Register 0 + /// + /* b0,1 US Unit Select (driveno during interrupt) b2 HD Head Address (head during interrupt) b3 NR Not Ready (drive not ready or non-existing 2nd head selected) @@ -230,12 +230,12 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum b6,7 IC Interrupt Code (0=OK, 1=aborted:readfail/OK if EN, 2=unknown cmd or senseint with no int occured, 3=aborted:disc removed etc.) */ - private byte Status0; + private byte Status0; - /// - /// Status Register 1 - /// - /* + /// + /// Status Register 1 + /// + /* b0 MA Missing Address Mark (Sector_ID or DAM not found) b1 NW Not Writeable (tried to write/format disc with wprot_tab=on) b2 ND No Data (Sector_ID not found, CRC fail in ID_field) @@ -244,12 +244,12 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum b5 DE Data Error (CRC-fail in ID- or Data-Field) b7 EN End of Track (set past most read/write commands) (see IC) */ - private byte Status1; + private byte Status1; - /// - /// Status Register 2 - /// - /* + /// + /// Status Register 2 + /// + /* b0 MD Missing Address Mark in Data Field (DAM not found) b1 BC Bad Cylinder (read/programmed track-ID different and read-ID = FF) b2 SN Scan Not Satisfied (no fitting sector found) @@ -259,12 +259,12 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum b6 CM Control Mark (read/scan command found sector with deleted DAM) b7 0 Not Used */ - private byte Status2; + private byte Status2; - /// - /// Status Register 3 - /// - /* + /// + /// Status Register 3 + /// + /* b0,1 US Unit Select (pin 28,29 of FDC) b2 HD Head Address (pin 27 of FDC) b3 TS Two Side (0=yes, 1=no (!)) @@ -273,1900 +273,1900 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum b6 WP Write Protected (write protected) b7 FT Fault (if supported: 1=Drive failure) */ - private byte Status3; + private byte Status3; - #endregion + #endregion - #region UPD Internal Functions + #region UPD Internal Functions - #region READ Commands + #region READ Commands - /// - /// Read Data - /// COMMAND: 8 parameter bytes - /// EXECUTION: Data transfer between FDD and FDC - /// RESULT: 7 result bytes - /// - private void UPD_ReadData() - { - switch (ActivePhase) - { - //---------------------------------------- - // FDC is waiting for a command byte - //---------------------------------------- - case Phase.Idle: - break; + /// + /// Read Data + /// COMMAND: 8 parameter bytes + /// EXECUTION: Data transfer between FDD and FDC + /// RESULT: 7 result bytes + /// + private void UPD_ReadData() + { + switch (ActivePhase) + { + //---------------------------------------- + // FDC is waiting for a command byte + //---------------------------------------- + case Phase.Idle: + break; - //---------------------------------------- - // Receiving command parameter bytes - //---------------------------------------- - case Phase.Command: + //---------------------------------------- + // Receiving command parameter bytes + //---------------------------------------- + case Phase.Command: - // store the parameter in the command buffer - CommBuffer[CommCounter] = LastByteReceived; + // store the parameter in the command buffer + CommBuffer[CommCounter] = LastByteReceived; - // process parameter byte - ParseParamByteStandard(CommCounter); + // process parameter byte + ParseParamByteStandard(CommCounter); - // increment command parameter counter - CommCounter++; + // increment command parameter counter + CommCounter++; - // was that the last parameter byte? - if (CommCounter == ActiveCommand.ParameterByteCount) - { - // all parameter bytes received - setup for execution phase + // was that the last parameter byte? + if (CommCounter == ActiveCommand.ParameterByteCount) + { + // all parameter bytes received - setup for execution phase - // clear exec buffer and status registers - ClearExecBuffer(); - Status0 = 0; - Status1 = 0; - Status2 = 0; - Status3 = 0; + // clear exec buffer and status registers + ClearExecBuffer(); + Status0 = 0; + Status1 = 0; + Status2 = 0; + Status3 = 0; - // temp sector index - byte secIdx = ActiveCommandParams.Sector; + // temp sector index + byte secIdx = ActiveCommandParams.Sector; - // hack for when another drive (non-existent) is being called - if (ActiveDrive.ID != 0) - DiskDriveIndex = 0; + // hack for when another drive (non-existent) is being called + if (ActiveDrive.ID != 0) + DiskDriveIndex = 0; - // do we have a valid disk inserted? - if (!ActiveDrive.FLAG_READY) - { - // no disk, no tracks or motor is not on - SetBit(SR0_IC0, ref Status0); - SetBit(SR0_NR, ref Status0); + // do we have a valid disk inserted? + if (!ActiveDrive.FLAG_READY) + { + // no disk, no tracks or motor is not on + SetBit(SR0_IC0, ref Status0); + SetBit(SR0_NR, ref Status0); - CommitResultCHRN(); - CommitResultStatus(); - //ResBuffer[RS_ST0] = Status0; + CommitResultCHRN(); + CommitResultStatus(); + //ResBuffer[RS_ST0] = Status0; - // move to result phase - ActivePhase = Phase.Result; - break; - } + // move to result phase + ActivePhase = Phase.Result; + break; + } - int buffPos = 0; - int sectorSize = 0; - int maxTransferCap = 0; + int buffPos = 0; + int sectorSize = 0; + int maxTransferCap = 0; - // calculate requested size of data required - if (ActiveCommandParams.SectorSize == 0) - { - // When N=0, then DTL defines the data length which the FDC must treat as a sector. If DTL is smaller than the actual - // data length in a sector, the data beyond DTL in the sector is not sent to the Data Bus. The FDC reads (internally) - // the complete sector performing the CRC check and, depending upon the manner of command termination, may perform - // a Multi-Sector Read Operation. - sectorSize = ActiveCommandParams.DTL; + // calculate requested size of data required + if (ActiveCommandParams.SectorSize == 0) + { + // When N=0, then DTL defines the data length which the FDC must treat as a sector. If DTL is smaller than the actual + // data length in a sector, the data beyond DTL in the sector is not sent to the Data Bus. The FDC reads (internally) + // the complete sector performing the CRC check and, depending upon the manner of command termination, may perform + // a Multi-Sector Read Operation. + sectorSize = ActiveCommandParams.DTL; - // calculate maximum transfer capacity - if (!CMD_FLAG_MF) - maxTransferCap = 3328; + // calculate maximum transfer capacity + if (!CMD_FLAG_MF) + maxTransferCap = 3328; if (maxTransferCap == 0) { } - } - else - { - // When N is non - zero, then DTL has no meaning and should be set to ffh - ActiveCommandParams.DTL = 0xFF; + } + else + { + // When N is non - zero, then DTL has no meaning and should be set to ffh + ActiveCommandParams.DTL = 0xFF; - // calculate maximum transfer capacity - switch (ActiveCommandParams.SectorSize) - { - case 1: - if (CMD_FLAG_MF) - maxTransferCap = 6656; - else - maxTransferCap = 3840; - break; - case 2: - if (CMD_FLAG_MF) - maxTransferCap = 7680; - else - maxTransferCap = 4096; - break; - case 3: - if (CMD_FLAG_MF) - maxTransferCap = 8192; - else - maxTransferCap = 4096; - break; - } + // calculate maximum transfer capacity + switch (ActiveCommandParams.SectorSize) + { + case 1: + if (CMD_FLAG_MF) + maxTransferCap = 6656; + else + maxTransferCap = 3840; + break; + case 2: + if (CMD_FLAG_MF) + maxTransferCap = 7680; + else + maxTransferCap = 4096; + break; + case 3: + if (CMD_FLAG_MF) + maxTransferCap = 8192; + else + maxTransferCap = 4096; + break; + } - sectorSize = 0x80 << ActiveCommandParams.SectorSize; - } + sectorSize = 0x80 << ActiveCommandParams.SectorSize; + } - // get the current track - var track = ActiveDrive.Disk.DiskTracks.Where(a => a.TrackNumber == ActiveDrive.CurrentTrackID).FirstOrDefault(); + // get the current track + var track = ActiveDrive.Disk.DiskTracks.FirstOrDefault(a => a.TrackNumber == ActiveDrive.CurrentTrackID); - if (track == null || track.NumberOfSectors <= 0) - { - // track could not be found - SetBit(SR0_IC0, ref Status0); - SetBit(SR0_NR, ref Status0); + if (track == null || track.NumberOfSectors <= 0) + { + // track could not be found + SetBit(SR0_IC0, ref Status0); + SetBit(SR0_NR, ref Status0); - CommitResultCHRN(); - CommitResultStatus(); + CommitResultCHRN(); + CommitResultStatus(); - //ResBuffer[RS_ST0] = Status0; + //ResBuffer[RS_ST0] = Status0; - // move to result phase - ActivePhase = Phase.Result; - break; - } + // move to result phase + ActivePhase = Phase.Result; + break; + } - FloppyDisk.Sector sector = null; + FloppyDisk.Sector sector = null; - // sector read loop - for (;;) - { - bool terminate = false; + // sector read loop + for (; ; ) + { + bool terminate = false; - // lookup the sector - sector = GetSector(); + // lookup the sector + sector = GetSector(); - if (sector == null) - { - // sector was not found after two passes of the disk index hole - SetBit(SR1_ND, ref Status1); - SetBit(SR0_IC0, ref Status0); - UnSetBit(SR0_IC1, ref Status0); + if (sector == null) + { + // sector was not found after two passes of the disk index hole + SetBit(SR1_ND, ref Status1); + SetBit(SR0_IC0, ref Status0); + UnSetBit(SR0_IC1, ref Status0); - // result requires the actual track id, rather than the sector track id - ActiveCommandParams.Cylinder = track.TrackNumber; + // result requires the actual track id, rather than the sector track id + ActiveCommandParams.Cylinder = track.TrackNumber; - CommitResultCHRN(); - CommitResultStatus(); - ActivePhase = Phase.Result; - break; - } + CommitResultCHRN(); + CommitResultStatus(); + ActivePhase = Phase.Result; + break; + } - // sector ID was found on this track + // sector ID was found on this track - // get status regs from sector - Status1 = sector.Status1; - Status2 = sector.Status2; + // get status regs from sector + Status1 = sector.Status1; + Status2 = sector.Status2; - // we dont need EN - UnSetBit(SR1_EN, ref Status1); + // we dont need EN + UnSetBit(SR1_EN, ref Status1); - // If SK=1, the FDC skips the sector with the Deleted Data Address Mark and reads the next sector. - // The CRC bits in the deleted data field are not checked when SK=1 - if (CMD_FLAG_SK && Status2.Bit(SR2_CM)) - { - if (ActiveCommandParams.Sector != ActiveCommandParams.EOT) - { - // increment the sector ID and search again - ActiveCommandParams.Sector++; - continue; - } - else - { - // no execution phase - SetBit(SR0_IC0, ref Status0); - UnSetBit(SR0_IC1, ref Status0); + // If SK=1, the FDC skips the sector with the Deleted Data Address Mark and reads the next sector. + // The CRC bits in the deleted data field are not checked when SK=1 + if (CMD_FLAG_SK && Status2.Bit(SR2_CM)) + { + if (ActiveCommandParams.Sector != ActiveCommandParams.EOT) + { + // increment the sector ID and search again + ActiveCommandParams.Sector++; + continue; + } + else + { + // no execution phase + SetBit(SR0_IC0, ref Status0); + UnSetBit(SR0_IC1, ref Status0); - // result requires the actual track id, rather than the sector track id - ActiveCommandParams.Cylinder = track.TrackNumber; + // result requires the actual track id, rather than the sector track id + ActiveCommandParams.Cylinder = track.TrackNumber; - CommitResultCHRN(); - CommitResultStatus(); - ActivePhase = Phase.Result; - break; - } - } + CommitResultCHRN(); + CommitResultStatus(); + ActivePhase = Phase.Result; + break; + } + } - // read the sector - for (int i = 0; i < sector.DataLen; i++) - { - ExecBuffer[buffPos++] = sector.ActualData[i]; - } + // read the sector + for (int i = 0; i < sector.DataLen; i++) + { + ExecBuffer[buffPos++] = sector.ActualData[i]; + } - // mark the sector read - sector.SectorReadCompleted(); + // mark the sector read + sector.SectorReadCompleted(); - // any CRC errors? - if (Status1.Bit(SR1_DE) || Status2.Bit(SR2_DD)) - { - SetBit(SR0_IC0, ref Status0); - UnSetBit(SR0_IC1, ref Status0); - terminate = true; - } + // any CRC errors? + if (Status1.Bit(SR1_DE) || Status2.Bit(SR2_DD)) + { + SetBit(SR0_IC0, ref Status0); + UnSetBit(SR0_IC1, ref Status0); + terminate = true; + } - if (!CMD_FLAG_SK && Status2.Bit(SR2_CM)) - { - // deleted address mark was detected with NO skip flag set - ActiveCommandParams.EOT = ActiveCommandParams.Sector; - SetBit(SR2_CM, ref Status2); - SetBit(SR0_IC0, ref Status0); - UnSetBit(SR0_IC1, ref Status0); - terminate = true; - } + if (!CMD_FLAG_SK && Status2.Bit(SR2_CM)) + { + // deleted address mark was detected with NO skip flag set + ActiveCommandParams.EOT = ActiveCommandParams.Sector; + SetBit(SR2_CM, ref Status2); + SetBit(SR0_IC0, ref Status0); + UnSetBit(SR0_IC1, ref Status0); + terminate = true; + } - if (sector.SectorID == ActiveCommandParams.EOT || terminate) - { - // this was the last sector to read - // or termination requested + if (sector.SectorID == ActiveCommandParams.EOT || terminate) + { + // this was the last sector to read + // or termination requested - SetBit(SR1_EN, ref Status1); + SetBit(SR1_EN, ref Status1); - int keyIndex = 0; - for (int i = 0; i < track.Sectors.Length; i++) - { - if (track.Sectors[i].SectorID == sector.SectorID) - { - keyIndex = i; - break; - } - } + int keyIndex = 0; + for (int i = 0; i < track.Sectors.Length; i++) + { + if (track.Sectors[i].SectorID == sector.SectorID) + { + keyIndex = i; + break; + } + } - if (keyIndex == track.Sectors.Length - 1) - { - // last sector on the cylinder, set EN - SetBit(SR1_EN, ref Status1); + if (keyIndex == track.Sectors.Length - 1) + { + // last sector on the cylinder, set EN + SetBit(SR1_EN, ref Status1); - // increment cylinder - ActiveCommandParams.Cylinder++; + // increment cylinder + ActiveCommandParams.Cylinder++; - // reset sector - ActiveCommandParams.Sector = sector.SectorID; // 1; - ActiveDrive.SectorIndex = 0; - } - else - { - ActiveDrive.SectorIndex++; - } + // reset sector + ActiveCommandParams.Sector = sector.SectorID; // 1; + ActiveDrive.SectorIndex = 0; + } + else + { + ActiveDrive.SectorIndex++; + } - UnSetBit(SR0_IC1, ref Status0); - if (terminate) - SetBit(SR0_IC0, ref Status0); - else - UnSetBit(SR0_IC0, ref Status0); + UnSetBit(SR0_IC1, ref Status0); + if (terminate) + SetBit(SR0_IC0, ref Status0); + else + UnSetBit(SR0_IC0, ref Status0); - SetBit(SR0_IC0, ref Status0); + SetBit(SR0_IC0, ref Status0); - // result requires the actual track id, rather than the sector track id - ActiveCommandParams.Cylinder = track.TrackNumber; + // result requires the actual track id, rather than the sector track id + ActiveCommandParams.Cylinder = track.TrackNumber; - CommitResultCHRN(); - CommitResultStatus(); - ActivePhase = Phase.Execution; - break; - } - else - { - // continue with multi-sector read operation - ActiveCommandParams.Sector++; - //ActiveDrive.SectorIndex++; - } - } + CommitResultCHRN(); + CommitResultStatus(); + ActivePhase = Phase.Execution; + break; + } + else + { + // continue with multi-sector read operation + ActiveCommandParams.Sector++; + //ActiveDrive.SectorIndex++; + } + } - if (ActivePhase == Phase.Execution) - { - ExecLength = buffPos; - ExecCounter = buffPos; + if (ActivePhase == Phase.Execution) + { + ExecLength = buffPos; + ExecCounter = buffPos; - DriveLight = true; - } - } + DriveLight = true; + } + } - break; + break; - //---------------------------------------- - // FDC in execution phase reading/writing bytes - //---------------------------------------- - case Phase.Execution: + //---------------------------------------- + // FDC in execution phase reading/writing bytes + //---------------------------------------- + case Phase.Execution: - var index = ExecLength - ExecCounter; + var index = ExecLength - ExecCounter; - LastSectorDataReadByte = ExecBuffer[index]; + LastSectorDataReadByte = ExecBuffer[index]; - OverrunCounter--; - ExecCounter--; + OverrunCounter--; + ExecCounter--; - break; + break; - //---------------------------------------- - // Result bytes being sent to CPU - //---------------------------------------- - case Phase.Result: - break; - } - } + //---------------------------------------- + // Result bytes being sent to CPU + //---------------------------------------- + case Phase.Result: + break; + } + } - /// - /// Read Deleted Data - /// COMMAND: 8 parameter bytes - /// EXECUTION: Data transfer between the FDD and FDC - /// RESULT: 7 result bytes - /// - private void UPD_ReadDeletedData() - { - switch (ActivePhase) - { - //---------------------------------------- - // FDC is waiting for a command byte - //---------------------------------------- - case Phase.Idle: - break; + /// + /// Read Deleted Data + /// COMMAND: 8 parameter bytes + /// EXECUTION: Data transfer between the FDD and FDC + /// RESULT: 7 result bytes + /// + private void UPD_ReadDeletedData() + { + switch (ActivePhase) + { + //---------------------------------------- + // FDC is waiting for a command byte + //---------------------------------------- + case Phase.Idle: + break; - //---------------------------------------- - // Receiving command parameter bytes - //---------------------------------------- - case Phase.Command: - // store the parameter in the command buffer - CommBuffer[CommCounter] = LastByteReceived; + //---------------------------------------- + // Receiving command parameter bytes + //---------------------------------------- + case Phase.Command: + // store the parameter in the command buffer + CommBuffer[CommCounter] = LastByteReceived; - // process parameter byte - ParseParamByteStandard(CommCounter); + // process parameter byte + ParseParamByteStandard(CommCounter); - // increment command parameter counter - CommCounter++; + // increment command parameter counter + CommCounter++; - // was that the last parameter byte? - if (CommCounter == ActiveCommand.ParameterByteCount) - { - // all parameter bytes received - setup for execution phase + // was that the last parameter byte? + if (CommCounter == ActiveCommand.ParameterByteCount) + { + // all parameter bytes received - setup for execution phase - // clear exec buffer and status registers - ClearExecBuffer(); - Status0 = 0; - Status1 = 0; - Status2 = 0; - Status3 = 0; + // clear exec buffer and status registers + ClearExecBuffer(); + Status0 = 0; + Status1 = 0; + Status2 = 0; + Status3 = 0; - // temp sector index - byte secIdx = ActiveCommandParams.Sector; + // temp sector index + byte secIdx = ActiveCommandParams.Sector; - // do we have a valid disk inserted? - if (!ActiveDrive.FLAG_READY) - { - // no disk, no tracks or motor is not on - SetBit(SR0_IC0, ref Status0); - SetBit(SR0_NR, ref Status0); + // do we have a valid disk inserted? + if (!ActiveDrive.FLAG_READY) + { + // no disk, no tracks or motor is not on + SetBit(SR0_IC0, ref Status0); + SetBit(SR0_NR, ref Status0); - CommitResultCHRN(); - CommitResultStatus(); - //ResBuffer[RS_ST0] = Status0; + CommitResultCHRN(); + CommitResultStatus(); + //ResBuffer[RS_ST0] = Status0; - // move to result phase - ActivePhase = Phase.Result; - break; - } + // move to result phase + ActivePhase = Phase.Result; + break; + } - int buffPos = 0; - int sectorSize = 0; - int maxTransferCap = 0; + int buffPos = 0; + int sectorSize = 0; + int maxTransferCap = 0; if (maxTransferCap > 0) { } - // calculate requested size of data required - if (ActiveCommandParams.SectorSize == 0) - { - // When N=0, then DTL defines the data length which the FDC must treat as a sector. If DTL is smaller than the actual - // data length in a sector, the data beyond DTL in the sector is not sent to the Data Bus. The FDC reads (internally) - // the complete sector performing the CRC check and, depending upon the manner of command termination, may perform - // a Multi-Sector Read Operation. - sectorSize = ActiveCommandParams.DTL; + // calculate requested size of data required + if (ActiveCommandParams.SectorSize == 0) + { + // When N=0, then DTL defines the data length which the FDC must treat as a sector. If DTL is smaller than the actual + // data length in a sector, the data beyond DTL in the sector is not sent to the Data Bus. The FDC reads (internally) + // the complete sector performing the CRC check and, depending upon the manner of command termination, may perform + // a Multi-Sector Read Operation. + sectorSize = ActiveCommandParams.DTL; - // calculate maximum transfer capacity - if (!CMD_FLAG_MF) - maxTransferCap = 3328; - } - else - { - // When N is non - zero, then DTL has no meaning and should be set to ffh - ActiveCommandParams.DTL = 0xFF; + // calculate maximum transfer capacity + if (!CMD_FLAG_MF) + maxTransferCap = 3328; + } + else + { + // When N is non - zero, then DTL has no meaning and should be set to ffh + ActiveCommandParams.DTL = 0xFF; - // calculate maximum transfer capacity - switch (ActiveCommandParams.SectorSize) - { - case 1: - if (CMD_FLAG_MF) - maxTransferCap = 6656; - else - maxTransferCap = 3840; - break; - case 2: - if (CMD_FLAG_MF) - maxTransferCap = 7680; - else - maxTransferCap = 4096; - break; - case 3: - if (CMD_FLAG_MF) - maxTransferCap = 8192; - else - maxTransferCap = 4096; - break; - } + // calculate maximum transfer capacity + switch (ActiveCommandParams.SectorSize) + { + case 1: + if (CMD_FLAG_MF) + maxTransferCap = 6656; + else + maxTransferCap = 3840; + break; + case 2: + if (CMD_FLAG_MF) + maxTransferCap = 7680; + else + maxTransferCap = 4096; + break; + case 3: + if (CMD_FLAG_MF) + maxTransferCap = 8192; + else + maxTransferCap = 4096; + break; + } - sectorSize = 0x80 << ActiveCommandParams.SectorSize; - } + sectorSize = 0x80 << ActiveCommandParams.SectorSize; + } - // get the current track - var track = ActiveDrive.Disk.DiskTracks.Where(a => a.TrackNumber == ActiveDrive.CurrentTrackID).FirstOrDefault(); + // get the current track + var track = ActiveDrive.Disk.DiskTracks.FirstOrDefault(a => a.TrackNumber == ActiveDrive.CurrentTrackID); - if (track == null || track.NumberOfSectors <= 0) - { - // track could not be found - SetBit(SR0_IC0, ref Status0); - SetBit(SR0_NR, ref Status0); + if (track == null || track.NumberOfSectors <= 0) + { + // track could not be found + SetBit(SR0_IC0, ref Status0); + SetBit(SR0_NR, ref Status0); - CommitResultCHRN(); - CommitResultStatus(); + CommitResultCHRN(); + CommitResultStatus(); - //ResBuffer[RS_ST0] = Status0; + //ResBuffer[RS_ST0] = Status0; - // move to result phase - ActivePhase = Phase.Result; - break; - } + // move to result phase + ActivePhase = Phase.Result; + break; + } - FloppyDisk.Sector sector = null; + FloppyDisk.Sector sector = null; - // sector read loop - for (;;) - { - bool terminate = false; + // sector read loop + for (; ; ) + { + bool terminate = false; - // lookup the sector - sector = GetSector(); + // lookup the sector + sector = GetSector(); - if (sector == null) - { - // sector was not found after two passes of the disk index hole - SetBit(SR1_ND, ref Status1); - SetBit(SR0_IC0, ref Status0); - UnSetBit(SR0_IC1, ref Status0); + if (sector == null) + { + // sector was not found after two passes of the disk index hole + SetBit(SR1_ND, ref Status1); + SetBit(SR0_IC0, ref Status0); + UnSetBit(SR0_IC1, ref Status0); - // result requires the actual track id, rather than the sector track id - ActiveCommandParams.Cylinder = track.TrackNumber; + // result requires the actual track id, rather than the sector track id + ActiveCommandParams.Cylinder = track.TrackNumber; - CommitResultCHRN(); - CommitResultStatus(); - ActivePhase = Phase.Result; - break; - } + CommitResultCHRN(); + CommitResultStatus(); + ActivePhase = Phase.Result; + break; + } - // sector ID was found on this track + // sector ID was found on this track - // get status regs from sector - Status1 = sector.Status1; - Status2 = sector.Status2; + // get status regs from sector + Status1 = sector.Status1; + Status2 = sector.Status2; - // we dont need EN - UnSetBit(SR1_EN, ref Status1); + // we dont need EN + UnSetBit(SR1_EN, ref Status1); - // invert CM for read deleted data command - if (Status2.Bit(SR2_CM)) - UnSetBit(SR2_CM, ref Status2); - else - SetBit(SR2_CM, ref Status2); + // invert CM for read deleted data command + if (Status2.Bit(SR2_CM)) + UnSetBit(SR2_CM, ref Status2); + else + SetBit(SR2_CM, ref Status2); - // skip flag is set and no DAM found - if (CMD_FLAG_SK && Status2.Bit(SR2_CM)) - { - if (ActiveCommandParams.Sector != ActiveCommandParams.EOT) - { - // increment the sector ID and search again - ActiveCommandParams.Sector++; - continue; - } - else - { - // no execution phase - SetBit(SR0_IC0, ref Status0); - UnSetBit(SR0_IC1, ref Status0); + // skip flag is set and no DAM found + if (CMD_FLAG_SK && Status2.Bit(SR2_CM)) + { + if (ActiveCommandParams.Sector != ActiveCommandParams.EOT) + { + // increment the sector ID and search again + ActiveCommandParams.Sector++; + continue; + } + else + { + // no execution phase + SetBit(SR0_IC0, ref Status0); + UnSetBit(SR0_IC1, ref Status0); - // result requires the actual track id, rather than the sector track id - ActiveCommandParams.Cylinder = track.TrackNumber; + // result requires the actual track id, rather than the sector track id + ActiveCommandParams.Cylinder = track.TrackNumber; - CommitResultCHRN(); - CommitResultStatus(); - ActivePhase = Phase.Result; - break; - } - } - // we can read this sector - else - { - // if DAM is not set this will be the last sector to read - if (Status2.Bit(SR2_CM)) - { - ActiveCommandParams.EOT = ActiveCommandParams.Sector; - } + CommitResultCHRN(); + CommitResultStatus(); + ActivePhase = Phase.Result; + break; + } + } + // we can read this sector + else + { + // if DAM is not set this will be the last sector to read + if (Status2.Bit(SR2_CM)) + { + ActiveCommandParams.EOT = ActiveCommandParams.Sector; + } - if (!CMD_FLAG_SK && !Status2.Bit(SR2_CM) && - ActiveDrive.Disk.Protection == ProtectionType.PaulOwens) - { - ActiveCommandParams.EOT = ActiveCommandParams.Sector; - SetBit(SR2_CM, ref Status2); - SetBit(SR0_IC0, ref Status0); - UnSetBit(SR0_IC1, ref Status0); - terminate = true; - } + if (!CMD_FLAG_SK && !Status2.Bit(SR2_CM) && + ActiveDrive.Disk.Protection == ProtectionType.PaulOwens) + { + ActiveCommandParams.EOT = ActiveCommandParams.Sector; + SetBit(SR2_CM, ref Status2); + SetBit(SR0_IC0, ref Status0); + UnSetBit(SR0_IC1, ref Status0); + terminate = true; + } - // read the sector - for (int i = 0; i < sectorSize; i++) - { - ExecBuffer[buffPos++] = sector.ActualData[i]; - } + // read the sector + for (int i = 0; i < sectorSize; i++) + { + ExecBuffer[buffPos++] = sector.ActualData[i]; + } - // mark the sector read - sector.SectorReadCompleted(); + // mark the sector read + sector.SectorReadCompleted(); - if (sector.SectorID == ActiveCommandParams.EOT) - { - // this was the last sector to read + if (sector.SectorID == ActiveCommandParams.EOT) + { + // this was the last sector to read - SetBit(SR1_EN, ref Status1); + SetBit(SR1_EN, ref Status1); - int keyIndex = 0; - for (int i = 0; i < track.Sectors.Length; i++) - { - if (track.Sectors[i].SectorID == sector.SectorID) - { - keyIndex = i; - break; - } - } + int keyIndex = 0; + for (int i = 0; i < track.Sectors.Length; i++) + { + if (track.Sectors[i].SectorID == sector.SectorID) + { + keyIndex = i; + break; + } + } - if (keyIndex == track.Sectors.Length - 1) - { - // last sector on the cylinder, set EN - SetBit(SR1_EN, ref Status1); + if (keyIndex == track.Sectors.Length - 1) + { + // last sector on the cylinder, set EN + SetBit(SR1_EN, ref Status1); - // increment cylinder - ActiveCommandParams.Cylinder++; + // increment cylinder + ActiveCommandParams.Cylinder++; - // reset sector - ActiveCommandParams.Sector = 1; - ActiveDrive.SectorIndex = 0; - } - else - { - ActiveDrive.SectorIndex++; - } + // reset sector + ActiveCommandParams.Sector = 1; + ActiveDrive.SectorIndex = 0; + } + else + { + ActiveDrive.SectorIndex++; + } - UnSetBit(SR0_IC1, ref Status0); - if (terminate) - SetBit(SR0_IC0, ref Status0); - else - UnSetBit(SR0_IC0, ref Status0); + UnSetBit(SR0_IC1, ref Status0); + if (terminate) + SetBit(SR0_IC0, ref Status0); + else + UnSetBit(SR0_IC0, ref Status0); - SetBit(SR0_IC0, ref Status0); + SetBit(SR0_IC0, ref Status0); - // result requires the actual track id, rather than the sector track id - ActiveCommandParams.Cylinder = track.TrackNumber; + // result requires the actual track id, rather than the sector track id + ActiveCommandParams.Cylinder = track.TrackNumber; - // remove CM (appears to be required to defeat Alkatraz copy protection) - UnSetBit(SR2_CM, ref Status2); + // remove CM (appears to be required to defeat Alkatraz copy protection) + UnSetBit(SR2_CM, ref Status2); - CommitResultCHRN(); - CommitResultStatus(); - ActivePhase = Phase.Execution; - break; - } - else - { - // continue with multi-sector read operation - ActiveCommandParams.Sector++; - //ActiveDrive.SectorIndex++; - } - } - } + CommitResultCHRN(); + CommitResultStatus(); + ActivePhase = Phase.Execution; + break; + } + else + { + // continue with multi-sector read operation + ActiveCommandParams.Sector++; + //ActiveDrive.SectorIndex++; + } + } + } - if (ActivePhase == Phase.Execution) - { - ExecLength = buffPos; - ExecCounter = buffPos; - DriveLight = true; - } - } - break; + if (ActivePhase == Phase.Execution) + { + ExecLength = buffPos; + ExecCounter = buffPos; + DriveLight = true; + } + } + break; - //---------------------------------------- - // FDC in execution phase reading/writing bytes - //---------------------------------------- - case Phase.Execution: - var index = ExecLength - ExecCounter; + //---------------------------------------- + // FDC in execution phase reading/writing bytes + //---------------------------------------- + case Phase.Execution: + var index = ExecLength - ExecCounter; - LastSectorDataReadByte = ExecBuffer[index]; + LastSectorDataReadByte = ExecBuffer[index]; - OverrunCounter--; - ExecCounter--; - - break; + OverrunCounter--; + ExecCounter--; - //---------------------------------------- - // Result bytes being sent to CPU - //---------------------------------------- - case Phase.Result: - break; - } - } + break; - /// - /// Read Diagnostic (read track) - /// COMMAND: 8 parameter bytes - /// EXECUTION: Data transfer between FDD and FDC. FDC reads all data fields from index hole to EDT - /// RESULT: 7 result bytes - /// - private void UPD_ReadDiagnostic() - { - switch (ActivePhase) - { - //---------------------------------------- - // FDC is waiting for a command byte - //---------------------------------------- - case Phase.Idle: - break; + //---------------------------------------- + // Result bytes being sent to CPU + //---------------------------------------- + case Phase.Result: + break; + } + } - //---------------------------------------- - // Receiving command parameter bytes - //---------------------------------------- - case Phase.Command: + /// + /// Read Diagnostic (read track) + /// COMMAND: 8 parameter bytes + /// EXECUTION: Data transfer between FDD and FDC. FDC reads all data fields from index hole to EDT + /// RESULT: 7 result bytes + /// + private void UPD_ReadDiagnostic() + { + switch (ActivePhase) + { + //---------------------------------------- + // FDC is waiting for a command byte + //---------------------------------------- + case Phase.Idle: + break; - // store the parameter in the command buffer - CommBuffer[CommCounter] = LastByteReceived; + //---------------------------------------- + // Receiving command parameter bytes + //---------------------------------------- + case Phase.Command: - // process parameter byte - ParseParamByteStandard(CommCounter); + // store the parameter in the command buffer + CommBuffer[CommCounter] = LastByteReceived; - // increment command parameter counter - CommCounter++; + // process parameter byte + ParseParamByteStandard(CommCounter); - // was that the last parameter byte? - if (CommCounter == ActiveCommand.ParameterByteCount) - { - // all parameter bytes received - setup for execution phase + // increment command parameter counter + CommCounter++; - // clear exec buffer and status registers - ClearExecBuffer(); - Status0 = 0; - Status1 = 0; - Status2 = 0; - Status3 = 0; + // was that the last parameter byte? + if (CommCounter == ActiveCommand.ParameterByteCount) + { + // all parameter bytes received - setup for execution phase - // temp sector index - byte secIdx = ActiveCommandParams.Sector; + // clear exec buffer and status registers + ClearExecBuffer(); + Status0 = 0; + Status1 = 0; + Status2 = 0; + Status3 = 0; - // do we have a valid disk inserted? - if (!ActiveDrive.FLAG_READY) - { - // no disk, no tracks or motor is not on - SetBit(SR0_IC0, ref Status0); - SetBit(SR0_NR, ref Status0); + // temp sector index + byte secIdx = ActiveCommandParams.Sector; - CommitResultCHRN(); - CommitResultStatus(); - //ResBuffer[RS_ST0] = Status0; + // do we have a valid disk inserted? + if (!ActiveDrive.FLAG_READY) + { + // no disk, no tracks or motor is not on + SetBit(SR0_IC0, ref Status0); + SetBit(SR0_NR, ref Status0); - // move to result phase - ActivePhase = Phase.Result; - break; - } + CommitResultCHRN(); + CommitResultStatus(); + //ResBuffer[RS_ST0] = Status0; - int buffPos = 0; - int sectorSize = 0; - int maxTransferCap = 0; + // move to result phase + ActivePhase = Phase.Result; + break; + } + + int buffPos = 0; + int sectorSize = 0; + int maxTransferCap = 0; if (maxTransferCap > 0) { } - // calculate requested size of data required - if (ActiveCommandParams.SectorSize == 0) - { - // When N=0, then DTL defines the data length which the FDC must treat as a sector. If DTL is smaller than the actual - // data length in a sector, the data beyond DTL in the sector is not sent to the Data Bus. The FDC reads (internally) - // the complete sector performing the CRC check and, depending upon the manner of command termination, may perform - // a Multi-Sector Read Operation. - sectorSize = ActiveCommandParams.DTL; - - // calculate maximum transfer capacity - if (!CMD_FLAG_MF) - maxTransferCap = 3328; - } - else - { - // When N is non - zero, then DTL has no meaning and should be set to ffh - ActiveCommandParams.DTL = 0xFF; - - // calculate maximum transfer capacity - switch (ActiveCommandParams.SectorSize) - { - case 1: - if (CMD_FLAG_MF) - maxTransferCap = 6656; - else - maxTransferCap = 3840; - break; - case 2: - if (CMD_FLAG_MF) - maxTransferCap = 7680; - else - maxTransferCap = 4096; - break; - case 3: - if (CMD_FLAG_MF) - maxTransferCap = 8192; - else - maxTransferCap = 4096; - break; - } - - sectorSize = 0x80 << ActiveCommandParams.SectorSize; - } - - // get the current track - var track = ActiveDrive.Disk.DiskTracks.Where(a => a.TrackNumber == ActiveDrive.CurrentTrackID).FirstOrDefault(); - - if (track == null || track.NumberOfSectors <= 0) - { - // track could not be found - SetBit(SR0_IC0, ref Status0); - SetBit(SR0_NR, ref Status0); - - CommitResultCHRN(); - CommitResultStatus(); - - //ResBuffer[RS_ST0] = Status0; - - // move to result phase - ActivePhase = Phase.Result; - break; - } - - //FloppyDisk.Sector sector = null; - ActiveDrive.SectorIndex = 0; - - int secCount = 0; - - // read the whole track - for (int i = 0; i < track.Sectors.Length; i++) - { - if (secCount >= ActiveCommandParams.EOT) - { - break; - } - - var sec = track.Sectors[i]; - for (int b = 0; b < sec.ActualData.Length; b++) - { - ExecBuffer[buffPos++] = sec.ActualData[b]; - } - - // mark the sector read - sec.SectorReadCompleted(); - - // end of sector - compare IDs - if (sec.TrackNumber != ActiveCommandParams.Cylinder || - sec.SideNumber != ActiveCommandParams.Head || - sec.SectorID != ActiveCommandParams.Sector || - sec.SectorSize != ActiveCommandParams.SectorSize) - { - SetBit(SR1_ND, ref Status1); - } - - secCount++; - ActiveDrive.SectorIndex = i; - } - - if (secCount == ActiveCommandParams.EOT) - { - // this was the last sector to read - // or termination requested - - int keyIndex = 0; - for (int i = 0; i < track.Sectors.Length; i++) - { - if (track.Sectors[i].SectorID == track.Sectors[ActiveDrive.SectorIndex].SectorID) - { - keyIndex = i; - break; - } - } - - if (keyIndex == track.Sectors.Length - 1) - { - // last sector on the cylinder, set EN - SetBit(SR1_EN, ref Status1); - - // increment cylinder - ActiveCommandParams.Cylinder++; - - // reset sector - ActiveCommandParams.Sector = 1; - ActiveDrive.SectorIndex = 0; - } - else - { - ActiveDrive.SectorIndex++; - } - - UnSetBit(SR0_IC1, ref Status0); - UnSetBit(SR0_IC0, ref Status0); - - CommitResultCHRN(); - CommitResultStatus(); - ActivePhase = Phase.Execution; - } - - if (ActivePhase == Phase.Execution) - { - ExecLength = buffPos; - ExecCounter = buffPos; - - DriveLight = true; - } - } - - break; - - //---------------------------------------- - // FDC in execution phase reading/writing bytes - //---------------------------------------- - case Phase.Execution: - - var index = ExecLength - ExecCounter; - - LastSectorDataReadByte = ExecBuffer[index]; - - OverrunCounter--; - ExecCounter--; - - break; - - //---------------------------------------- - // Result bytes being sent to CPU - //---------------------------------------- - case Phase.Result: - break; - } - } - - /// - /// Read ID - /// COMMAND: 1 parameter byte - /// EXECUTION: The first correct ID information on the cylinder is stored in the data register - /// RESULT: 7 result bytes - /// - private void UPD_ReadID() - { - switch (ActivePhase) - { - //---------------------------------------- - // FDC is waiting for a command byte - //---------------------------------------- - case Phase.Idle: - break; - - //---------------------------------------- - // Receiving command parameter bytes - //---------------------------------------- - case Phase.Command: - - // store the parameter in the command buffer - CommBuffer[CommCounter] = LastByteReceived; - - // process parameter byte - ParseParamByteStandard(CommCounter); - - // increment command parameter counter - CommCounter++; - - // was that the last parameter byte? - if (CommCounter == ActiveCommand.ParameterByteCount) - { - DriveLight = true; - - // all parameter bytes received - ClearResultBuffer(); - Status0 = 0; - Status1 = 0; - Status2 = 0; - Status3 = 0; - - // set unit select - //SetUnitSelect(ActiveDrive.ID, ref Status0); - - // HD should always be 0 - UnSetBit(SR0_HD, ref Status0); - - if (!ActiveDrive.FLAG_READY) - { - // no disk, no tracks or motor is not on - // it is at this point the +3 detects whether a disk is present - // if not (and after another readid and SIS) it will eventually proceed to loading from tape - SetBit(SR0_IC0, ref Status0); - SetBit(SR0_NR, ref Status0); - - // setup the result buffer - ResBuffer[RS_ST0] = Status0; - for (int i = 1; i < 7; i++) - ResBuffer[i] = 0; - - // move to result phase - ActivePhase = Phase.Result; - break; - } - - var track = ActiveDrive.Disk.DiskTracks.Where(a => a.TrackNumber == ActiveDrive.CurrentTrackID).FirstOrDefault(); - - if (track != null && track.NumberOfSectors > 0 && track.TrackNumber != 0xff) - { - // formatted track - - // is the index out of bounds? - if (ActiveDrive.SectorIndex >= track.NumberOfSectors) - { - // reset the index - ActiveDrive.SectorIndex = 0; - } - - if (ActiveDrive.SectorIndex == 0 && ActiveDrive.Disk.DiskTracks[ActiveDrive.CurrentTrackID].Sectors.Length > 1) - { - // looks like readid always skips the first sector on a track - ActiveDrive.SectorIndex++; - } - - // read the sector data - var data = track.Sectors[ActiveDrive.SectorIndex]; //.GetCHRN(); - ResBuffer[RS_C] = data.TrackNumber; - ResBuffer[RS_H] = data.SideNumber; - ResBuffer[RS_R] = data.SectorID; - ResBuffer[RS_N] = data.SectorSize; - - ResBuffer[RS_ST0] = Status0; - - // check for DAM & CRC - //if (data.Status2.Bit(SR2_CM)) - //SetBit(SR2_CM, ref ResBuffer[RS_ST2]); - - - // increment the current sector - ActiveDrive.SectorIndex++; - - // is the index out of bounds? - if (ActiveDrive.SectorIndex >= track.NumberOfSectors) - { - // reset the index - ActiveDrive.SectorIndex = 0; - } - } - else - { - // unformatted track? - CommitResultCHRN(); - - SetBit(SR0_IC0, ref Status0); - ResBuffer[RS_ST0] = Status0; - ResBuffer[RS_ST1] = 0x01; - } - - ActivePhase = Phase.Result; - } - - break; - - //---------------------------------------- - // FDC in execution phase reading/writing bytes - //---------------------------------------- - case Phase.Execution: - break; - - //---------------------------------------- - // Result bytes being sent to CPU - //---------------------------------------- - case Phase.Result: - break; - } - } - - #endregion - - #region WRITE Commands - - /// - /// Write Data - /// COMMAND: 8 parameter bytes - /// EXECUTION: Data transfer between FDC and FDD - /// RESULT: 7 result bytes - /// - private void UPD_WriteData() - { - switch (ActivePhase) - { - //---------------------------------------- - // FDC is waiting for a command byte - //---------------------------------------- - case Phase.Idle: - break; - - //---------------------------------------- - // Receiving command parameter bytes - //---------------------------------------- - case Phase.Command: - - // store the parameter in the command buffer - CommBuffer[CommCounter] = LastByteReceived; - - // process parameter byte - ParseParamByteStandard(CommCounter); - - // increment command parameter counter - CommCounter++; - - // was that the last parameter byte? - if (CommCounter == ActiveCommand.ParameterByteCount) - { - // all parameter bytes received - setup for execution phase - - // clear exec buffer and status registers - ClearExecBuffer(); - Status0 = 0; - Status1 = 0; - Status2 = 0; - Status3 = 0; - - // temp sector index - byte secIdx = ActiveCommandParams.Sector; - - // hack for when another drive (non-existent) is being called - if (ActiveDrive.ID != 0) - DiskDriveIndex = 0; - - // do we have a valid disk inserted? - if (!ActiveDrive.FLAG_READY) - { - // no disk, no tracks or motor is not on - SetBit(SR0_IC0, ref Status0); - SetBit(SR0_NR, ref Status0); - - CommitResultCHRN(); - CommitResultStatus(); - //ResBuffer[RS_ST0] = Status0; - - // move to result phase - ActivePhase = Phase.Result; - break; - } - - // check write protect tab - if (ActiveDrive.FLAG_WRITEPROTECT) - { - SetBit(SR0_IC0, ref Status0); - SetBit(SR1_NW, ref Status1); - - CommitResultCHRN(); - CommitResultStatus(); - //ResBuffer[RS_ST0] = Status0; - - // move to result phase - ActivePhase = Phase.Result; - break; - } - else - { - - // calculate the number of bytes to write - int byteCounter = 0; - byte startSecID = ActiveCommandParams.Sector; - byte endSecID = ActiveCommandParams.EOT; - bool lastSec = false; - - // get the first sector - var track = ActiveDrive.Disk.DiskTracks[ActiveCommandParams.Cylinder]; - //int secIndex = 0; - for (int s = 0; s < track.Sectors.Length; s++) - { - if (track.Sectors[s].SectorID == endSecID) - lastSec = true; - - for (int i = 0; i < 0x80 << ActiveCommandParams.SectorSize; i++) - { - byteCounter++; - - if (i == (0x80 << ActiveCommandParams.SectorSize) - 1 && lastSec) - { - break; - } - } - - if (lastSec) - break; - } - - ExecCounter = byteCounter; - ExecLength = byteCounter; - ActivePhase = Phase.Execution; - DriveLight = true; - break; - } - } - - break; - - //---------------------------------------- - // FDC in execution phase reading/writing bytes - //---------------------------------------- - case Phase.Execution: - - var index = ExecLength - ExecCounter; - - ExecBuffer[index] = LastSectorDataWriteByte; - - OverrunCounter--; - ExecCounter--; - - if (ExecCounter <= 0) - { - int cnt = 0; - - // all data received - byte startSecID = ActiveCommandParams.Sector; - byte endSecID = ActiveCommandParams.EOT; - bool lastSec = false; - var track = ActiveDrive.Disk.DiskTracks[ActiveCommandParams.Cylinder]; - //int secIndex = 0; - - for (int s = 0; s < track.Sectors.Length; s++) - { - if (cnt == ExecLength) - break; - - ActiveCommandParams.Sector = track.Sectors[s].SectorID; - - if (track.Sectors[s].SectorID == endSecID) - lastSec = true; - - int size = 0x80 << track.Sectors[s].SectorSize; - - for (int d = 0; d < size; d++) - { - track.Sectors[s].SectorData[d] = ExecBuffer[cnt++]; - } - - if (lastSec) - break; - } - - SetBit(SR0_IC0, ref Status0); - SetBit(SR1_EN, ref Status1); - - CommitResultCHRN(); - CommitResultStatus(); - } - - break; - - //---------------------------------------- - // Result bytes being sent to CPU - //---------------------------------------- - case Phase.Result: - break; - } - } - - /// - /// Write ID (format write) - /// COMMAND: 5 parameter bytes - /// EXECUTION: Entire track is formatted - /// RESULT: 7 result bytes - /// - private void UPD_WriteID() - { - switch (ActivePhase) - { - //---------------------------------------- - // FDC is waiting for a command byte - //---------------------------------------- - case Phase.Idle: - break; - - //---------------------------------------- - // Receiving command parameter bytes - //---------------------------------------- - case Phase.Command: - - // store the parameter in the command buffer - CommBuffer[CommCounter] = LastByteReceived; - - // process parameter byte - ParseParamByteStandard(CommCounter); - - // increment command parameter counter - CommCounter++; - - // was that the last parameter byte? - if (CommCounter == ActiveCommand.ParameterByteCount) - { - // all parameter bytes received - setup for execution phase - DriveLight = true; - - // clear exec buffer and status registers - ClearExecBuffer(); - Status0 = 0; - Status1 = 0; - Status2 = 0; - Status3 = 0; - - // temp sector index - byte secIdx = ActiveCommandParams.Sector; - - // hack for when another drive (non-existent) is being called - if (ActiveDrive.ID != 0) - DiskDriveIndex = 0; - - // do we have a valid disk inserted? - if (!ActiveDrive.FLAG_READY) - { - // no disk, no tracks or motor is not on - SetBit(SR0_IC0, ref Status0); - SetBit(SR0_NR, ref Status0); - - CommitResultCHRN(); - CommitResultStatus(); - //ResBuffer[RS_ST0] = Status0; - - // move to result phase - ActivePhase = Phase.Result; - break; - } - - // check write protect tab - if (ActiveDrive.FLAG_WRITEPROTECT) - { - SetBit(SR0_IC0, ref Status0); - SetBit(SR1_NW, ref Status1); - - CommitResultCHRN(); - CommitResultStatus(); - //ResBuffer[RS_ST0] = Status0; - - // move to result phase - ActivePhase = Phase.Result; - break; - } - else - { - // not implemented yet - SetBit(SR0_IC0, ref Status0); - SetBit(SR1_NW, ref Status1); - - CommitResultCHRN(); - CommitResultStatus(); - //ResBuffer[RS_ST0] = Status0; - - // move to result phase - ActivePhase = Phase.Result; - break; - } - } - - break; - - //---------------------------------------- - // FDC in execution phase reading/writing bytes - //---------------------------------------- - case Phase.Execution: - break; - - //---------------------------------------- - // Result bytes being sent to CPU - //---------------------------------------- - case Phase.Result: - break; - } - } - - /// - /// Write Deleted Data - /// COMMAND: 8 parameter bytes - /// EXECUTION: Data transfer between FDC and FDD - /// RESULT: 7 result bytes - /// - private void UPD_WriteDeletedData() - { - switch (ActivePhase) - { - //---------------------------------------- - // FDC is waiting for a command byte - //---------------------------------------- - case Phase.Idle: - break; - - //---------------------------------------- - // Receiving command parameter bytes - //---------------------------------------- - case Phase.Command: - - // store the parameter in the command buffer - CommBuffer[CommCounter] = LastByteReceived; - - // process parameter byte - ParseParamByteStandard(CommCounter); - - // increment command parameter counter - CommCounter++; - - // was that the last parameter byte? - if (CommCounter == ActiveCommand.ParameterByteCount) - { - // all parameter bytes received - setup for execution phase - - // clear exec buffer and status registers - ClearExecBuffer(); - Status0 = 0; - Status1 = 0; - Status2 = 0; - Status3 = 0; - - // temp sector index - byte secIdx = ActiveCommandParams.Sector; - - // hack for when another drive (non-existent) is being called - if (ActiveDrive.ID != 0) - DiskDriveIndex = 0; - - // do we have a valid disk inserted? - if (!ActiveDrive.FLAG_READY) - { - // no disk, no tracks or motor is not on - SetBit(SR0_IC0, ref Status0); - SetBit(SR0_NR, ref Status0); - - CommitResultCHRN(); - CommitResultStatus(); - //ResBuffer[RS_ST0] = Status0; - - // move to result phase - ActivePhase = Phase.Result; - break; - } - - // check write protect tab - if (ActiveDrive.FLAG_WRITEPROTECT) - { - SetBit(SR0_IC0, ref Status0); - SetBit(SR1_NW, ref Status1); - - CommitResultCHRN(); - CommitResultStatus(); - //ResBuffer[RS_ST0] = Status0; - - // move to result phase - ActivePhase = Phase.Result; - break; - } - else - { - - // calculate the number of bytes to write - int byteCounter = 0; - byte startSecID = ActiveCommandParams.Sector; - byte endSecID = ActiveCommandParams.EOT; - bool lastSec = false; - - // get the first sector - var track = ActiveDrive.Disk.DiskTracks[ActiveCommandParams.Cylinder]; - //int secIndex = 0; - for (int s = 0; s < track.Sectors.Length; s++) - { - if (track.Sectors[s].SectorID == endSecID) - lastSec = true; - - for (int i = 0; i < 0x80 << ActiveCommandParams.SectorSize; i++) - { - byteCounter++; - - if (i == (0x80 << ActiveCommandParams.SectorSize) - 1 && lastSec) - { - break; - } - } - - if (lastSec) - break; - } - - ExecCounter = byteCounter; - ExecLength = byteCounter; - ActivePhase = Phase.Execution; - DriveLight = true; - break; - } - } - - break; - - //---------------------------------------- - // FDC in execution phase reading/writing bytes - //---------------------------------------- - case Phase.Execution: - - var index = ExecLength - ExecCounter; - - ExecBuffer[index] = LastSectorDataWriteByte; - - OverrunCounter--; - ExecCounter--; - - if (ExecCounter <= 0) - { - int cnt = 0; - - // all data received - byte startSecID = ActiveCommandParams.Sector; - byte endSecID = ActiveCommandParams.EOT; - bool lastSec = false; - var track = ActiveDrive.Disk.DiskTracks[ActiveCommandParams.Cylinder]; - //int secIndex = 0; - - for (int s = 0; s < track.Sectors.Length; s++) - { - if (cnt == ExecLength) - break; - - ActiveCommandParams.Sector = track.Sectors[s].SectorID; - - if (track.Sectors[s].SectorID == endSecID) - lastSec = true; - - int size = 0x80 << track.Sectors[s].SectorSize; - - for (int d = 0; d < size; d++) - { - track.Sectors[s].SectorData[d] = ExecBuffer[cnt++]; - } - - if (lastSec) - break; - } - - SetBit(SR0_IC0, ref Status0); - SetBit(SR1_EN, ref Status1); - - CommitResultCHRN(); - CommitResultStatus(); - } - - break; - - //---------------------------------------- - // Result bytes being sent to CPU - //---------------------------------------- - case Phase.Result: - break; - } - } - - #endregion - - #region SCAN Commands - - /// - /// Scan Equal - /// COMMAND: 8 parameter bytes - /// EXECUTION: Data compared between the FDD and FDC - /// RESULT: 7 result bytes - /// - private void UPD_ScanEqual() - { - switch (ActivePhase) - { - //---------------------------------------- - // FDC is waiting for a command byte - //---------------------------------------- - case Phase.Idle: - break; - - //---------------------------------------- - // Receiving command parameter bytes - //---------------------------------------- - case Phase.Command: - break; - - //---------------------------------------- - // FDC in execution phase reading/writing bytes - //---------------------------------------- - case Phase.Execution: - break; - - //---------------------------------------- - // Result bytes being sent to CPU - //---------------------------------------- - case Phase.Result: - break; - } - } - - /// - /// Scan Low or Equal - /// COMMAND: 8 parameter bytes - /// EXECUTION: Data compared between the FDD and FDC - /// RESULT: 7 result bytes - /// - private void UPD_ScanLowOrEqual() - { - switch (ActivePhase) - { - //---------------------------------------- - // FDC is waiting for a command byte - //---------------------------------------- - case Phase.Idle: - break; - - //---------------------------------------- - // Receiving command parameter bytes - //---------------------------------------- - case Phase.Command: - break; - - //---------------------------------------- - // FDC in execution phase reading/writing bytes - //---------------------------------------- - case Phase.Execution: - break; - - //---------------------------------------- - // Result bytes being sent to CPU - //---------------------------------------- - case Phase.Result: - break; - } - } - - /// - /// Scan High or Equal - /// COMMAND: 8 parameter bytes - /// EXECUTION: Data compared between the FDD and FDC - /// RESULT: 7 result bytes - /// - private void UPD_ScanHighOrEqual() - { - switch (ActivePhase) - { - //---------------------------------------- - // FDC is waiting for a command byte - //---------------------------------------- - case Phase.Idle: - break; - - //---------------------------------------- - // Receiving command parameter bytes - //---------------------------------------- - case Phase.Command: - break; - - //---------------------------------------- - // FDC in execution phase reading/writing bytes - //---------------------------------------- - case Phase.Execution: - break; - - //---------------------------------------- - // Result bytes being sent to CPU - //---------------------------------------- - case Phase.Result: - break; - } - } - - #endregion - - #region OTHER Commands - - /// - /// Specify - /// COMMAND: 2 parameter bytes - /// EXECUTION: NO execution phase - /// RESULT: NO result phase - /// - /// Looks like specify command returns status 0x80 throughout its lifecycle - /// so CB is NOT set - /// - private void UPD_Specify() - { - switch (ActivePhase) - { - //---------------------------------------- - // FDC is waiting for a command byte - //---------------------------------------- - case Phase.Idle: - break; - - //---------------------------------------- - // Receiving command parameter bytes - //---------------------------------------- - case Phase.Command: - - // store the parameter in the command buffer - CommBuffer[CommCounter] = LastByteReceived; - - // process parameter byte - byte currByte = CommBuffer[CommCounter]; - BitArray bi = new BitArray(new byte[] { currByte }); - - switch (CommCounter) - { - // SRT & HUT - case 0: - SRT = 16 - (currByte >> 4) & 0x0f; - HUT = (currByte & 0x0f) << 4; - if (HUT == 0) - { - HUT = 255; - } - break; - // HLT & ND - case 1: - if (bi[0]) - ND = true; - else - ND = false; - - HLT = currByte & 0xfe; - if (HLT == 0) - { - HLT = 255; - } - break; - } - - // increment command parameter counter - CommCounter++; - - // was that the last parameter byte? - if (CommCounter == ActiveCommand.ParameterByteCount) - { - // all parameter bytes received - ActivePhase = Phase.Idle; - } - - break; - - //---------------------------------------- - // FDC in execution phase reading/writing bytes - //---------------------------------------- - case Phase.Execution: - break; - - //---------------------------------------- - // Result bytes being sent to CPU - //---------------------------------------- - case Phase.Result: - break; - } - } - - /// - /// Seek - /// COMMAND: 2 parameter bytes - /// EXECUTION: Head is positioned over proper cylinder on disk - /// RESULT: NO result phase - /// - private void UPD_Seek() - { - switch (ActivePhase) - { - //---------------------------------------- - // FDC is waiting for a command byte - //---------------------------------------- - case Phase.Idle: - break; - - //---------------------------------------- - // Receiving command parameter bytes - //---------------------------------------- - case Phase.Command: - // store the parameter in the command buffer - CommBuffer[CommCounter] = LastByteReceived; - - // process parameter byte - byte currByte = CommBuffer[CommCounter]; - switch (CommCounter) - { - case 0: - ParseParamByteStandard(CommCounter); - break; - case 1: - ActiveDrive.SeekingTrack = currByte; - break; - } - - // increment command parameter counter - CommCounter++; - - // was that the last parameter byte? - if (CommCounter == ActiveCommand.ParameterByteCount) - { - // all parameter bytes received - DriveLight = true; - ActivePhase = Phase.Execution; - ActiveCommand.CommandDelegate(); - } - break; - - //---------------------------------------- - // FDC in execution phase reading/writing bytes - //---------------------------------------- - case Phase.Execution: - // set seek flag - ActiveDrive.SeekStatus = SEEK_SEEK; - - if (ActiveDrive.CurrentTrackID == CommBuffer[CM_C]) - { - // we are already on the correct track - ActiveDrive.SectorIndex = 0; - } - else - { - // immediate seek - ActiveDrive.CurrentTrackID = CommBuffer[CM_C]; - - ActiveDrive.SectorIndex = 0; - - if (ActiveDrive.Disk.DiskTracks[ActiveDrive.CurrentTrackID].Sectors.Length > 1) - { - // always read the first sector - //ActiveDrive.SectorIndex++; - } - } - - // skip execution mode and go directly to idle - // result is determined by SIS command - ActivePhase = Phase.Idle; - break; - - //---------------------------------------- - // Result bytes being sent to CPU - //---------------------------------------- - case Phase.Result: - break; - } - } - - /// - /// Recalibrate (seek track 0) - /// COMMAND: 1 parameter byte - /// EXECUTION: Head retracted to track 0 - /// RESULT: NO result phase - /// - private void UPD_Recalibrate() - { - switch (ActivePhase) - { - //---------------------------------------- - // FDC is waiting for a command byte - //---------------------------------------- - case Phase.Idle: - break; - - //---------------------------------------- - // Receiving command parameter bytes - //---------------------------------------- - case Phase.Command: - // store the parameter in the command buffer - CommBuffer[CommCounter] = LastByteReceived; - - // process parameter byte - ParseParamByteStandard(CommCounter); - - // increment command parameter counter - CommCounter++; - - // was that the last parameter byte? - if (CommCounter == ActiveCommand.ParameterByteCount) - { - // all parameter bytes received - DriveLight = true; - ActivePhase = Phase.Execution; - ActiveCommand.CommandDelegate(); - } - break; - - //---------------------------------------- - // FDC in execution phase reading/writing bytes - //---------------------------------------- - case Phase.Execution: - - // immediate recalibration - ActiveDrive.TrackIndex = 0; - ActiveDrive.SectorIndex = 0; - - // recalibrate appears to always skip the first sector - //if (ActiveDrive.Disk.DiskTracks[ActiveDrive.TrackIndex].Sectors.Length > 1) - //ActiveDrive.SectorIndex++; - - // set seek flag - ActiveDrive.SeekStatus = SEEK_RECALIBRATE; - - // skip execution mode and go directly to idle - // result is determined by SIS command - ActivePhase = Phase.Idle; - break; - - //---------------------------------------- - // Result bytes being sent to CPU - //---------------------------------------- - case Phase.Result: - break; - } - } - - /// - /// Sense Interrupt Status - /// COMMAND: NO parameter bytes - /// EXECUTION: NO execution phase - /// RESULT: 2 result bytes - /// - private void UPD_SenseInterruptStatus() - { - switch (ActivePhase) - { - //---------------------------------------- - // FDC is waiting for a command byte - //---------------------------------------- - case Phase.Idle: - break; - - //---------------------------------------- - // Receiving command parameter bytes - //---------------------------------------- - case Phase.Command: - break; - - //---------------------------------------- - // FDC in execution phase reading/writing bytes - //---------------------------------------- - case Phase.Execution: - // SIS should return 2 bytes if sucessfully sensed an interrupt - // 1 byte otherwise - - // it seems like the +3 ROM makes 3 SIS calls for each seek/recalibrate call for some reason - // possibly one for each drive??? - // 1 - the interrupt is acknowleged with ST0 = 32 and track number - // 2 - second sis returns 1 ST0 byte with 192 - // 3 - third SIS call returns standard 1 byte 0x80 (unknown cmd or SIS with no interrupt occured) - // for now I will assume that the first call is aimed at DriveA, the second at DriveB (which we are NOT implementing) - - // check active drive first - if (ActiveDrive.SeekStatus == SEEK_RECALIBRATE || - ActiveDrive.SeekStatus == SEEK_SEEK) - { - // interrupt has been raised for this drive - // acknowledge - ActiveDrive.SeekStatus = SEEK_IDLE;// SEEK_INTACKNOWLEDGED; - - // result length 2 - ResLength = 2; - - // first byte ST0 0x20 - Status0 = 0x20; - ResBuffer[0] = Status0; - // second byte is the current track id - ResBuffer[1] = ActiveDrive.CurrentTrackID; - } - /* + // calculate requested size of data required + if (ActiveCommandParams.SectorSize == 0) + { + // When N=0, then DTL defines the data length which the FDC must treat as a sector. If DTL is smaller than the actual + // data length in a sector, the data beyond DTL in the sector is not sent to the Data Bus. The FDC reads (internally) + // the complete sector performing the CRC check and, depending upon the manner of command termination, may perform + // a Multi-Sector Read Operation. + sectorSize = ActiveCommandParams.DTL; + + // calculate maximum transfer capacity + if (!CMD_FLAG_MF) + maxTransferCap = 3328; + } + else + { + // When N is non - zero, then DTL has no meaning and should be set to ffh + ActiveCommandParams.DTL = 0xFF; + + // calculate maximum transfer capacity + switch (ActiveCommandParams.SectorSize) + { + case 1: + if (CMD_FLAG_MF) + maxTransferCap = 6656; + else + maxTransferCap = 3840; + break; + case 2: + if (CMD_FLAG_MF) + maxTransferCap = 7680; + else + maxTransferCap = 4096; + break; + case 3: + if (CMD_FLAG_MF) + maxTransferCap = 8192; + else + maxTransferCap = 4096; + break; + } + + sectorSize = 0x80 << ActiveCommandParams.SectorSize; + } + + // get the current track + var track = ActiveDrive.Disk.DiskTracks.FirstOrDefault(a => a.TrackNumber == ActiveDrive.CurrentTrackID); + + if (track == null || track.NumberOfSectors <= 0) + { + // track could not be found + SetBit(SR0_IC0, ref Status0); + SetBit(SR0_NR, ref Status0); + + CommitResultCHRN(); + CommitResultStatus(); + + //ResBuffer[RS_ST0] = Status0; + + // move to result phase + ActivePhase = Phase.Result; + break; + } + + //FloppyDisk.Sector sector = null; + ActiveDrive.SectorIndex = 0; + + int secCount = 0; + + // read the whole track + for (int i = 0; i < track.Sectors.Length; i++) + { + if (secCount >= ActiveCommandParams.EOT) + { + break; + } + + var sec = track.Sectors[i]; + for (int b = 0; b < sec.ActualData.Length; b++) + { + ExecBuffer[buffPos++] = sec.ActualData[b]; + } + + // mark the sector read + sec.SectorReadCompleted(); + + // end of sector - compare IDs + if (sec.TrackNumber != ActiveCommandParams.Cylinder || + sec.SideNumber != ActiveCommandParams.Head || + sec.SectorID != ActiveCommandParams.Sector || + sec.SectorSize != ActiveCommandParams.SectorSize) + { + SetBit(SR1_ND, ref Status1); + } + + secCount++; + ActiveDrive.SectorIndex = i; + } + + if (secCount == ActiveCommandParams.EOT) + { + // this was the last sector to read + // or termination requested + + int keyIndex = 0; + for (int i = 0; i < track.Sectors.Length; i++) + { + if (track.Sectors[i].SectorID == track.Sectors[ActiveDrive.SectorIndex].SectorID) + { + keyIndex = i; + break; + } + } + + if (keyIndex == track.Sectors.Length - 1) + { + // last sector on the cylinder, set EN + SetBit(SR1_EN, ref Status1); + + // increment cylinder + ActiveCommandParams.Cylinder++; + + // reset sector + ActiveCommandParams.Sector = 1; + ActiveDrive.SectorIndex = 0; + } + else + { + ActiveDrive.SectorIndex++; + } + + UnSetBit(SR0_IC1, ref Status0); + UnSetBit(SR0_IC0, ref Status0); + + CommitResultCHRN(); + CommitResultStatus(); + ActivePhase = Phase.Execution; + } + + if (ActivePhase == Phase.Execution) + { + ExecLength = buffPos; + ExecCounter = buffPos; + + DriveLight = true; + } + } + + break; + + //---------------------------------------- + // FDC in execution phase reading/writing bytes + //---------------------------------------- + case Phase.Execution: + + var index = ExecLength - ExecCounter; + + LastSectorDataReadByte = ExecBuffer[index]; + + OverrunCounter--; + ExecCounter--; + + break; + + //---------------------------------------- + // Result bytes being sent to CPU + //---------------------------------------- + case Phase.Result: + break; + } + } + + /// + /// Read ID + /// COMMAND: 1 parameter byte + /// EXECUTION: The first correct ID information on the cylinder is stored in the data register + /// RESULT: 7 result bytes + /// + private void UPD_ReadID() + { + switch (ActivePhase) + { + //---------------------------------------- + // FDC is waiting for a command byte + //---------------------------------------- + case Phase.Idle: + break; + + //---------------------------------------- + // Receiving command parameter bytes + //---------------------------------------- + case Phase.Command: + + // store the parameter in the command buffer + CommBuffer[CommCounter] = LastByteReceived; + + // process parameter byte + ParseParamByteStandard(CommCounter); + + // increment command parameter counter + CommCounter++; + + // was that the last parameter byte? + if (CommCounter == ActiveCommand.ParameterByteCount) + { + DriveLight = true; + + // all parameter bytes received + ClearResultBuffer(); + Status0 = 0; + Status1 = 0; + Status2 = 0; + Status3 = 0; + + // set unit select + //SetUnitSelect(ActiveDrive.ID, ref Status0); + + // HD should always be 0 + UnSetBit(SR0_HD, ref Status0); + + if (!ActiveDrive.FLAG_READY) + { + // no disk, no tracks or motor is not on + // it is at this point the +3 detects whether a disk is present + // if not (and after another readid and SIS) it will eventually proceed to loading from tape + SetBit(SR0_IC0, ref Status0); + SetBit(SR0_NR, ref Status0); + + // setup the result buffer + ResBuffer[RS_ST0] = Status0; + for (int i = 1; i < 7; i++) + ResBuffer[i] = 0; + + // move to result phase + ActivePhase = Phase.Result; + break; + } + + var track = ActiveDrive.Disk.DiskTracks.FirstOrDefault(a => a.TrackNumber == ActiveDrive.CurrentTrackID); + + if (track != null && track.NumberOfSectors > 0 && track.TrackNumber != 0xff) + { + // formatted track + + // is the index out of bounds? + if (ActiveDrive.SectorIndex >= track.NumberOfSectors) + { + // reset the index + ActiveDrive.SectorIndex = 0; + } + + if (ActiveDrive.SectorIndex == 0 && ActiveDrive.Disk.DiskTracks[ActiveDrive.CurrentTrackID].Sectors.Length > 1) + { + // looks like readid always skips the first sector on a track + ActiveDrive.SectorIndex++; + } + + // read the sector data + var data = track.Sectors[ActiveDrive.SectorIndex]; //.GetCHRN(); + ResBuffer[RS_C] = data.TrackNumber; + ResBuffer[RS_H] = data.SideNumber; + ResBuffer[RS_R] = data.SectorID; + ResBuffer[RS_N] = data.SectorSize; + + ResBuffer[RS_ST0] = Status0; + + // check for DAM & CRC + //if (data.Status2.Bit(SR2_CM)) + //SetBit(SR2_CM, ref ResBuffer[RS_ST2]); + + + // increment the current sector + ActiveDrive.SectorIndex++; + + // is the index out of bounds? + if (ActiveDrive.SectorIndex >= track.NumberOfSectors) + { + // reset the index + ActiveDrive.SectorIndex = 0; + } + } + else + { + // unformatted track? + CommitResultCHRN(); + + SetBit(SR0_IC0, ref Status0); + ResBuffer[RS_ST0] = Status0; + ResBuffer[RS_ST1] = 0x01; + } + + ActivePhase = Phase.Result; + } + + break; + + //---------------------------------------- + // FDC in execution phase reading/writing bytes + //---------------------------------------- + case Phase.Execution: + break; + + //---------------------------------------- + // Result bytes being sent to CPU + //---------------------------------------- + case Phase.Result: + break; + } + } + + #endregion + + #region WRITE Commands + + /// + /// Write Data + /// COMMAND: 8 parameter bytes + /// EXECUTION: Data transfer between FDC and FDD + /// RESULT: 7 result bytes + /// + private void UPD_WriteData() + { + switch (ActivePhase) + { + //---------------------------------------- + // FDC is waiting for a command byte + //---------------------------------------- + case Phase.Idle: + break; + + //---------------------------------------- + // Receiving command parameter bytes + //---------------------------------------- + case Phase.Command: + + // store the parameter in the command buffer + CommBuffer[CommCounter] = LastByteReceived; + + // process parameter byte + ParseParamByteStandard(CommCounter); + + // increment command parameter counter + CommCounter++; + + // was that the last parameter byte? + if (CommCounter == ActiveCommand.ParameterByteCount) + { + // all parameter bytes received - setup for execution phase + + // clear exec buffer and status registers + ClearExecBuffer(); + Status0 = 0; + Status1 = 0; + Status2 = 0; + Status3 = 0; + + // temp sector index + byte secIdx = ActiveCommandParams.Sector; + + // hack for when another drive (non-existent) is being called + if (ActiveDrive.ID != 0) + DiskDriveIndex = 0; + + // do we have a valid disk inserted? + if (!ActiveDrive.FLAG_READY) + { + // no disk, no tracks or motor is not on + SetBit(SR0_IC0, ref Status0); + SetBit(SR0_NR, ref Status0); + + CommitResultCHRN(); + CommitResultStatus(); + //ResBuffer[RS_ST0] = Status0; + + // move to result phase + ActivePhase = Phase.Result; + break; + } + + // check write protect tab + if (ActiveDrive.FLAG_WRITEPROTECT) + { + SetBit(SR0_IC0, ref Status0); + SetBit(SR1_NW, ref Status1); + + CommitResultCHRN(); + CommitResultStatus(); + //ResBuffer[RS_ST0] = Status0; + + // move to result phase + ActivePhase = Phase.Result; + break; + } + else + { + + // calculate the number of bytes to write + int byteCounter = 0; + byte startSecID = ActiveCommandParams.Sector; + byte endSecID = ActiveCommandParams.EOT; + bool lastSec = false; + + // get the first sector + var track = ActiveDrive.Disk.DiskTracks[ActiveCommandParams.Cylinder]; + //int secIndex = 0; + for (int s = 0; s < track.Sectors.Length; s++) + { + if (track.Sectors[s].SectorID == endSecID) + lastSec = true; + + for (int i = 0; i < 0x80 << ActiveCommandParams.SectorSize; i++) + { + byteCounter++; + + if (i == (0x80 << ActiveCommandParams.SectorSize) - 1 && lastSec) + { + break; + } + } + + if (lastSec) + break; + } + + ExecCounter = byteCounter; + ExecLength = byteCounter; + ActivePhase = Phase.Execution; + DriveLight = true; + break; + } + } + + break; + + //---------------------------------------- + // FDC in execution phase reading/writing bytes + //---------------------------------------- + case Phase.Execution: + + var index = ExecLength - ExecCounter; + + ExecBuffer[index] = LastSectorDataWriteByte; + + OverrunCounter--; + ExecCounter--; + + if (ExecCounter <= 0) + { + int cnt = 0; + + // all data received + byte startSecID = ActiveCommandParams.Sector; + byte endSecID = ActiveCommandParams.EOT; + bool lastSec = false; + var track = ActiveDrive.Disk.DiskTracks[ActiveCommandParams.Cylinder]; + //int secIndex = 0; + + for (int s = 0; s < track.Sectors.Length; s++) + { + if (cnt == ExecLength) + break; + + ActiveCommandParams.Sector = track.Sectors[s].SectorID; + + if (track.Sectors[s].SectorID == endSecID) + lastSec = true; + + int size = 0x80 << track.Sectors[s].SectorSize; + + for (int d = 0; d < size; d++) + { + track.Sectors[s].SectorData[d] = ExecBuffer[cnt++]; + } + + if (lastSec) + break; + } + + SetBit(SR0_IC0, ref Status0); + SetBit(SR1_EN, ref Status1); + + CommitResultCHRN(); + CommitResultStatus(); + } + + break; + + //---------------------------------------- + // Result bytes being sent to CPU + //---------------------------------------- + case Phase.Result: + break; + } + } + + /// + /// Write ID (format write) + /// COMMAND: 5 parameter bytes + /// EXECUTION: Entire track is formatted + /// RESULT: 7 result bytes + /// + private void UPD_WriteID() + { + switch (ActivePhase) + { + //---------------------------------------- + // FDC is waiting for a command byte + //---------------------------------------- + case Phase.Idle: + break; + + //---------------------------------------- + // Receiving command parameter bytes + //---------------------------------------- + case Phase.Command: + + // store the parameter in the command buffer + CommBuffer[CommCounter] = LastByteReceived; + + // process parameter byte + ParseParamByteStandard(CommCounter); + + // increment command parameter counter + CommCounter++; + + // was that the last parameter byte? + if (CommCounter == ActiveCommand.ParameterByteCount) + { + // all parameter bytes received - setup for execution phase + DriveLight = true; + + // clear exec buffer and status registers + ClearExecBuffer(); + Status0 = 0; + Status1 = 0; + Status2 = 0; + Status3 = 0; + + // temp sector index + byte secIdx = ActiveCommandParams.Sector; + + // hack for when another drive (non-existent) is being called + if (ActiveDrive.ID != 0) + DiskDriveIndex = 0; + + // do we have a valid disk inserted? + if (!ActiveDrive.FLAG_READY) + { + // no disk, no tracks or motor is not on + SetBit(SR0_IC0, ref Status0); + SetBit(SR0_NR, ref Status0); + + CommitResultCHRN(); + CommitResultStatus(); + //ResBuffer[RS_ST0] = Status0; + + // move to result phase + ActivePhase = Phase.Result; + break; + } + + // check write protect tab + if (ActiveDrive.FLAG_WRITEPROTECT) + { + SetBit(SR0_IC0, ref Status0); + SetBit(SR1_NW, ref Status1); + + CommitResultCHRN(); + CommitResultStatus(); + //ResBuffer[RS_ST0] = Status0; + + // move to result phase + ActivePhase = Phase.Result; + break; + } + else + { + // not implemented yet + SetBit(SR0_IC0, ref Status0); + SetBit(SR1_NW, ref Status1); + + CommitResultCHRN(); + CommitResultStatus(); + //ResBuffer[RS_ST0] = Status0; + + // move to result phase + ActivePhase = Phase.Result; + break; + } + } + + break; + + //---------------------------------------- + // FDC in execution phase reading/writing bytes + //---------------------------------------- + case Phase.Execution: + break; + + //---------------------------------------- + // Result bytes being sent to CPU + //---------------------------------------- + case Phase.Result: + break; + } + } + + /// + /// Write Deleted Data + /// COMMAND: 8 parameter bytes + /// EXECUTION: Data transfer between FDC and FDD + /// RESULT: 7 result bytes + /// + private void UPD_WriteDeletedData() + { + switch (ActivePhase) + { + //---------------------------------------- + // FDC is waiting for a command byte + //---------------------------------------- + case Phase.Idle: + break; + + //---------------------------------------- + // Receiving command parameter bytes + //---------------------------------------- + case Phase.Command: + + // store the parameter in the command buffer + CommBuffer[CommCounter] = LastByteReceived; + + // process parameter byte + ParseParamByteStandard(CommCounter); + + // increment command parameter counter + CommCounter++; + + // was that the last parameter byte? + if (CommCounter == ActiveCommand.ParameterByteCount) + { + // all parameter bytes received - setup for execution phase + + // clear exec buffer and status registers + ClearExecBuffer(); + Status0 = 0; + Status1 = 0; + Status2 = 0; + Status3 = 0; + + // temp sector index + byte secIdx = ActiveCommandParams.Sector; + + // hack for when another drive (non-existent) is being called + if (ActiveDrive.ID != 0) + DiskDriveIndex = 0; + + // do we have a valid disk inserted? + if (!ActiveDrive.FLAG_READY) + { + // no disk, no tracks or motor is not on + SetBit(SR0_IC0, ref Status0); + SetBit(SR0_NR, ref Status0); + + CommitResultCHRN(); + CommitResultStatus(); + //ResBuffer[RS_ST0] = Status0; + + // move to result phase + ActivePhase = Phase.Result; + break; + } + + // check write protect tab + if (ActiveDrive.FLAG_WRITEPROTECT) + { + SetBit(SR0_IC0, ref Status0); + SetBit(SR1_NW, ref Status1); + + CommitResultCHRN(); + CommitResultStatus(); + //ResBuffer[RS_ST0] = Status0; + + // move to result phase + ActivePhase = Phase.Result; + break; + } + else + { + + // calculate the number of bytes to write + int byteCounter = 0; + byte startSecID = ActiveCommandParams.Sector; + byte endSecID = ActiveCommandParams.EOT; + bool lastSec = false; + + // get the first sector + var track = ActiveDrive.Disk.DiskTracks[ActiveCommandParams.Cylinder]; + //int secIndex = 0; + for (int s = 0; s < track.Sectors.Length; s++) + { + if (track.Sectors[s].SectorID == endSecID) + lastSec = true; + + for (int i = 0; i < 0x80 << ActiveCommandParams.SectorSize; i++) + { + byteCounter++; + + if (i == (0x80 << ActiveCommandParams.SectorSize) - 1 && lastSec) + { + break; + } + } + + if (lastSec) + break; + } + + ExecCounter = byteCounter; + ExecLength = byteCounter; + ActivePhase = Phase.Execution; + DriveLight = true; + break; + } + } + + break; + + //---------------------------------------- + // FDC in execution phase reading/writing bytes + //---------------------------------------- + case Phase.Execution: + + var index = ExecLength - ExecCounter; + + ExecBuffer[index] = LastSectorDataWriteByte; + + OverrunCounter--; + ExecCounter--; + + if (ExecCounter <= 0) + { + int cnt = 0; + + // all data received + byte startSecID = ActiveCommandParams.Sector; + byte endSecID = ActiveCommandParams.EOT; + bool lastSec = false; + var track = ActiveDrive.Disk.DiskTracks[ActiveCommandParams.Cylinder]; + //int secIndex = 0; + + for (int s = 0; s < track.Sectors.Length; s++) + { + if (cnt == ExecLength) + break; + + ActiveCommandParams.Sector = track.Sectors[s].SectorID; + + if (track.Sectors[s].SectorID == endSecID) + lastSec = true; + + int size = 0x80 << track.Sectors[s].SectorSize; + + for (int d = 0; d < size; d++) + { + track.Sectors[s].SectorData[d] = ExecBuffer[cnt++]; + } + + if (lastSec) + break; + } + + SetBit(SR0_IC0, ref Status0); + SetBit(SR1_EN, ref Status1); + + CommitResultCHRN(); + CommitResultStatus(); + } + + break; + + //---------------------------------------- + // Result bytes being sent to CPU + //---------------------------------------- + case Phase.Result: + break; + } + } + + #endregion + + #region SCAN Commands + + /// + /// Scan Equal + /// COMMAND: 8 parameter bytes + /// EXECUTION: Data compared between the FDD and FDC + /// RESULT: 7 result bytes + /// + private void UPD_ScanEqual() + { + switch (ActivePhase) + { + //---------------------------------------- + // FDC is waiting for a command byte + //---------------------------------------- + case Phase.Idle: + break; + + //---------------------------------------- + // Receiving command parameter bytes + //---------------------------------------- + case Phase.Command: + break; + + //---------------------------------------- + // FDC in execution phase reading/writing bytes + //---------------------------------------- + case Phase.Execution: + break; + + //---------------------------------------- + // Result bytes being sent to CPU + //---------------------------------------- + case Phase.Result: + break; + } + } + + /// + /// Scan Low or Equal + /// COMMAND: 8 parameter bytes + /// EXECUTION: Data compared between the FDD and FDC + /// RESULT: 7 result bytes + /// + private void UPD_ScanLowOrEqual() + { + switch (ActivePhase) + { + //---------------------------------------- + // FDC is waiting for a command byte + //---------------------------------------- + case Phase.Idle: + break; + + //---------------------------------------- + // Receiving command parameter bytes + //---------------------------------------- + case Phase.Command: + break; + + //---------------------------------------- + // FDC in execution phase reading/writing bytes + //---------------------------------------- + case Phase.Execution: + break; + + //---------------------------------------- + // Result bytes being sent to CPU + //---------------------------------------- + case Phase.Result: + break; + } + } + + /// + /// Scan High or Equal + /// COMMAND: 8 parameter bytes + /// EXECUTION: Data compared between the FDD and FDC + /// RESULT: 7 result bytes + /// + private void UPD_ScanHighOrEqual() + { + switch (ActivePhase) + { + //---------------------------------------- + // FDC is waiting for a command byte + //---------------------------------------- + case Phase.Idle: + break; + + //---------------------------------------- + // Receiving command parameter bytes + //---------------------------------------- + case Phase.Command: + break; + + //---------------------------------------- + // FDC in execution phase reading/writing bytes + //---------------------------------------- + case Phase.Execution: + break; + + //---------------------------------------- + // Result bytes being sent to CPU + //---------------------------------------- + case Phase.Result: + break; + } + } + + #endregion + + #region OTHER Commands + + /// + /// Specify + /// COMMAND: 2 parameter bytes + /// EXECUTION: NO execution phase + /// RESULT: NO result phase + /// + /// Looks like specify command returns status 0x80 throughout its lifecycle + /// so CB is NOT set + /// + private void UPD_Specify() + { + switch (ActivePhase) + { + //---------------------------------------- + // FDC is waiting for a command byte + //---------------------------------------- + case Phase.Idle: + break; + + //---------------------------------------- + // Receiving command parameter bytes + //---------------------------------------- + case Phase.Command: + + // store the parameter in the command buffer + CommBuffer[CommCounter] = LastByteReceived; + + // process parameter byte + byte currByte = CommBuffer[CommCounter]; + BitArray bi = new BitArray(new byte[] { currByte }); + + switch (CommCounter) + { + // SRT & HUT + case 0: + SRT = 16 - (currByte >> 4) & 0x0f; + HUT = (currByte & 0x0f) << 4; + if (HUT == 0) + { + HUT = 255; + } + break; + // HLT & ND + case 1: + if (bi[0]) + ND = true; + else + ND = false; + + HLT = currByte & 0xfe; + if (HLT == 0) + { + HLT = 255; + } + break; + } + + // increment command parameter counter + CommCounter++; + + // was that the last parameter byte? + if (CommCounter == ActiveCommand.ParameterByteCount) + { + // all parameter bytes received + ActivePhase = Phase.Idle; + } + + break; + + //---------------------------------------- + // FDC in execution phase reading/writing bytes + //---------------------------------------- + case Phase.Execution: + break; + + //---------------------------------------- + // Result bytes being sent to CPU + //---------------------------------------- + case Phase.Result: + break; + } + } + + /// + /// Seek + /// COMMAND: 2 parameter bytes + /// EXECUTION: Head is positioned over proper cylinder on disk + /// RESULT: NO result phase + /// + private void UPD_Seek() + { + switch (ActivePhase) + { + //---------------------------------------- + // FDC is waiting for a command byte + //---------------------------------------- + case Phase.Idle: + break; + + //---------------------------------------- + // Receiving command parameter bytes + //---------------------------------------- + case Phase.Command: + // store the parameter in the command buffer + CommBuffer[CommCounter] = LastByteReceived; + + // process parameter byte + byte currByte = CommBuffer[CommCounter]; + switch (CommCounter) + { + case 0: + ParseParamByteStandard(CommCounter); + break; + case 1: + ActiveDrive.SeekingTrack = currByte; + break; + } + + // increment command parameter counter + CommCounter++; + + // was that the last parameter byte? + if (CommCounter == ActiveCommand.ParameterByteCount) + { + // all parameter bytes received + DriveLight = true; + ActivePhase = Phase.Execution; + ActiveCommand.CommandDelegate(); + } + break; + + //---------------------------------------- + // FDC in execution phase reading/writing bytes + //---------------------------------------- + case Phase.Execution: + // set seek flag + ActiveDrive.SeekStatus = SEEK_SEEK; + + if (ActiveDrive.CurrentTrackID == CommBuffer[CM_C]) + { + // we are already on the correct track + ActiveDrive.SectorIndex = 0; + } + else + { + // immediate seek + ActiveDrive.CurrentTrackID = CommBuffer[CM_C]; + + ActiveDrive.SectorIndex = 0; + + if (ActiveDrive.Disk.DiskTracks[ActiveDrive.CurrentTrackID].Sectors.Length > 1) + { + // always read the first sector + //ActiveDrive.SectorIndex++; + } + } + + // skip execution mode and go directly to idle + // result is determined by SIS command + ActivePhase = Phase.Idle; + break; + + //---------------------------------------- + // Result bytes being sent to CPU + //---------------------------------------- + case Phase.Result: + break; + } + } + + /// + /// Recalibrate (seek track 0) + /// COMMAND: 1 parameter byte + /// EXECUTION: Head retracted to track 0 + /// RESULT: NO result phase + /// + private void UPD_Recalibrate() + { + switch (ActivePhase) + { + //---------------------------------------- + // FDC is waiting for a command byte + //---------------------------------------- + case Phase.Idle: + break; + + //---------------------------------------- + // Receiving command parameter bytes + //---------------------------------------- + case Phase.Command: + // store the parameter in the command buffer + CommBuffer[CommCounter] = LastByteReceived; + + // process parameter byte + ParseParamByteStandard(CommCounter); + + // increment command parameter counter + CommCounter++; + + // was that the last parameter byte? + if (CommCounter == ActiveCommand.ParameterByteCount) + { + // all parameter bytes received + DriveLight = true; + ActivePhase = Phase.Execution; + ActiveCommand.CommandDelegate(); + } + break; + + //---------------------------------------- + // FDC in execution phase reading/writing bytes + //---------------------------------------- + case Phase.Execution: + + // immediate recalibration + ActiveDrive.TrackIndex = 0; + ActiveDrive.SectorIndex = 0; + + // recalibrate appears to always skip the first sector + //if (ActiveDrive.Disk.DiskTracks[ActiveDrive.TrackIndex].Sectors.Length > 1) + //ActiveDrive.SectorIndex++; + + // set seek flag + ActiveDrive.SeekStatus = SEEK_RECALIBRATE; + + // skip execution mode and go directly to idle + // result is determined by SIS command + ActivePhase = Phase.Idle; + break; + + //---------------------------------------- + // Result bytes being sent to CPU + //---------------------------------------- + case Phase.Result: + break; + } + } + + /// + /// Sense Interrupt Status + /// COMMAND: NO parameter bytes + /// EXECUTION: NO execution phase + /// RESULT: 2 result bytes + /// + private void UPD_SenseInterruptStatus() + { + switch (ActivePhase) + { + //---------------------------------------- + // FDC is waiting for a command byte + //---------------------------------------- + case Phase.Idle: + break; + + //---------------------------------------- + // Receiving command parameter bytes + //---------------------------------------- + case Phase.Command: + break; + + //---------------------------------------- + // FDC in execution phase reading/writing bytes + //---------------------------------------- + case Phase.Execution: + // SIS should return 2 bytes if sucessfully sensed an interrupt + // 1 byte otherwise + + // it seems like the +3 ROM makes 3 SIS calls for each seek/recalibrate call for some reason + // possibly one for each drive??? + // 1 - the interrupt is acknowleged with ST0 = 32 and track number + // 2 - second sis returns 1 ST0 byte with 192 + // 3 - third SIS call returns standard 1 byte 0x80 (unknown cmd or SIS with no interrupt occured) + // for now I will assume that the first call is aimed at DriveA, the second at DriveB (which we are NOT implementing) + + // check active drive first + if (ActiveDrive.SeekStatus == SEEK_RECALIBRATE || + ActiveDrive.SeekStatus == SEEK_SEEK) + { + // interrupt has been raised for this drive + // acknowledge + ActiveDrive.SeekStatus = SEEK_IDLE;// SEEK_INTACKNOWLEDGED; + + // result length 2 + ResLength = 2; + + // first byte ST0 0x20 + Status0 = 0x20; + ResBuffer[0] = Status0; + // second byte is the current track id + ResBuffer[1] = ActiveDrive.CurrentTrackID; + } + /* else if (ActiveDrive.SeekStatus == SEEK_INTACKNOWLEDGED) { // DriveA interrupt has already been acknowledged @@ -2177,407 +2177,407 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum ResBuffer[0] = Status0; } */ - else if (ActiveDrive.SeekStatus == SEEK_IDLE) - { - // SIS with no interrupt - ResLength = 1; - Status0 = 0x80; - ResBuffer[0] = Status0; - } + else if (ActiveDrive.SeekStatus == SEEK_IDLE) + { + // SIS with no interrupt + ResLength = 1; + Status0 = 0x80; + ResBuffer[0] = Status0; + } - ActivePhase = Phase.Result; + ActivePhase = Phase.Result; - break; + break; - //---------------------------------------- - // Result bytes being sent to CPU - //---------------------------------------- - case Phase.Result: - break; - } - } + //---------------------------------------- + // Result bytes being sent to CPU + //---------------------------------------- + case Phase.Result: + break; + } + } - /// - /// Sense Drive Status - /// COMMAND: 1 parameter byte - /// EXECUTION: NO execution phase - /// RESULT: 1 result byte - /// - /// The ZX spectrum appears to only specify drive 1 as the parameter byte, NOT drive 0 - /// After the final param byte is received main status changes to 0xd0 - /// Data register (ST3) result is 0x51 if drive/disk not available - /// 0x71 if disk is present in 2nd drive - /// - private void UPD_SenseDriveStatus() - { - switch (ActivePhase) - { - //---------------------------------------- - // FDC is waiting for a command byte - //---------------------------------------- - case Phase.Idle: - break; + /// + /// Sense Drive Status + /// COMMAND: 1 parameter byte + /// EXECUTION: NO execution phase + /// RESULT: 1 result byte + /// + /// The ZX spectrum appears to only specify drive 1 as the parameter byte, NOT drive 0 + /// After the final param byte is received main status changes to 0xd0 + /// Data register (ST3) result is 0x51 if drive/disk not available + /// 0x71 if disk is present in 2nd drive + /// + private void UPD_SenseDriveStatus() + { + switch (ActivePhase) + { + //---------------------------------------- + // FDC is waiting for a command byte + //---------------------------------------- + case Phase.Idle: + break; - //---------------------------------------- - // Receiving command parameter bytes - //---------------------------------------- - case Phase.Command: - // store the parameter in the command buffer - CommBuffer[CommCounter] = LastByteReceived; + //---------------------------------------- + // Receiving command parameter bytes + //---------------------------------------- + case Phase.Command: + // store the parameter in the command buffer + CommBuffer[CommCounter] = LastByteReceived; - // process parameter byte - ParseParamByteStandard(CommCounter); + // process parameter byte + ParseParamByteStandard(CommCounter); - // increment command parameter counter - CommCounter++; + // increment command parameter counter + CommCounter++; - // was that the last parameter byte? - if (CommCounter == ActiveCommand.ParameterByteCount) - { - // all parameter bytes received - ActivePhase = Phase.Execution; - UPD_SenseDriveStatus(); - } - break; + // was that the last parameter byte? + if (CommCounter == ActiveCommand.ParameterByteCount) + { + // all parameter bytes received + ActivePhase = Phase.Execution; + UPD_SenseDriveStatus(); + } + break; - //---------------------------------------- - // FDC in execution phase reading/writing bytes - //---------------------------------------- - case Phase.Execution: - // one ST3 byte required + //---------------------------------------- + // FDC in execution phase reading/writing bytes + //---------------------------------------- + case Phase.Execution: + // one ST3 byte required - // set US - Status3 = (byte)ActiveDrive.ID; + // set US + Status3 = (byte)ActiveDrive.ID; - if (Status3 != 0) - { - // we only support 1 drive - SetBit(SR3_FT, ref Status3); - } - else - { - // HD - only one side - UnSetBit(SR3_HD, ref Status3); + if (Status3 != 0) + { + // we only support 1 drive + SetBit(SR3_FT, ref Status3); + } + else + { + // HD - only one side + UnSetBit(SR3_HD, ref Status3); - // write protect - if (ActiveDrive.FLAG_WRITEPROTECT) - SetBit(SR3_WP, ref Status3); + // write protect + if (ActiveDrive.FLAG_WRITEPROTECT) + SetBit(SR3_WP, ref Status3); - // track 0 - if (ActiveDrive.FLAG_TRACK0) - SetBit(SR3_T0, ref Status3); + // track 0 + if (ActiveDrive.FLAG_TRACK0) + SetBit(SR3_T0, ref Status3); - // rdy - if (ActiveDrive.Disk != null) - SetBit(SR3_RY, ref Status3); - } + // rdy + if (ActiveDrive.Disk != null) + SetBit(SR3_RY, ref Status3); + } - ResBuffer[0] = Status3; - ActivePhase = Phase.Result; - - break; + ResBuffer[0] = Status3; + ActivePhase = Phase.Result; - //---------------------------------------- - // Result bytes being sent to CPU - //---------------------------------------- - case Phase.Result: - break; - } - } + break; - /// - /// Version - /// COMMAND: NO parameter bytes - /// EXECUTION: NO execution phase - /// RESULT: 1 result byte - /// - private void UPD_Version() - { - switch (ActivePhase) - { - case Phase.Idle: - case Phase.Command: - case Phase.Execution: - case Phase.Result: - UPD_Invalid(); - break; - } - } + //---------------------------------------- + // Result bytes being sent to CPU + //---------------------------------------- + case Phase.Result: + break; + } + } - /// - /// Invalid - /// COMMAND: NO parameter bytes - /// EXECUTION: NO execution phase - /// RESULT: 1 result byte - /// - private void UPD_Invalid() - { - switch (ActivePhase) - { - //---------------------------------------- - // FDC is waiting for a command byte - //---------------------------------------- - case Phase.Idle: - break; + /// + /// Version + /// COMMAND: NO parameter bytes + /// EXECUTION: NO execution phase + /// RESULT: 1 result byte + /// + private void UPD_Version() + { + switch (ActivePhase) + { + case Phase.Idle: + case Phase.Command: + case Phase.Execution: + case Phase.Result: + UPD_Invalid(); + break; + } + } - //---------------------------------------- - // Receiving command parameter bytes - //---------------------------------------- - case Phase.Command: - break; + /// + /// Invalid + /// COMMAND: NO parameter bytes + /// EXECUTION: NO execution phase + /// RESULT: 1 result byte + /// + private void UPD_Invalid() + { + switch (ActivePhase) + { + //---------------------------------------- + // FDC is waiting for a command byte + //---------------------------------------- + case Phase.Idle: + break; - //---------------------------------------- - // FDC in execution phase reading/writing bytes - //---------------------------------------- - case Phase.Execution: - // no execution phase - ActivePhase = Phase.Result; - UPD_Invalid(); - break; + //---------------------------------------- + // Receiving command parameter bytes + //---------------------------------------- + case Phase.Command: + break; - //---------------------------------------- - // Result bytes being sent to CPU - //---------------------------------------- - case Phase.Result: - ResBuffer[0] = 0x80; - break; - } - } + //---------------------------------------- + // FDC in execution phase reading/writing bytes + //---------------------------------------- + case Phase.Execution: + // no execution phase + ActivePhase = Phase.Result; + UPD_Invalid(); + break; - #endregion + //---------------------------------------- + // Result bytes being sent to CPU + //---------------------------------------- + case Phase.Result: + ResBuffer[0] = 0x80; + break; + } + } - #endregion + #endregion - #region Controller Methods + #endregion - /// - /// Called when a status register read is required - /// This can be called at any time - /// The main status register appears to be queried nearly all the time - /// so needs to be kept updated. It keeps the CPU informed of the current state - /// - private byte ReadMainStatus() - { - SetBit(MSR_RQM, ref StatusMain); + #region Controller Methods - switch (ActivePhase) - { - case Phase.Idle: - UnSetBit(MSR_DIO, ref StatusMain); - UnSetBit(MSR_CB, ref StatusMain); - UnSetBit(MSR_EXM, ref StatusMain); - break; - case Phase.Command: - UnSetBit(MSR_DIO, ref StatusMain); - SetBit(MSR_CB, ref StatusMain); - UnSetBit(MSR_EXM, ref StatusMain); - break; - case Phase.Execution: - if (ActiveCommand.Direction == CommandDirection.OUT) - SetBit(MSR_DIO, ref StatusMain); - else - UnSetBit(MSR_DIO, ref StatusMain); + /// + /// Called when a status register read is required + /// This can be called at any time + /// The main status register appears to be queried nearly all the time + /// so needs to be kept updated. It keeps the CPU informed of the current state + /// + private byte ReadMainStatus() + { + SetBit(MSR_RQM, ref StatusMain); - SetBit(MSR_EXM, ref StatusMain); - SetBit(MSR_CB, ref StatusMain); + switch (ActivePhase) + { + case Phase.Idle: + UnSetBit(MSR_DIO, ref StatusMain); + UnSetBit(MSR_CB, ref StatusMain); + UnSetBit(MSR_EXM, ref StatusMain); + break; + case Phase.Command: + UnSetBit(MSR_DIO, ref StatusMain); + SetBit(MSR_CB, ref StatusMain); + UnSetBit(MSR_EXM, ref StatusMain); + break; + case Phase.Execution: + if (ActiveCommand.Direction == CommandDirection.OUT) + SetBit(MSR_DIO, ref StatusMain); + else + UnSetBit(MSR_DIO, ref StatusMain); - // overrun detection - OverrunCounter++; - if (OverrunCounter >= 64) - { - // CPU has read the status register 64 times without reading the data register - // switch the current command into result phase - ActivePhase = Phase.Result; + SetBit(MSR_EXM, ref StatusMain); + SetBit(MSR_CB, ref StatusMain); - // reset the overun counter - OverrunCounter = 0; - } + // overrun detection + OverrunCounter++; + if (OverrunCounter >= 64) + { + // CPU has read the status register 64 times without reading the data register + // switch the current command into result phase + ActivePhase = Phase.Result; - break; - case Phase.Result: - SetBit(MSR_DIO, ref StatusMain); - SetBit(MSR_CB, ref StatusMain); - UnSetBit(MSR_EXM, ref StatusMain); - break; - } + // reset the overun counter + OverrunCounter = 0; + } - //if (!CheckTiming()) - //{ - // UnSetBit(MSR_EXM, ref StatusMain); - //} + break; + case Phase.Result: + SetBit(MSR_DIO, ref StatusMain); + SetBit(MSR_CB, ref StatusMain); + UnSetBit(MSR_EXM, ref StatusMain); + break; + } - return StatusMain; - } + //if (!CheckTiming()) + //{ + // UnSetBit(MSR_EXM, ref StatusMain); + //} + + return StatusMain; + } //private int testCount = 0; - /// - /// Handles CPU reading from the data register - /// - private byte ReadDataRegister() - { - // default return value - byte res = 0xff; + /// + /// Handles CPU reading from the data register + /// + private byte ReadDataRegister() + { + // default return value + byte res = 0xff; - // check RQM flag status - if (!GetBit(MSR_RQM, StatusMain)) - { - // FDC is not ready to return data - return res; - } + // check RQM flag status + if (!GetBit(MSR_RQM, StatusMain)) + { + // FDC is not ready to return data + return res; + } - // check active direction - if (!GetBit(MSR_DIO, StatusMain)) - { - // FDC is expecting to receive, not send data - return res; - } + // check active direction + if (!GetBit(MSR_DIO, StatusMain)) + { + // FDC is expecting to receive, not send data + return res; + } - switch (ActivePhase) - { - case Phase.Execution: - // reset overrun counter - OverrunCounter = 0; + switch (ActivePhase) + { + case Phase.Execution: + // reset overrun counter + OverrunCounter = 0; - // execute read - ActiveCommand.CommandDelegate(); + // execute read + ActiveCommand.CommandDelegate(); - res = LastSectorDataReadByte; + res = LastSectorDataReadByte; - if (ExecCounter <= 0) - { - // end of execution phase - ActivePhase = Phase.Result; - } + if (ExecCounter <= 0) + { + // end of execution phase + ActivePhase = Phase.Result; + } - return res; - - case Phase.Result: + return res; - DriveLight = false; + case Phase.Result: - ActiveCommand.CommandDelegate(); + DriveLight = false; - // result byte reading - res = ResBuffer[ResCounter]; + ActiveCommand.CommandDelegate(); - // increment result counter - ResCounter++; + // result byte reading + res = ResBuffer[ResCounter]; - if (ResCounter >= ResLength) - { - ActivePhase = Phase.Idle; - } + // increment result counter + ResCounter++; - break; - } + if (ResCounter >= ResLength) + { + ActivePhase = Phase.Idle; + } - return res; - } + break; + } - /// - /// Handles CPU writing to the data register - /// - private void WriteDataRegister(byte data) - { - if (!GetBit(MSR_RQM, StatusMain) || GetBit(MSR_DIO, StatusMain)) - { - // FDC will not receive and process any bytes - return; - } + return res; + } - // store the incoming byte - LastByteReceived = data; + /// + /// Handles CPU writing to the data register + /// + private void WriteDataRegister(byte data) + { + if (!GetBit(MSR_RQM, StatusMain) || GetBit(MSR_DIO, StatusMain)) + { + // FDC will not receive and process any bytes + return; + } - // process incoming bytes - switch (ActivePhase) - { - //// controller is idle awaiting the first command byte of a new instruction - case Phase.Idle: - ParseCommandByte(data); - break; - //// we are in command phase - case Phase.Command: - // attempt to process this parameter byte - //ProcessCommand(data); - ActiveCommand.CommandDelegate(); - break; - //// we are in execution phase - case Phase.Execution: - // CPU is going to be sending data bytes to the FDC to be written to disk - - // store the byte - LastSectorDataWriteByte = data; - ActiveCommand.CommandDelegate(); + // store the incoming byte + LastByteReceived = data; - if (ExecCounter <= 0) - { - // end of execution phase - ActivePhase = Phase.Result; - } + // process incoming bytes + switch (ActivePhase) + { + //// controller is idle awaiting the first command byte of a new instruction + case Phase.Idle: + ParseCommandByte(data); + break; + //// we are in command phase + case Phase.Command: + // attempt to process this parameter byte + //ProcessCommand(data); + ActiveCommand.CommandDelegate(); + break; + //// we are in execution phase + case Phase.Execution: + // CPU is going to be sending data bytes to the FDC to be written to disk - break; - //// result phase - case Phase.Result: - // data register will not receive bytes during result phase - break; - } - } + // store the byte + LastSectorDataWriteByte = data; + ActiveCommand.CommandDelegate(); - /// - /// Processes the first command byte (within a command instruction) - /// Returns TRUE if successful. FALSE if otherwise - /// Called only in idle phase - /// - private bool ParseCommandByte(byte cmdByte) - { - // clear counters - CommCounter = 0; - ResCounter = 0; + if (ExecCounter <= 0) + { + // end of execution phase + ActivePhase = Phase.Result; + } - // get the first 4 bytes - byte cByte = (byte)(cmdByte & 0x0f); + break; + //// result phase + case Phase.Result: + // data register will not receive bytes during result phase + break; + } + } - // get MT, MD and SK states - CMD_FLAG_MT = cmdByte.Bit(7); - CMD_FLAG_MF = cmdByte.Bit(6); - CMD_FLAG_SK = cmdByte.Bit(5); + /// + /// Processes the first command byte (within a command instruction) + /// Returns TRUE if successful. FALSE if otherwise + /// Called only in idle phase + /// + private bool ParseCommandByte(byte cmdByte) + { + // clear counters + CommCounter = 0; + ResCounter = 0; - cmdByte = cByte; + // get the first 4 bytes + byte cByte = (byte)(cmdByte & 0x0f); - // lookup the command - var cmd = CommandList.Where(a => a.CommandCode == cmdByte).FirstOrDefault(); + // get MT, MD and SK states + CMD_FLAG_MT = cmdByte.Bit(7); + CMD_FLAG_MF = cmdByte.Bit(6); + CMD_FLAG_SK = cmdByte.Bit(5); - if (cmd == null) - { - // no command found - use invalid - CMDIndex = CommandList.Count() - 1; - } - else - { - // valid command found - CMDIndex = CommandList.FindIndex(a => a.CommandCode == cmdByte); + cmdByte = cByte; - // check validity of command byte flags - // if a flag is set but not valid for this command then it is invalid - bool invalid = false; + // lookup the command + var cmd = CommandList.FirstOrDefault(a => a.CommandCode == cmdByte); - if (!ActiveCommand.MT) - if (CMD_FLAG_MT) - invalid = true; - if (!ActiveCommand.MF) - if (CMD_FLAG_MF) - invalid = true; - if (!ActiveCommand.SK) - if (CMD_FLAG_SK) - invalid = true; + if (cmd == null) + { + // no command found - use invalid + CMDIndex = CommandList.Count() - 1; + } + else + { + // valid command found + CMDIndex = CommandList.FindIndex(a => a.CommandCode == cmdByte); - if (invalid) - { - // command byte included spurious bit 5,6 or 7 flags - CMDIndex = CommandList.Count() - 1; - } + // check validity of command byte flags + // if a flag is set but not valid for this command then it is invalid + bool invalid = false; - /* + if (!ActiveCommand.MT) + if (CMD_FLAG_MT) + invalid = true; + if (!ActiveCommand.MF) + if (CMD_FLAG_MF) + invalid = true; + if (!ActiveCommand.SK) + if (CMD_FLAG_SK) + invalid = true; + + if (invalid) + { + // command byte included spurious bit 5,6 or 7 flags + CMDIndex = CommandList.Count() - 1; + } + + /* if ((CMD_FLAG_MF && !ActiveCommand.MF) || (CMD_FLAG_MT && !ActiveCommand.MT) || (CMD_FLAG_SK && !ActiveCommand.SK)) @@ -2586,16 +2586,16 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum CMDIndex = CommandList.Count() - 1; } */ - } + } - CommCounter = 0; - ResCounter = 0; + CommCounter = 0; + ResCounter = 0; - // there will now be an active command set - // move to command phase - ActivePhase = Phase.Command; + // there will now be an active command set + // move to command phase + ActivePhase = Phase.Command; - /* + /* // check for invalid SIS if (ActiveInterrupt == InterruptState.None && CMDIndex == CC_SENSE_INTSTATUS) { @@ -2604,237 +2604,237 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum } */ - // set reslength - ResLength = ActiveCommand.ResultByteCount; - - // if there are no expected param bytes to receive - go ahead and run the command - if (ActiveCommand.ParameterByteCount == 0) - { - ActivePhase = Phase.Execution; - ActiveCommand.CommandDelegate(); - } + // set reslength + ResLength = ActiveCommand.ResultByteCount; - return true; - } + // if there are no expected param bytes to receive - go ahead and run the command + if (ActiveCommand.ParameterByteCount == 0) + { + ActivePhase = Phase.Execution; + ActiveCommand.CommandDelegate(); + } - /// - /// Parses the first 5 command argument bytes that are of the standard format - /// - private void ParseParamByteStandard(int index) - { - byte currByte = CommBuffer[index]; - BitArray bi = new BitArray(new byte[] { currByte }); + return true; + } - switch (index) - { - // HD & US - case CM_HEAD: - if (bi[2]) - ActiveCommandParams.Side = 1; - else - ActiveCommandParams.Side = 0; + /// + /// Parses the first 5 command argument bytes that are of the standard format + /// + private void ParseParamByteStandard(int index) + { + byte currByte = CommBuffer[index]; + BitArray bi = new BitArray(new byte[] { currByte }); - ActiveCommandParams.UnitSelect = (byte)(GetUnitSelect(currByte)); - DiskDriveIndex = ActiveCommandParams.UnitSelect; - break; - - // C - case CM_C: - ActiveCommandParams.Cylinder = currByte; - break; + switch (index) + { + // HD & US + case CM_HEAD: + if (bi[2]) + ActiveCommandParams.Side = 1; + else + ActiveCommandParams.Side = 0; - // H - case CM_H: - ActiveCommandParams.Head = currByte; - break; + ActiveCommandParams.UnitSelect = (byte)(GetUnitSelect(currByte)); + DiskDriveIndex = ActiveCommandParams.UnitSelect; + break; - // R - case CM_R: - ActiveCommandParams.Sector = currByte; - break; + // C + case CM_C: + ActiveCommandParams.Cylinder = currByte; + break; - // N - case CM_N: - ActiveCommandParams.SectorSize = currByte; - break; + // H + case CM_H: + ActiveCommandParams.Head = currByte; + break; - // EOT - case CM_EOT: - ActiveCommandParams.EOT = currByte; - break; + // R + case CM_R: + ActiveCommandParams.Sector = currByte; + break; - // GPL - case CM_GPL: - ActiveCommandParams.Gap3Length = currByte; - break; + // N + case CM_N: + ActiveCommandParams.SectorSize = currByte; + break; - // DTL - case CM_DTL: - ActiveCommandParams.DTL = currByte; - break; + // EOT + case CM_EOT: + ActiveCommandParams.EOT = currByte; + break; - default: - break; - } - } + // GPL + case CM_GPL: + ActiveCommandParams.Gap3Length = currByte; + break; - /// - /// Clears the result buffer - /// - public void ClearResultBuffer() - { - for (int i = 0; i < ResBuffer.Length; i++) - { - ResBuffer[i] = 0; - } - } + // DTL + case CM_DTL: + ActiveCommandParams.DTL = currByte; + break; - /// - /// Clears the result buffer - /// - public void ClearExecBuffer() - { - for (int i = 0; i < ExecBuffer.Length; i++) - { - ExecBuffer[i] = 0; - } - } + default: + break; + } + } - /// - /// Populates the result status registers - /// - private void CommitResultStatus() - { - // check for read diag - if (ActiveCommand.CommandCode == 0x02) - { - // commit to result buffer - ResBuffer[RS_ST0] = Status0; - ResBuffer[RS_ST1] = Status1; - return; - } + /// + /// Clears the result buffer + /// + public void ClearResultBuffer() + { + for (int i = 0; i < ResBuffer.Length; i++) + { + ResBuffer[i] = 0; + } + } - // check for error bits - if (GetBit(SR1_DE, Status1) || - GetBit(SR1_MA, Status1) || - GetBit(SR1_ND, Status1) || - GetBit(SR1_NW, Status1) || - GetBit(SR1_OR, Status1) || - GetBit(SR2_BC, Status2) || - GetBit(SR2_CM, Status2) || - GetBit(SR2_DD, Status2) || - GetBit(SR2_MD, Status2) || - GetBit(SR2_SN, Status2) || - GetBit(SR2_WC, Status2)) - { - // error bits set - unset end of track - UnSetBit(SR1_EN, ref Status1); - } + /// + /// Clears the result buffer + /// + public void ClearExecBuffer() + { + for (int i = 0; i < ExecBuffer.Length; i++) + { + ExecBuffer[i] = 0; + } + } - // check for data errors - if (GetBit(SR1_DE, Status1) || - GetBit(SR2_DD, Status2)) - { - // unset control mark - UnSetBit(SR2_CM, ref Status2); - } - else if (GetBit(SR2_CM, Status2)) - { - // DAM found - unset IC and US0 - UnSetBit(SR0_IC0, ref Status0); - UnSetBit(SR0_US0, ref Status0); - } + /// + /// Populates the result status registers + /// + private void CommitResultStatus() + { + // check for read diag + if (ActiveCommand.CommandCode == 0x02) + { + // commit to result buffer + ResBuffer[RS_ST0] = Status0; + ResBuffer[RS_ST1] = Status1; + return; + } - // commit to result buffer - ResBuffer[RS_ST0] = Status0; - ResBuffer[RS_ST1] = Status1; - ResBuffer[RS_ST2] = Status2; - - } + // check for error bits + if (GetBit(SR1_DE, Status1) || + GetBit(SR1_MA, Status1) || + GetBit(SR1_ND, Status1) || + GetBit(SR1_NW, Status1) || + GetBit(SR1_OR, Status1) || + GetBit(SR2_BC, Status2) || + GetBit(SR2_CM, Status2) || + GetBit(SR2_DD, Status2) || + GetBit(SR2_MD, Status2) || + GetBit(SR2_SN, Status2) || + GetBit(SR2_WC, Status2)) + { + // error bits set - unset end of track + UnSetBit(SR1_EN, ref Status1); + } - /// - /// Populates the result CHRN values - /// - private void CommitResultCHRN() - { - ResBuffer[RS_C] = ActiveCommandParams.Cylinder; - ResBuffer[RS_H] = ActiveCommandParams.Head; - ResBuffer[RS_R] = ActiveCommandParams.Sector; - ResBuffer[RS_N] = ActiveCommandParams.SectorSize; - } + // check for data errors + if (GetBit(SR1_DE, Status1) || + GetBit(SR2_DD, Status2)) + { + // unset control mark + UnSetBit(SR2_CM, ref Status2); + } + else if (GetBit(SR2_CM, Status2)) + { + // DAM found - unset IC and US0 + UnSetBit(SR0_IC0, ref Status0); + UnSetBit(SR0_US0, ref Status0); + } - /// - /// Moves active phase into idle - /// - public void SetPhase_Idle() - { - ActivePhase = Phase.Idle; + // commit to result buffer + ResBuffer[RS_ST0] = Status0; + ResBuffer[RS_ST1] = Status1; + ResBuffer[RS_ST2] = Status2; - // active direction - UnSetBit(MSR_DIO, ref StatusMain); - // CB - UnSetBit(MSR_CB, ref StatusMain); - // RQM - SetBit(MSR_RQM, ref StatusMain); + } - CommCounter = 0; - ResCounter = 0; - } + /// + /// Populates the result CHRN values + /// + private void CommitResultCHRN() + { + ResBuffer[RS_C] = ActiveCommandParams.Cylinder; + ResBuffer[RS_H] = ActiveCommandParams.Head; + ResBuffer[RS_R] = ActiveCommandParams.Sector; + ResBuffer[RS_N] = ActiveCommandParams.SectorSize; + } - /// - /// Moves to result phase - /// - public void SetPhase_Result() - { - ActivePhase = Phase.Result; + /// + /// Moves active phase into idle + /// + public void SetPhase_Idle() + { + ActivePhase = Phase.Idle; - // active direction - SetBit(MSR_DIO, ref StatusMain); - // CB - SetBit(MSR_CB, ref StatusMain); - // RQM - SetBit(MSR_RQM, ref StatusMain); - // EXM - UnSetBit(MSR_EXM, ref StatusMain); + // active direction + UnSetBit(MSR_DIO, ref StatusMain); + // CB + UnSetBit(MSR_CB, ref StatusMain); + // RQM + SetBit(MSR_RQM, ref StatusMain); - CommCounter = 0; - ResCounter = 0; - } + CommCounter = 0; + ResCounter = 0; + } - /// - /// Moves to command phase - /// - public void SetPhase_Command() - { - ActivePhase = Phase.Command; + /// + /// Moves to result phase + /// + public void SetPhase_Result() + { + ActivePhase = Phase.Result; - // default 0x80 - just RQM - SetBit(MSR_RQM, ref StatusMain); - UnSetBit(MSR_DIO, ref StatusMain); - UnSetBit(MSR_CB, ref StatusMain); - UnSetBit(MSR_EXM, ref StatusMain); - CommCounter = 0; - ResCounter = 0; - } + // active direction + SetBit(MSR_DIO, ref StatusMain); + // CB + SetBit(MSR_CB, ref StatusMain); + // RQM + SetBit(MSR_RQM, ref StatusMain); + // EXM + UnSetBit(MSR_EXM, ref StatusMain); - /// - /// Moves to execution phase - /// - public void SetPhase_Execution() - { - ActivePhase = Phase.Execution; + CommCounter = 0; + ResCounter = 0; + } - // EXM - SetBit(MSR_EXM, ref StatusMain); - // CB - SetBit(MSR_CB, ref StatusMain); - // RQM - UnSetBit(MSR_RQM, ref StatusMain); + /// + /// Moves to command phase + /// + public void SetPhase_Command() + { + ActivePhase = Phase.Command; - CommCounter = 0; - ResCounter = 0; - } + // default 0x80 - just RQM + SetBit(MSR_RQM, ref StatusMain); + UnSetBit(MSR_DIO, ref StatusMain); + UnSetBit(MSR_CB, ref StatusMain); + UnSetBit(MSR_EXM, ref StatusMain); + CommCounter = 0; + ResCounter = 0; + } - #endregion - } + /// + /// Moves to execution phase + /// + public void SetPhase_Execution() + { + ActivePhase = Phase.Execution; + + // EXM + SetBit(MSR_EXM, ref StatusMain); + // CB + SetBit(MSR_CB, ref StatusMain); + // RQM + UnSetBit(MSR_RQM, ref StatusMain); + + CommCounter = 0; + ResCounter = 0; + } + + #endregion + } } diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.FDD.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.FDD.cs index dba0cadbc2..5ea4b182a4 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.FDD.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Disk/NECUPD765.FDD.cs @@ -5,331 +5,318 @@ using System.Linq; namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { - /// - /// Floppy drive related stuff - /// - #region Attribution - /* + /// + /// Floppy drive related stuff + /// + #region Attribution + /* Implementation based on the information contained here: http://www.cpcwiki.eu/index.php/765_FDC and here: http://www.cpcwiki.eu/imgs/f/f3/UPD765_Datasheet_OCRed.pdf */ - #endregion - public partial class NECUPD765 : IFDDHost - { - #region Drive State + #endregion + public partial class NECUPD765 : IFDDHost + { + #region Drive State - /// - /// FDD Flag - motor on/off - /// - public bool FDD_FLAG_MOTOR; + /// + /// FDD Flag - motor on/off + /// + public bool FDD_FLAG_MOTOR; - /// - /// The index of the currently active disk drive - /// - public int DiskDriveIndex - { - get => _diskDriveIndex; - set - { - // when index is changed update the ActiveDrive - _diskDriveIndex = value; - ActiveDrive = DriveStates[_diskDriveIndex]; - } - } - private int _diskDriveIndex = 0; + /// + /// The index of the currently active disk drive + /// + public int DiskDriveIndex + { + get => _diskDriveIndex; + set + { + // when index is changed update the ActiveDrive + _diskDriveIndex = value; + ActiveDrive = DriveStates[_diskDriveIndex]; + } + } + private int _diskDriveIndex = 0; - /// - /// The currently active drive - /// - private DriveState ActiveDrive; + /// + /// The currently active drive + /// + private DriveState ActiveDrive; - /// - /// Array that holds state information for each possible drive - /// - private DriveState[] DriveStates = new DriveState[4]; + /// + /// Array that holds state information for each possible drive + /// + private DriveState[] DriveStates = new DriveState[4]; - #endregion + #endregion - #region FDD Methods + #region FDD Methods - /// - /// Initialization / reset of the floppy drive subsystem - /// - private void FDD_Init() - { - for (int i = 0; i < 4; i++) - { - DriveState ds = new DriveState(i, this); - DriveStates[i] = ds; - } - } + /// + /// Initialization / reset of the floppy drive subsystem + /// + private void FDD_Init() + { + for (int i = 0; i < 4; i++) + { + DriveState ds = new DriveState(i, this); + DriveStates[i] = ds; + } + } - /// - /// Searches for the requested sector - /// - private FloppyDisk.Sector GetSector() - { - FloppyDisk.Sector sector = null; + /// + /// Searches for the requested sector + /// + private FloppyDisk.Sector GetSector() + { + FloppyDisk.Sector sector = null; - // get the current track - var trk = ActiveDrive.Disk.DiskTracks[ActiveDrive.TrackIndex]; + // get the current track + var trk = ActiveDrive.Disk.DiskTracks[ActiveDrive.TrackIndex]; - // get the current sector index - int index = ActiveDrive.SectorIndex; + // get the current sector index + int index = ActiveDrive.SectorIndex; - // make sure this index exists - if (index > trk.Sectors.Length) - { - index = 0; - } + // make sure this index exists + if (index > trk.Sectors.Length) + { + index = 0; + } - // index hole count - int iHole = 0; + // index hole count + int iHole = 0; - // loop through the sectors in a track - // the loop ends with either the sector being found - // or the index hole being passed twice - while (iHole <= 2) - { - // does the requested sector match the current sector - if (trk.Sectors[index].SectorIDInfo.C == ActiveCommandParams.Cylinder && - trk.Sectors[index].SectorIDInfo.H == ActiveCommandParams.Head && - trk.Sectors[index].SectorIDInfo.R == ActiveCommandParams.Sector && - trk.Sectors[index].SectorIDInfo.N == ActiveCommandParams.SectorSize) - { - // sector has been found - sector = trk.Sectors[index]; + // loop through the sectors in a track + // the loop ends with either the sector being found + // or the index hole being passed twice + while (iHole <= 2) + { + // does the requested sector match the current sector + if (trk.Sectors[index].SectorIDInfo.C == ActiveCommandParams.Cylinder && + trk.Sectors[index].SectorIDInfo.H == ActiveCommandParams.Head && + trk.Sectors[index].SectorIDInfo.R == ActiveCommandParams.Sector && + trk.Sectors[index].SectorIDInfo.N == ActiveCommandParams.SectorSize) + { + // sector has been found + sector = trk.Sectors[index]; - UnSetBit(SR2_BC, ref Status2); - UnSetBit(SR2_WC, ref Status2); - break; - } + UnSetBit(SR2_BC, ref Status2); + UnSetBit(SR2_WC, ref Status2); + break; + } - // check for bad cylinder - if (trk.Sectors[index].SectorIDInfo.C == 255) - { - SetBit(SR2_BC, ref Status2); - } - // check for no cylinder - else if (trk.Sectors[index].SectorIDInfo.C != ActiveCommandParams.Cylinder) - { - SetBit(SR2_WC, ref Status2); - } + // check for bad cylinder + if (trk.Sectors[index].SectorIDInfo.C == 255) + { + SetBit(SR2_BC, ref Status2); + } + // check for no cylinder + else if (trk.Sectors[index].SectorIDInfo.C != ActiveCommandParams.Cylinder) + { + SetBit(SR2_WC, ref Status2); + } - // incrememnt sector index - index++; + // incrememnt sector index + index++; - // have we reached the index hole? - if (trk.Sectors.Length <= index) - { - // wrap around - index = 0; - iHole++; - } - } + // have we reached the index hole? + if (trk.Sectors.Length <= index) + { + // wrap around + index = 0; + iHole++; + } + } - // search loop has completed and the sector may or may not have been found + // search loop has completed and the sector may or may not have been found - // bad cylinder detected? - if (Status2.Bit(SR2_BC)) - { - // remove WC - UnSetBit(SR2_WC, ref Status2); - } + // bad cylinder detected? + if (Status2.Bit(SR2_BC)) + { + // remove WC + UnSetBit(SR2_WC, ref Status2); + } - // update sectorindex on drive - ActiveDrive.SectorIndex = index; + // update sectorindex on drive + ActiveDrive.SectorIndex = index; - return sector; - } + return sector; + } - #endregion + #endregion - #region IFDDHost + #region IFDDHost - // IFDDHost methods that fall through to the currently active drive + // IFDDHost methods that fall through to the currently active drive - /// - /// Parses a new disk image and loads it into this floppy drive - /// - public void FDD_LoadDisk(byte[] diskData) - { - // we are only going to load into the first drive - DriveStates[0].FDD_LoadDisk(diskData); - } + /// + /// Parses a new disk image and loads it into this floppy drive + /// + public void FDD_LoadDisk(byte[] diskData) + { + // we are only going to load into the first drive + DriveStates[0].FDD_LoadDisk(diskData); + } - /// - /// Ejects the current disk - /// - public void FDD_EjectDisk() - { - DriveStates[0].FDD_EjectDisk(); - } + /// + /// Ejects the current disk + /// + public void FDD_EjectDisk() + { + DriveStates[0].FDD_EjectDisk(); + } - /// - /// Signs whether the current active drive has a disk inserted - /// - public bool FDD_IsDiskLoaded - { - get { return DriveStates[DiskDriveIndex].FDD_IsDiskLoaded; } - } + /// + /// Signs whether the current active drive has a disk inserted + /// + public bool FDD_IsDiskLoaded => DriveStates[DiskDriveIndex].FDD_IsDiskLoaded; - /// - /// Returns the disk object from drive 0 - /// - public FloppyDisk DiskPointer - { - get { return DriveStates[0].Disk; } - } - - public FloppyDisk Disk { get; set; } + /// + /// Returns the disk object from drive 0 + /// + public FloppyDisk DiskPointer => DriveStates[0].Disk; - #endregion + public FloppyDisk Disk { get; set; } - #region Drive Status Class + #endregion - /// - /// Holds specfic state information about a drive - /// - private class DriveState : IFDDHost - { - #region State + #region Drive Status Class - /// - /// The drive ID from an FDC perspective - /// - public int ID; + /// + /// Holds specfic state information about a drive + /// + private class DriveState : IFDDHost + { + #region State - /// - /// Signs whether this drive ready - /// TRUE if both drive exists and has a disk inserted - /// - public bool FLAG_READY - { - get - { - if (!FDD_IsDiskLoaded || Disk.GetTrackCount() == 0 || !FDC.FDD_FLAG_MOTOR) - return false; - else - return true; - } - } + /// + /// The drive ID from an FDC perspective + /// + public int ID; - /// - /// Disk is write protected (TRUE BY DEFAULT) - /// - public bool FLAG_WRITEPROTECT = false; + /// + /// Signs whether this drive ready + /// TRUE if both drive exists and has a disk inserted + /// + public bool FLAG_READY + { + get + { + if (!FDD_IsDiskLoaded || Disk.GetTrackCount() == 0 || !FDC.FDD_FLAG_MOTOR) + return false; + else + return true; + } + } - /// - /// Storage for seek steps - /// One step for each indexpulse (track index) until seeked track - /// - public int SeekCounter; + /// + /// Disk is write protected (TRUE BY DEFAULT) + /// + public bool FLAG_WRITEPROTECT = false; - /// - /// Seek status - /// - public int SeekStatus; + /// + /// Storage for seek steps + /// One step for each indexpulse (track index) until seeked track + /// + public int SeekCounter; - /// - /// Age counter - /// - public int SeekAge; + /// + /// Seek status + /// + public int SeekStatus; - /// - /// The current side - /// - public byte CurrentSide; + /// + /// Age counter + /// + public int SeekAge; - /// - /// The current track index in the DiskTracks array - /// - public byte TrackIndex; + /// + /// The current side + /// + public byte CurrentSide; - /// - /// The track ID of the current cylinder - /// - public byte CurrentTrackID - { - get - { - // default invalid track - int id = 0xff; + /// + /// The current track index in the DiskTracks array + /// + public byte TrackIndex; - if (Disk == null) - return (byte)id; + /// + /// The track ID of the current cylinder + /// + public byte CurrentTrackID + { + get + { + // default invalid track + int id = 0xff; - if (Disk.DiskTracks.Count() == 0) - return (byte)id; + if (Disk == null) + return (byte)id; - if (TrackIndex >= Disk.GetTrackCount()) - TrackIndex = 0; - else if (TrackIndex < 0) - TrackIndex = 0; + if (Disk.DiskTracks.Count() == 0) + return (byte)id; - var track = Disk.DiskTracks[TrackIndex]; + if (TrackIndex >= Disk.GetTrackCount()) + TrackIndex = 0; + else if (TrackIndex < 0) + TrackIndex = 0; - id = track.TrackNumber; + var track = Disk.DiskTracks[TrackIndex]; - return (byte)id; - } - set - { - for (int i = 0; i < Disk.GetTrackCount(); i++) - { - if (Disk.DiskTracks[i].TrackNumber == value) - { - TrackIndex = (byte)i; - break; - } - } - } - } + id = track.TrackNumber; + + return (byte)id; + } + set + { + for (int i = 0; i < Disk.GetTrackCount(); i++) + { + if (Disk.DiskTracks[i].TrackNumber == value) + { + TrackIndex = (byte)i; + break; + } + } + } + } - /// - /// The new track that the drive is seeking to - /// (used in seek operations) - /// - public int SeekingTrack; + /// + /// The new track that the drive is seeking to + /// (used in seek operations) + /// + public int SeekingTrack; - /// - /// The current sector index in the Sectors array - /// - public int SectorIndex; + /// + /// The current sector index in the Sectors array + /// + public int SectorIndex; - /// - /// The currently loaded floppy disk - /// - public FloppyDisk Disk { get; set; } + /// + /// The currently loaded floppy disk + /// + public FloppyDisk Disk { get; set; } - /// - /// The parent controller - /// - private NECUPD765 FDC; + /// + /// The parent controller + /// + private NECUPD765 FDC; - #endregion + #endregion - #region Lookups + #region Lookups - /// - /// TRUE if we are on track 0 - /// - public bool FLAG_TRACK0 - { - get - { - if (TrackIndex == 0) { return true; } - else { return false; } - } - } + /// + /// TRUE if we are on track 0 + /// + public bool FLAG_TRACK0 => TrackIndex == 0; - #endregion + #endregion - #region Public Methods - /* + #region Public Methods + /* /// /// Moves the head across the disk cylinders /// @@ -369,7 +356,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum } */ - /* + /* /// /// Finds a supplied sector @@ -524,7 +511,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum } */ - /* + /* /// /// The drive performs a seek operation if necessary @@ -751,139 +738,139 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum SetBit(SR0_EC, ref IntStatus); } */ - /* - // UnitSelect - SetUnitSelect(ID, ref IntStatus); + /* + // UnitSelect + SetUnitSelect(ID, ref IntStatus); - // move to none state - //CurrentState = DriveMainState.None; + // move to none state + //CurrentState = DriveMainState.None; - //SeekState = SeekSubState.SeekCompleted; + //SeekState = SeekSubState.SeekCompleted; - // set the seek interrupt flag for this drive - // this will be cleared at the next successful senseint - FLAG_SEEK_INTERRUPT = true; + // set the seek interrupt flag for this drive + // this will be cleared at the next successful senseint + FLAG_SEEK_INTERRUPT = true; - //CurrentState = DriveMainState.None; + //CurrentState = DriveMainState.None; - } - */ + } + */ - #endregion + #endregion - #region Construction + #region Construction - public DriveState(int driveID, NECUPD765 fdc) - { - ID = driveID; - FDC = fdc; - } + public DriveState(int driveID, NECUPD765 fdc) + { + ID = driveID; + FDC = fdc; + } - #endregion + #endregion - #region IFDDHost + #region IFDDHost - /// - /// Parses a new disk image and loads it into this floppy drive - /// - public void FDD_LoadDisk(byte[] diskData) - { - // try dsk first - FloppyDisk fdd = null; - bool found = false; + /// + /// Parses a new disk image and loads it into this floppy drive + /// + public void FDD_LoadDisk(byte[] diskData) + { + // try dsk first + FloppyDisk fdd = null; + bool found = false; - foreach (DiskType type in Enum.GetValues(typeof(DiskType))) - { - switch (type) - { - case DiskType.CPCExtended: - fdd = new CPCExtendedFloppyDisk(); - found = fdd.ParseDisk(diskData); - break; - case DiskType.CPC: - fdd = new CPCFloppyDisk(); - found = fdd.ParseDisk(diskData); - break; - case DiskType.IPF: - fdd = new IPFFloppyDisk(); - found = fdd.ParseDisk(diskData); - break; - case DiskType.UDI: - fdd = new UDI1_0FloppyDisk(); - found = fdd.ParseDisk(diskData); - break; - } + foreach (DiskType type in Enum.GetValues(typeof(DiskType))) + { + switch (type) + { + case DiskType.CPCExtended: + fdd = new CPCExtendedFloppyDisk(); + found = fdd.ParseDisk(diskData); + break; + case DiskType.CPC: + fdd = new CPCFloppyDisk(); + found = fdd.ParseDisk(diskData); + break; + case DiskType.IPF: + fdd = new IPFFloppyDisk(); + found = fdd.ParseDisk(diskData); + break; + case DiskType.UDI: + fdd = new UDI1_0FloppyDisk(); + found = fdd.ParseDisk(diskData); + break; + } - if (found) - { - Disk = fdd; - break; - } - } + if (found) + { + Disk = fdd; + break; + } + } - if (!found) - { - throw new Exception(this.GetType().ToString() + - "\n\nDisk image file could not be parsed. Potentially an unknown format."); - } - } + if (!found) + { + throw new Exception(this.GetType().ToString() + + "\n\nDisk image file could not be parsed. Potentially an unknown format."); + } + } - /// - /// Ejects the current disk - /// - public void FDD_EjectDisk() - { - Disk = null; - //FLAG_READY = false; - } + /// + /// Ejects the current disk + /// + public void FDD_EjectDisk() + { + Disk = null; + //FLAG_READY = false; + } - /// - /// Signs whether the current active drive has a disk inserted - /// - public bool FDD_IsDiskLoaded - { - get - { - if (Disk != null) - return true; - else - return false; - } - } + /// + /// Signs whether the current active drive has a disk inserted + /// + public bool FDD_IsDiskLoaded + { + get + { + if (Disk != null) + return true; + else + return false; + } + } - #endregion + #endregion - #region StateSerialization + #region StateSerialization - public void SyncState(Serializer ser) - { - ser.Sync(nameof(ID), ref ID); - ser.Sync(nameof(FLAG_WRITEPROTECT), ref FLAG_WRITEPROTECT); - //ser.Sync(nameof(FLAG_DISKCHANGED), ref FLAG_DISKCHANGED); - //ser.Sync(nameof(FLAG_RECALIBRATING), ref FLAG_RECALIBRATING); - //ser.Sync(nameof(FLAG_SEEK_INTERRUPT), ref FLAG_SEEK_INTERRUPT); - //ser.Sync(nameof(IntStatus), ref IntStatus); - //ser.Sync(nameof(ST0), ref ST0); - //ser.Sync(nameof(RecalibrationCounter), ref RecalibrationCounter); - ser.Sync(nameof(SeekCounter), ref SeekCounter); - ser.Sync(nameof(SeekStatus), ref SeekStatus); - ser.Sync(nameof(SeekAge), ref SeekAge); - ser.Sync(nameof(CurrentSide), ref CurrentSide); - //ser.Sync(nameof(CurrentTrack), ref CurrentTrack); - ser.Sync(nameof(TrackIndex), ref TrackIndex); - ser.Sync(nameof(SeekingTrack), ref SeekingTrack); - //ser.Sync(nameof(CurrentSector), ref CurrentSector); - ser.Sync(nameof(SectorIndex), ref SectorIndex); - //ser.Sync(nameof(RAngles), ref RAngles); - //ser.Sync(nameof(DataPointer), ref DataPointer); - //ser.SyncEnum(nameof(CurrentState), ref CurrentState); - //ser.SyncEnum(nameof(SeekState), ref SeekState); - //ser.SyncEnum(nameof(SeekIntState), ref SeekIntState); - } + public void SyncState(Serializer ser) + { + ser.Sync(nameof(ID), ref ID); + ser.Sync(nameof(FLAG_WRITEPROTECT), ref FLAG_WRITEPROTECT); + //ser.Sync(nameof(FLAG_DISKCHANGED), ref FLAG_DISKCHANGED); + //ser.Sync(nameof(FLAG_RECALIBRATING), ref FLAG_RECALIBRATING); + //ser.Sync(nameof(FLAG_SEEK_INTERRUPT), ref FLAG_SEEK_INTERRUPT); + //ser.Sync(nameof(IntStatus), ref IntStatus); + //ser.Sync(nameof(ST0), ref ST0); + //ser.Sync(nameof(RecalibrationCounter), ref RecalibrationCounter); + ser.Sync(nameof(SeekCounter), ref SeekCounter); + ser.Sync(nameof(SeekStatus), ref SeekStatus); + ser.Sync(nameof(SeekAge), ref SeekAge); + ser.Sync(nameof(CurrentSide), ref CurrentSide); + //ser.Sync(nameof(CurrentTrack), ref CurrentTrack); + ser.Sync(nameof(TrackIndex), ref TrackIndex); + ser.Sync(nameof(SeekingTrack), ref SeekingTrack); + //ser.Sync(nameof(CurrentSector), ref CurrentSector); + ser.Sync(nameof(SectorIndex), ref SectorIndex); + //ser.Sync(nameof(RAngles), ref RAngles); + //ser.Sync(nameof(DataPointer), ref DataPointer); + //ser.SyncEnum(nameof(CurrentState), ref CurrentState); + //ser.SyncEnum(nameof(SeekState), ref SeekState); + //ser.SyncEnum(nameof(SeekIntState), ref SeekIntState); + } - #endregion - } + #endregion + } -#endregion - } + #endregion + } } diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Rom/RomData.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Rom/RomData.cs index fd2201bb30..2f5da5e94d 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Rom/RomData.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Hardware/Rom/RomData.cs @@ -51,11 +51,9 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum private ushort _loadBytesResumeAddress; private ushort _loadBytesInvalidHeaderAddress; - public static RomData InitROM(MachineType machineType, byte[] rom) { - RomData RD = new RomData(); - RD.RomBytes = new byte[rom.Length]; + RomData RD = new RomData { RomBytes = new byte[rom.Length] }; RD.RomBytes = rom; switch (machineType) diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/Pentagon128K/Pentagon128.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/Pentagon128K/Pentagon128.cs index 46e72eff95..ae6163431e 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/Pentagon128K/Pentagon128.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/Pentagon128K/Pentagon128.cs @@ -19,8 +19,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum Spectrum = spectrum; CPU = cpu; - CPUMon = new CPUMonitor(this); - CPUMon.machineType = MachineType.Pentagon128; + CPUMon = new CPUMonitor(this) { machineType = MachineType.Pentagon128 }; ROMPaged = 0; SHADOWPaged = false; diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Input.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Input.cs index d1aa437419..bac2ae50c5 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Input.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.Input.cs @@ -3,340 +3,338 @@ using System.Linq; namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { - /// - /// The abstract class that all emulated models will inherit from - /// * Input * - /// - public abstract partial class SpectrumBase - { - string Play = "Play Tape"; - string Stop = "Stop Tape"; - string RTZ = "RTZ Tape"; - string Record = "Record Tape"; - string NextTape = "Insert Next Tape"; - string PrevTape = "Insert Previous Tape"; - string NextBlock = "Next Tape Block"; - string PrevBlock = "Prev Tape Block"; - string TapeStatus = "Get Tape Status"; + /// + /// The abstract class that all emulated models will inherit from + /// * Input * + /// + public abstract partial class SpectrumBase + { + string Play = "Play Tape"; + string Stop = "Stop Tape"; + string RTZ = "RTZ Tape"; + string Record = "Record Tape"; + string NextTape = "Insert Next Tape"; + string PrevTape = "Insert Previous Tape"; + string NextBlock = "Next Tape Block"; + string PrevBlock = "Prev Tape Block"; + string TapeStatus = "Get Tape Status"; - string NextDisk = "Insert Next Disk"; - string PrevDisk = "Insert Previous Disk"; - string EjectDisk = "Eject Current Disk"; - string DiskStatus = "Get Disk Status"; + string NextDisk = "Insert Next Disk"; + string PrevDisk = "Insert Previous Disk"; + string EjectDisk = "Eject Current Disk"; + string DiskStatus = "Get Disk Status"; - string HardResetStr = "Power"; - string SoftResetStr = "Reset"; + string HardResetStr = "Power"; + string SoftResetStr = "Reset"; - bool pressed_Play = false; - bool pressed_Stop = false; - bool pressed_RTZ = false; - bool pressed_NextTape = false; - bool pressed_PrevTape = false; - bool pressed_NextBlock = false; - bool pressed_PrevBlock = false; - bool pressed_TapeStatus = false; - bool pressed_NextDisk = false; - bool pressed_PrevDisk = false; - bool pressed_EjectDisk = false; - bool pressed_DiskStatus = false; - bool pressed_HardReset = false; - bool pressed_SoftReset = false; + bool pressed_Play; + bool pressed_Stop; + bool pressed_RTZ; + bool pressed_NextTape; + bool pressed_PrevTape; + bool pressed_NextBlock; + bool pressed_PrevBlock; + bool pressed_TapeStatus; + bool pressed_NextDisk; + bool pressed_PrevDisk; + bool pressed_EjectDisk; + bool pressed_DiskStatus; + bool pressed_HardReset; + bool pressed_SoftReset; - /// - /// Cycles through all the input callbacks - /// This should be done once per frame - /// - public void PollInput() - { - Spectrum.InputCallbacks.Call(); + /// + /// Cycles through all the input callbacks + /// This should be done once per frame + /// + public void PollInput() + { + Spectrum.InputCallbacks.Call(); - lock (this) - { - // parse single keyboard matrix keys - for (var i = 0; i < KeyboardDevice.KeyboardMatrix.Length; i++) - { - string key = KeyboardDevice.KeyboardMatrix[i]; - bool prevState = KeyboardDevice.GetKeyStatus(key); - bool currState = Spectrum._controller.IsPressed(key); + lock (this) + { + // parse single keyboard matrix keys + for (var i = 0; i < KeyboardDevice.KeyboardMatrix.Length; i++) + { + string key = KeyboardDevice.KeyboardMatrix[i]; + bool prevState = KeyboardDevice.GetKeyStatus(key); + bool currState = Spectrum._controller.IsPressed(key); - if (currState != prevState) - KeyboardDevice.SetKeyStatus(key, currState); - } + if (currState != prevState) + KeyboardDevice.SetKeyStatus(key, currState); + } - // non matrix keys - foreach (string k in KeyboardDevice.NonMatrixKeys) - { - if (!k.StartsWith("Key")) - continue; + // non matrix keys + foreach (string k in KeyboardDevice.NonMatrixKeys) + { + if (!k.StartsWith("Key")) + continue; - bool currState = Spectrum._controller.IsPressed(k); + bool currState = Spectrum._controller.IsPressed(k); - KeyboardDevice.SetKeyStatus(k, currState); - } + KeyboardDevice.SetKeyStatus(k, currState); + } - // J1 - foreach (string j in JoystickCollection[0].ButtonCollection) - { - bool prevState = JoystickCollection[0].GetJoyInput(j); - bool currState = Spectrum._controller.IsPressed(j); + // J1 + foreach (string j in JoystickCollection[0].ButtonCollection) + { + bool prevState = JoystickCollection[0].GetJoyInput(j); + bool currState = Spectrum._controller.IsPressed(j); - if (currState != prevState) - JoystickCollection[0].SetJoyInput(j, currState); - } + if (currState != prevState) + JoystickCollection[0].SetJoyInput(j, currState); + } - // J2 - foreach (string j in JoystickCollection[1].ButtonCollection) - { - bool prevState = JoystickCollection[1].GetJoyInput(j); - bool currState = Spectrum._controller.IsPressed(j); + // J2 + foreach (string j in JoystickCollection[1].ButtonCollection) + { + bool prevState = JoystickCollection[1].GetJoyInput(j); + bool currState = Spectrum._controller.IsPressed(j); - if (currState != prevState) - JoystickCollection[1].SetJoyInput(j, currState); - } + if (currState != prevState) + JoystickCollection[1].SetJoyInput(j, currState); + } - // J3 - foreach (string j in JoystickCollection[2].ButtonCollection) - { - bool prevState = JoystickCollection[2].GetJoyInput(j); - bool currState = Spectrum._controller.IsPressed(j); + // J3 + foreach (string j in JoystickCollection[2].ButtonCollection) + { + bool prevState = JoystickCollection[2].GetJoyInput(j); + bool currState = Spectrum._controller.IsPressed(j); - if (currState != prevState) - JoystickCollection[2].SetJoyInput(j, currState); - } - } + if (currState != prevState) + JoystickCollection[2].SetJoyInput(j, currState); + } + } - // Tape control - if (Spectrum._controller.IsPressed(Play)) - { - if (!pressed_Play) - { - Spectrum.OSD_FireInputMessage(Play); - TapeDevice.Play(); - pressed_Play = true; - } - } - else - pressed_Play = false; + // Tape control + if (Spectrum._controller.IsPressed(Play)) + { + if (!pressed_Play) + { + Spectrum.OSD_FireInputMessage(Play); + TapeDevice.Play(); + pressed_Play = true; + } + } + else + pressed_Play = false; - if (Spectrum._controller.IsPressed(Stop)) - { - if (!pressed_Stop) - { - Spectrum.OSD_FireInputMessage(Stop); - TapeDevice.Stop(); - pressed_Stop = true; - } - } - else - pressed_Stop = false; + if (Spectrum._controller.IsPressed(Stop)) + { + if (!pressed_Stop) + { + Spectrum.OSD_FireInputMessage(Stop); + TapeDevice.Stop(); + pressed_Stop = true; + } + } + else + pressed_Stop = false; - if (Spectrum._controller.IsPressed(RTZ)) - { - if (!pressed_RTZ) - { - Spectrum.OSD_FireInputMessage(RTZ); - TapeDevice.RTZ(); - pressed_RTZ = true; - } - } - else - pressed_RTZ = false; + if (Spectrum._controller.IsPressed(RTZ)) + { + if (!pressed_RTZ) + { + Spectrum.OSD_FireInputMessage(RTZ); + TapeDevice.RTZ(); + pressed_RTZ = true; + } + } + else + pressed_RTZ = false; - if (Spectrum._controller.IsPressed(Record)) - { + if (Spectrum._controller.IsPressed(Record)) + { - } - if (Spectrum._controller.IsPressed(NextTape)) - { - if (!pressed_NextTape) - { - Spectrum.OSD_FireInputMessage(NextTape); - TapeMediaIndex++; - pressed_NextTape = true; - } - } - else - pressed_NextTape = false; + } + if (Spectrum._controller.IsPressed(NextTape)) + { + if (!pressed_NextTape) + { + Spectrum.OSD_FireInputMessage(NextTape); + TapeMediaIndex++; + pressed_NextTape = true; + } + } + else + pressed_NextTape = false; - if (Spectrum._controller.IsPressed(PrevTape)) - { - if (!pressed_PrevTape) - { - Spectrum.OSD_FireInputMessage(PrevTape); - TapeMediaIndex--; - pressed_PrevTape = true; - } - } - else - pressed_PrevTape = false; + if (Spectrum._controller.IsPressed(PrevTape)) + { + if (!pressed_PrevTape) + { + Spectrum.OSD_FireInputMessage(PrevTape); + TapeMediaIndex--; + pressed_PrevTape = true; + } + } + else + pressed_PrevTape = false; - if (Spectrum._controller.IsPressed(NextBlock)) - { - if (!pressed_NextBlock) - { - Spectrum.OSD_FireInputMessage(NextBlock); - TapeDevice.SkipBlock(true); - pressed_NextBlock = true; - } - } - else - pressed_NextBlock = false; + if (Spectrum._controller.IsPressed(NextBlock)) + { + if (!pressed_NextBlock) + { + Spectrum.OSD_FireInputMessage(NextBlock); + TapeDevice.SkipBlock(true); + pressed_NextBlock = true; + } + } + else + pressed_NextBlock = false; - if (Spectrum._controller.IsPressed(PrevBlock)) - { - if (!pressed_PrevBlock) - { - Spectrum.OSD_FireInputMessage(PrevBlock); - TapeDevice.SkipBlock(false); - pressed_PrevBlock = true; - } - } - else - pressed_PrevBlock = false; + if (Spectrum._controller.IsPressed(PrevBlock)) + { + if (!pressed_PrevBlock) + { + Spectrum.OSD_FireInputMessage(PrevBlock); + TapeDevice.SkipBlock(false); + pressed_PrevBlock = true; + } + } + else + pressed_PrevBlock = false; - if (Spectrum._controller.IsPressed(TapeStatus)) - { - if (!pressed_TapeStatus) - { - Spectrum.OSD_ShowTapeStatus(); - pressed_TapeStatus = true; - } - } - else - pressed_TapeStatus = false; + if (Spectrum._controller.IsPressed(TapeStatus)) + { + if (!pressed_TapeStatus) + { + Spectrum.OSD_ShowTapeStatus(); + pressed_TapeStatus = true; + } + } + else + pressed_TapeStatus = false; - if (Spectrum._controller.IsPressed(HardResetStr)) - { - if (!pressed_HardReset) - { - HardReset(); - pressed_HardReset = true; - } - } - else - pressed_HardReset = false; + if (Spectrum._controller.IsPressed(HardResetStr)) + { + if (!pressed_HardReset) + { + HardReset(); + pressed_HardReset = true; + } + } + else + pressed_HardReset = false; - if (Spectrum._controller.IsPressed(SoftResetStr)) - { - if (!pressed_SoftReset) - { - SoftReset(); - pressed_SoftReset = true; - } - } - else - pressed_SoftReset = false; + if (Spectrum._controller.IsPressed(SoftResetStr)) + { + if (!pressed_SoftReset) + { + SoftReset(); + pressed_SoftReset = true; + } + } + else + pressed_SoftReset = false; - // disk control - if (Spectrum._controller.IsPressed(NextDisk)) - { - if (!pressed_NextDisk) - { - Spectrum.OSD_FireInputMessage(NextDisk); - DiskMediaIndex++; - pressed_NextDisk = true; - } - } - else - pressed_NextDisk = false; + // disk control + if (Spectrum._controller.IsPressed(NextDisk)) + { + if (!pressed_NextDisk) + { + Spectrum.OSD_FireInputMessage(NextDisk); + DiskMediaIndex++; + pressed_NextDisk = true; + } + } + else + pressed_NextDisk = false; - if (Spectrum._controller.IsPressed(PrevDisk)) - { - if (!pressed_PrevDisk) - { - Spectrum.OSD_FireInputMessage(PrevDisk); - DiskMediaIndex--; - pressed_PrevDisk = true; - } - } - else - pressed_PrevDisk = false; + if (Spectrum._controller.IsPressed(PrevDisk)) + { + if (!pressed_PrevDisk) + { + Spectrum.OSD_FireInputMessage(PrevDisk); + DiskMediaIndex--; + pressed_PrevDisk = true; + } + } + else + pressed_PrevDisk = false; - if (Spectrum._controller.IsPressed(EjectDisk)) - { - if (!pressed_EjectDisk) - { - Spectrum.OSD_FireInputMessage(EjectDisk); - if (UPDDiskDevice != null) - UPDDiskDevice.FDD_EjectDisk(); - } - } - else - pressed_EjectDisk = false; + if (Spectrum._controller.IsPressed(EjectDisk)) + { + if (!pressed_EjectDisk) + { + Spectrum.OSD_FireInputMessage(EjectDisk); + UPDDiskDevice?.FDD_EjectDisk(); + } + } + else + pressed_EjectDisk = false; - if (Spectrum._controller.IsPressed(DiskStatus)) - { - if (!pressed_DiskStatus) - { - Spectrum.OSD_ShowDiskStatus(); - pressed_DiskStatus = true; - } - } - else - pressed_DiskStatus = false; - } + if (Spectrum._controller.IsPressed(DiskStatus)) + { + if (!pressed_DiskStatus) + { + Spectrum.OSD_ShowDiskStatus(); + pressed_DiskStatus = true; + } + } + else + pressed_DiskStatus = false; + } - /// - /// Instantiates the joysticks array - /// - protected void InitJoysticks(List joys) - { - List jCollection = new List(); + /// + /// Instantiates the joysticks array + /// + protected void InitJoysticks(List joys) + { + var jCollection = new List(); - for (int i = 0; i < joys.Count(); i++) - { - jCollection.Add(InstantiateJoystick(joys[i], i + 1)); - } + for (int i = 0; i < joys.Count(); i++) + { + jCollection.Add(InstantiateJoystick(joys[i], i + 1)); + } - JoystickCollection = jCollection.ToArray(); + JoystickCollection = jCollection.ToArray(); - for (int i = 0; i < JoystickCollection.Length; i++) - { - Spectrum.OSD_FireInputMessage("Joystick " + (i + 1) + ": " + JoystickCollection[i].JoyType.ToString()); - } - } + for (int i = 0; i < JoystickCollection.Length; i++) + { + Spectrum.OSD_FireInputMessage("Joystick " + (i + 1) + ": " + JoystickCollection[i].JoyType); + } + } - /// - /// Instantiates a new IJoystick object - /// - public IJoystick InstantiateJoystick(JoystickType type, int playerNumber) - { - switch (type) - { - case JoystickType.Kempston: - return new KempstonJoystick(this, playerNumber); - case JoystickType.Cursor: - return new CursorJoystick(this, playerNumber); - case JoystickType.SinclairLEFT: - return new SinclairJoystick1(this, playerNumber); - case JoystickType.SinclairRIGHT: - return new SinclairJoystick2(this, playerNumber); - case JoystickType.NULL: - return new NullJoystick(this, playerNumber); - } + /// + /// Instantiates a new IJoystick object + /// + public IJoystick InstantiateJoystick(JoystickType type, int playerNumber) + { + switch (type) + { + case JoystickType.Kempston: + return new KempstonJoystick(this, playerNumber); + case JoystickType.Cursor: + return new CursorJoystick(this, playerNumber); + case JoystickType.SinclairLEFT: + return new SinclairJoystick1(this, playerNumber); + case JoystickType.SinclairRIGHT: + return new SinclairJoystick2(this, playerNumber); + case JoystickType.NULL: + return new NullJoystick(this, playerNumber); + } - return null; - } + return null; + } - /// - /// Returns a IJoystick object depending on the type (or null if not found) - /// - protected IJoystick LocateUniqueJoystick(JoystickType type) - { - return JoystickCollection.Where(a => a.JoyType == type).FirstOrDefault(); - } + /// + /// Returns a IJoystick object depending on the type (or null if not found) + /// + protected IJoystick LocateUniqueJoystick(JoystickType type) + { + return JoystickCollection.FirstOrDefault(a => a.JoyType == type); + } - /// - /// Signs whether input read has been requested - /// This forms part of the IEmulator LagFrame implementation - /// - private bool inputRead; - public bool InputRead - { - get => inputRead; - set => inputRead = value; - } - - } + /// + /// Signs whether input read has been requested + /// This forms part of the IEmulator LagFrame implementation + /// + private bool inputRead; + public bool InputRead + { + get => inputRead; + set => inputRead = value; + } + } } diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.cs index 3e71750447..c218adbca6 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/SpectrumBase.cs @@ -154,8 +154,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum if (_renderSound) { - if (AYDevice != null) - AYDevice.StartFrame(); + AYDevice?.StartFrame(); } PollInput(); @@ -185,8 +184,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum ULADevice.LastTState = 0; - if (AYDevice != null) - AYDevice.EndFrame(); + AYDevice?.EndFrame(); FrameCount++; @@ -243,10 +241,9 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum CPU.Regs[CPU.R] = 0; TapeDevice.Reset(); - if (AYDevice != null) - AYDevice.Reset(); + AYDevice?.Reset(); - byte[][] rams = new byte[][] + byte[][] rams = { RAM0, RAM1, @@ -295,10 +292,9 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum CPU.Regs[CPU.R] = 0; TapeDevice.Reset(); - if (AYDevice != null) - AYDevice.Reset(); + AYDevice?.Reset(); - byte[][] rams = new byte[][] + byte[][] rams = { RAM0, RAM1, @@ -364,7 +360,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum if (AYDevice != null) { AYDevice.SyncState(ser); - ((AY38912)AYDevice as AY38912).PanningConfiguration = Spectrum.Settings.AYPanConfig; + ((AY38912)AYDevice).PanningConfiguration = Spectrum.Settings.AYPanConfig; } ser.Sync(nameof(tapeMediaIndex), ref tapeMediaIndex); @@ -375,7 +371,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum IsLoadState = false; } - TapeDevice.SyncState(ser); ser.Sync(nameof(diskMediaIndex), ref diskMediaIndex); @@ -386,10 +381,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum IsLoadState = false; } - if (UPDDiskDevice != null) - { - UPDDiskDevice.SyncState(ser); - } + UPDDiskDevice?.SyncState(ser); ser.EndSection(); } diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ULA.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ULA.cs index 1178831579..542c3b3a4e 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ULA.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ULA.cs @@ -857,10 +857,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum set { } } - public int VsyncDenominator - { - get { return ClockSpeed; }//FrameLength; } - } + public int VsyncDenominator => ClockSpeed; // FrameLength; public int[] GetVideoBuffer() { diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.cs index 28859c3fa6..20c965097d 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.cs @@ -19,8 +19,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum Spectrum = spectrum; CPU = cpu; - CPUMon = new CPUMonitor(this); - CPUMon.machineType = MachineType.ZXSpectrum128; + CPUMon = new CPUMonitor(this) { machineType = MachineType.ZXSpectrum128 }; ROMPaged = 0; SHADOWPaged = false; diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus2a/ZX128Plus2a.Memory.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus2a/ZX128Plus2a.Memory.cs index da344caa71..243581e569 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus2a/ZX128Plus2a.Memory.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus2a/ZX128Plus2a.Memory.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus2a/ZX128Plus2a.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus2a/ZX128Plus2a.cs index 69140ea87d..ee0e0af87d 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus2a/ZX128Plus2a.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus2a/ZX128Plus2a.cs @@ -19,8 +19,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum Spectrum = spectrum; CPU = cpu; - CPUMon = new CPUMonitor(this); - CPUMon.machineType = MachineType.ZXSpectrum128Plus2a; + CPUMon = new CPUMonitor(this) { machineType = MachineType.ZXSpectrum128Plus2a }; ROMPaged = 0; SHADOWPaged = false; diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus3/ZX128Plus3.Memory.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus3/ZX128Plus3.Memory.cs index 3fb9cdb2e6..ca174ac903 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus3/ZX128Plus3.Memory.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus3/ZX128Plus3.Memory.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus3/ZX128Plus3.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus3/ZX128Plus3.cs index 9b372a0a35..cb3bb54eab 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus3/ZX128Plus3.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128KPlus3/ZX128Plus3.cs @@ -19,8 +19,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum Spectrum = spectrum; CPU = cpu; - CPUMon = new CPUMonitor(this); - CPUMon.machineType = MachineType.ZXSpectrum128Plus3; + CPUMon = new CPUMonitor(this) { machineType = MachineType.ZXSpectrum128Plus3 }; ROMPaged = 0; SHADOWPaged = false; diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.Memory.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.Memory.cs index b35cade838..279a9b3a08 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.Memory.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.Memory.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum +namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { /// /// 48K Memory diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/FloppyDisk.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/FloppyDisk.cs index 663e9585b8..5c9ce9ba02 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/FloppyDisk.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/FloppyDisk.cs @@ -593,7 +593,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum public virtual byte TrackType { get; set; } public virtual int TLEN { get; set; } - public virtual int CLEN { get { return TLEN / 8 + (TLEN % 8 / 7) / 8; } } + public virtual int CLEN => TLEN / 8 + (TLEN % 8 / 7) / 8; public virtual byte[] TrackData { get; set; } #endregion @@ -646,10 +646,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { return ActualDataByteLength; } - else - { - return ActualDataByteLength / (ActualDataByteLength / (0x80 << SectorSize)); - } + + return ActualDataByteLength / (ActualDataByteLength / (0x80 << SectorSize)); } } @@ -676,10 +674,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum return l.ToArray(); } - else - { - return SectorData; - } + + return SectorData; } else { @@ -709,21 +705,16 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum } } - public CHRN SectorIDInfo - { - get + public CHRN SectorIDInfo => + new CHRN { - return new CHRN - { - C = TrackNumber, - H = SideNumber, - R = SectorID, - N = SectorSize, - Flag1 = Status1, - Flag2 = Status2, - }; - } - } + C = TrackNumber, + H = SideNumber, + R = SectorID, + N = SectorSize, + Flag1 = Status1, + Flag2 = Status2, + }; } } diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/IPFFormat/IPFFloppyDisk.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/IPFFormat/IPFFloppyDisk.cs index bcf51ca14e..96e446c2c2 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/IPFFormat/IPFFloppyDisk.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/IPFFormat/IPFFloppyDisk.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; -using System.Threading.Tasks; namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { @@ -63,7 +62,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum } // now process the blocks - var infoBlock = blocks.Where(a => a.RecordType == RecordHeaderType.INFO).FirstOrDefault(); + var infoBlock = blocks.FirstOrDefault(a => a.RecordType == RecordHeaderType.INFO); var IMGEblocks = blocks.Where(a => a.RecordType == RecordHeaderType.IMGE).ToList(); var DATAblocks = blocks.Where(a => a.RecordType == RecordHeaderType.DATA); @@ -79,7 +78,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum var trk = DiskTracks[t]; var blockCount = img.IMGEblockCount; - var dataBlock = DATAblocks.Where(a => a.DATAdataKey == img.IMGEdataKey).FirstOrDefault(); + var dataBlock = DATAblocks.FirstOrDefault(a => a.DATAdataKey == img.IMGEdataKey); trk.SideNumber = (byte)img.IMGEside; trk.TrackNumber = (byte)img.IMGEtrack; diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/UDIFormat/UDI1_0FloppyDisk.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/UDIFormat/UDI1_0FloppyDisk.cs index 5b6006bf9c..95cd1ea1d0 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/UDIFormat/UDI1_0FloppyDisk.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/UDIFormat/UDI1_0FloppyDisk.cs @@ -4,7 +4,6 @@ using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; -using System.Threading.Tasks; namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { @@ -60,11 +59,14 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum // process track information for (int t = 0; t < DiskHeader.NumberOfTracks; t++) { - DiskTracks[t] = new UDIv1Track(); - DiskTracks[t].TrackNumber = (byte)t; - DiskTracks[t].SideNumber = 0; - DiskTracks[t].TrackType = data[pos++]; - DiskTracks[t].TLEN = MediaConverter.GetWordValue(data, pos); pos += 2; + DiskTracks[t] = new UDIv1Track + { + TrackNumber = (byte) t, + SideNumber = 0, + TrackType = data[pos++], + TLEN = MediaConverter.GetWordValue(data, pos) + }; + pos += 2; DiskTracks[t].TrackData = new byte[DiskTracks[t].TLEN + DiskTracks[t].CLEN]; Array.Copy(data, pos, DiskTracks[t].TrackData, 0, DiskTracks[t].TLEN + DiskTracks[t].CLEN); pos += DiskTracks[t].TLEN + DiskTracks[t].CLEN; diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/MediaConverter.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/MediaConverter.cs index a8fa0effbd..67a345a99a 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/MediaConverter.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/MediaConverter.cs @@ -19,24 +19,12 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum /// /// Signs whether this class can be used to read the data format /// - public virtual bool IsReader - { - get - { - return false; - } - } + public virtual bool IsReader => false; /// /// Signs whether this class can be used to write the data format /// - public virtual bool IsWriter - { - get - { - return false; - } - } + public virtual bool IsWriter => false; /// /// Serialization method diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Snapshot/SZX/SZX.Methods.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Snapshot/SZX/SZX.Methods.cs index c8f0f5e7a2..f87809efb9 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Snapshot/SZX/SZX.Methods.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Snapshot/SZX/SZX.Methods.cs @@ -1,13 +1,8 @@ -using BizHawk.Common.NumberExtensions; -using BizHawk.Emulation.Cores.Components.Z80A; -using System; -using System.Collections; +using BizHawk.Emulation.Cores.Components.Z80A; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Runtime.InteropServices; using System.Text; -using System.Threading.Tasks; namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { @@ -35,9 +30,9 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum byte[] result = null; - using (MemoryStream ms = new MemoryStream()) + using (var ms = new MemoryStream()) { - using (BinaryWriter r = new BinaryWriter(ms)) + using (var r = new BinaryWriter(ms)) { // temp buffer byte[] buff; @@ -45,11 +40,13 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum ZXSTBLOCK block = new ZXSTBLOCK(); // header - ZXSTHEADER header = new ZXSTHEADER(); - header.dwMagic = MediaConverter.GetUInt32(Encoding.UTF8.GetBytes("ZXST"), 0); - header.chMajorVersion = 1; - header.chMinorVersion = 4; - header.chFlags = 0; + ZXSTHEADER header = new ZXSTHEADER + { + dwMagic = MediaConverter.GetUInt32(Encoding.UTF8.GetBytes("ZXST"), 0), + chMajorVersion = 1, + chMinorVersion = 4, + chFlags = 0 + }; switch (s._machine.Spectrum.MachineType) { case MachineType.ZXSpectrum16: header.chMachineId = (int)MachineIdentifier.ZXSTMID_16K; break; @@ -98,7 +95,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum buff = MediaConverter.SerializeRaw(eStruct); r.Write(buff); - // ZXSTJOYSTICK + // ZXSTJOYSTICK var fStruct = s.GetZXSTJOYSTICK(); block.dwId = MediaConverter.GetUInt32(Encoding.UTF8.GetBytes("JOY\0"), 0); block.dwSize = (uint)Marshal.SizeOf(fStruct); @@ -256,26 +253,28 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum private ZXSTZ80REGS GetZXSTZ80REGS() { - var s = new ZXSTZ80REGS(); - s.AF = (ushort)_machine.Spectrum.GetCpuFlagsAndRegisters()["AF"].Value; - s.BC = (ushort)_machine.Spectrum.GetCpuFlagsAndRegisters()["BC"].Value; - s.DE = (ushort)_machine.Spectrum.GetCpuFlagsAndRegisters()["DE"].Value; - s.HL = (ushort)_machine.Spectrum.GetCpuFlagsAndRegisters()["HL"].Value; - s.AF1 = (ushort)_machine.Spectrum.GetCpuFlagsAndRegisters()["Shadow AF"].Value; - s.BC1 = (ushort)_machine.Spectrum.GetCpuFlagsAndRegisters()["Shadow BC"].Value; - s.DE1 = (ushort)_machine.Spectrum.GetCpuFlagsAndRegisters()["Shadow DE"].Value; - s.HL1 = (ushort)_machine.Spectrum.GetCpuFlagsAndRegisters()["Shadow HL"].Value; - s.IX = (ushort)_machine.Spectrum.GetCpuFlagsAndRegisters()["IX"].Value; - s.IY = (ushort)_machine.Spectrum.GetCpuFlagsAndRegisters()["IY"].Value; - s.SP = (ushort)_machine.Spectrum.GetCpuFlagsAndRegisters()["SP"].Value; - s.PC = (ushort)_machine.Spectrum.GetCpuFlagsAndRegisters()["PC"].Value; - s.I = (byte)_machine.CPU.Regs[_machine.CPU.I]; - s.R = (byte)_machine.CPU.Regs[_machine.CPU.R]; - s.IFF1 = (byte)(_machine.CPU.IFF1 ? 1 : 0); - s.IFF2 = (byte)(_machine.CPU.IFF2 ? 1 : 0); - s.IM = (byte)_machine.CPU.InterruptMode; - s.dwCyclesStart = (uint)(_machine.CurrentFrameCycle + _machine.ULADevice.InterruptStartTime); - s.wMemPtr = (ushort)(_machine.CPU.Regs[_machine.CPU.Z] + (_machine.CPU.Regs[_machine.CPU.W] << 8)); + var s = new ZXSTZ80REGS + { + AF = (ushort) _machine.Spectrum.GetCpuFlagsAndRegisters()["AF"].Value, + BC = (ushort) _machine.Spectrum.GetCpuFlagsAndRegisters()["BC"].Value, + DE = (ushort) _machine.Spectrum.GetCpuFlagsAndRegisters()["DE"].Value, + HL = (ushort) _machine.Spectrum.GetCpuFlagsAndRegisters()["HL"].Value, + AF1 = (ushort) _machine.Spectrum.GetCpuFlagsAndRegisters()["Shadow AF"].Value, + BC1 = (ushort) _machine.Spectrum.GetCpuFlagsAndRegisters()["Shadow BC"].Value, + DE1 = (ushort) _machine.Spectrum.GetCpuFlagsAndRegisters()["Shadow DE"].Value, + HL1 = (ushort) _machine.Spectrum.GetCpuFlagsAndRegisters()["Shadow HL"].Value, + IX = (ushort) _machine.Spectrum.GetCpuFlagsAndRegisters()["IX"].Value, + IY = (ushort) _machine.Spectrum.GetCpuFlagsAndRegisters()["IY"].Value, + SP = (ushort) _machine.Spectrum.GetCpuFlagsAndRegisters()["SP"].Value, + PC = (ushort) _machine.Spectrum.GetCpuFlagsAndRegisters()["PC"].Value, + I = (byte) _machine.CPU.Regs[_machine.CPU.I], + R = (byte) _machine.CPU.Regs[_machine.CPU.R], + IFF1 = (byte) (_machine.CPU.IFF1 ? 1 : 0), + IFF2 = (byte) (_machine.CPU.IFF2 ? 1 : 0), + IM = (byte) _machine.CPU.InterruptMode, + dwCyclesStart = (uint) (_machine.CurrentFrameCycle + _machine.ULADevice.InterruptStartTime), + wMemPtr = (ushort) (_machine.CPU.Regs[_machine.CPU.Z] + (_machine.CPU.Regs[_machine.CPU.W] << 8)) + }; //s.chHoldIntReqCycles = ? if (_machine.CPU.EIPending > 0) diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Snapshot/SZX/SZX.Objects.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Snapshot/SZX/SZX.Objects.cs index 50699fa0bc..c9419a3de5 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Snapshot/SZX/SZX.Objects.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Snapshot/SZX/SZX.Objects.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; +using System.Runtime.InteropServices; namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/CSW/CswConverter.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/CSW/CswConverter.cs index 679370c5ca..479571ebc4 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/CSW/CswConverter.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/CSW/CswConverter.cs @@ -1,7 +1,6 @@ using BizHawk.Common.NumberExtensions; using System; using System.Collections.Generic; -using System.Linq; using System.Text; namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum @@ -16,13 +15,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum /// The type of serializer /// private MediaConverterType _formatType = MediaConverterType.CSW; - public override MediaConverterType FormatType - { - get - { - return _formatType; - } - } + public override MediaConverterType FormatType => _formatType; /// /// Position counter @@ -32,12 +25,12 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum /// /// Signs whether this class can be used to read the data format /// - public override bool IsReader { get { return true; } } + public override bool IsReader => true; /// /// Signs whether this class can be used to write the data format /// - public override bool IsWriter { get { return false; } } + public override bool IsWriter => false; #region Construction @@ -70,10 +63,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum // this is not a valid CSW format file return false; } - else - { - return true; - } + + return true; } /// diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/PZX/PzxConverter.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/PZX/PzxConverter.cs index 6201b52b83..7f1b1b29dc 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/PZX/PzxConverter.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/PZX/PzxConverter.cs @@ -1,7 +1,6 @@ using BizHawk.Common.NumberExtensions; using System; using System.Collections.Generic; -using System.Linq; using System.Text; namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum @@ -16,23 +15,17 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum /// The type of serializer /// private MediaConverterType _formatType = MediaConverterType.PZX; - public override MediaConverterType FormatType - { - get - { - return _formatType; - } - } + public override MediaConverterType FormatType => _formatType; /// /// Signs whether this class can be used to read the data format /// - public override bool IsReader { get { return true; } } + public override bool IsReader => true; /// /// Signs whether this class can be used to write the data format /// - public override bool IsWriter { get { return false; } } + public override bool IsWriter => false; /// /// Working list of generated tape data blocks @@ -80,10 +73,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum // this is not a valid PZX format file return false; } - else - { - return true; - } + + return true; } /// 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 1e01558da6..3016b7aba0 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TAP/TapConverter.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TAP/TapConverter.cs @@ -15,23 +15,17 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum /// The type of serializer /// private MediaConverterType _formatType = MediaConverterType.TAP; - public override MediaConverterType FormatType - { - get - { - return _formatType; - } - } + public override MediaConverterType FormatType => _formatType; /// /// Signs whether this class can be used to read the data format /// - public override bool IsReader { get { return true; } } + public override bool IsReader => true; /// /// Signs whether this class can be used to write the data format /// - public override bool IsWriter { get { return false; } } + public override bool IsWriter => false; #region Construction @@ -222,7 +216,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { // data block description = "Data Block " + (blockSize - 2) + "bytes"; - tdb.AddMetaData(BlockDescriptorTitle.Data_Bytes, (blockSize - 2).ToString() + " Bytes"); + tdb.AddMetaData(BlockDescriptorTitle.Data_Bytes, (blockSize - 2) + " Bytes"); } else { @@ -362,7 +356,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum // PAUS block if neccessary if (pauseInTStates > 0) { - tdbPause.AddMetaData(BlockDescriptorTitle.Block_ID, pauseInTStates.ToString() + " cycles"); + tdbPause.AddMetaData(BlockDescriptorTitle.Block_ID, pauseInTStates + " cycles"); int by1000 = pauseInTStates / 70000; int rem1000 = pauseInTStates % 70000; 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 af39dcb628..1cffcaaf4e 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TZX/TzxConverter.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TZX/TzxConverter.cs @@ -14,23 +14,17 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum /// The type of serializer /// private MediaConverterType _formatType = MediaConverterType.TZX; - public override MediaConverterType FormatType - { - get - { - return _formatType; - } - } + public override MediaConverterType FormatType => _formatType; /// /// Signs whether this class can be used to read the data format /// - public override bool IsReader { get { return true; } } + public override bool IsReader => true; /// /// Signs whether this class can be used to write the data format /// - public override bool IsWriter { get { return false; } } + public override bool IsWriter => false; /// /// Working list of generated tape data blocks @@ -125,7 +119,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum if (ident != "ZXTape!" || eotm != 0x1A) { // this is not a valid TZX format file - throw new Exception(this.GetType().ToString() + + throw new Exception(this.GetType() + "This is not a valid TZX format file"); } @@ -402,7 +396,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum int pulseLength = GetWordValue(data, _position); int pulseCount = GetWordValue(data, _position + 2); - t.AddMetaData(BlockDescriptorTitle.Pulse_Length, pulseLength.ToString() + " T-States"); + t.AddMetaData(BlockDescriptorTitle.Pulse_Length, pulseLength + " T-States"); t.AddMetaData(BlockDescriptorTitle.Pulse_Count, pulseCount.ToString()); // build period information @@ -423,20 +417,21 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum /* length: [00]*02+01 Offset Value Type Description 0x00 N BYTE Number of pulses - 0x01 - WORD[N] Pulses' lengths + 0x01 - WORD[N] Pulses' lengths This will produce N pulses, each having its own timing. Up to 255 pulses can be stored in this block; this is useful for non-standard sync tones used by some protection schemes. */ private void ProcessBlockID13(byte[] data) { - TapeDataBlock t = new TapeDataBlock(); - t.BlockID = 0x13; - t.BlockDescription = BlockType.Pulse_Sequence; - t.DataPeriods = new List(); + TapeDataBlock t = new TapeDataBlock + { + BlockID = 0x13, + BlockDescription = BlockType.Pulse_Sequence, + DataPeriods = new List(), + PauseInMS = 0 + }; - t.PauseInMS = 0; - - // get pulse count + // get pulse count int pulseCount = data[_position]; t.AddMetaData(BlockDescriptorTitle.Pulse_Count, pulseCount.ToString()); _position++; @@ -446,7 +441,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { // get pulse length int pulseLength = GetWordValue(data, _position); - t.AddMetaData(BlockDescriptorTitle.Needs_Parsing, "Pulse " + p + " Length\t" + pulseLength.ToString() + " T-States"); + t.AddMetaData(BlockDescriptorTitle.Needs_Parsing, "Pulse " + p + " Length\t" + pulseLength + " T-States"); t.DataPeriods.Add(pulseLength); } @@ -1676,7 +1671,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { // data block description = "Data Block " + (blockSize - 2) + "bytes"; - block.AddMetaData(BlockDescriptorTitle.Data_Bytes, (blockSize - 2).ToString() + " Bytes"); + block.AddMetaData(BlockDescriptorTitle.Data_Bytes, (blockSize - 2) + " Bytes"); } else { @@ -1742,10 +1737,10 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum if (dataBlockType == DataBlockType.Turbo) block.BlockDescription = BlockType.Turbo_Speed_Data_Block; - block.AddMetaData(BlockDescriptorTitle.Pilot_Pulse_Length, pilotToneLength.ToString() + " T-States"); - block.AddMetaData(BlockDescriptorTitle.Pilot_Pulse_Count, pilotCount.ToString() + " Pulses"); - block.AddMetaData(BlockDescriptorTitle.First_Sync_Length, sync1PulseLength.ToString() + " T-States"); - block.AddMetaData(BlockDescriptorTitle.Second_Sync_Length, sync2PulseLength.ToString() + " T-States"); + block.AddMetaData(BlockDescriptorTitle.Pilot_Pulse_Length, pilotToneLength + " T-States"); + block.AddMetaData(BlockDescriptorTitle.Pilot_Pulse_Count, pilotCount + " Pulses"); + block.AddMetaData(BlockDescriptorTitle.First_Sync_Length, sync1PulseLength + " T-States"); + block.AddMetaData(BlockDescriptorTitle.Second_Sync_Length, sync2PulseLength + " T-States"); break; case DataBlockType.Pure: @@ -1753,11 +1748,11 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum break; } - block.AddMetaData(BlockDescriptorTitle.Zero_Bit_Length, bit0PulseLength.ToString() + " T-States"); - block.AddMetaData(BlockDescriptorTitle.One_Bit_Length, bit1PulseLength.ToString() + " T-States"); - block.AddMetaData(BlockDescriptorTitle.Data_Length, blockSize.ToString() + " Bytes"); - block.AddMetaData(BlockDescriptorTitle.Bits_In_Last_Byte, bitsInLastByte.ToString() + " Bits"); - block.AddMetaData(BlockDescriptorTitle.Pause_After_Data, pauseAfterBlock.ToString() + " ms"); + block.AddMetaData(BlockDescriptorTitle.Zero_Bit_Length, bit0PulseLength + " T-States"); + block.AddMetaData(BlockDescriptorTitle.One_Bit_Length, bit1PulseLength + " T-States"); + block.AddMetaData(BlockDescriptorTitle.Data_Length, blockSize + " Bytes"); + block.AddMetaData(BlockDescriptorTitle.Bits_In_Last_Byte, bitsInLastByte + " Bits"); + block.AddMetaData(BlockDescriptorTitle.Pause_After_Data, pauseAfterBlock + " ms"); // calculate period information List dataPeriods = new List(); @@ -1886,7 +1881,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum pBlock.PauseInMS = 0; var pauseInTStates = TranslatePause(original.PauseInMS); - pBlock.AddMetaData(BlockDescriptorTitle.Block_ID, pauseInTStates.ToString() + " cycles"); + pBlock.AddMetaData(BlockDescriptorTitle.Block_ID, pauseInTStates + " cycles"); int by1000 = pauseInTStates / 70000; int rem1000 = pauseInTStates % 70000; diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TapeDataBlock.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TapeDataBlock.cs index b59ae01ab2..b05036d7ef 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TapeDataBlock.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/TapeDataBlock.cs @@ -1,7 +1,6 @@ using BizHawk.Common; using System.Collections.Generic; using System.Linq; -using System.Text; namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/WAV/WavConverter.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/WAV/WavConverter.cs index c783ce59c5..8d1780c193 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/WAV/WavConverter.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/WAV/WavConverter.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Text; namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum @@ -16,23 +15,17 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum /// The type of serializer /// private MediaConverterType _formatType = MediaConverterType.WAV; - public override MediaConverterType FormatType - { - get - { - return _formatType; - } - } + public override MediaConverterType FormatType => _formatType; /// /// Signs whether this class can be used to read the data format /// - public override bool IsReader { get { return true; } } + public override bool IsReader => true; /// /// Signs whether this class can be used to write the data format /// - public override bool IsWriter { get { return false; } } + public override bool IsWriter => false; /// /// Position counter 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 336d2ac64a..abd3230469 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/WAV/WavHeader.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/WAV/WavHeader.cs @@ -1,9 +1,6 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; using System.Text; -using System.Threading.Tasks; namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { 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 9be471d3de..eafda0af6b 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/WAV/WavStreamReader.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Tape/WAV/WavStreamReader.cs @@ -17,9 +17,9 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum m_header.Deserialize(stream); } - public WavHeader Header { get { return m_header; } } + public WavHeader Header => m_header; - public int Count { get { return m_header.dataSize / m_header.fmtBlockAlign; } } + public int Count => m_header.dataSize / m_header.fmtBlockAlign; public Int32 ReadNext() { diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.Controllers.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.Controllers.cs index 20aded49cb..e4f06906b1 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.Controllers.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.Controllers.cs @@ -16,63 +16,65 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum { get { - ControllerDefinition definition = new ControllerDefinition(); - definition.Name = "ZXSpectrum Controller"; + var definition = new ControllerDefinition + { + Name = "ZXSpectrum Controller" + }; // joysticks - List joys1 = new List + var joys1 = new List { - // P1 Joystick - "P1 Up", "P1 Down", "P1 Left", "P1 Right", "P1 Button", + // P1 Joystick + "P1 Up", "P1 Down", "P1 Left", "P1 Right", "P1 Button", }; foreach (var s in joys1) { definition.BoolButtons.Add(s); - definition.CategoryLabels[s] = "J1 (" + ((ZXSpectrumSyncSettings)SyncSettings as ZXSpectrumSyncSettings).JoystickType1.ToString() + ")"; + definition.CategoryLabels[s] = "J1 (" + SyncSettings.JoystickType1 + ")"; } - List joys2 = new List + var joys2 = new List { - // P2 Joystick - "P2 Up", "P2 Down", "P2 Left", "P2 Right", "P2 Button", + // P2 Joystick + "P2 Up", "P2 Down", "P2 Left", "P2 Right", "P2 Button", }; foreach (var s in joys2) { definition.BoolButtons.Add(s); - definition.CategoryLabels[s] = "J2 (" + ((ZXSpectrumSyncSettings)SyncSettings as ZXSpectrumSyncSettings).JoystickType2.ToString() + ")"; + definition.CategoryLabels[s] = "J2 (" + SyncSettings.JoystickType2 + ")"; } - List joys3 = new List + var joys3 = new List { - // P3 Joystick - "P3 Up", "P3 Down", "P3 Left", "P3 Right", "P3 Button", + // P3 Joystick + "P3 Up", "P3 Down", "P3 Left", "P3 Right", "P3 Button", }; foreach (var s in joys3) { definition.BoolButtons.Add(s); - definition.CategoryLabels[s] = "J3 (" + ((ZXSpectrumSyncSettings)SyncSettings as ZXSpectrumSyncSettings).JoystickType3.ToString() + ")"; + definition.CategoryLabels[s] = "J3 (" + SyncSettings.JoystickType3 + ")"; } // keyboard - List keys = new List + var keys = new List { - // Controller mapping includes all keyboard keys from the following models: - // https://upload.wikimedia.org/wikipedia/commons/thumb/3/33/ZXSpectrum48k.jpg/1200px-ZXSpectrum48k.jpg - // https://upload.wikimedia.org/wikipedia/commons/c/ca/ZX_Spectrum%2B.jpg - - // Keyboard - row 1 - "Key True Video", "Key Inv Video", "Key 1", "Key 2", "Key 3", "Key 4", "Key 5", "Key 6", "Key 7", "Key 8", "Key 9", "Key 0", "Key Break", - // Keyboard - row 2 - "Key Delete", "Key Graph", "Key Q", "Key W", "Key E", "Key R", "Key T", "Key Y", "Key U", "Key I", "Key O", "Key P", - // Keyboard - row 3 - "Key Extend Mode", "Key Edit", "Key A", "Key S", "Key D", "Key F", "Key G", "Key H", "Key J", "Key K", "Key L", "Key Return", - // Keyboard - row 4 - "Key Caps Shift", "Key Caps Lock", "Key Z", "Key X", "Key C", "Key V", "Key B", "Key N", "Key M", "Key Period", - // Keyboard - row 5 - "Key Symbol Shift", "Key Semi-Colon", "Key Quote", "Key Left Cursor", "Key Right Cursor", "Key Space", "Key Up Cursor", "Key Down Cursor", "Key Comma", + // Controller mapping includes all keyboard keys from the following models: + // https://upload.wikimedia.org/wikipedia/commons/thumb/3/33/ZXSpectrum48k.jpg/1200px-ZXSpectrum48k.jpg + // https://upload.wikimedia.org/wikipedia/commons/c/ca/ZX_Spectrum%2B.jpg + + // Keyboard - row 1 + "Key True Video", "Key Inv Video", "Key 1", "Key 2", "Key 3", "Key 4", "Key 5", "Key 6", "Key 7", "Key 8", "Key 9", "Key 0", "Key Break", + // Keyboard - row 2 + "Key Delete", "Key Graph", "Key Q", "Key W", "Key E", "Key R", "Key T", "Key Y", "Key U", "Key I", "Key O", "Key P", + // Keyboard - row 3 + "Key Extend Mode", "Key Edit", "Key A", "Key S", "Key D", "Key F", "Key G", "Key H", "Key J", "Key K", "Key L", "Key Return", + // Keyboard - row 4 + "Key Caps Shift", "Key Caps Lock", "Key Z", "Key X", "Key C", "Key V", "Key B", "Key N", "Key M", "Key Period", + // Keyboard - row 5 + "Key Symbol Shift", "Key Semi-Colon", "Key Quote", "Key Left Cursor", "Key Right Cursor", "Key Space", "Key Up Cursor", "Key Down Cursor", "Key Comma", }; foreach (var s in keys) @@ -82,10 +84,10 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum } // Power functions - List power = new List + var power = new List { - // Power functions - "Reset", "Power" + // Power functions + "Reset", "Power" }; foreach (var s in power) @@ -95,10 +97,10 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum } // Datacorder (tape device) - List tape = new List + var tape = new List { - // Tape functions - "Play Tape", "Stop Tape", "RTZ Tape", "Record Tape", "Insert Next Tape", + // Tape functions + "Play Tape", "Stop Tape", "RTZ Tape", "Record Tape", "Insert Next Tape", "Insert Previous Tape", "Next Tape Block", "Prev Tape Block", "Get Tape Status" }; @@ -109,10 +111,10 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum } // Datacorder (tape device) - List disk = new List + var disk = new List { - // Tape functions - "Insert Next Disk", "Insert Previous Disk", /*"Eject Current Disk",*/ "Get Disk Status" + // Tape functions + "Insert Next Disk", "Insert Previous Disk", /*"Eject Current Disk",*/ "Get Disk Status" }; foreach (var s in disk) diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.ICodeDataLog.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.ICodeDataLog.cs index 3fb7b45b5d..e2246a0ecc 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.ICodeDataLog.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.ICodeDataLog.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using BizHawk.Emulation.Common; +using BizHawk.Emulation.Common; using System.IO; namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IStatable.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IStatable.cs index 53dd15ecf6..65bf11630c 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IStatable.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.IStatable.cs @@ -39,9 +39,9 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum if (tmpM != _machineType && _machineType.ToString() != "72") { string msg = "SAVESTATE FAILED TO LOAD!!\n\n"; - msg += "Current Configuration: " + tmpM.ToString(); + msg += "Current Configuration: " + tmpM; msg += "\n"; - msg += "Saved Configuration: " + _machineType.ToString(); + msg += "Saved Configuration: " + _machineType; msg += "\n\n"; msg += "If you wish to load this SaveState ensure that you have the correct machine configuration selected, reboot the core, then try again."; CoreComm.ShowMessage(msg); diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs index 7eb069c2ec..15a7941276 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs @@ -107,23 +107,21 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 // here we advance past start up irregularities to see how long a frame is based on calls to Vsync // we run 72 frames, then run 270 scanlines worth of cycles. // if we don't hit a new frame, we can be pretty confident we are in PAL - using (Atari2600 emu = new Atari2600(new CoreComm(null, null), newgame, rom, null, null)) + using var emu = new Atari2600(new CoreComm(null, null), newgame, rom, null, null); + for (int i = 0; i < 72; i++) { - for (int i = 0; i < 72; i++) - { - emu.FrameAdvance(NullController.Instance, false, false); - } - - for (int i = 0; i < 61560; i++) - { - emu.Cycle(); - } - - bool pal = !emu._tia.New_Frame; - - Console.WriteLine("PAL Detection: {0}", pal); - return pal; + emu.FrameAdvance(NullController.Instance, false, false); } + + for (int i = 0; i < 61560; i++) + { + emu.Cycle(); + } + + bool pal = !emu._tia.New_Frame; + + Console.WriteLine("PAL Detection: {0}", pal); + return pal; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/M6532.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/M6532.cs index e13945a1b2..19204e8fcf 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/M6532.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/M6532.cs @@ -1,5 +1,4 @@ using BizHawk.Common; -using System; namespace BizHawk.Emulation.Cores.Atari.Atari2600 { diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.Audio.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.Audio.cs index 26a5582806..73fdae12c3 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.Audio.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.Audio.cs @@ -1,5 +1,4 @@ -using System; -using BizHawk.Common; +using BizHawk.Common; namespace BizHawk.Emulation.Cores.Atari.Atari2600 { diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800HawkControllers.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800HawkControllers.cs index 85f62dc6bc..813f492afe 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800HawkControllers.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/A7800HawkControllers.cs @@ -1,5 +1,4 @@ -using System; -using System.ComponentModel; +using System.ComponentModel; using System.Linq; using BizHawk.Common; diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/M6532.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/M6532.cs index 43b773dfe7..cd9e3a54b5 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/M6532.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/M6532.cs @@ -1,5 +1,4 @@ using BizHawk.Common; -using System; namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperBase.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperBase.cs index 44d939b7a5..5254436347 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperBase.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperBase.cs @@ -1,5 +1,4 @@ using BizHawk.Common; -using System; namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperDefault.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperDefault.cs index 6b1b627a33..2be6034060 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperDefault.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperDefault.cs @@ -1,6 +1,4 @@ -using BizHawk.Common; -using BizHawk.Common.NumberExtensions; -using System; +using BizHawk.Common.NumberExtensions; namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperF18.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperF18.cs index fa00abe0a9..162598bbe6 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperF18.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperF18.cs @@ -1,6 +1,5 @@ using BizHawk.Common; using BizHawk.Common.NumberExtensions; -using System; namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperFractalus.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperFractalus.cs index 964b5539fc..82abeb94e1 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperFractalus.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperFractalus.cs @@ -1,6 +1,5 @@ using BizHawk.Common; using BizHawk.Common.NumberExtensions; -using System; namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperRampage.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperRampage.cs index bd9d342f33..2c742d422c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperRampage.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperRampage.cs @@ -1,6 +1,5 @@ using BizHawk.Common; using BizHawk.Common.NumberExtensions; -using System; namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperSG.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperSG.cs index b308a2e500..e07b369dff 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperSG.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperSG.cs @@ -1,6 +1,5 @@ using BizHawk.Common; using BizHawk.Common.NumberExtensions; -using System; namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperSGE.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperSGE.cs index 1c5c78d968..7305e6541b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperSGE.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Mappers/MapperSGE.cs @@ -1,6 +1,5 @@ using BizHawk.Common; using BizHawk.Common.NumberExtensions; -using System; namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Pokey.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Pokey.cs index 2b5d6ff334..164910b879 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Pokey.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/Pokey.cs @@ -1,5 +1,4 @@ -using System; -using BizHawk.Common.NumberExtensions; +using BizHawk.Common.NumberExtensions; using BizHawk.Common; namespace BizHawk.Emulation.Cores.Atari.A7800Hawk diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/TIA_Sound/TIA.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/TIA_Sound/TIA.cs index 15363fdaff..5c63494a5b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/TIA_Sound/TIA.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/TIA_Sound/TIA.cs @@ -1,6 +1,4 @@ -using System; - -namespace BizHawk.Emulation.Cores.Atari.A7800Hawk +namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { // Emulates the TIA public partial class TIA diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/TIA_Sound/Tia.Audio.cs b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/TIA_Sound/Tia.Audio.cs index 7f30740347..796235db25 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/TIA_Sound/Tia.Audio.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/A7800Hawk/TIA_Sound/Tia.Audio.cs @@ -1,5 +1,4 @@ -using System; -using BizHawk.Common; +using BizHawk.Common; namespace BizHawk.Emulation.Cores.Atari.A7800Hawk { diff --git a/BizHawk.Emulation.Cores/Consoles/Belogic/LibUzem.cs b/BizHawk.Emulation.Cores/Consoles/Belogic/LibUzem.cs index 661c116be0..413a6798b3 100644 --- a/BizHawk.Emulation.Cores/Consoles/Belogic/LibUzem.cs +++ b/BizHawk.Emulation.Cores/Consoles/Belogic/LibUzem.cs @@ -1,11 +1,6 @@ using BizHawk.BizInvoke; using BizHawk.Emulation.Cores.Waterbox; -using System; -using System.Collections.Generic; -using System.Linq; using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; namespace BizHawk.Emulation.Cores.Consoles.Belogic { diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/AY_3_8910_SGM.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/AY_3_8910_SGM.cs index cc21e6a0f7..92bafc6595 100644 --- a/BizHawk.Emulation.Cores/Consoles/Coleco/AY_3_8910_SGM.cs +++ b/BizHawk.Emulation.Cores/Consoles/Coleco/AY_3_8910_SGM.cs @@ -1,6 +1,4 @@ -using System; - -using BizHawk.Common; +using BizHawk.Common; using BizHawk.Common.NumberExtensions; namespace BizHawk.Emulation.Cores.ColecoVision diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IMemoryDomains.cs index 2dd95c12be..d781388cd9 100644 --- a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IMemoryDomains.cs @@ -17,7 +17,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision var domains = new List { new MemoryDomainDelegate("System Bus", 0x10000, MemoryDomain.Endian.Little, - (addr) => + addr => { if (addr < 0 || addr >= 65536) { diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/SN76489col.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/SN76489col.cs index 265bfce147..b558dab3ed 100644 --- a/BizHawk.Emulation.Cores/Consoles/Coleco/SN76489col.cs +++ b/BizHawk.Emulation.Cores/Consoles/Coleco/SN76489col.cs @@ -1,6 +1,4 @@ -using System; - -using BizHawk.Common; +using BizHawk.Common; using BizHawk.Common.NumberExtensions; namespace BizHawk.Emulation.Cores.ColecoVision @@ -190,7 +188,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision noise_clock = Chan_tone[2] + 1; } - noise_clock *= 2; + noise_clock *= 2; } if (clock_A == 0) diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/TMS9918A.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/TMS9918A.cs index 5846aecaca..b58a04aaa0 100644 --- a/BizHawk.Emulation.Cores/Consoles/Coleco/TMS9918A.cs +++ b/BizHawk.Emulation.Cores/Consoles/Coleco/TMS9918A.cs @@ -462,7 +462,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision } public readonly int[] FrameBuffer = new int[256 * 192]; - public int[] GetVideoBuffer() { return FrameBuffer; } + public int[] GetVideoBuffer() => FrameBuffer; public int VirtualWidth => 293; public int VirtualHeight => 192; @@ -473,19 +473,13 @@ namespace BizHawk.Emulation.Cores.ColecoVision public int VsyncNumerator { [FeatureNotImplemented] - get - { - return NullVideo.DefaultVsyncNum; - } + get => NullVideo.DefaultVsyncNum; } public int VsyncDenominator { [FeatureNotImplemented] - get - { - return NullVideo.DefaultVsyncDen; - } + get => NullVideo.DefaultVsyncDen; } private readonly int[] PaletteTMS9918 = diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Audio.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Audio.cs index 11f155e181..bcae065dae 100644 --- a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Audio.cs +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Audio.cs @@ -1,9 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using BizHawk.Common; using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Consoles.ChannelF @@ -21,7 +16,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF private int tone = 0; - private double[] tone_freqs = new double[] { 0, 1000, 500, 120 }; + private double[] tone_freqs = { 0, 1000, 500, 120 }; private double amplitude = 0; private double decay = 0.998; private double time = 0; diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Cart.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Cart.cs index d2d52dda5b..2fbaf8aeab 100644 --- a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Cart.cs +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Cart.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BizHawk.Emulation.Cores.Consoles.ChannelF +namespace BizHawk.Emulation.Cores.Consoles.ChannelF { /// /// Cartridge and related functions diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.Controllers.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.Controllers.cs index 80a2ae7931..4f5d80a361 100644 --- a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.Controllers.cs +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.Controllers.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Windows.Forms; -using BizHawk.Common.BufferExtensions; -using BizHawk.Common.NumberExtensions; +using System.Collections.Generic; using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Consoles.ChannelF @@ -10,10 +6,11 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF public partial class ChannelF { public bool[] StateConsole = new bool[4]; - public string[] ButtonsConsole = new string[] + public string[] ButtonsConsole = { "TIME", "MODE", "HOLD", "START" }; + public byte DataConsole { get @@ -30,7 +27,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF } public bool[] StateRight = new bool[8]; - public string[] ButtonsRight = new string[] + public string[] ButtonsRight = { "Right", "Left", "Back", "Forward", "CCW", "CW", "Pull", "Push" }; @@ -50,7 +47,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF } public bool[] StateLeft = new bool[8]; - public string[] ButtonsLeft = new string[] + public string[] ButtonsLeft = { "Right", "Left", "Back", "Forward", "CCW", "CW", "Pull", "Push" }; @@ -126,13 +123,15 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF { get { - ControllerDefinition definition = new ControllerDefinition(); - definition.Name = "ChannelF Controller"; + ControllerDefinition definition = new ControllerDefinition + { + Name = "ChannelF Controller" + }; string pre = "P1 "; // sticks - List stickR = new List + var stickR = new List { // P1 (right) stick pre + "Forward", pre + "Back", pre + "Left", pre + "Right", pre + "CCW", pre + "CW", pre + "Pull", pre + "Push" @@ -146,7 +145,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF pre = "P2 "; - List stickL = new List + var stickL = new List { // P2 (left) stick pre + "Forward", pre + "Back", pre + "Left", pre + "Right", pre + "CCW", pre + "CW", pre + "Pull", pre + "Push" @@ -159,7 +158,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF } // console - List consoleButtons = new List + var consoleButtons = new List { "RESET", "START", "HOLD", "MODE", "TIME" }; diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IDebuggable.cs index ee961bcf67..bdeab52390 100644 --- a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IDebuggable.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using BizHawk.Common.BufferExtensions; using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Consoles.ChannelF diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IEmulator.cs index fa44fd2e45..be9914449e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IEmulator.cs @@ -1,6 +1,4 @@ -using System; -using BizHawk.Common.BufferExtensions; -using BizHawk.Emulation.Common; +using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Consoles.ChannelF { @@ -71,7 +69,6 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF public void Dispose() { - } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.ISettable.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.ISettable.cs index d23b8b87b1..fe454f84b9 100644 --- a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.ISettable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.ISettable.cs @@ -1,9 +1,6 @@ -using System; -using System.ComponentModel; +using System.ComponentModel; using BizHawk.Common; -using BizHawk.Common.BufferExtensions; using BizHawk.Emulation.Common; -using BizHawk.Emulation.Cores.Nintendo.NES; namespace BizHawk.Emulation.Cores.Consoles.ChannelF { diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IVideoProvider.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IVideoProvider.cs index 5393e91dcf..69926573e1 100644 --- a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IVideoProvider.cs +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.IVideoProvider.cs @@ -1,6 +1,4 @@ -using System; -using BizHawk.Common; -using BizHawk.Common.BufferExtensions; +using BizHawk.Common; using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Consoles.ChannelF diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.InputPollable.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.InputPollable.cs index 27c4b8f796..ed8c28be36 100644 --- a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.InputPollable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.InputPollable.cs @@ -16,7 +16,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF set => _isLag = value; } - public IInputCallbackSystem InputCallbacks { get; } + public IInputCallbackSystem InputCallbacks { get; } = new InputCallbackSystem(); private int _lagCount = 0; private bool _isLag = false; diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.MemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.MemoryDomains.cs index 0f62cab512..d7f865e2ec 100644 --- a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.MemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.MemoryDomains.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using BizHawk.Common.BufferExtensions; using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Consoles.ChannelF diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.cs index e9ef7fdae5..640841c5b2 100644 --- a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.cs +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/ChannelF.cs @@ -16,7 +16,6 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF var ser = new BasicServiceProvider(this); ServiceProvider = ser; CoreComm = comm; - InputCallbacks = new InputCallbackSystem(); MemoryCallbacks = new MemoryCallbackSystem(new[] { "System Bus" }); ControllerDefinition = ChannelFControllerDefinition; diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.Disassembler.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.Disassembler.cs index 86a4722a55..49fcf6aa85 100644 --- a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.Disassembler.cs +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.Disassembler.cs @@ -1,9 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using BizHawk.Common; using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Consoles.ChannelF @@ -328,10 +324,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF set { } } - public string PCRegisterName - { - get { return "PC"; } - } + public string PCRegisterName => "PC"; public IEnumerable AvailableCpus { diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.Execute.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.Execute.cs index 7c5ae0e707..cc3d15a8a6 100644 --- a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.Execute.cs +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.Execute.cs @@ -1,12 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using BizHawk.Common; -using BizHawk.Emulation.Common; - -namespace BizHawk.Emulation.Cores.Consoles.ChannelF +namespace BizHawk.Emulation.Cores.Consoles.ChannelF { public sealed partial class F3850 { diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.Operations.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.Operations.cs index 648f3120d3..cb90354087 100644 --- a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.Operations.cs +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.Operations.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using BizHawk.Common.NumberExtensions; +using BizHawk.Common.NumberExtensions; namespace BizHawk.Emulation.Cores.Consoles.ChannelF { diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.Registers.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.Registers.cs index b065569b88..261b2a748b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.Registers.cs +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.Registers.cs @@ -1,13 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms.VisualStyles; -using BizHawk.Common; -using BizHawk.Emulation.Common; - -namespace BizHawk.Emulation.Cores.Consoles.ChannelF +namespace BizHawk.Emulation.Cores.Consoles.ChannelF { /// /// Internal Registers diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.Tables.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.Tables.cs index 8273969482..e5a2ee023d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.Tables.cs +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.Tables.cs @@ -1,13 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using BizHawk.Common; -using BizHawk.Emulation.Common; -using BizHawk.Emulation.Cores.Components; - -namespace BizHawk.Emulation.Cores.Consoles.ChannelF +namespace BizHawk.Emulation.Cores.Consoles.ChannelF { /// /// Vectors of Instruction Operations diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.cs index fe3d423af3..e778b1cc20 100644 --- a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.cs +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/F8/F3850.cs @@ -1,10 +1,4 @@ using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; using BizHawk.Common; using BizHawk.Common.NumberExtensions; using BizHawk.Emulation.Common; diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Memory.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Memory.cs index 41fbd55593..ed847802b2 100644 --- a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Memory.cs +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Memory.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BizHawk.Emulation.Cores.Consoles.ChannelF +namespace BizHawk.Emulation.Cores.Consoles.ChannelF { /// /// Memory and related functions diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Ports.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Ports.cs index acf9373e9e..a3472a4566 100644 --- a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Ports.cs +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Ports.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.Remoting.Messaging; -using System.Text; -using System.Threading.Tasks; -using BizHawk.Common.NumberExtensions; +using BizHawk.Common.NumberExtensions; namespace BizHawk.Emulation.Cores.Consoles.ChannelF { diff --git a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Video.cs b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Video.cs index 9c26fec92f..8a54cd7603 100644 --- a/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Video.cs +++ b/BizHawk.Emulation.Cores/Consoles/Fairchild/ChannelF/Video.cs @@ -1,10 +1,4 @@ -using System; -using System.CodeDom; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using BizHawk.Common; +using BizHawk.Common; namespace BizHawk.Emulation.Cores.Consoles.ChannelF { diff --git a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/Mappers/MapperBase.cs b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/Mappers/MapperBase.cs index eac99fa142..acf5d26a51 100644 --- a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/Mappers/MapperBase.cs +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/Mappers/MapperBase.cs @@ -1,6 +1,4 @@ using BizHawk.Common; -using System; - using BizHawk.Emulation.Cores.Components.MC6809; namespace BizHawk.Emulation.Cores.Consoles.Vectrex diff --git a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/Mappers/Mapper_Default.cs b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/Mappers/Mapper_Default.cs index 2168f41fd9..9203ad35af 100644 --- a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/Mappers/Mapper_Default.cs +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/Mappers/Mapper_Default.cs @@ -1,8 +1,4 @@ -using BizHawk.Common; -using BizHawk.Common.NumberExtensions; -using System; - -namespace BizHawk.Emulation.Cores.Consoles.Vectrex +namespace BizHawk.Emulation.Cores.Consoles.Vectrex { // Default mapper with no bank switching // make sure peekmemory and poke memory don't effect the rest of the system! diff --git a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/MemoryMap.cs b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/MemoryMap.cs index a15500d6ad..371fb53971 100644 --- a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/MemoryMap.cs +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/MemoryMap.cs @@ -1,6 +1,4 @@ -using System; - -using BizHawk.Emulation.Common; +using BizHawk.Emulation.Common; /* 0x0000 - 0x7FFF ROM diff --git a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/SerialPort.cs b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/SerialPort.cs index cb10b8e578..45169eb289 100644 --- a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/SerialPort.cs +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/SerialPort.cs @@ -1,6 +1,4 @@ -using System; - -using BizHawk.Common; +using BizHawk.Common; namespace BizHawk.Emulation.Cores.Consoles.Vectrex { diff --git a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.IDebuggable.cs index 1aaea63599..3ee34607e8 100644 --- a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.IDebuggable.cs @@ -87,20 +87,11 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex public IMemoryCallbackSystem MemoryCallbacks { get; } = new MemoryCallbackSystem(new[] { "System Bus" }); - public bool CanStep(StepType type) - { - return false; - } + public bool CanStep(StepType type) => false; [FeatureNotImplemented] - public void Step(StepType type) - { - throw new NotImplementedException(); - } + public void Step(StepType type) => throw new NotImplementedException(); - public long TotalExecutedCycles - { - get { return (long)cpu.TotalExecutedCycles; } - } + public long TotalExecutedCycles => (long)cpu.TotalExecutedCycles; } } diff --git a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.IMemoryDomains.cs index 0a0e505aa6..3606d69e0a 100644 --- a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.IMemoryDomains.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using BizHawk.Emulation.Common; diff --git a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.ISaveRam.cs b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.ISaveRam.cs index 6db3ef9021..aec0223973 100644 --- a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.ISaveRam.cs +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.ISaveRam.cs @@ -1,5 +1,4 @@ -using System; -using BizHawk.Emulation.Common; +using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Consoles.Vectrex { @@ -15,12 +14,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex } - public bool SaveRamModified - { - get - { - return false; - } - } + public bool SaveRamModified => false; } } diff --git a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.ISettable.cs b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.ISettable.cs index 7e3595662c..0c9765633d 100644 --- a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.ISettable.cs +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawk.ISettable.cs @@ -1,5 +1,4 @@ -using System; -using System.ComponentModel; +using System.ComponentModel; using Newtonsoft.Json; diff --git a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawkControllers.cs b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawkControllers.cs index 898a9ebfaf..872442ed4b 100644 --- a/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawkControllers.cs +++ b/BizHawk.Emulation.Cores/Consoles/GCE/Vectrex/VectrexHawkControllers.cs @@ -1,6 +1,4 @@ -using System; - -using System.ComponentModel; +using System.ComponentModel; using System.Linq; using BizHawk.Common; diff --git a/BizHawk.Emulation.Cores/Consoles/Intellivision/STIC.cs b/BizHawk.Emulation.Cores/Consoles/Intellivision/STIC.cs index dbb20b910c..4b292e3856 100644 --- a/BizHawk.Emulation.Cores/Consoles/Intellivision/STIC.cs +++ b/BizHawk.Emulation.Cores/Consoles/Intellivision/STIC.cs @@ -85,19 +85,13 @@ namespace BizHawk.Emulation.Cores.Intellivision public int VsyncNumerator { [FeatureNotImplemented] - get - { - return NullVideo.DefaultVsyncNum; - } + get => NullVideo.DefaultVsyncNum; } public int VsyncDenominator { [FeatureNotImplemented] - get - { - return NullVideo.DefaultVsyncDen; - } + get => NullVideo.DefaultVsyncDen; } public void Reset() @@ -114,15 +108,8 @@ namespace BizHawk.Emulation.Cores.Intellivision ColorSP = 0x0028; } - public bool GetSr1() - { - return Sr1; - } - - public bool GetSr2() - { - return Sr2; - } + public bool GetSr1() => Sr1; + public bool GetSr2() => Sr2; public void ToggleSr2() { diff --git a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/Mappers/MapperBase.cs b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/Mappers/MapperBase.cs index b4033f33b9..68d5c00431 100644 --- a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/Mappers/MapperBase.cs +++ b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/Mappers/MapperBase.cs @@ -1,6 +1,4 @@ using BizHawk.Common; -using System; - using BizHawk.Emulation.Cores.Components.I8048; namespace BizHawk.Emulation.Cores.Consoles.O2Hawk diff --git a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/Mappers/Mapper_Default.cs b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/Mappers/Mapper_Default.cs index e0d240c910..845dbb7895 100644 --- a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/Mappers/Mapper_Default.cs +++ b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/Mappers/Mapper_Default.cs @@ -1,8 +1,4 @@ -using BizHawk.Common; -using BizHawk.Common.NumberExtensions; -using System; - -using BizHawk.Emulation.Cores.Components.I8048; +using BizHawk.Emulation.Cores.Components.I8048; namespace BizHawk.Emulation.Cores.Consoles.O2Hawk { diff --git a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/MemoryMap.cs b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/MemoryMap.cs index 1db2e713f0..27490eacd4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/MemoryMap.cs +++ b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/MemoryMap.cs @@ -1,6 +1,4 @@ using System; - -using BizHawk.Common.BufferExtensions; using BizHawk.Common.NumberExtensions; using BizHawk.Emulation.Common; diff --git a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.ICodeDataLog.cs b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.ICodeDataLog.cs index a840dd4671..deb475a98e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.ICodeDataLog.cs +++ b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.ICodeDataLog.cs @@ -1,7 +1,4 @@ -using System; using System.IO; -using System.Collections.Generic; - using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Components.I8048; diff --git a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IDebuggable.cs index c3767aa2b1..9134a8a9bb 100644 --- a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IDebuggable.cs @@ -90,10 +90,7 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk public IMemoryCallbackSystem MemoryCallbacks { get; } = new MemoryCallbackSystem(new[] { "System Bus" }); - public bool CanStep(StepType type) - { - return false; - } + public bool CanStep(StepType type) => false; [FeatureNotImplemented] public void Step(StepType type) @@ -101,9 +98,6 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk throw new NotImplementedException(); } - public long TotalExecutedCycles - { - get { return (long)cpu.TotalExecutedCycles; } - } + public long TotalExecutedCycles => (long)cpu.TotalExecutedCycles; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IEmulator.cs index d7ce0d5573..06501baae3 100644 --- a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IEmulator.cs @@ -1,7 +1,4 @@ -using System; - -using BizHawk.Common.NumberExtensions; -using BizHawk.Emulation.Common; +using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Consoles.O2Hawk { diff --git a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IMemoryDomains.cs index 360704d211..69d4c4cc62 100644 --- a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IMemoryDomains.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; - +using System.Collections.Generic; using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Consoles.O2Hawk diff --git a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.ISaveRam.cs b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.ISaveRam.cs index 0544f61835..efa4a2cd83 100644 --- a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.ISaveRam.cs +++ b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.ISaveRam.cs @@ -7,14 +7,7 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk { public byte[] CloneSaveRam() { - if (cart_RAM != null) - { - return (byte[])cart_RAM.Clone(); - } - else - { - return null; - } + return (byte[])cart_RAM?.Clone(); } public void StoreSaveRam(byte[] data) @@ -26,12 +19,6 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk } } - public bool SaveRamModified - { - get - { - return has_bat & _syncSettings.Use_SRAM; - } - } + public bool SaveRamModified => has_bat & _syncSettings.Use_SRAM; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2HawkControllers.cs b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2HawkControllers.cs index 0535df5038..ff9c879e90 100644 --- a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2HawkControllers.cs +++ b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2HawkControllers.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; +using System.ComponentModel; using System.Linq; using BizHawk.Common; diff --git a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/SerialPort.cs b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/SerialPort.cs index f52eeb4433..a3e4cf3bc4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/SerialPort.cs +++ b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/SerialPort.cs @@ -1,7 +1,4 @@ -using System; -using BizHawk.Emulation.Common; -using BizHawk.Common.NumberExtensions; -using BizHawk.Common; +using BizHawk.Common; namespace BizHawk.Emulation.Cores.Consoles.O2Hawk { diff --git a/BizHawk.Emulation.Cores/Consoles/NEC/PCFX/LibTst.cs b/BizHawk.Emulation.Cores/Consoles/NEC/PCFX/LibTst.cs index 829980880f..007c42b427 100644 --- a/BizHawk.Emulation.Cores/Consoles/NEC/PCFX/LibTst.cs +++ b/BizHawk.Emulation.Cores/Consoles/NEC/PCFX/LibTst.cs @@ -2,11 +2,7 @@ using BizHawk.Emulation.Cores.Consoles.Sega.Saturn; using BizHawk.Emulation.Cores.Waterbox; using System; -using System.Collections.Generic; -using System.Linq; using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; namespace BizHawk.Emulation.Cores.Consoles.NEC.PCFX { diff --git a/BizHawk.Emulation.Cores/Consoles/NEC/PCFX/Tst.cs b/BizHawk.Emulation.Cores/Consoles/NEC/PCFX/Tst.cs index 239a41bfc8..82deaf9a92 100644 --- a/BizHawk.Emulation.Cores/Consoles/NEC/PCFX/Tst.cs +++ b/BizHawk.Emulation.Cores/Consoles/NEC/PCFX/Tst.cs @@ -6,8 +6,6 @@ using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; using System.IO; using System.ComponentModel; using System.ComponentModel.DataAnnotations; diff --git a/BizHawk.Emulation.Cores/Consoles/NEC/PCFX/TstControllerDeck.cs b/BizHawk.Emulation.Cores/Consoles/NEC/PCFX/TstControllerDeck.cs index e1fe608f5c..790d01ffeb 100644 --- a/BizHawk.Emulation.Cores/Consoles/NEC/PCFX/TstControllerDeck.cs +++ b/BizHawk.Emulation.Cores/Consoles/NEC/PCFX/TstControllerDeck.cs @@ -1,9 +1,6 @@ using BizHawk.Emulation.Common; -using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace BizHawk.Emulation.Cores.Consoles.NEC.PCFX { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/LibVBANext.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/LibVBANext.cs index ca1e532cad..7c955cc8b3 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/LibVBANext.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/LibVBANext.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Runtime.InteropServices; using BizHawk.Emulation.Common; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/LibmGBA.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/LibmGBA.cs index dcf2a5ab56..6f9f3084c5 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/LibmGBA.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/LibmGBA.cs @@ -1,9 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Runtime.InteropServices; -using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Nintendo.GBA { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.IDebuggable.cs index eb97242ded..1fd8c676d9 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.IDebuggable.cs @@ -27,27 +27,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA } [FeatureNotImplemented] - public IMemoryCallbackSystem MemoryCallbacks - { - get { throw new NotImplementedException(); } - } + public IMemoryCallbackSystem MemoryCallbacks => throw new NotImplementedException(); - public bool CanStep(StepType type) - { - return false; - } + public bool CanStep(StepType type) => false; [FeatureNotImplemented] - public void Step(StepType type) - { - throw new NotImplementedException(); - } + public void Step(StepType type) => throw new NotImplementedException(); [FeatureNotImplemented] - public long TotalExecutedCycles - { - get { throw new NotImplementedException(); } - } + public long TotalExecutedCycles => throw new NotImplementedException(); private static readonly string[] RegisterNames = { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.IInputPollable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.IInputPollable.cs index ee6b0d9fb4..bce8513a90 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.IInputPollable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.IInputPollable.cs @@ -9,9 +9,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA public bool IsLagFrame { get; set; } [FeatureNotImplemented] - public IInputCallbackSystem InputCallbacks - { - get { throw new NotImplementedException(); } - } + public IInputCallbackSystem InputCallbacks => throw new NotImplementedException(); } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.IDebuggable.cs index 71592fbc3d..68c4559bd9 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.IDebuggable.cs @@ -7,35 +7,19 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA { public partial class VBANext : IDebuggable { - public IDictionary GetCpuFlagsAndRegisters() - { - return regs.GetAllRegisters(); - } + public IDictionary GetCpuFlagsAndRegisters() => regs.GetAllRegisters(); - public void SetCpuRegister(string register, int value) - { - regs.SetRegister(register, value); - } + public void SetCpuRegister(string register, int value) => regs.SetRegister(register, value); - - public bool CanStep(StepType type) - { - return false; - } + public bool CanStep(StepType type) => false; private readonly MemoryCallbackSystem _memorycallbacks = new MemoryCallbackSystem(new[] { "System Bus" }); public IMemoryCallbackSystem MemoryCallbacks => _memorycallbacks; [FeatureNotImplemented] - public void Step(StepType type) - { - throw new NotImplementedException(); - } + public void Step(StepType type) => throw new NotImplementedException(); [FeatureNotImplemented] - public long TotalExecutedCycles - { - get { throw new NotImplementedException(); } - } + public long TotalExecutedCycles => throw new NotImplementedException(); } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs index 3251fa76f9..80f1ffa700 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs @@ -93,7 +93,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA IntPtr Core; - public IEmulatorServiceProvider ServiceProvider { get; private set; } + public IEmulatorServiceProvider ServiceProvider { get; } public bool FrameAdvance(IController controller, bool render, bool rendersound = true) { @@ -118,9 +118,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA private ITraceable Tracer { get; set; } - public string SystemId { get { return "GBA"; } } + public string SystemId => "GBA"; - public bool DeterministicEmulation { get; private set; } + public bool DeterministicEmulation { get; } public void ResetCounters() { @@ -154,7 +154,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA LibVBANext.TraceCallback tracecb; private readonly InputCallbackSystem _inputCallbacks = new InputCallbackSystem(); - public IInputCallbackSystem InputCallbacks { get { return _inputCallbacks; } } + public IInputCallbackSystem InputCallbacks => _inputCallbacks; TraceInfo Trace(uint addr, uint opcode) { @@ -215,7 +215,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA #region Controller - public ControllerDefinition ControllerDefinition { get { return GBA.GBAController; } } + public ControllerDefinition ControllerDefinition => GBA.GBAController; public static LibVBANext.Buttons GetButtons(IController c) { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBARegisterHelper.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBARegisterHelper.cs index ddb50a3d07..d17c116601 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBARegisterHelper.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBARegisterHelper.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Runtime.InteropServices; using BizHawk.Emulation.Common; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Audio.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Audio.cs index 08e9cc62ff..50129d7ea1 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Audio.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Audio.cs @@ -1,7 +1,6 @@ using System; using BizHawk.Common; -using BizHawk.Common.BufferExtensions; using BizHawk.Emulation.Common; using BizHawk.Common.NumberExtensions; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBC_PPU.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBC_PPU.cs index 59fa917b3f..33b77646eb 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBC_PPU.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBC_PPU.cs @@ -26,20 +26,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public byte HDMA_byte; // accessors for derived values - public byte BG_pal_ret - { - get { return (byte)(((BG_bytes_inc ? 1 : 0) << 7) | (BG_bytes_index & 0x3F)); } - } + public byte BG_pal_ret => (byte)(((BG_bytes_inc ? 1 : 0) << 7) | (BG_bytes_index & 0x3F)); - public byte OBJ_pal_ret - { - get { return(byte)(((OBJ_bytes_inc ? 1 : 0) << 7) | (OBJ_bytes_index & 0x3F)); } - } + public byte OBJ_pal_ret => (byte)(((OBJ_bytes_inc ? 1 : 0) << 7) | (OBJ_bytes_index & 0x3F)); - public byte HDMA_ctrl - { - get { return (byte)(((HDMA_active ? 0 : 1) << 7) | ((HDMA_length >> 4) - 1)); } - } + public byte HDMA_ctrl => (byte)(((HDMA_active ? 0 : 1) << 7) | ((HDMA_length >> 4) - 1)); // controls for tile attributes diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBC_PPU_GB.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBC_PPU_GB.cs index 886d0738f7..15a3770287 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBC_PPU_GB.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBC_PPU_GB.cs @@ -28,20 +28,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public byte HDMA_byte; // accessors for derived values - public byte BG_pal_ret - { - get { return (byte)(((BG_bytes_inc ? 1 : 0) << 7) | (BG_bytes_index & 0x3F)); } - } + public byte BG_pal_ret => (byte)(((BG_bytes_inc ? 1 : 0) << 7) | (BG_bytes_index & 0x3F)); - public byte OBJ_pal_ret - { - get { return (byte)(((OBJ_bytes_inc ? 1 : 0) << 7) | (OBJ_bytes_index & 0x3F)); } - } + public byte OBJ_pal_ret => (byte)(((OBJ_bytes_inc ? 1 : 0) << 7) | (OBJ_bytes_index & 0x3F)); - public byte HDMA_ctrl - { - get { return (byte)(((HDMA_active ? 0 : 1) << 7) | ((HDMA_length >> 4) - 1)); } - } + public byte HDMA_ctrl => (byte)(((HDMA_active ? 0 : 1) << 7) | ((HDMA_length >> 4) - 1)); // controls for tile attributes diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.ICodeDataLog.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.ICodeDataLog.cs index 0101ce5e93..6f7c9f3b27 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.ICodeDataLog.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.ICodeDataLog.cs @@ -1,7 +1,4 @@ -using System; using System.IO; -using System.Collections.Generic; - using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Components.LR35902; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IDebuggable.cs index a1323f8564..0891ae41a6 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IDebuggable.cs @@ -58,20 +58,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public IMemoryCallbackSystem MemoryCallbacks { get; } = new MemoryCallbackSystem(new[] { "System Bus" }); - public bool CanStep(StepType type) - { - return false; - } + public bool CanStep(StepType type) => false; [FeatureNotImplemented] - public void Step(StepType type) - { - throw new NotImplementedException(); - } + public void Step(StepType type) => throw new NotImplementedException(); - public long TotalExecutedCycles - { - get { return (long)cpu.TotalExecutedCycles; } - } + public long TotalExecutedCycles => (long)cpu.TotalExecutedCycles; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IEmulator.cs index bec4dfea06..eb3ad6e220 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IEmulator.cs @@ -1,7 +1,6 @@ using BizHawk.Common.NumberExtensions; using BizHawk.Emulation.Common; using System; -using System.Collections.Generic; using System.Runtime.InteropServices; namespace BizHawk.Emulation.Cores.Nintendo.GBHawk diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IMemoryDomains.cs index ecb0940aa5..370d50303c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IMemoryDomains.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; - +using System.Collections.Generic; using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Nintendo.GBHawk diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.ISaveRam.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.ISaveRam.cs index f1fcca72b7..d77ee0d317 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.ISaveRam.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.ISaveRam.cs @@ -7,14 +7,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk { public byte[] CloneSaveRam() { - if (cart_RAM != null) - { - return (byte[])cart_RAM.Clone(); - } - else - { - return null; - } + return (byte[])cart_RAM?.Clone(); } public void StoreSaveRam(byte[] data) @@ -26,12 +19,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk } } - public bool SaveRamModified - { - get - { - return has_bat & _syncSettings.Use_SRAM; - } - } + public bool SaveRamModified => has_bat & _syncSettings.Use_SRAM; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawkControllers.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawkControllers.cs index 358ff7aa21..e0f1e59368 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawkControllers.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawkControllers.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.ComponentModel; using System.Linq; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/MapperBase.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/MapperBase.cs index 16431bd209..7dd2a53dcb 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/MapperBase.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/MapperBase.cs @@ -1,6 +1,4 @@ using BizHawk.Common; -using System; - using BizHawk.Emulation.Cores.Components.LR35902; namespace BizHawk.Emulation.Cores.Nintendo.GBHawk diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_Camera.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_Camera.cs index d93785de9f..fed372995c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_Camera.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_Camera.cs @@ -1,8 +1,4 @@ -using BizHawk.Common; -using BizHawk.Common.NumberExtensions; -using System; - -using BizHawk.Emulation.Cores.Components.LR35902; +using BizHawk.Emulation.Cores.Components.LR35902; namespace BizHawk.Emulation.Cores.Nintendo.GBHawk { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_Default.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_Default.cs index 0a11082556..fed448d690 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_Default.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_Default.cs @@ -1,8 +1,4 @@ -using BizHawk.Common; -using BizHawk.Common.NumberExtensions; -using System; - -using BizHawk.Emulation.Cores.Components.LR35902; +using BizHawk.Emulation.Cores.Components.LR35902; namespace BizHawk.Emulation.Cores.Nintendo.GBHawk { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_HuC1.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_HuC1.cs index 9af7efb20f..597463c32d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_HuC1.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_HuC1.cs @@ -1,7 +1,4 @@ using BizHawk.Common; -using BizHawk.Common.NumberExtensions; -using System; - using BizHawk.Emulation.Cores.Components.LR35902; namespace BizHawk.Emulation.Cores.Nintendo.GBHawk diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_HuC3.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_HuC3.cs index b4125e739c..babe712202 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_HuC3.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_HuC3.cs @@ -1,5 +1,4 @@ -using System; -using BizHawk.Common; +using BizHawk.Common; using BizHawk.Emulation.Cores.Components.LR35902; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC1.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC1.cs index c77c147267..bc51ec8582 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC1.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC1.cs @@ -1,7 +1,4 @@ using BizHawk.Common; -using BizHawk.Common.NumberExtensions; -using System; - using BizHawk.Emulation.Cores.Components.LR35902; namespace BizHawk.Emulation.Cores.Nintendo.GBHawk diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC1_Multi.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC1_Multi.cs index 40224941f2..4cb9b418c7 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC1_Multi.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC1_Multi.cs @@ -1,7 +1,4 @@ using BizHawk.Common; -using BizHawk.Common.NumberExtensions; -using System; - using BizHawk.Emulation.Cores.Components.LR35902; namespace BizHawk.Emulation.Cores.Nintendo.GBHawk diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC2.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC2.cs index 0265773efa..4b059ecaba 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC2.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC2.cs @@ -1,7 +1,4 @@ using BizHawk.Common; -using BizHawk.Common.NumberExtensions; -using System; - using BizHawk.Emulation.Cores.Components.LR35902; namespace BizHawk.Emulation.Cores.Nintendo.GBHawk diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC3.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC3.cs index 580940fd8e..1ba4e8f373 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC3.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC3.cs @@ -1,7 +1,4 @@ using BizHawk.Common; -using BizHawk.Common.NumberExtensions; -using System; - using BizHawk.Emulation.Cores.Components.LR35902; namespace BizHawk.Emulation.Cores.Nintendo.GBHawk diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC5.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC5.cs index 38015c1d10..3916ee92d4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC5.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC5.cs @@ -1,7 +1,4 @@ using BizHawk.Common; -using BizHawk.Common.NumberExtensions; -using System; - using BizHawk.Emulation.Cores.Components.LR35902; namespace BizHawk.Emulation.Cores.Nintendo.GBHawk diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC6.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC6.cs index 0b1eaadccb..2adc8effc7 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC6.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC6.cs @@ -1,8 +1,4 @@ -using BizHawk.Common; -using BizHawk.Common.NumberExtensions; -using System; - -using BizHawk.Emulation.Cores.Components.LR35902; +using BizHawk.Emulation.Cores.Components.LR35902; namespace BizHawk.Emulation.Cores.Nintendo.GBHawk { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC7.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC7.cs index c381bffb16..18a377b56e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC7.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MBC7.cs @@ -1,7 +1,5 @@ using BizHawk.Common; using BizHawk.Common.NumberExtensions; -using System; - using BizHawk.Emulation.Cores.Components.LR35902; namespace BizHawk.Emulation.Cores.Nintendo.GBHawk diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MMM01.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MMM01.cs index fedec0e091..a366715bf0 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MMM01.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_MMM01.cs @@ -1,8 +1,4 @@ -using BizHawk.Common; -using BizHawk.Common.NumberExtensions; -using System; - -using BizHawk.Emulation.Cores.Components.LR35902; +using BizHawk.Emulation.Cores.Components.LR35902; namespace BizHawk.Emulation.Cores.Nintendo.GBHawk { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_RockMan8.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_RockMan8.cs index c02e72025d..b23d2b3749 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_RockMan8.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_RockMan8.cs @@ -1,7 +1,4 @@ using BizHawk.Common; -using BizHawk.Common.NumberExtensions; -using System; - using BizHawk.Emulation.Cores.Components.LR35902; namespace BizHawk.Emulation.Cores.Nintendo.GBHawk diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_Sachen_MMC1.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_Sachen_MMC1.cs index 7eb7cda766..c488d8df83 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_Sachen_MMC1.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_Sachen_MMC1.cs @@ -1,5 +1,4 @@ using BizHawk.Common; -using BizHawk.Common.NumberExtensions; using System; using BizHawk.Emulation.Cores.Components.LR35902; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_Sachen_MMC2.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_Sachen_MMC2.cs index 2ec65a4c7b..1914d9b74e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_Sachen_MMC2.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_Sachen_MMC2.cs @@ -1,5 +1,4 @@ using BizHawk.Common; -using BizHawk.Common.NumberExtensions; using System; using BizHawk.Emulation.Cores.Components.LR35902; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_TAMA5.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_TAMA5.cs index 0207d7ba71..e350ab2ab0 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_TAMA5.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_TAMA5.cs @@ -1,7 +1,4 @@ using BizHawk.Common; -using BizHawk.Common.NumberExtensions; -using System; - using BizHawk.Emulation.Cores.Components.LR35902; namespace BizHawk.Emulation.Cores.Nintendo.GBHawk diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_WisdomTree.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_WisdomTree.cs index 93bacdc279..273b0fab2e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_WisdomTree.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Mappers/Mapper_WisdomTree.cs @@ -1,7 +1,4 @@ using BizHawk.Common; -using BizHawk.Common.NumberExtensions; -using System; - using BizHawk.Emulation.Cores.Components.LR35902; namespace BizHawk.Emulation.Cores.Nintendo.GBHawk diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/MemoryMap.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/MemoryMap.cs index f14efba84b..0714a36673 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/MemoryMap.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/MemoryMap.cs @@ -1,7 +1,4 @@ -using System; - -using BizHawk.Common.BufferExtensions; -using BizHawk.Emulation.Common; +using BizHawk.Emulation.Common; /* diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/PPU.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/PPU.cs index 6afdad2f57..539db02990 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/PPU.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/PPU.cs @@ -1,5 +1,4 @@ -using System; -using BizHawk.Common; +using BizHawk.Common; namespace BizHawk.Emulation.Cores.Nintendo.GBHawk { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/SerialPort.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/SerialPort.cs index 1d1a8cb8b6..71bb4d8b2b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/SerialPort.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/SerialPort.cs @@ -1,6 +1,4 @@ -using System; -using BizHawk.Emulation.Common; -using BizHawk.Common.NumberExtensions; +using BizHawk.Common.NumberExtensions; using BizHawk.Common; namespace BizHawk.Emulation.Cores.Nintendo.GBHawk diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Timer.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Timer.cs index 2f4932bad9..84ab4c60dc 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Timer.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Timer.cs @@ -1,6 +1,5 @@ using BizHawk.Common; using BizHawk.Common.NumberExtensions; -using System; namespace BizHawk.Emulation.Cores.Nintendo.GBHawk { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.ICodeDataLog.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.ICodeDataLog.cs index 7429ec6a3e..c105f38872 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.ICodeDataLog.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.ICodeDataLog.cs @@ -1,4 +1,3 @@ -using System; using System.IO; using BizHawk.Emulation.Common; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IDebuggable.cs index e9b191d02a..7d14a24b97 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IDebuggable.cs @@ -58,20 +58,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink public IMemoryCallbackSystem MemoryCallbacks { get; } = new MemoryCallbackSystem(new[] { "System Bus" }); - public bool CanStep(StepType type) - { - return false; - } + public bool CanStep(StepType type) => false; [FeatureNotImplemented] - public void Step(StepType type) - { - throw new NotImplementedException(); - } + public void Step(StepType type) => throw new NotImplementedException(); - public long TotalExecutedCycles - { - get { return (long)L.cpu.TotalExecutedCycles; } - } + public long TotalExecutedCycles => (long)L.cpu.TotalExecutedCycles; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IEmulator.cs index 7719e9ac6c..09703258ee 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IEmulator.cs @@ -1,7 +1,6 @@ using System; using BizHawk.Emulation.Common; -using BizHawk.Emulation.Cores.Nintendo.GBHawk; namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IMemoryDomains.cs index baa6162919..f0073ec8aa 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IMemoryDomains.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using BizHawk.Emulation.Common; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.ISaveRam.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.ISaveRam.cs index 0fd92601bb..dc19140a96 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.ISaveRam.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.ISaveRam.cs @@ -45,10 +45,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink return temp; } - else - { - return null; - } + + return null; } public void StoreSaveRam(byte[] data) @@ -73,12 +71,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink } } - public bool SaveRamModified - { - get - { - return (L.has_bat || R.has_bat) & linkSyncSettings.Use_SRAM; - } - } + public bool SaveRamModified => (L.has_bat || R.has_bat) & linkSyncSettings.Use_SRAM; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.ISettable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.ISettable.cs index 2258250cfb..814704a22a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.ISettable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.ISettable.cs @@ -5,7 +5,6 @@ using Newtonsoft.Json; using BizHawk.Common; using BizHawk.Emulation.Common; -using BizHawk.Emulation.Cores.Nintendo.GBHawk; namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.cs index d9185bd68e..b4fc80a4e5 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.cs @@ -1,8 +1,4 @@ -using System; - -using BizHawk.Emulation.Common; - -using BizHawk.Emulation.Cores.Nintendo.GBHawk; +using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLinkControllers.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLinkControllers.cs index b1617ce740..1fe269ddbc 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLinkControllers.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLinkControllers.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; +using System.ComponentModel; using System.Linq; using BizHawk.Common; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.ICodeDataLog.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.ICodeDataLog.cs index 5ecf084b22..3d669fa4a4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.ICodeDataLog.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.ICodeDataLog.cs @@ -1,4 +1,3 @@ -using System; using System.IO; using BizHawk.Emulation.Common; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.IDebuggable.cs index ca2133a5ab..aaa497014d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.IDebuggable.cs @@ -58,20 +58,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x public IMemoryCallbackSystem MemoryCallbacks { get; } = new MemoryCallbackSystem(new[] { "System Bus" }); - public bool CanStep(StepType type) - { - return false; - } + public bool CanStep(StepType type) => false; [FeatureNotImplemented] - public void Step(StepType type) - { - throw new NotImplementedException(); - } + public void Step(StepType type) => throw new NotImplementedException(); - public long TotalExecutedCycles - { - get { return (long)L.cpu.TotalExecutedCycles; } - } + public long TotalExecutedCycles => (long)L.cpu.TotalExecutedCycles; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.IEmulator.cs index 12805da47a..7e6e062407 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.IEmulator.cs @@ -1,7 +1,6 @@ using System; using BizHawk.Emulation.Common; -using BizHawk.Emulation.Cores.Nintendo.GBHawk; namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.IMemoryDomains.cs index 940f1524e4..5cfbc95c33 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.IMemoryDomains.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using BizHawk.Emulation.Common; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.ISaveRam.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.ISaveRam.cs index ee6ea5ef72..c5f531e030 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.ISaveRam.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.ISaveRam.cs @@ -60,10 +60,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x return temp; } - else - { - return null; - } + + return null; } public void StoreSaveRam(byte[] data) @@ -93,12 +91,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x } } - public bool SaveRamModified - { - get - { - return (L.has_bat || C.has_bat || R.has_bat) & Link3xSyncSettings.Use_SRAM; - } - } + public bool SaveRamModified => (L.has_bat || C.has_bat || R.has_bat) & Link3xSyncSettings.Use_SRAM; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.ISettable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.ISettable.cs index 3f9c4ea610..253cf59809 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.ISettable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.ISettable.cs @@ -5,7 +5,6 @@ using Newtonsoft.Json; using BizHawk.Common; using BizHawk.Emulation.Common; -using BizHawk.Emulation.Cores.Nintendo.GBHawk; namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3xControllers.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3xControllers.cs index 06500bfb75..35542a3525 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3xControllers.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3xControllers.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; +using System.ComponentModel; using System.Linq; using BizHawk.Common; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.ICodeDataLog.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.ICodeDataLog.cs index 13b952cbfd..eb78190b2b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.ICodeDataLog.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.ICodeDataLog.cs @@ -1,4 +1,3 @@ -using System; using System.IO; using BizHawk.Emulation.Common; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.IDebuggable.cs index cf63fea6e8..dba57d3ea6 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.IDebuggable.cs @@ -58,20 +58,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x public IMemoryCallbackSystem MemoryCallbacks { get; } = new MemoryCallbackSystem(new[] { "System Bus" }); - public bool CanStep(StepType type) - { - return false; - } + public bool CanStep(StepType type) => false; [FeatureNotImplemented] - public void Step(StepType type) - { - throw new NotImplementedException(); - } + public void Step(StepType type) => throw new NotImplementedException(); - public long TotalExecutedCycles - { - get { return (long)A.cpu.TotalExecutedCycles; } - } + public long TotalExecutedCycles => (long)A.cpu.TotalExecutedCycles; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.IEmulator.cs index f1591222d9..c1c0d30f20 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.IEmulator.cs @@ -1,7 +1,6 @@ using System; using BizHawk.Emulation.Common; -using BizHawk.Emulation.Cores.Nintendo.GBHawk; namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.IMemoryDomains.cs index 8ef115c4bc..98f30e794b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.IMemoryDomains.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using BizHawk.Emulation.Common; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.ISaveRam.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.ISaveRam.cs index 689782c57b..7f99865062 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.ISaveRam.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.ISaveRam.cs @@ -7,7 +7,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x { public byte[] CloneSaveRam() { - if ((A.cart_RAM != null) || (B.cart_RAM != null) || (C.cart_RAM != null) || (D.cart_RAM != null)) + if (A.cart_RAM != null || B.cart_RAM != null || C.cart_RAM != null || D.cart_RAM != null) { int Len1 = 0; int Len2 = 0; @@ -75,10 +75,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x return temp; } - else - { - return null; - } + + return null; } public void StoreSaveRam(byte[] data) @@ -114,12 +112,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x } } - public bool SaveRamModified - { - get - { - return (A.has_bat || B.has_bat || C.has_bat || D.has_bat) & Link4xSyncSettings.Use_SRAM; - } - } + public bool SaveRamModified => (A.has_bat || B.has_bat || C.has_bat || D.has_bat) & Link4xSyncSettings.Use_SRAM; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.ISettable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.ISettable.cs index 3b6b176563..eb684c6ad0 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.ISettable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.ISettable.cs @@ -5,7 +5,6 @@ using Newtonsoft.Json; using BizHawk.Common; using BizHawk.Emulation.Common; -using BizHawk.Emulation.Cores.Nintendo.GBHawk; namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4xControllers.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4xControllers.cs index cf0cd408c6..bfb5f79867 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4xControllers.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4xControllers.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; +using System.ComponentModel; using System.Linq; using BizHawk.Common; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IDebuggable.cs index 17e1041253..027daf5830 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IDebuggable.cs @@ -28,26 +28,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy } [FeatureNotImplemented] - public void SetCpuRegister(string register, int value) - { - throw new NotImplementedException(); - } + public void SetCpuRegister(string register, int value) => throw new NotImplementedException(); - public bool CanStep(StepType type) - { - return false; - } + public bool CanStep(StepType type) => false; [FeatureNotImplemented] - public void Step(StepType type) - { - throw new NotImplementedException(); - } + public void Step(StepType type) => throw new NotImplementedException(); - public long TotalExecutedCycles - { - get { return Math.Max((long)_cycleCount, (long)callbackCycleCount); } - } + public long TotalExecutedCycles => Math.Max((long)_cycleCount, (long)callbackCycleCount); private MemoryCallbackSystem _memorycallbacks = new MemoryCallbackSystem(new[] { "System Bus" }); public IMemoryCallbackSystem MemoryCallbacks => _memorycallbacks; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IEmulator.cs index c0b371b389..8c15640a43 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IEmulator.cs @@ -2,7 +2,6 @@ using System.Diagnostics; using BizHawk.Emulation.Common; -using System.Runtime.InteropServices; namespace BizHawk.Emulation.Cores.Nintendo.Gameboy { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.ILinkable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.ILinkable.cs index 93f65cbff6..e76ed0d7c6 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.ILinkable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.ILinkable.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -using BizHawk.Emulation.Common; +using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Nintendo.Gameboy { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.ISettable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.ISettable.cs index 4ca0287656..3e4df88d3e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.ISettable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.ISettable.cs @@ -1,5 +1,4 @@ -using System; -using System.ComponentModel; +using System.ComponentModel; using Newtonsoft.Json; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.ICodeDataLog.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.ICodeDataLog.cs index 7585653826..07baaf12ea 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.ICodeDataLog.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.ICodeDataLog.cs @@ -1,7 +1,4 @@ -using System; using System.IO; -using System.Collections.Generic; - using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Nintendo.Gameboy diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IDebuggable.cs index 92759e216d..04783cc4b2 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IDebuggable.cs @@ -31,24 +31,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy } } - public IMemoryCallbackSystem MemoryCallbacks - { - get { return _memorycallbacks; } - } + public IMemoryCallbackSystem MemoryCallbacks { get; } = new MemoryCallbackSystem(new[] { "System Bus" }); - public bool CanStep(StepType type) - { - return false; - } + public bool CanStep(StepType type) => false; [FeatureNotImplemented] - public void Step(StepType type) { throw new NotImplementedException(); } + public void Step(StepType type) => throw new NotImplementedException(); [FeatureNotImplemented] - public long TotalExecutedCycles - { - get { throw new NotImplementedException(); } - } + public long TotalExecutedCycles => throw new NotImplementedException(); private readonly MemoryCallbackSystem _memorycallbacks = new MemoryCallbackSystem(new[] { "System Bus" }); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IInputPollable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IInputPollable.cs index 1148b51f94..bec5b06ed3 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IInputPollable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IInputPollable.cs @@ -1,5 +1,4 @@ -using System; -using BizHawk.Emulation.Common; +using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Nintendo.Gameboy { @@ -9,10 +8,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy public bool IsLagFrame { get; set; } - public IInputCallbackSystem InputCallbacks - { - get { return _inputCallbacks; } - } + public IInputCallbackSystem InputCallbacks => _inputCallbacks; private InputCallbackSystem _inputCallbacks = new InputCallbackSystem(); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IMemoryDomains.cs index 4f5117d274..5268637ec9 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IMemoryDomains.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; - +using System.Collections.Generic; using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Nintendo.Gameboy diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.ISaveRam.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.ISaveRam.cs index dd14a5221a..ec648bba8c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.ISaveRam.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.ISaveRam.cs @@ -5,13 +5,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy { public partial class GambatteLink : ISaveRam { - public bool SaveRamModified - { - get - { - return L.SaveRamModified || R.SaveRamModified; - } - } + public bool SaveRamModified => L.SaveRamModified || R.SaveRamModified; public byte[] CloneSaveRam() { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.ISettable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.ISettable.cs index a1ecea1798..7249a7630d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.ISettable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.ISettable.cs @@ -1,5 +1,4 @@ -using System; -using BizHawk.Emulation.Common; +using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Nintendo.Gameboy { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IStatable.cs index 78ffc80eb3..94337d11dc 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IStatable.cs @@ -1,5 +1,4 @@ -using System; -using System.IO; +using System.IO; using Newtonsoft.Json; using BizHawk.Emulation.Common; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IVideoProvider.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IVideoProvider.cs index b00cb6a4fa..40721eaf40 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IVideoProvider.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IVideoProvider.cs @@ -1,29 +1,22 @@ -using System; -using BizHawk.Emulation.Common; +using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Nintendo.Gameboy { public partial class GambatteLink : IVideoProvider { - public int VirtualWidth { get { return 320; } } - public int VirtualHeight { get { return 144; } } - public int BufferWidth { get { return 320; } } - public int BufferHeight { get { return 144; } } + public int VirtualWidth => 320; + public int VirtualHeight => 144; + public int BufferWidth => 320; + public int BufferHeight => 144; public int VsyncNumerator => L.VsyncNumerator; public int VsyncDenominator => L.VsyncDenominator; - public int BackgroundColor - { - get { return unchecked((int)0xff000000); } - } + public int BackgroundColor => unchecked((int)0xff000000); - public int[] GetVideoBuffer() - { - return VideoBuffer; - } + public int[] GetVideoBuffer() => VideoBuffer; - private int[] VideoBuffer = new int[160 * 2 * 144]; + private readonly int[] VideoBuffer = new int[160 * 2 * 144]; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambattePrinter.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambattePrinter.cs index 9654403751..4392612105 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambattePrinter.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambattePrinter.cs @@ -244,7 +244,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy uint[] outputImage = new uint[image_offset]; int palette = command_data[2]; - uint[] colors = new uint[] { + uint[] colors = { 0xFFFFFFFFU, 0xFFAAAAAAU, 0xFF555555U, diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IDebuggable.cs index 6a7b66d383..c7dbca888b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IDebuggable.cs @@ -77,10 +77,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 throw new NotImplementedException(); } - public IMemoryCallbackSystem MemoryCallbacks - { - get { return _memorycallbacks; } - } + public IMemoryCallbackSystem MemoryCallbacks { get; } private readonly MemoryCallbackSystem _memorycallbacks = new MemoryCallbackSystem(new[] { "System Bus" }); @@ -100,10 +97,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 } [FeatureNotImplemented] - public long TotalExecutedCycles - { - get { throw new NotImplementedException(); } - } + public long TotalExecutedCycles => throw new NotImplementedException(); public void Step(StepType type) { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IDisassemblable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IDisassemblable.cs index 047186def9..3e1a4a6ae8 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IDisassemblable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IDisassemblable.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Runtime.InteropServices; using BizHawk.Emulation.Common; @@ -22,10 +21,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 } } - public string PCRegisterName - { - get { return "PC"; } - } + public string PCRegisterName => "PC"; public string Disassemble(MemoryDomain m, uint addr, out int length) { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IInputPollable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IInputPollable.cs index 31d7b96745..d929acae2d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IInputPollable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IInputPollable.cs @@ -34,18 +34,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 public bool IsVIFrame { - get - { - return _videoProvider.IsVIFrame; - } - - internal set - { - _videoProvider.IsVIFrame = value; - } + get => _videoProvider.IsVIFrame; + internal set => _videoProvider.IsVIFrame = value; } // TODO: optimize managed to unmanaged using the ActiveChanged event - public IInputCallbackSystem InputCallbacks { [FeatureNotImplemented] get; private set; } + public IInputCallbackSystem InputCallbacks { [FeatureNotImplemented] get; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.ISaveRam.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.ISaveRam.cs index 6a2faa8b88..347dc9e819 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.ISaveRam.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.ISaveRam.cs @@ -14,9 +14,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 api.LoadSaveram(data); } - public bool SaveRamModified - { - get { return true; } - } + public bool SaveRamModified => true; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.ITraceable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.ITraceable.cs index 7fa36ce944..6bfedfa210 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.ITraceable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.ITraceable.cs @@ -1,8 +1,5 @@ using System; -using System.Runtime.InteropServices; using System.Text; - -using BizHawk.Common.NumberExtensions; using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Nintendo.N64.NativeApi; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs index 2de5cc5f6c..e9829e8738 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs @@ -163,12 +163,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 private bool _disableExpansionSlot = true; - public IEmulatorServiceProvider ServiceProvider { get; private set; } + public IEmulatorServiceProvider ServiceProvider { get; } - public bool UsingExpansionSlot - { - get { return !_disableExpansionSlot; } - } + public bool UsingExpansionSlot => !_disableExpansionSlot; public bool IsOverridingUserExpansionSlotSetting { get; set; } @@ -261,16 +258,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 return true; } - public string SystemId { get { return "N64"; } } + public string SystemId => "N64"; - public CoreComm CoreComm { get; private set; } + public CoreComm CoreComm { get; } - public DisplayType Region { get { return _display_type; } } + public DisplayType Region => _display_type; - public ControllerDefinition ControllerDefinition - { - get { return _inputProvider.ControllerDefinition; } - } + public ControllerDefinition ControllerDefinition => _inputProvider.ControllerDefinition; public void ResetCounters() { @@ -279,6 +273,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 IsLagFrame = false; } - public bool DeterministicEmulation { get { return false; } } + public bool DeterministicEmulation => false; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64Audio.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64Audio.cs index 2e71ffec95..689974e4ab 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64Audio.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64Audio.cs @@ -23,10 +23,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 /// public uint SamplingRate { - get - { - return _samplingRate; - } + get => _samplingRate; private set { _samplingRate = value; @@ -80,8 +77,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 public void Dispose() { coreAPI.VInterrupt -= DoAudioFrame; - if(Resampler != null) - Resampler.Dispose(); + Resampler?.Dispose(); Resampler = null; api = null; } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64SyncSettings.GLideN64.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64SyncSettings.GLideN64.cs index d09a6571fb..f270deb10c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64SyncSettings.GLideN64.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64SyncSettings.GLideN64.cs @@ -1,7 +1,4 @@ -using System.Collections.Generic; -using System.ComponentModel; -using System.Reflection; - +using System.ComponentModel; using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Nintendo.N64 diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64SyncSettings.Glide.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64SyncSettings.Glide.cs index f047f28240..99752cfc13 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64SyncSettings.Glide.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64SyncSettings.Glide.cs @@ -1,7 +1,4 @@ -using System.Collections.Generic; -using System.ComponentModel; -using System.Reflection; - +using System.ComponentModel; using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Nintendo.N64 diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64SyncSettings.GlideMk2.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64SyncSettings.GlideMk2.cs index 765f000844..1a213198c0 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64SyncSettings.GlideMk2.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64SyncSettings.GlideMk2.cs @@ -1,8 +1,6 @@ -using System.Collections.Generic; -using System.ComponentModel; +using System.ComponentModel; using BizHawk.Emulation.Common; -using System.Reflection; namespace BizHawk.Emulation.Cores.Nintendo.N64 { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64SyncSettings.Rice.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64SyncSettings.Rice.cs index 7a1eb23897..b06bbb0318 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64SyncSettings.Rice.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64SyncSettings.Rice.cs @@ -1,8 +1,6 @@ -using System.Collections.Generic; -using System.ComponentModel; +using System.ComponentModel; using BizHawk.Emulation.Common; -using System.Reflection; namespace BizHawk.Emulation.Cores.Nintendo.N64 { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64SyncSettings.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64SyncSettings.cs index 87bf14407a..9bf129bd10 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64SyncSettings.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64SyncSettings.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Nintendo.N64.NativeApi; -using Newtonsoft.Json; using System.ComponentModel; using System.Reflection; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64VideoProvider.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64VideoProvider.cs index 5306a7b4ad..1623e0f3f8 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64VideoProvider.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64VideoProvider.cs @@ -33,16 +33,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 coreAPI.BeforeRender += () => { IsVIFrame = true; }; } - public int[] GetVideoBuffer() - { - return frameBuffer; - } + public int[] GetVideoBuffer() => frameBuffer; - public int VirtualWidth { get { return BufferWidth; } } - public int VirtualHeight { get { return BufferHeight; } } + public int VirtualWidth => BufferWidth; + public int VirtualHeight => BufferHeight; public int BufferWidth { get; private set; } public int BufferHeight { get; private set; } - public int BackgroundColor { get { return 0; } } + public int BackgroundColor => 0; public int VsyncNumerator { get; internal set; } public int VsyncDenominator { get; internal set; } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusAudioApi.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusAudioApi.cs index 74d7833a76..6901b7d0b3 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusAudioApi.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusAudioApi.cs @@ -1,6 +1,5 @@ using System; using System.Runtime.InteropServices; -using BizHawk.Emulation.Cores.Nintendo.N64; namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusCoreApi.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusCoreApi.cs index 609c5a399c..c45eecf935 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusCoreApi.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusCoreApi.cs @@ -1027,23 +1027,20 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi private void FireFrameFinishedEvent() { // Execute Frame Callback functions - if (FrameFinished != null) - FrameFinished(); + FrameFinished?.Invoke(); } private void FireVIEvent() { // Execute VI Callback functions - if (VInterrupt != null) - VInterrupt(); + VInterrupt?.Invoke(); event_frameend = true; //order important m64pEvent.Set(); //order important } private void FireRenderEvent() { - if (BeforeRender != null) - BeforeRender(); + BeforeRender?.Invoke(); } private bool CheckBreakpointFlag(ref m64p_breakpoint bkp, m64p_dbg_bkp_flags flag) @@ -1054,8 +1051,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi private void FireBreakpointEvent(int bpt) { // bpt equal to -1 means we're stepping - if((bpt == -1) || (BreakpointHit == null)) + if (bpt == -1 || BreakpointHit == null) + { return; + } m64p_breakpoint breakpoint = new m64p_breakpoint(); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusInputApi.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusInputApi.cs index 6b5531f99d..cbf5566ced 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusInputApi.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusInputApi.cs @@ -1,9 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Runtime.InteropServices; -using BizHawk.Emulation.Cores.Nintendo.N64; namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi { @@ -86,8 +82,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi private void FireOnRumbleChange(int Control, int on) { - if (OnRumbleChange != null) - OnRumbleChange(Control, on); + OnRumbleChange?.Invoke(Control, @on); } public void SetM64PControllerPakType(int controller, N64SyncSettings.N64ControllerSettings.N64ControllerPakType type) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusVideoApi.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusVideoApi.cs index ca8e64834e..e174dd40da 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusVideoApi.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeApi/mupen64plusVideoApi.cs @@ -1,11 +1,6 @@ using System; using System.Collections.Generic; -using System.IO; -using System.Linq; using System.Runtime.InteropServices; -using System.Security.Cryptography; -using System.Text; - using BizHawk.Common; namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/APU.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/APU.cs index 759e7822a8..ab7a45787a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/APU.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/APU.cs @@ -11,8 +11,6 @@ // TODO - refactor length counter to be separate component using System; -using System.Collections.Generic; - using BizHawk.Common; using BizHawk.Common.NumberExtensions; @@ -32,14 +30,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { this.nes = nes; dmc = new DMCUnit(this, pal); - if (pal) - { - sequencer_lut = sequencer_lut_pal; - } - else - { - sequencer_lut = sequencer_lut_ntsc; - } + sequencer_lut = pal ? sequencer_lut_pal : sequencer_lut_ntsc; noise = new NoiseUnit(this, pal); triangle = new TriangleUnit(this); @@ -307,31 +298,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } } - public bool Debug_IsSilenced - { - get - { - if (swp_silence || len_cnt == 0) - return true; - else return false; - } - } + public bool Debug_IsSilenced => swp_silence || len_cnt == 0; - public int Debug_DutyType - { - get - { - return duty_cnt; - } - } + public int Debug_DutyType => duty_cnt; - public int Debug_Volume - { - get - { - return env_output; - } - } + public int Debug_Volume => env_output; } public sealed class NoiseUnit @@ -371,25 +342,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES get { if (len_cnt == 0) return true; - else return false; + return false; } } - public int Debug_Period - { - get - { - return period_cnt; - } - } + public int Debug_Period => period_cnt; - public int Debug_Volume - { - get - { - return env_output; - } - } + public int Debug_Volume => env_output; public void SyncState(Serializer ser) { @@ -416,7 +375,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES ser.EndSection(); } - public bool IsLenCntNonZero() { return len_cnt > 0; } + public bool IsLenCntNonZero() => len_cnt > 0; public void WriteReg(int addr, byte val) { @@ -623,13 +582,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } } - public int Debug_PeriodValue - { - get - { - return timer_cnt; - } - } + public int Debug_PeriodValue => timer_cnt; public void Run() { @@ -724,7 +677,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES int out_shift, out_bits_remaining, out_deltacounter; bool out_silence; - public int sample { get { return out_deltacounter /* - 64*/; } } + public int sample => out_deltacounter /* - 64*/; public void SyncState(Serializer ser) { @@ -786,7 +739,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { delay = 3; } - } + } } // I did some tests in Visual 2A03 and there seems to be some delay betwen when a DMC is first needed and when the @@ -863,7 +816,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES // If the DMC bit is clear, the DMC bytes remaining will be set to 0 // and the DMC will silence when it empties. sample_length = 0; - } + } else { // only start playback if playback is stopped @@ -1003,14 +956,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES int[][] sequencer_lut = new int[2][]; - static int[][] sequencer_lut_ntsc = new int[][]{ - new int[]{7457,14913,22371,29830}, - new int[]{7457,14913,22371,29830,37282} + static int[][] sequencer_lut_ntsc = { + new[]{7457,14913,22371,29830}, + new[]{7457,14913,22371,29830,37282} }; - static int[][] sequencer_lut_pal = new int[][]{ - new int[]{8313,16627,24939,33254}, - new int[]{8313,16627,24939,33254,41566} + static int[][] sequencer_lut_pal = { + new[]{8313,16627,24939,33254}, + new[]{8313,16627,24939,33254,41566} }; void sequencer_write_tick(byte val) @@ -1335,7 +1288,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES nes._irq_apu = irq_pending; // since the units run concurrently, the APU frame sequencer is ran last because - // it can change the ouput values of the pulse/triangle channels + // it can change the output values of the pulse/triangle channels // we want the changes to affect it on the *next* cycle. if (sequencer_irq_flag == false) @@ -1345,8 +1298,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (DebugCallbackTimer == 0) { - if (DebugCallback != null) - DebugCallback(); + DebugCallback?.Invoke(); DebugCallbackTimer = DebugCallbackDivider; } else DebugCallbackTimer--; @@ -1402,7 +1354,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return mix; } - return oldmix; + return oldmix; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BANDAI-FCG-1.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BANDAI-FCG-1.cs index d8e990dd50..1d0f66675a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BANDAI-FCG-1.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/BANDAI-FCG-1.cs @@ -61,10 +61,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES ser.Sync(nameof(irq_counter), ref irq_counter); ser.Sync(nameof(irq_enabled), ref irq_enabled); ser.Sync(nameof(irq_latch), ref irq_latch); - if (eprom != null) - eprom.SyncState(ser); - if (reader != null) - reader.SyncState(ser); + eprom?.SyncState(ser); + reader?.SyncState(ser); SyncPRG(); } @@ -271,8 +269,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES break; case 0xD: - if (eprom != null) - eprom.WriteByte(value); + eprom?.WriteByte(value); break; } } @@ -333,10 +330,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } return ret; } - else - { - return WRAM[addr]; - } + + return WRAM[addr]; } public override void ClockCPU() @@ -354,10 +349,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES irq_counter--; } } - if (reader != null) - { - reader.Clock(); - } + + reader?.Clock(); } @@ -390,10 +383,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES else return VROM[CalcPPUAddress(addr)]; } - else - { - return base.ReadPPU(addr); - } + + return base.ReadPPU(addr); } public override void WritePPU(int addr, byte value) @@ -414,15 +405,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES get { if (eprom != null) + { return eprom.GetSaveRAM(); - else if (jump2) + } + + if (jump2) { return WRAM; } - else - { - return null; - } + + return null; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CoolBoy.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CoolBoy.cs index 8e33a2420a..3f4cc1d502 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CoolBoy.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CoolBoy.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - using BizHawk.Common; using BizHawk.Common.NumberExtensions; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/DatachBarcode.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/DatachBarcode.cs index d392ff4104..59b2730990 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/DatachBarcode.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/DatachBarcode.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - using BizHawk.Common.NumberExtensions; using BizHawk.Common; using BizHawk.Emulation.Common; @@ -59,7 +55,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES int stream_idx; byte[] data = new byte[0]; - byte streamoutput { get { return data[stream_idx]; } } + byte streamoutput => data[stream_idx]; public void SyncState(Serializer ser) { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/ExROM.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/ExROM.cs index e47c3925ca..ff555d35d4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/ExROM.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/ExROM.cs @@ -1,5 +1,4 @@ using System; - using BizHawk.Common; using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Components; @@ -18,7 +17,7 @@ using BizHawk.Emulation.Cores.Components; //FUTURE - we may need to split this into a separate MMC5 class. but for now it is just a pain. namespace BizHawk.Emulation.Cores.Nintendo.NES { - [NES.INESBoardImplPriority] + [NES.INESBoardImplPriorityAttribute] public sealed class ExROM : NES.NESBoardBase { //configuraton @@ -55,12 +54,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES /// /// use with caution /// - public byte[] GetExRAMArray() - { - return EXRAM; - } + public byte[] GetExRAMArray() => EXRAM; - public bool ExAttrActive { get { return exram_mode == 1; } } + public bool ExAttrActive => exram_mode == 1; public override void SyncState(Serializer ser) { @@ -140,7 +136,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES PoweronState(); if (NES.apu != null) - audio = new MMC5Audio(NES.apu.ExternalQueue, (e) => { irq_audio = e; SyncIRQ(); }); + audio = new MMC5Audio(NES.apu.ExternalQueue, e => { irq_audio = e; SyncIRQ(); }); return true; } @@ -216,10 +212,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES byte ReadWRAMActual(int bank, int offs) { int? bbank = MaskWRAM(bank); - if (bbank.HasValue) - return WRAM[(int)bbank << 13 | offs]; - else - return NES.DB; + return bbank.HasValue + ? WRAM[(int)bbank << 13 | offs] + : NES.DB; } //this could be handy, but probably not. I did it on accident. @@ -269,10 +264,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES bank_1k = b_banks_1k[bank_1k]; else { - if (ab_mode == 0) - bank_1k = a_banks_1k[bank_1k]; - else - bank_1k = b_banks_1k[bank_1k]; + bank_1k = ab_mode == 0 + ? a_banks_1k[bank_1k] + : b_banks_1k[bank_1k]; } } else @@ -292,59 +286,57 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES addr = MapCHR(addr); return (VROM ?? VRAM)[addr]; } + + addr -= 0x2000; + int nt_entry = addr & 0x3FF; + if (nt_entry < 0x3C0) + { + //track the last nametable entry read so that subsequent pattern and attribute reads will know which exram address to use + last_nt_read = nt_entry; + } else { - addr -= 0x2000; - int nt_entry = addr & 0x3FF; - if (nt_entry < 0x3C0) + //attribute table + if (exram_mode == 1) { - //track the last nametable entry read so that subsequent pattern and attribute reads will know which exram address to use - last_nt_read = nt_entry; - } - else - { - //attribute table - if (exram_mode == 1) - { - //attribute will be in the top 2 bits of the exram byte - int exram_addr = last_nt_read; - int attribute = EXRAM[exram_addr] >> 6; - //calculate tile address by getting x/y from last nametable - int tx = last_nt_read & 0x1F; - int ty = last_nt_read / 32; - //attribute table address is just these coords shifted - int atx = tx >> 1; - int aty = ty >> 1; - //figure out how we need to shift the attribute to fake out the ppu - int at_shift = ((aty & 1) << 1) + (atx & 1); - at_shift <<= 1; - attribute <<= at_shift; - return (byte)attribute; - } - } - int nt = (addr >> 10) & 3; // &3 to read from the NT mirrors at 3xxx - int offset = addr & ((1 << 10) - 1); - nt = nt_modes[nt]; - switch (nt) - { - case 0: //NES internal NTA - return NES.CIRAM[offset]; - case 1: //NES internal NTB - return NES.CIRAM[0x400 | offset]; - case 2: //use ExRAM as NT - //TODO - additional r/w security - if (exram_mode >= 2) - return 0; - else - return EXRAM[offset]; - case 3: // Fill Mode - if (offset >= 0x3c0) - return nt_fill_attrib; - else - return nt_fill_tile; - default: throw new Exception(); + //attribute will be in the top 2 bits of the exram byte + int exram_addr = last_nt_read; + int attribute = EXRAM[exram_addr] >> 6; + //calculate tile address by getting x/y from last nametable + int tx = last_nt_read & 0x1F; + int ty = last_nt_read / 32; + //attribute table address is just these coords shifted + int atx = tx >> 1; + int aty = ty >> 1; + //figure out how we need to shift the attribute to fake out the ppu + int at_shift = ((aty & 1) << 1) + (atx & 1); + at_shift <<= 1; + attribute <<= at_shift; + return (byte)attribute; } } + int nt = (addr >> 10) & 3; // &3 to read from the NT mirrors at 3xxx + int offset = addr & ((1 << 10) - 1); + nt = nt_modes[nt]; + switch (nt) + { + case 0: //NES internal NTA + return NES.CIRAM[offset]; + case 1: //NES internal NTB + return NES.CIRAM[0x400 | offset]; + case 2: //use ExRAM as NT + //TODO - additional r/w security + if (exram_mode >= 2) + return 0; + else + return EXRAM[offset]; + case 3: // Fill Mode + if (offset >= 0x3c0) + return nt_fill_attrib; + else + return nt_fill_tile; + default: throw new Exception(); + } } public override byte PeekPPU(int addr) @@ -354,59 +346,57 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES addr = MapCHR(addr); return (VROM ?? VRAM)[addr]; } + + addr -= 0x2000; + int nt_entry = addr & 0x3FF; + if (nt_entry < 0x3C0) + { + //track the last nametable entry read so that subsequent pattern and attribute reads will know which exram address to use + //last_nt_read = nt_entry; + } else { - addr -= 0x2000; - int nt_entry = addr & 0x3FF; - if (nt_entry < 0x3C0) + //attribute table + if (exram_mode == 1) { - //track the last nametable entry read so that subsequent pattern and attribute reads will know which exram address to use - //last_nt_read = nt_entry; - } - else - { - //attribute table - if (exram_mode == 1) - { - //attribute will be in the top 2 bits of the exram byte - int exram_addr = last_nt_read; - int attribute = EXRAM[exram_addr] >> 6; - //calculate tile address by getting x/y from last nametable - int tx = last_nt_read & 0x1F; - int ty = last_nt_read / 32; - //attribute table address is just these coords shifted - int atx = tx >> 1; - int aty = ty >> 1; - //figure out how we need to shift the attribute to fake out the ppu - int at_shift = ((aty & 1) << 1) + (atx & 1); - at_shift <<= 1; - attribute <<= at_shift; - return (byte)attribute; - } - } - int nt = (addr >> 10) & 3; // &3 to read from the NT mirrors at 3xxx - int offset = addr & ((1 << 10) - 1); - nt = nt_modes[nt]; - switch (nt) - { - case 0: //NES internal NTA - return NES.CIRAM[offset]; - case 1: //NES internal NTB - return NES.CIRAM[0x400 | offset]; - case 2: //use ExRAM as NT - //TODO - additional r/w security - if (exram_mode >= 2) - return 0; - else - return EXRAM[offset]; - case 3: // Fill Mode - if (offset >= 0x3c0) - return nt_fill_attrib; - else - return nt_fill_tile; - default: throw new Exception(); + //attribute will be in the top 2 bits of the exram byte + int exram_addr = last_nt_read; + int attribute = EXRAM[exram_addr] >> 6; + //calculate tile address by getting x/y from last nametable + int tx = last_nt_read & 0x1F; + int ty = last_nt_read / 32; + //attribute table address is just these coords shifted + int atx = tx >> 1; + int aty = ty >> 1; + //figure out how we need to shift the attribute to fake out the ppu + int at_shift = ((aty & 1) << 1) + (atx & 1); + at_shift <<= 1; + attribute <<= at_shift; + return (byte)attribute; } } + int nt = (addr >> 10) & 3; // &3 to read from the NT mirrors at 3xxx + int offset = addr & ((1 << 10) - 1); + nt = nt_modes[nt]; + switch (nt) + { + case 0: //NES internal NTA + return NES.CIRAM[offset]; + case 1: //NES internal NTB + return NES.CIRAM[0x400 | offset]; + case 2: //use ExRAM as NT + //TODO - additional r/w security + if (exram_mode >= 2) + return 0; + else + return EXRAM[offset]; + case 3: // Fill Mode + if (offset >= 0x3c0) + return nt_fill_attrib; + else + return nt_fill_tile; + default: throw new Exception(); + } } public override void WritePPU(int addr, byte value) @@ -442,15 +432,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } } - public override void WriteWRAM(int addr, byte value) - { - WriteWRAMActual(wram_bank, addr & 0x1fff, value); - } + public override void WriteWRAM(int addr, byte value) => WriteWRAMActual(wram_bank, addr & 0x1fff, value); - public override byte ReadWRAM(int addr) - { - return ReadWRAMActual(wram_bank, addr & 0x1fff); - } + public override byte ReadWRAM(int addr) => ReadWRAMActual(wram_bank, addr & 0x1fff); public override byte ReadPRG(int addr) { @@ -472,10 +456,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (addr >= 0x8000) return PeekPRG(addr - 0x8000); - else if (addr >= 0x6000) + if (addr >= 0x6000) return ReadWRAM(addr - 0x6000); - else - return PeekEXP(addr - 0x4000); + return PeekEXP(addr - 0x4000); } public byte PeekPRG(int addr) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/FFE/Mapper017.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/FFE/Mapper017.cs index 4606856e21..a7b79eac34 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/FFE/Mapper017.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/FFE/Mapper017.cs @@ -172,6 +172,5 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { SyncIRQ(irq_pending); } - } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/FS304.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/FS304.cs index 101c1c0307..f0cf13a11c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/FS304.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/FS304.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace BizHawk.Emulation.Cores.Nintendo.NES +namespace BizHawk.Emulation.Cores.Nintendo.NES { public class FS304 : NES.NESBoardBase { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Farid-UNROM-8-in-1.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Farid-UNROM-8-in-1.cs index fdb10c00d0..94c1ae52e2 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Farid-UNROM-8-in-1.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Farid-UNROM-8-in-1.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace BizHawk.Emulation.Cores.Nintendo.NES +namespace BizHawk.Emulation.Cores.Nintendo.NES { public sealed class Farid_UNROM_8_in_1 : NES.NESBoardBase { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MLT-ACTION52.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MLT-ACTION52.cs index 9dc3bf9ac9..143a67a928 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MLT-ACTION52.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MLT-ACTION52.cs @@ -1,83 +1,11 @@ using BizHawk.Common; using BizHawk.Common.NumberExtensions; -using System; +// http://wiki.nesdev.com/w/index.php/INES_Mapper_228 namespace BizHawk.Emulation.Cores.Nintendo.NES { public sealed class MLT_ACTION52 : NES.NESBoardBase { - /* - Here are Disch's original notes: - ======================== - = Mapper 228 = - ======================== - - - Example Games: - -------------------------- - Action 52 - Cheetah Men II - - - Notes: - --------------------------- - Cheetah Men II is infamous for how freaking terrible it is. Action 52 is none better. These games are SO - bad, it's hilarious. - - Action 52's PRG size is weird (not a power of 2 value). This is because there are 3 seperate 512k PRG chips. - PRG Setup section will cover details. - - - Powerup and Reset: - --------------------------- - Apparently the games expect $00 to be written to $8000 on powerup/reset. - - - Registers: - --------------------------- - - $4020-4023: [.... RRRR] RAM (readable/writable) - (16 bits of RAM -- 4 bits in each of the 4 regs) - $4024-5FFF: mirrors $4020-4023 - - $8000-FFFF: [.... ..CC] Low 2 bits of CHR - A~[..MH HPPP PPO. CCCC] - - M = Mirroring (0=Vert, 1=Horz) - H = PRG Chip Select - P = PRG Page Select - O = PRG Mode - C = High 4 bits of CHR - - CHR Setup: - --------------------------- - - $0000 $0400 $0800 $0C00 $1000 $1400 $1800 $1C00 - +---------------------------------------------------------------+ - | $8000 | - +---------------------------------------------------------------+ - - - PRG Setup: - --------------------------- - - 'H' bits select the PRG chip. Each chip is 512k in size. Chip 2 does not exist, and when selected, will - result in open bus. The Action 52 .nes ROM file contains chips 0, 1, and 3: - - chip 0: offset 0x000010 - chip 1: offset 0x080010 - chip 2: -- non existant -- - chip 3: offset 0x100010 - - 'P' selects the PRG page on the currently selected chip. - - $8000 $A000 $C000 $E000 - +-------------------------------+ - PRG Mode 0: | <$8000> | - +-------------------------------+ - PRG Mode 1: | $8000 | $8000 | - +---------------+---------------+ - */ [MapperProp] public bool prg_mode = false; [MapperProp] diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/HKROM.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/HKROM.cs index 23eb8af17a..91aeebdf55 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/HKROM.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/HKROM.cs @@ -111,7 +111,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if (block_enabled) return base.ReadWRAM(addr); - else return 0; + return 0; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/MMC3.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/MMC3.cs index db0bea34ba..03f15b6940 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/MMC3.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/MMC3.cs @@ -13,7 +13,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { //state public int reg_addr; - public bool get_chr_mode { get { return chr_mode; } } // one of the pirate mappers needs this + public bool get_chr_mode => chr_mode; // one of the pirate mappers needs this public bool chr_mode; public bool prg_mode; public ByteBuffer regs = new ByteBuffer(8); @@ -339,7 +339,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void Dispose() { - if(mmc3 != null) mmc3.Dispose(); + mmc3?.Dispose(); } public override void SyncState(Serializer ser) @@ -377,7 +377,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return VROM[addr + extra_vrom]; else return VRAM[addr]; } - else return base.ReadPPU(addr); + + return base.ReadPPU(addr); } public override void WritePPU(int addr, byte value) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper012.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper012.cs index 24214c6344..dedcae7b0e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper012.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper012.cs @@ -30,11 +30,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES int block0, block1; - public override void WritePRG(int addr, byte value) - { - base.WritePRG(addr, value); - } - public override void WriteEXP(int addr, byte value) { base.WriteEXP(addr, value); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper044.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper044.cs index dda7224722..a92224030b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper044.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper044.cs @@ -41,10 +41,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } } - static readonly int[] PRG_AND = new int[] {0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0f }; - static readonly int[] PRG_OR = new int[] { 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x60 }; - static readonly int[] CHR_AND = new int[] { 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7f }; - static readonly int[] CHR_OR = new int[] { 0x000, 0x080, 0x100, 0x180, 0x200, 0x280, 0x300, 0x300 }; + static readonly int[] PRG_AND = {0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0f }; + static readonly int[] PRG_OR = { 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x60 }; + static readonly int[] CHR_AND = { 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7f }; + static readonly int[] CHR_OR = { 0x000, 0x080, 0x100, 0x180, 0x200, 0x280, 0x300, 0x300 }; protected override int Get_PRGBank_8K(int addr) { @@ -57,6 +57,5 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES int bank_1k = base.Get_CHRBank_1K(addr); return (bank_1k & CHR_AND[block_select]) | CHR_OR[block_select]; } - } } \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper049.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper049.cs index 59afd1d5d4..604058dc7d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper049.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper049.cs @@ -57,6 +57,5 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return (base.Get_CHRBank_1K(addr)&0x7F) + block * 128; } - } } \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper052.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper052.cs index e8aab5b12e..2cebd03ecb 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper052.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper052.cs @@ -84,10 +84,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return 0x0F; } - else - { - return 0x1F; - } + + return 0x1F; } private int PRG_OR() @@ -96,10 +94,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return prg_or; } - else - { - return (prg_or & 0x60); - } + + return (prg_or & 0x60); } protected override int MapCHR(int addr) @@ -119,10 +115,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return 0x7F; } - else - { - return 0xFF; - } + + return 0xFF; } private int CHR_OR() @@ -131,10 +125,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return chr_or; } - else - { - return (chr_or & 0x300); - } + + return (chr_or & 0x300); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper074.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper074.cs index f5c2d36e78..da514e8808 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper074.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper074.cs @@ -66,25 +66,25 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return VRAM[addr & 0x03FF]; } - else if (bank == 0x09) + + if (bank == 0x09) { return VRAM[(addr & 0x03FF) + 0x400]; } - else + + addr = MapCHR(addr); + + // Ying Kiong Chuan Qi, no VROM + // Nestopia maps this to mapper 224, perhaps we should do the same instead of attempt to account for this scenario here + if (VROM == null) { - addr = MapCHR(addr); - - // Ying Kiong Chuan Qi, no VROM - // Nestopia maps this to mapper 224, perhaps we should do the same instead of attempt to account for this scenario here - if (VROM == null) - { - return VRAM[addr]; - } - - return VROM[addr]; + return VRAM[addr]; } + + return VROM[addr]; } - else return base.ReadPPU(addr); + + return base.ReadPPU(addr); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper114.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper114.cs index 5786a0042d..5bbe30006b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper114.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper114.cs @@ -1,5 +1,4 @@ using BizHawk.Common; -using System; namespace BizHawk.Emulation.Cores.Nintendo.NES { @@ -98,10 +97,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES var bank = EXPREGS[0] & 0x1F & prg_mask_16; return ROM[(bank << 14) + (addr & 0x3FFF)]; } - else - { - return base.ReadPRG(addr); - } + + return base.ReadPRG(addr); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper187.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper187.cs index f150e98789..1582c41cc5 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper187.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper187.cs @@ -80,13 +80,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return base.ReadEXP(addr); } - private byte MMc3_cmd - { - get - { - return (byte)(mmc3.chr_mode ? 0x80 : 0); - } - } + private byte MMc3_cmd => (byte)(mmc3.chr_mode ? 0x80 : 0); protected override int Get_CHRBank_1K(int addr) { @@ -109,15 +103,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return ROM[((bank >> 2) << 15) + addr]; } - else - { - return ROM[((bank >> 1) << 15) + addr]; // hacky! two mappers in one! need real hw carts to test - } - } - else - { - return ROM[(bank << 14) + (addr & 0x3FFF)]; + + return ROM[((bank >> 1) << 15) + addr]; // hacky! two mappers in one! need real hw carts to test } + + return ROM[(bank << 14) + (addr & 0x3FFF)]; } return base.ReadPRG(addr); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper191.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper191.cs index 40b62d754b..f4f14be8aa 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper191.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper191.cs @@ -1,5 +1,4 @@ -using System; -using BizHawk.Common.NumberExtensions; +using BizHawk.Common.NumberExtensions; namespace BizHawk.Emulation.Cores.Nintendo.NES { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper195.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper195.cs index 0ebe1eaa24..e25eabab99 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper195.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper195.cs @@ -1,6 +1,4 @@ -using System; - -namespace BizHawk.Emulation.Cores.Nintendo.NES +namespace BizHawk.Emulation.Cores.Nintendo.NES { public sealed class Mapper195 : MMC3Board_Base { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper195_CW.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper195_CW.cs index 60d113fe43..3215ba1f40 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper195_CW.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper195_CW.cs @@ -1,4 +1,4 @@ -using System; + // This is a modified 195 board specifically for Chaos World (CH) // It is a Work in Progress // Save Ram is broken and the game will not load with save ram written through this mapper diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper196.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper196.cs index 4fdd8ce17c..3cbe10fd78 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper196.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper196.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using BizHawk.Common; namespace BizHawk.Emulation.Cores.Nintendo.NES diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper198.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper198.cs index c89c0a5c00..bc313daeea 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper198.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper198.cs @@ -1,6 +1,4 @@ -using BizHawk.Common; - -namespace BizHawk.Emulation.Cores.Nintendo.NES +namespace BizHawk.Emulation.Cores.Nintendo.NES { public class Mapper198 : MMC3Board_Base { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper215.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper215.cs index fe37155ab2..55bccaf229 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper215.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper215.cs @@ -1,5 +1,4 @@ using BizHawk.Common; -using System; namespace BizHawk.Emulation.Cores.Nintendo.NES { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper217.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper217.cs index 5510b72bf1..2e7f1c5e6a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper217.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper217.cs @@ -1,5 +1,4 @@ using BizHawk.Common; -using BizHawk.Common.NumberExtensions; namespace BizHawk.Emulation.Cores.Nintendo.NES { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper219.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper219.cs index 306dc183f3..1a38b8cba3 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper219.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper219.cs @@ -1,5 +1,4 @@ -using System; -using BizHawk.Common; +using BizHawk.Common; namespace BizHawk.Emulation.Cores.Nintendo.NES { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper223.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper223.cs index 4175440a11..f2af9de55f 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper223.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper223.cs @@ -1,6 +1,4 @@ -using BizHawk.Common; - -namespace BizHawk.Emulation.Cores.Nintendo.NES +namespace BizHawk.Emulation.Cores.Nintendo.NES { // TODO public sealed class Mapper223 : MMC3Board_Base diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper245.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper245.cs index c139cb7770..b58c9fb67f 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper245.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Mapper245.cs @@ -1,6 +1,5 @@ using BizHawk.Common; using BizHawk.Common.NumberExtensions; -using System; namespace BizHawk.Emulation.Cores.Nintendo.NES { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Pocahontas.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Pocahontas.cs index 03f47bafea..58c53216d9 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Pocahontas.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/Pocahontas.cs @@ -1,5 +1,4 @@ using BizHawk.Common; -using System; namespace BizHawk.Emulation.Cores.Nintendo.NES { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/RexSoftSL1632.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/RexSoftSL1632.cs index 4dc315a931..9e8cee9ab7 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/RexSoftSL1632.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/RexSoftSL1632.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using BizHawk.Common; -using BizHawk.Common.NumberExtensions; +using BizHawk.Common.NumberExtensions; namespace BizHawk.Emulation.Cores.Nintendo.NES { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TLSROM.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TLSROM.cs index 6a665045ec..a8878d7582 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TLSROM.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TLSROM.cs @@ -1,6 +1,4 @@ -using System; using BizHawk.Common; -using BizHawk.Common.NumberExtensions; namespace BizHawk.Emulation.Cores.Nintendo.NES { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TxROM.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TxROM.cs index b6fefb3402..4df800e8e2 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TxROM.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TxROM.cs @@ -25,12 +25,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } } - - public override void SyncState(Serializer ser) - { - base.SyncState(ser); - } - public override bool Configure(NES.EDetectionOrigin origin) { //analyze board type @@ -125,8 +119,5 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return true; } - } - - } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper015.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper015.cs index 62aeae6a9b..679aa607e5 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper015.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper015.cs @@ -1,6 +1,5 @@ using BizHawk.Common; using BizHawk.Common.NumberExtensions; -using System; namespace BizHawk.Emulation.Cores.Nintendo.NES { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper029.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper029.cs index e94624f7f3..dbc179a403 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper029.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper029.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace BizHawk.Emulation.Cores.Nintendo.NES +namespace BizHawk.Emulation.Cores.Nintendo.NES { // what is this? public class Mapper029 : NES.NESBoardBase diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper030.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper030.cs index a5296db020..24e4e99ff2 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper030.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper030.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Text; using BizHawk.Common; namespace BizHawk.Emulation.Cores.Nintendo.NES @@ -221,14 +219,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return ROM[bank << 14 | addr & 0x3fff]; } - public override byte[] SaveRam { get { return flash_rom; } } + public override byte[] SaveRam => flash_rom; public override byte ReadPPU(int addr) { if (addr < 0x2000) return VRAM[addr | chr << 13]; - else - return base.ReadPPU(addr); + return base.ReadPPU(addr); } public override void WritePPU(int addr, byte value) { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper034.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper034.cs index 05173bf5a2..9881e11681 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper034.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper034.cs @@ -1,7 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using BizHawk.Common; namespace BizHawk.Emulation.Cores.Nintendo.NES diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper043.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper043.cs index eae264daff..a5502edecc 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper043.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper043.cs @@ -1,5 +1,4 @@ -using System; -using BizHawk.Common; +using BizHawk.Common; namespace BizHawk.Emulation.Cores.Nintendo.NES { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper053.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper053.cs index 6abfd9e928..22abe47c62 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper053.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper053.cs @@ -9,7 +9,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES private byte _reg0; private byte _reg1; - private bool Prg16kMode { get { return _reg0.Bit(4); } } + private bool Prg16kMode => _reg0.Bit(4); public override bool Configure(NES.EDetectionOrigin origin) { @@ -88,7 +88,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES private byte _reg0; private byte _reg1; - private bool Prg16kMode { get { return _reg0.Bit(4); } } + private bool Prg16kMode => _reg0.Bit(4); public override bool Configure(NES.EDetectionOrigin origin) { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper058.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper058.cs index 6167a25e02..b0299a79d8 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper058.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper058.cs @@ -1,43 +1,11 @@ using BizHawk.Common; using BizHawk.Common.NumberExtensions; +// http://wiki.nesdev.com/w/index.php/INES_Mapper_058 namespace BizHawk.Emulation.Cores.Nintendo.NES { public sealed class Mapper058 : NES.NESBoardBase { - /* - * Here are Disch's original notes: - ======================== - = Mapper 058 = - ======================== - - Example Games: - -------------------------- - 68-in-1 (Game Star) - Study and Game 32-in-1 - - - Registers: - --------------------------- - - $8000-FFFF: A~[.... .... MOCC CPPP] - P = PRG page select - C = CHR page select (8k @ $0000) - O = PRG Mode - M = Mirroring (0=Vert, 1=Horz) - - - PRG Setup: - --------------------------- - - $8000 $A000 $C000 $E000 - +-------------------------------+ - PRG Mode 0: | <$8000> | - +-------------------------------+ - PRG Mode 1: | $8000 | $8000 | - +---------------+---------------+ - */ - bool prg_mode = false; int chr_reg; int prg_reg; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper063.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper063.cs index cd0a062a47..73aa648de6 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper063.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper063.cs @@ -1,5 +1,4 @@ -using System; -using BizHawk.Common; +using BizHawk.Common; namespace BizHawk.Emulation.Cores.Nintendo.NES { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper090.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper090.cs index 1b0246b699..87f2225bbe 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper090.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper090.cs @@ -1,5 +1,4 @@ -using System; -using BizHawk.Common; +using BizHawk.Common; using BizHawk.Common.NumberExtensions; namespace BizHawk.Emulation.Cores.Nintendo.NES diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper091.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper091.cs index 8a882247be..968220925f 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper091.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper091.cs @@ -47,7 +47,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { prg_regs_8k.Dispose(); chr_regs_2k.Dispose(); - if(mmc3 != null) mmc3.Dispose(); + mmc3?.Dispose(); base.Dispose(); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper168.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper168.cs index 99ec6833db..f41057fc51 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper168.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper168.cs @@ -35,10 +35,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override byte ReadPRG(int addr) { - if (addr >= 0x4000) - return ROM[addr + 0x8000]; - else - return ROM[addr + (prg << 14)]; + return addr >= 0x4000 + ? ROM[addr + 0x8000] + : ROM[addr + (prg << 14)]; } // the chr reg on hardware is supposedly bitscrambled and then inverted from @@ -66,10 +65,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (addr < 0x1000) return VRAM[addr | Scramble(0) << 12]; - else if (addr < 0x2000) + if (addr < 0x2000) return VRAM[(addr & 0xfff) | Scramble(chr) << 12]; - else - return base.ReadPPU(addr); + return base.ReadPPU(addr); } public override void WritePPU(int addr, byte value) @@ -82,7 +80,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES base.WritePPU(addr, value); } - public override byte[] SaveRam { get { return VRAM; } } + public override byte[] SaveRam => VRAM; public override void SyncState(Serializer ser) { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper183.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper183.cs index cf5551146a..cac17c2453 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper183.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper183.cs @@ -1,6 +1,5 @@ using BizHawk.Common; using BizHawk.Common.NumberExtensions; -using System; namespace BizHawk.Emulation.Cores.Nintendo.NES { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper188.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper188.cs index dd37801bd2..b88e89ae81 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper188.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper188.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using BizHawk.Common; +using BizHawk.Common; namespace BizHawk.Emulation.Cores.Nintendo.NES { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper190.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper190.cs index 5e17d8b56c..1d1364fa4b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper190.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper190.cs @@ -1,6 +1,4 @@ using BizHawk.Common; -using BizHawk.Common.NumberExtensions; -using System; namespace BizHawk.Emulation.Cores.Nintendo.NES { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper200.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper200.cs index 063cac6307..9139a179b9 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper200.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper200.cs @@ -1,48 +1,11 @@ using BizHawk.Common; using BizHawk.Common.NumberExtensions; +// https://wiki.nesdev.com/w/index.php/INES_Mapper_200 namespace BizHawk.Emulation.Cores.Nintendo.NES { public sealed class Mapper200 : NES.NESBoardBase { - /* - Here are Disch's original notes: - ======================== - = Mapper 200 = - ======================== - - Example Games: - -------------------------- - 1200-in-1 - 36-in-1 - - - Registers: - --------------------------- - - - $8000-FFFF: A~[.... .... .... MRRR] - M = Mirroring (0=Vert, 1=Horz) - R = PRG/CHR Reg - - - CHR Setup: - --------------------------- - - $0000 $0400 $0800 $0C00 $1000 $1400 $1800 $1C00 - +---------------------------------------------------------------+ - | $8000 | - +---------------------------------------------------------------+ - - - PRG Setup: - --------------------------- - - $8000 $A000 $C000 $E000 - +---------------+---------------+ - | $8000 | $8000 | - +---------------+---------------+ - */ int prg_reg_16k, chr_reg_8k; int prg_bank_mask_16k; int chr_bank_mask_8k; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper201.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper201.cs index f5594f9bcb..48549976fa 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper201.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper201.cs @@ -1,47 +1,10 @@ using BizHawk.Common; +// https://wiki.nesdev.com/w/index.php/INES_Mapper_201 namespace BizHawk.Emulation.Cores.Nintendo.NES { public sealed class Mapper201 : NES.NESBoardBase { - /* - Here are Disch's original notes: - ======================== - = Mapper 201 = - ======================== - - Example Games: - -------------------------- - 8-in-1 - 21-in-1 (2006-CA) (Unl) - - - Registers: - --------------------------- - - - $8000-FFFF: A~[.... .... RRRR RRRR] - R = PRG/CHR Reg - - - CHR Setup: - --------------------------- - - $0000 $0400 $0800 $0C00 $1000 $1400 $1800 $1C00 - +---------------------------------------------------------------+ - | $8000 | - +---------------------------------------------------------------+ - - - PRG Setup: - --------------------------- - - $8000 $A000 $C000 $E000 - +-------------------------------+ - | $8000 | - +-------------------------------+ - */ - public int reg; public int prg_bank_mask_32k; public int chr_bank_mask_8k; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper203.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper203.cs index cb7f07e21a..434e460b5c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper203.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper203.cs @@ -1,47 +1,10 @@ using BizHawk.Common; +// https://wiki.nesdev.com/w/index.php/INES_Mapper_203 namespace BizHawk.Emulation.Cores.Nintendo.NES { public sealed class Mapper203 : NES.NESBoardBase { - /* - Here are Disch's original notes: - ======================== - = Mapper 203 = - ======================== - - Example Games: - -------------------------- - 35-in-1 - - - Registers: - --------------------------- - - - $8000-FFFF: [PPPP PPCC] - P = PRG Reg - C = CHR Reg - - - CHR Setup: - --------------------------- - - $0000 $0400 $0800 $0C00 $1000 $1400 $1800 $1C00 - +---------------------------------------------------------------+ - | $8000 | - +---------------------------------------------------------------+ - - - PRG Setup: - --------------------------- - - $8000 $A000 $C000 $E000 - +---------------+---------------+ - | $8000 | $8000 | - +---------------+---------------+ - */ - int prg_reg_16k, chr_reg_8k; int prg_bank_mask_16k; int chr_bank_mask_8k; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper222.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper222.cs index 8747abf6f4..36e0655218 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper222.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper222.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using BizHawk.Common; using BizHawk.Common.NumberExtensions; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper230.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper230.cs index a271b134fa..057ef5fc35 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper230.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper230.cs @@ -1,72 +1,12 @@ using BizHawk.Common; using BizHawk.Common.NumberExtensions; +// http://wiki.nesdev.com/w/index.php/INES_Mapper_230 namespace BizHawk.Emulation.Cores.Nintendo.NES { public sealed class Mapper230 : NES.NESBoardBase { - /* - * Here are Disch's original notes: - ======================== - = Mapper 230 = - ======================== - - Example Game: - -------------------------- - 22-in-1 - - - Reset Driven: - --------------------------- - The mapper has 2 main modes: Contra mode, and multicart mode. Performing a Soft Reset switches between - them. - - - Notes: - --------------------------- - - This multicart has an odd PRG size (not power of 2). This is because there are 2 PRG chips. - The first is 128k and contains Contra, the other is 512k and contains the multicart. - - A soft reset changes which chip is used as well as other stuff relating to the mode - - - Registers: - --------------------------- - - - Contra Mode $8000-FFFF: [.... .PPP] - - Multicart Mode $8000-FFFF: [.MOP PPPP] - - M = Mirroring (0=Horz, 1=Vert) - O = PRG Mode - P = PRG Page - - Note: - Mirroring is always Vert in Contra Mode. - - - - PRG Setup: - --------------------------- - - $8000 $A000 $C000 $E000 - +---------------+---------------+ - Contra Mode: | $8000 | { 7 } | <--- use chip 0 - +-------------------------------+ - Multi Mode 0: | | <--- use chip 1 - +-------------------------------+ - Multi Mode 1: | Reg | Reg | <--- use chip 1 - +---------------+---------------+ - - - chip 0 = 128k PRG (offset 0x00010-0x2000F) - chip 1 = 512k PRG (offset 0x20010-0xA000F) - */ - //TODO: soft reset back to contra = fails - public int prg_page; public bool prg_mode; public bool contra_mode; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper231.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper231.cs index 3233fe7de9..1ba1b0c1bc 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper231.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper231.cs @@ -1,43 +1,11 @@ using BizHawk.Common; using BizHawk.Common.NumberExtensions; +// http://wiki.nesdev.com/w/index.php/INES_Mapper_231 namespace BizHawk.Emulation.Cores.Nintendo.NES { public sealed class Mapper231 : NES.NESBoardBase { - /* - * Here are Disch's original notes: - ======================== - = Mapper 231 = - ======================== - - Example Game: - -------------------------- - 20-in-1 - - - - Registers: - --------------------------- - - $8000-FFFF: A~[.... .... M.LP PPP.] - M = Mirroring (0=Vert, 1=Horz) - L = Low bit of PRG - P = High bits of PRG - - - - PRG Setup: - --------------------------- - - Note that 'L' and 'P' bits make up the PRG reg, and the 'L' is the low bit. - - - $8000 $A000 $C000 $E000 - +---------------+---------------+ - | $8000 AND $1E | $8000 | - +---------------+---------------+ - */ public int prg_reg; public int prg_bank_mask_16k; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper233.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper233.cs index 367526136d..1d7abea274 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper233.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper233.cs @@ -1,68 +1,11 @@ using BizHawk.Common; using BizHawk.Common.NumberExtensions; +// http://wiki.nesdev.com/w/index.php/INES_Mapper_233 namespace BizHawk.Emulation.Cores.Nintendo.NES { public sealed class Mapper233 : NES.NESBoardBase { - /* - Here are Disch's original notes: - ======================== - = Mapper 233 = - ======================== - - - Example Game: - -------------------------- - ???? "42-in-1" ???? - - - Notes: - --------------------------- - Sources report this mapper as "42-in-1" with description layed out below. I did not test this, - since I could not find a copy of the ROM in question. The only ROM I have that's marked as - 233 is "Unknown Multicart 1", and it does *not* follow the description in this doc at all. - - There is a "Super 42-in-1"... but that is mapper 226. 226, by the way, is strikingly similar - to the below description. I wonder if below description really applies to 233? - - - - Registers: - --------------------------- - - $8000-FFFF: [MMOP PPPP] - M = Mirroring - O = PRG Mode - P = PRG Page - - - PRG Setup: - --------------------------- - - $8000 $A000 $C000 $E000 - +-------------------------------+ - PRG Mode 0: | <$8000> | - +-------------------------------+ - PRG Mode 1: | $8000 | $8000 | - +---------------+---------------+ - - - Mirroring: - --------------------------- - - 'M' mirroring bits: - %00 = See below - %01 = Vert - %10 = Horz - %11 = 1ScB - - - Mode %00 (almost, but not quite 1ScA): - [ NTA ][ NTA ] - [ NTA ][ NTB ] - */ - public int prg_page; public bool prg_mode; @@ -116,10 +59,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return ROM[((prg_page >> 1) * 0x8000) + addr]; } - else - { - return ROM[(prg_page * 0x4000) + (addr & 0x3FFF)]; - } + + return ROM[(prg_page * 0x4000) + (addr & 0x3FFF)]; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper242.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper242.cs index 38989c8956..837d7ec9b8 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper242.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper242.cs @@ -31,7 +31,7 @@ mirroring - both default: return false; } - SetMirrorType(NES.NESBoardBase.EMirrorType.Vertical); + SetMirrorType(EMirrorType.Vertical); return true; } @@ -46,10 +46,7 @@ mirroring - both //fceux had different logic here for the mirroring, but that didnt match with experiments on dragon quest 8 nor disch's docs //i changed it at the same time bool mirror = addr.Bit(1); - if (mirror) - SetMirrorType(NES.NESBoardBase.EMirrorType.Horizontal); - else - SetMirrorType(NES.NESBoardBase.EMirrorType.Vertical); + SetMirrorType(mirror ? EMirrorType.Horizontal : EMirrorType.Vertical); } public override void SyncState(Serializer ser) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper246.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper246.cs index da6e5b5724..0dfb0f40e9 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper246.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper246.cs @@ -1,63 +1,10 @@ using BizHawk.Common; +// http://wiki.nesdev.com/w/index.php/INES_Mapper_246 namespace BizHawk.Emulation.Cores.Nintendo.NES { public sealed class Mapper246 : NES.NESBoardBase { - /* - Here are Disch's original notes: - ======================== - = Mapper 246 = - ======================== - - - Example Game: - -------------------------- - Fong Shen Bang - Zhu Lu Zhi Zhan - - - Notes: - -------------------------- - - Regs lie at $6000-67FF, but SRAM exists at $6800-7FFF. - - Don't know if there's only 6k of SRAM, or if there's 8k, but the first 2k is inaccessable. I find the latter - more likely. - - - Registers: - --------------------------- - - Range,Mask: $6000-67FF, $6007 - - - $6000-6003: PRG Regs - $6004-6007: CHR Regs - - - CHR Setup: - --------------------------- - - $0000 $0400 $0800 $0C00 $1000 $1400 $1800 $1C00 - +---------------+---------------+---------------+---------------+ - | $6004 | $6005 | $6006 | $6007 | - +---------------+---------------+---------------+---------------+ - - - PRG Setup: - --------------------------- - - $8000 $A000 $C000 $E000 - +-------+-------+-------+-------+ - | $6000 | $6001 | $6002 | $6003 | - +-------+-------+-------+-------+ - - - Powerup/Reset: - --------------------------- - $6003 set to $FF on powerup (and probably reset, but not sure). - */ - int prg_bank_mask_8k; ByteBuffer prg_banks_8k = new ByteBuffer(4); @@ -149,10 +96,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES addr = ApplyMemoryMap(11, chr_banks_2k, addr); return base.ReadPPUChr(addr); } - else - { - return base.ReadPPU(addr); - } + + return base.ReadPPU(addr); } public override byte ReadPRG(int addr) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper252.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper252.cs index 88de5db5fc..24eb6033a6 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper252.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper252.cs @@ -1,6 +1,5 @@ using BizHawk.Common; using BizHawk.Common.NumberExtensions; -using System; namespace BizHawk.Emulation.Cores.Nintendo.NES { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper60.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper60.cs index aac8e1b7a4..18579bca8d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper60.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper60.cs @@ -1,5 +1,4 @@ -using System; -using BizHawk.Common; +using BizHawk.Common; using BizHawk.Common.NumberExtensions; namespace BizHawk.Emulation.Cores.Nintendo.NES @@ -9,7 +8,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES // http://wiki.nesdev.com/w/index.php/INES_Mapper_060 private int _reg; - private bool IsPrg16Mode { get { return _reg.Bit(7); } } + private bool IsPrg16Mode => _reg.Bit(7); [MapperProp] public int Mapper60_DipSwitch; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper61.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper61.cs index 2fd0a4841c..b0f0dafe3b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper61.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper61.cs @@ -1,44 +1,11 @@ using BizHawk.Common; using BizHawk.Common.NumberExtensions; +// http://wiki.nesdev.com/w/index.php/INES_Mapper_061 namespace BizHawk.Emulation.Cores.Nintendo.NES { public sealed class Mapper61 : NES.NESBoardBase { - /* - * Here are Disch's original notes: - ======================== - = Mapper 061 = - ======================== - - Example Game: - -------------------------- - 20-in-1 - - - Registers: - --------------------------- - - $8000-FFFF: A~[.... .... M.LO HHHH] - H = High 4 bits of PRG Reg - L = Low bit of PRG Reg - O = PRG Mode - M = Mirroring (0=Vert, 1=Horz) - - - PRG Setup: - --------------------------- - - PRG Reg is 5 bits -- combination of 'H' and 'L' bits. - - $8000 $A000 $C000 $E000 - +-------------------------------+ - PRG Mode 0: | <$8000> | - +-------------------------------+ - PRG Mode 1: | $8000 | $8000 | - +---------------+---------------+ - */ - public int prg_page; public bool prg_mode; public int prg_byte_mask; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper62.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper62.cs index fe6e7ede65..f9ea67b83b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper62.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper62.cs @@ -1,50 +1,11 @@ using BizHawk.Common; using BizHawk.Common.NumberExtensions; +// http://wiki.nesdev.com/w/index.php/INES_Mapper_062 namespace BizHawk.Emulation.Cores.Nintendo.NES { public sealed class Mapper62 : NES.NESBoardBase { - /* - Here are Disch's original notes: - ======================== - = Mapper 062 = - ======================== - - Example Game: - -------------------------- - Super 700-in-1 - - - Registers: - --------------------------- - - $8000-FFFF: A~[..pp pppp MPOC CCCC] - [.... ..cc] - p = Low bits of PRG Reg - P = High bit of PRG Reg - c = Low bits of CHR Reg - C = High bits of CHR Reg - O = PRG Mode - M = Mirroring (0=Vert, 1=Horz) - - - PRG Setup: - --------------------------- - - - $8000 $A000 $C000 $E000 - +-------------------------------+ - PRG Mode 0: | <$8000> | - +-------------------------------+ - PRG Mode 1: | $8000 | $8000 | - +---------------+---------------+ - - - CHR Setup: - ---------------------------- - 'C' and 'c' select an 8k page @ $0000 - */ bool prg_mode = false; int chr_reg; int prg_reg; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NES-EVENT.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NES-EVENT.cs index c222b0e32b..1704390f1f 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NES-EVENT.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NES-EVENT.cs @@ -1,119 +1,8 @@ -#region Disch's Notes -/* - * Here are Disch's original notes: - ======================== - = Mapper 105 = - ======================== - - aka - -------------------------- - NES-EVENT - - - Example Game: - -------------------------- - Nintendo World Championships 1990 - - - Notes: - --------------------------- - This mapper is an MMC1 with crazy wiring and a huge 30-bit CPU cycle driven IRQ counter. Registers are all - internal and not directly accessable -- and the latch must be written to 1 bit at a time -- just like on a - normal MMC1. For details on how regs are written to, see mapper 001. - - This mapper has 8k CHR-RAM, and it is not swappable. - - - Registers: - --------------------------- - - Note that like a normal MMC1, registers are internal and not accessed directly. - - - $8000-9FFF: [.... PSMM] Same as MMC1 (but CHR mode bit isn't used) - - $A000-BFFF: [...I OAA.] - I = IRQ control / initialization toggle - O = PRG Mode/Chip select - A = PRG Reg 'A' - - $C000-DFFF: [.... ....] Unused - - $E000-FFFF: [...W BBBB] - W = WRAM disable (same as MMC1) - B = PRG Reg 'B' - - - - Powerup / Reset / Initialization: - --------------------------- - - On powerup and reset, the first 32k of PRG (from the first PRG chip) is selected at $8000 *no matter what*. - PRG cannot be swapped until the mapper has been "initialized" by setting the 'I' bit to 0, then to '1'. This - toggling will "unlock" PRG swapping on the mapper. - - Note 'I' also controls the IRQ counter (see below) - - - PRG Setup: - --------------------------- - - There are 2 PRG chips, each 128k. The 'O' bit selects between the chips, and also determines which PRG Reg - is used to select the page. - - O=0: Use first PRG chip (first 128k), use 'A' PRG Reg, 32k swap - O=1: Use second PRG chip (second 128k), use 'B' PRG Reg, MMC1 style swap - - In addition, if the mapper has not been "unlocked", the first 32k of the first chip is always selected - regardless (as if $A000 contained $00). - - Modes as listed below: - - $8000 $A000 $C000 $E000 - +-------------------------------+ - Uninitialized: | { 0 } | <-- use first 128k - +-------------------------------+ - O=0: | $A000 | <-- use first 128k - +-------------------------------+ - O=1, P=0: | <$E000> | <-- use second 128k - +-------------------------------+ - O=1, P=1, S=0: | { 0 } | $E000 | <-- use second 128k - +---------------+---------------+ - O=1, P=1, S=1: | $E000 | {$07} | <-- use second 128k - +---------------+---------------+ - - - - - IRQ Counter: - --------------------------- - - The 'I' bit in $A000 controls the IRQ counter. When cleared, the IRQ counter counts up every cycle. When - set, the IRQ counter is reset to 0 and stays there (does not count), and the pending IRQ is acknowledged. - - The cart has 4 dipswitches which control how high the counter must reach for an IRQ to be generated. - - The IRQ counter is 30 bits wide.. when it reaches the following value, an IRQ is fired: - - [1D CBAx xxxx xxxx xxxx xxxx xxxx xxxx] - ^ ^^^ - | ||| - either 0 or 1, depending on the corresponding dipswitch. - - So if all dipswitches are open (use '0' above), the counter must reach $20000000. - If all dipswitches are closed (use '1' above), the counter must reach $3E000000. - etc - - In the official tournament, 'C' was closed, and the others were open, so the counter had to reach $2800000. - */ -#endregion - -using System.Collections.Generic; -using System.Linq; - +using System.Collections.Generic; using BizHawk.Common; using BizHawk.Common.NumberExtensions; +// https://wiki.nesdev.com/w/index.php/INES_Mapper_105 namespace BizHawk.Emulation.Cores.Nintendo.NES { //AKA mapper 105 @@ -150,19 +39,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES [MapperProp] public bool Dipswitch4 = false; - private List Switches - { - get + private List Switches => + new List { - return new List - { - { Dipswitch1 }, - { Dipswitch2 }, - { Dipswitch3 }, - { Dipswitch4 } - }; - } - } + { Dipswitch1 }, + { Dipswitch2 }, + { Dipswitch3 }, + { Dipswitch4 } + }; public int IrqDestination { @@ -233,9 +117,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES SetMirrorType(EMirrorType.Vertical); - scnt = new MMC1.MMC1_SerialController(); - scnt.WriteRegister = SerialWriteRegister; - scnt.Reset = SerialReset; + scnt = new MMC1.MMC1_SerialController + { + WriteRegister = SerialWriteRegister, + Reset = SerialReset + }; InitValues(); @@ -297,11 +183,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES prg_banks_16k[1] &= prg_bank_mask_16k; } - public override void WritePPU(int addr, byte value) - { - base.WritePPU(addr, value); - } - void SerialWriteRegister(int addr, int value) { switch (addr) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NROM.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NROM.cs index 8e74c6767b..17a50c06fc 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NROM.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NROM.cs @@ -1,5 +1,3 @@ -using System; - namespace BizHawk.Emulation.Cores.Nintendo.NES { [NES.INESBoardImplPriority] diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NSFBoard.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NSFBoard.cs index bbc752cd2a..930ad514a3 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NSFBoard.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NSFBoard.cs @@ -360,11 +360,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return 0; } - public override byte ReadWRAM(int addr) - { - return base.ReadWRAM(addr); - } - public override byte ReadPRG(int addr) { //patch in vector reading diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot175_340.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot175_340.cs index 45f192721b..677a8ec5a9 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot175_340.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot175_340.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using BizHawk.Common; +using BizHawk.Common; using BizHawk.Common.NumberExtensions; namespace BizHawk.Emulation.Cores.Nintendo.NES diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/DRROM.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/DRROM.cs index 9edd0dbff4..e917a5dd69 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/DRROM.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/DRROM.cs @@ -54,5 +54,4 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES else base.WritePPU(addr, value); } } - } \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper076.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper076.cs index 89a3f3b548..91aa4b66ae 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper076.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper076.cs @@ -1,7 +1,5 @@ -using System; using BizHawk.Common; - namespace BizHawk.Emulation.Cores.Nintendo.NES { // aka NAMCOT-3446 @@ -71,8 +69,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (addr < 0x2000) return VROM[addr & 0x7ff | chr[addr >> 11] << 11]; - else - return base.ReadPPU(addr); + return base.ReadPPU(addr); } public override void SyncState(Serializer ser) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper088.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper088.cs index fed1acc9d7..953494cb83 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper088.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper088.cs @@ -13,7 +13,6 @@ Consequently, CHR is split into two halves. $0xxx can only have CHR from the first 64K, $1xxx can only have CHR from the second 64K. */ - public sealed class Mapper088 : Namcot108Board_Base { //configuration diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper154.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper154.cs index 516fda5db3..ed317e3c88 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper154.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper154.cs @@ -1,5 +1,4 @@ -using BizHawk.Common; -using BizHawk.Common.NumberExtensions; +using BizHawk.Common.NumberExtensions; namespace BizHawk.Emulation.Cores.Nintendo.NES { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper206.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper206.cs index d0c63f89c4..b5e2d2f3bc 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper206.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper206.cs @@ -1,5 +1,3 @@ -using System; - namespace BizHawk.Emulation.Cores.Nintendo.NES { //various japanese Namcot108 boards plus DEROM @@ -79,7 +77,5 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return true; } - } - } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Namco163Audio.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Namco163Audio.cs index a3f51e1e3d..a1098050fe 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Namco163Audio.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Namco163Audio.cs @@ -1,7 +1,5 @@ using System; - using BizHawk.Common; -using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Nintendo.NES { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Namcot1xx.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Namcot1xx.cs index d2fff1a5ac..944961677b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Namcot1xx.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Namcot1xx.cs @@ -95,7 +95,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } } - public abstract class Namcot108Board_Base : NES.NESBoardBase { //state @@ -110,13 +109,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES // security reading index for tko boxing int tko_security = 0; - static byte[] TKO = new byte[] { 0xFF, 0xBF, 0xB7, 0x97, 0x97, 0x17, 0x57, 0x4F, 0x6F, 0x6B, 0xEB, 0xA9, 0xB1, 0x90, 0x94, 0x14, + static byte[] TKO = { 0xFF, 0xBF, 0xB7, 0x97, 0x97, 0x17, 0x57, 0x4F, 0x6F, 0x6B, 0xEB, 0xA9, 0xB1, 0x90, 0x94, 0x14, 0x56, 0x4E, 0x6F, 0x6B, 0xEB, 0xA9, 0xB1, 0x90, 0xD4, 0x5C, 0x3E, 0x26, 0x87, 0x83, 0x13, 0x51}; public override void Dispose() { - if(mapper != null) - mapper.Dispose(); + mapper?.Dispose(); } public override void SyncState(Serializer ser) @@ -156,27 +154,24 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES addr &= chr_byte_mask; return VROM[addr]; } - else return VRAM[addr]; + + return VRAM[addr]; } - else + + if (NES._isVS) { - if (NES._isVS) + addr = addr - 0x2000; + if (addr < 0x800) { - addr = addr - 0x2000; - if (addr < 0x800) - { - return NES.CIRAM[addr]; - } - else - { - return CIRAM_VS[addr - 0x800]; - } + return NES.CIRAM[addr]; } - else - return base.ReadPPU(addr); - } + + return CIRAM_VS[addr - 0x800]; } + return base.ReadPPU(addr); + } + public override void WritePPU(int addr, byte value) { if (addr < 0x2000) @@ -228,80 +223,77 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (!NES._isVS) return base.ReadEXP(addr); + + if (Cart.vs_security == 16) + { + addr += 0x4000; + if (addr == 0x54FF) + return 0x05; + else if (addr == 0x5678) + { + if (NES.cpu.X == 0x0C) + return 0; + else + return 1; + } + + else if (addr == 0x578F) + { + if (NES.cpu.X == 0x0C) + return 0xD1; + else + return 0x89; + } + else if (addr == 0x5567) + { + if (NES.cpu.X == 0x0C) + return 0x3E; + else + return 0x37; + } + + else + return base.ReadEXP(addr - 0x4000); + } + else if (Cart.vs_security==32) + { + if (addr==0x1E00) + { + tko_security = 0; + return 0xAA; //not used?? + } + if (addr == 0x1E01) + { + tko_security++; + return TKO[tko_security - 1]; + } + return NES.DB; + } + else if (Cart.vs_security == 48) + { + if (addr == 0x1E00) + { + tko_security = 0; + return 0xAA; //not used?? + } + if (addr == 0x1E01) + { + if (tko_security==4) + { + return 0xB4; + } + if (tko_security == 9) + { + return 0x6F; + } + tko_security++; + return NES.DB; + } + return NES.DB; + } else { - - if (Cart.vs_security == 16) - { - addr += 0x4000; - if (addr == 0x54FF) - return 0x05; - else if (addr == 0x5678) - { - if (NES.cpu.X == 0x0C) - return 0; - else - return 1; - } - - else if (addr == 0x578F) - { - if (NES.cpu.X == 0x0C) - return 0xD1; - else - return 0x89; - } - else if (addr == 0x5567) - { - if (NES.cpu.X == 0x0C) - return 0x3E; - else - return 0x37; - } - - else - return base.ReadEXP(addr - 0x4000); - } - else if (Cart.vs_security==32) - { - if (addr==0x1E00) - { - tko_security = 0; - return 0xAA; //not used?? - } - if (addr == 0x1E01) - { - tko_security++; - return TKO[tko_security - 1]; - } - return NES.DB; - } - else if (Cart.vs_security == 48) - { - if (addr == 0x1E00) - { - tko_security = 0; - return 0xAA; //not used?? - } - if (addr == 0x1E01) - { - if (tko_security==4) - { - return 0xB4; - } - if (tko_security == 9) - { - return 0x6F; - } - tko_security++; - return NES.DB; - } - return NES.DB; - } - else - { - return NES.DB; - } + return NES.DB; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sachen8259.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sachen8259.cs index 8444e8a7bf..9deec3db7e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sachen8259.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sachen8259.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using BizHawk.Common; +using BizHawk.Common; using BizHawk.Common.NumberExtensions; namespace BizHawk.Emulation.Cores.Nintendo.NES diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SachenSimple.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SachenSimple.cs index 1cbfcfe8d9..fc1707b727 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SachenSimple.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SachenSimple.cs @@ -89,8 +89,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void WritePRG(int addr, byte value) { - if (PrgWrite != null) - PrgWrite(value); + PrgWrite?.Invoke(value); } public override byte ReadPRG(int addr) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft1_Alt.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft1_Alt.cs index 2a690fb454..3051ec27d8 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft1_Alt.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft1_Alt.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace BizHawk.Emulation.Cores.Nintendo.NES +namespace BizHawk.Emulation.Cores.Nintendo.NES { /* * Fantasy Zone (J, NOT TENGEN) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft2_m93.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft2_m93.cs index e577b11123..a0abe684c8 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft2_m93.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Sunsoft2_m93.cs @@ -1,5 +1,4 @@ -using System; -using BizHawk.Common; +using BizHawk.Common; namespace BizHawk.Emulation.Cores.Nintendo.NES { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SxROM.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SxROM.cs index 1eeb61ed64..2d70d28009 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SxROM.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SxROM.cs @@ -546,7 +546,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void Dispose() { base.Dispose(); - if(mmc1 != null) mmc1.Dispose(); + mmc1?.Dispose(); } } //class SxROM @@ -590,7 +590,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return base.ReadWRAM(Map_WRAM(addr)); } - } class SXROM : SuROM diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/TENGEN-800032.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/TENGEN-800032.cs index 9e2123011e..c8405c4e67 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/TENGEN-800032.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/TENGEN-800032.cs @@ -1,6 +1,5 @@ using BizHawk.Common; using BizHawk.Common.NumberExtensions; -using System; namespace BizHawk.Emulation.Cores.Nintendo.NES { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Taito_TC0190FMC.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Taito_TC0190FMC.cs index e032d56748..98b353770d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Taito_TC0190FMC.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Taito_TC0190FMC.cs @@ -77,13 +77,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { prg_regs_8k.Dispose(); chr_regs_1k.Dispose(); - if (mmc3 != null) mmc3.Dispose(); + mmc3?.Dispose(); } public override void SyncState(Serializer ser) { base.SyncState(ser); - if(mmc3 != null) mmc3.SyncState(ser); + mmc3?.SyncState(ser); ser.Sync(nameof(prg_regs_8k), ref prg_regs_8k); ser.Sync(nameof(chr_regs_1k), ref chr_regs_1k); ser.Sync(nameof(mirror_mode), ref mirror_mode); @@ -130,9 +130,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES void SyncMirror() { - if (mirror_mode == 0) - SetMirrorType(EMirrorType.Vertical); - else SetMirrorType(EMirrorType.Horizontal); + SetMirrorType(mirror_mode == 0 ? EMirrorType.Vertical : EMirrorType.Horizontal); } public override void WritePRG(int addr, byte value) @@ -214,8 +212,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES addr = (bank_1k << 10) | ofs; return VROM[addr]; } - else - return base.ReadPPU(addr); + + return base.ReadPPU(addr); } public override byte ReadPRG(int addr) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-12-IN-1.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-12-IN-1.cs index b268323987..185c7d2909 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-12-IN-1.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-12-IN-1.cs @@ -56,14 +56,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES private void SetMirroring(bool horizontal) { - if (horizontal) - { - SetMirrorType(EMirrorType.Horizontal); - } - else - { - SetMirrorType(EMirrorType.Vertical); - } + SetMirrorType(horizontal ? EMirrorType.Horizontal : EMirrorType.Vertical); } public override byte ReadPPU(int addr) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-D1038.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-D1038.cs index 97462732bf..7aa0648186 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-D1038.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC-D1038.cs @@ -16,7 +16,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES private int DipswitchMask = 3; - private bool Prg16kMode { get { return _reg.Bit(7); } } + private bool Prg16kMode => _reg.Bit(7); public override bool Configure(NES.EDetectionOrigin origin) { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMCFK23C.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMCFK23C.cs index 338676941e..bc248018a0 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMCFK23C.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMCFK23C.cs @@ -1,5 +1,4 @@ using BizHawk.Common; -using System; namespace BizHawk.Emulation.Cores.Nintendo.NES { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC_Super24in1SC03.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC_Super24in1SC03.cs index 83e14080d2..5eb1b28436 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC_Super24in1SC03.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_BMC_Super24in1SC03.cs @@ -1,5 +1,4 @@ using BizHawk.Common; -using BizHawk.Common.NumberExtensions; namespace BizHawk.Emulation.Cores.Nintendo.NES { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-KOF97.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-KOF97.cs index 2e7f029f53..b5785db527 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-KOF97.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-KOF97.cs @@ -1,6 +1,4 @@ -using BizHawk.Common; - -namespace BizHawk.Emulation.Cores.Nintendo.NES +namespace BizHawk.Emulation.Cores.Nintendo.NES { // adapted from Nestopia src public sealed class UNIF_UNL_KOF97 : MMC3Board_Base diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-LH10.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-LH10.cs index 17fa4b4518..3cb2495140 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-LH10.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL-LH10.cs @@ -88,10 +88,5 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES bank &= prg_bank_mask_8; return ROM[(bank << 13) + (addr & 0x1FFF)]; } - - public override byte ReadPPU(int addr) - { - return base.ReadPPU(addr); - } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL_DripGame.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL_DripGame.cs index 951e7305fd..e36c919a82 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL_DripGame.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL_DripGame.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using BizHawk.Common; namespace BizHawk.Emulation.Cores.Nintendo.NES @@ -233,20 +230,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { return VROM[addr & 0x7ff | chr[addr >> 11] << 11]; } - else + + int mappedaddr = addr & 0x3ff | nt[addr >> 10 & 3] << 10; + if (exattr && (addr & 0x3ff) >= 0x3c0) { - int mappedaddr = addr & 0x3ff | nt[addr >> 10 & 3] << 10; - if (exattr && (addr & 0x3ff) >= 0x3c0) - { - // pull palette data from exattr instead - return exram[lastntread]; - } - else - { - lastntread = mappedaddr; - return NES.CIRAM[mappedaddr]; - } + // pull palette data from exattr instead + return exram[lastntread]; } + + lastntread = mappedaddr; + return NES.CIRAM[mappedaddr]; } public override void WritePPU(int addr, byte value) @@ -321,8 +314,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } } - bool Empty { get { return writecursor == readcursor; } } - bool Full { get { return readcursor + 256 == writecursor; } } + bool Empty => writecursor == readcursor; + bool Full => readcursor + 256 == writecursor; public void Write(int addr, byte value) { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL_SMB2J.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL_SMB2J.cs index 2a74e04162..a32a5d78c2 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL_SMB2J.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UNIF/UNIF_UNL_SMB2J.cs @@ -1,5 +1,4 @@ -using System; -using BizHawk.Common; +using BizHawk.Common; namespace BizHawk.Emulation.Cores.Nintendo.NES { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC1.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC1.cs index 9ffbafd49d..553abc483a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC1.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC1.cs @@ -1,6 +1,5 @@ using BizHawk.Common; using BizHawk.Common.NumberExtensions; -using System; namespace BizHawk.Emulation.Cores.Nintendo.NES { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC7.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC7.cs index 1812d7090a..09df90739c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC7.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VRC7.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; - using BizHawk.Common; using BizHawk.Common.NumberExtensions; using BizHawk.Emulation.Cores.Components; @@ -36,8 +34,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public override void SyncState(Serializer ser) { base.SyncState(ser); - if (fm != null) - fm.SyncState(ser); + fm?.SyncState(ser); ser.Sync(nameof(prg_banks_8k), ref prg_banks_8k); ser.Sync(nameof(chr_banks_1k), ref chr_banks_1k); ser.Sync(nameof(irq_mode), ref irq_mode); @@ -111,7 +108,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES else if (Cart.pcb == "352402") { //lagrange point - remap = (addr) => ((addr & 0xF000) | ((addr & 0x30) >> 4)); + remap = addr => ((addr & 0xF000) | ((addr & 0x30) >> 4)); fm = new YM2413(YM2413.ChipType.VRC7); } else @@ -163,9 +160,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES addr = Map_PPU(addr); if (Cart.vram_size != 0) return base.ReadPPU(addr); - else return VROM[addr]; + + return VROM[addr]; } - else return base.ReadPPU(addr); + + return base.ReadPPU(addr); } public override void WritePPU(int addr, byte value) @@ -211,8 +210,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES break; case 0x1003: //sound data port - if (fm != null) - fm.Write(value); + fm?.Write(value); break; //a bit creepy to mask this for lagrange point which has no VROM, but the mask will be 0xFFFFFFFF so its OK @@ -228,10 +226,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES case 0x6000: switch (value & 3) { - case 0: SetMirrorType(NES.NESBoardBase.EMirrorType.Vertical); break; - case 1: SetMirrorType(NES.NESBoardBase.EMirrorType.Horizontal); break; - case 2: SetMirrorType(NES.NESBoardBase.EMirrorType.OneScreenA); break; - case 3: SetMirrorType(NES.NESBoardBase.EMirrorType.OneScreenB); break; + case 0: SetMirrorType(EMirrorType.Vertical); break; + case 1: SetMirrorType(EMirrorType.Horizontal); break; + case 2: SetMirrorType(EMirrorType.OneScreenA); break; + case 3: SetMirrorType(EMirrorType.OneScreenB); break; } break; @@ -324,6 +322,5 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } } } - } } \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VS_M99.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VS_M99.cs index cf083f4ffa..35b33da5a2 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VS_M99.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VS_M99.cs @@ -1,4 +1,3 @@ -using System; using BizHawk.Common; namespace BizHawk.Emulation.Cores.Nintendo.NES diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/inlnsf.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/inlnsf.cs index a6537bd966..ec87e482e1 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/inlnsf.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/inlnsf.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using BizHawk.Common; +using BizHawk.Common; namespace BizHawk.Emulation.Cores.Nintendo.NES { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/FDS/FDS.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/FDS/FDS.cs index 837a0bbaf5..bc2b849d18 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/FDS/FDS.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/FDS/FDS.cs @@ -115,10 +115,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES /// /// returns the currently set disk image. no effect on emulation (provided the image is not modified). /// - public byte[] GetDiskImage() - { - return diskimage; - } + public byte[] GetDiskImage() => diskimage; // as we have [INESBoardImplCancel], this will only be called with an fds disk image public override bool Configure(NES.EDetectionOrigin origin) @@ -146,7 +143,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES // with a bit of change, these methods could work with a better disk format - public int NumSides { get { return diskimage[4]; } } + public int NumSides => diskimage[4]; public void Eject() { @@ -222,8 +219,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES diskdrive.ApplyDiff(diskdiffs[(int)currentside]); } - public override byte[] SaveRam - { get { throw new Exception("FDS Saveram: Must access with method api!"); } } + public override byte[] SaveRam => throw new Exception("FDS Saveram: Must access with method api!"); public MemoryDomain GetDiskPeeker() diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/FDS/RamAdapter.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/FDS/RamAdapter.cs index ea85f1ce55..f31decf0ae 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/FDS/RamAdapter.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/FDS/RamAdapter.cs @@ -279,7 +279,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES /// /// memorydomain debugging /// - public int NumBytes { get { return 65500; } } + public int NumBytes => 65500; + /// /// memorydomain debugging /// diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/INESPPUViewable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/INESPPUViewable.cs index b9f0aeabfa..8ec1d8e67a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/INESPPUViewable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/INESPPUViewable.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Nintendo.NES diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.BoardSystem.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.BoardSystem.cs index 738debdcc1..12bf768d44 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.BoardSystem.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.BoardSystem.cs @@ -1,9 +1,8 @@ using System; -using System.Xml; -using System.IO; using System.Collections.Generic; +using System.IO; using System.Linq; - +using System.Xml; using BizHawk.Common; using BizHawk.Emulation.Common; @@ -19,7 +18,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES //base class pre-configuration void Create(NES nes); //one-time inherited classes configuration - bool Configure(NES.EDetectionOrigin origin); + bool Configure(EDetectionOrigin origin); //one-time base class configuration (which can take advantage of any information setup by the more-informed Configure() method) void PostConfigure(); @@ -68,7 +67,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public enum EMirrorType { Vertical, Horizontal, - OneScreenA, OneScreenB, + OneScreenA, OneScreenB } public virtual void Create(NES nes) @@ -78,7 +77,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public virtual void NESSoftReset() { - } Dictionary _initialRegisterValues = new Dictionary(); @@ -88,16 +86,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES set => _initialRegisterValues = value; } - public abstract bool Configure(NES.EDetectionOrigin origin); + public abstract bool Configure(EDetectionOrigin origin); public virtual void ClockPPU() { } public virtual void ClockCPU() { } public virtual void AtVsyncNMI() { } - public CartInfo Cart { get { return NES.cart; } } + public CartInfo Cart => NES.cart; public NES NES { get; set; } //this is set to true when SyncState is called, so that we know the base class SyncState was used - public bool SyncStateFlag = false; + public bool SyncStateFlag; public virtual void SyncState(Serializer ser) { @@ -154,10 +152,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if (pad_v == 0) return EMirrorType.OneScreenA; else return EMirrorType.Horizontal; - else - if (pad_v == 0) - return EMirrorType.Vertical; - else return EMirrorType.OneScreenB; + if (pad_v == 0) + return EMirrorType.Vertical; + return EMirrorType.OneScreenB; } protected void SetMirrorType(int pad_h, int pad_v) @@ -209,10 +206,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES wram_mask = (Cart.wram_size * 1024) - 1; } - public virtual byte ReadWRAM(int addr) { + public virtual byte ReadWRAM(int addr) + { if (wram != null) return wram[addr & wram_mask]; - else return NES.DB; + return NES.DB; } public virtual void WriteEXP(int addr, byte value) { } @@ -255,7 +253,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (VROM != null) return VROM[addr]; - else return VRAM[addr]; + return VRAM[addr]; } public virtual byte ReadPPU(int addr) @@ -264,12 +262,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { if (VROM != null) return VROM[addr]; - else return VRAM[addr]; - } - else - { - return NES.CIRAM[ApplyMirroring(addr)]; + return VRAM[addr]; } + + return NES.CIRAM[ApplyMirroring(addr)]; } /// @@ -340,7 +336,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public virtual void ApplyCustomAudio(short[] samples) { } - public bool DisableConfigAsserts = false; + public bool DisableConfigAsserts; } //this will be used to track classes that implement boards @@ -369,7 +365,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return board; } - public string BoardName { get { return Board.GetType().Name; } } + public string BoardName => Board.GetType().Name; void BoardSystemHardReset() { @@ -491,33 +487,29 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES /// static Type FindBoard(CartInfo cart, EDetectionOrigin origin, Dictionary properties) { - NES nes = new NES(); - nes.cart = cart; + NES nes = new NES { cart = cart }; Type ret = null; lock(INESBoardImplementors) foreach (var type in INESBoardImplementors) { - using (NESBoardBase board = (NESBoardBase)Activator.CreateInstance(type)) - { - //unif demands that the boards set themselves up with expected legal values based on the board size - //except, i guess, for the rom/chr sizes. go figure. - //so, disable the asserts here - if (origin == EDetectionOrigin.UNIF) - board.DisableConfigAsserts = true; + using NESBoardBase board = (NESBoardBase)Activator.CreateInstance(type); + //unif demands that the boards set themselves up with expected legal values based on the board size + //except, i guess, for the rom/chr sizes. go figure. + //so, disable the asserts here + if (origin == EDetectionOrigin.UNIF) + board.DisableConfigAsserts = true; - board.Create(nes); - board.InitialRegisterValues = properties; - if (board.Configure(origin)) - { + board.Create(nes); + board.InitialRegisterValues = properties; + if (board.Configure(origin)) + { #if DEBUG - if (ret != null) - throw new Exception($"Boards {ret} and {type} both responded to {nameof(NESBoardBase.Configure)}!"); - else - ret = type; + if (ret != null) + throw new Exception($"Boards {ret} and {type} both responded to {nameof(NESBoardBase.Configure)}!"); + ret = type; #else return type; #endif - } } } return ret; @@ -746,14 +738,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES [AttributeUsage(AttributeTargets.Field)] public class MapperPropAttribute : Attribute { - public string Name { get; private set; } - public MapperPropAttribute(string Name) + public string Name { get; } + + public MapperPropAttribute(string name) { - this.Name = Name; + Name = name; } + public MapperPropAttribute() { - this.Name = null; + Name = null; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.Core.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.Core.cs index 8d23b742c6..a39bb94bd8 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.Core.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.Core.cs @@ -66,10 +66,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES /// /// for debugging only! /// - public INESBoard GetBoard() - { - return Board; - } + public INESBoard GetBoard() => Board; #region Audio @@ -78,7 +75,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public int old_s = 0; - public bool CanProvideAsync { get { return false; } } + public bool CanProvideAsync => false; public void SetSyncMode(SyncSoundMode mode) { @@ -93,10 +90,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES throw new NotSupportedException("Async not supported"); } - public SyncSoundMode SyncMode - { - get { return SyncSoundMode.Sync; } - } + public SyncSoundMode SyncMode => SyncSoundMode.Sync; public void Dispose() { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.IInputPollable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.IInputPollable.cs index 2ac904f0be..d0ea8dc3de 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.IInputPollable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.IInputPollable.cs @@ -16,10 +16,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES set => islag = value; } - public IInputCallbackSystem InputCallbacks - { - get { return _inputCallbacks; } - } + public IInputCallbackSystem InputCallbacks => _inputCallbacks; private int _lagcount; private bool lagged = true; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.IMemoryDomains.cs index 30d37f6e20..13f764e8f3 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.IMemoryDomains.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; - +using System.Collections.Generic; using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Nintendo.NES diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.INESPPUViewable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.INESPPUViewable.cs index cc9748ed15..04942a68c9 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.INESPPUViewable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.INESPPUViewable.cs @@ -1,32 +1,17 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Nintendo.NES { partial class NES : INESPPUViewable { - public int[] GetPalette() - { - return palette_compiled; - } + public int[] GetPalette() => palette_compiled; - public bool BGBaseHigh - { - get { return ppu.reg_2000.bg_pattern_hi; } - } + public bool BGBaseHigh => ppu.reg_2000.bg_pattern_hi; - public bool SPBaseHigh - { - get { return ppu.reg_2000.obj_pattern_hi; } - } + public bool SPBaseHigh => ppu.reg_2000.obj_pattern_hi; - public bool SPTall - { - get { return ppu.reg_2000.obj_size_16; } - } + public bool SPTall => ppu.reg_2000.obj_size_16; public byte[] GetPPUBus() { @@ -38,20 +23,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES return ret; } - public byte[] GetPalRam() - { - return ppu.PALRAM; - } + public byte[] GetPalRam() => ppu.PALRAM; - public byte[] GetOam() - { - return ppu.OAM; - } + public byte[] GetOam() => ppu.OAM; - public byte PeekPPU(int addr) - { - return Board.PeekPPU(addr); - } + public byte PeekPPU(int addr) => Board.PeekPPU(addr); public byte[] GetExTiles() { @@ -65,27 +41,19 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } } - public bool ExActive - { - get { return Board is ExROM && (Board as ExROM).ExAttrActive; } - } + public bool ExActive => Board is ExROM ex && ex.ExAttrActive; public byte[] GetExRam() { - if (Board is ExROM) + if (Board is ExROM ex) { - return (Board as ExROM).GetExRAMArray(); - } - else - { - throw new InvalidOperationException(); + return ex.GetExRAMArray(); } + + throw new InvalidOperationException(); } - public MemoryDomain GetCHRROM() - { - return _memoryDomains["CHR VROM"]; - } + public MemoryDomain GetCHRROM() => _memoryDomains["CHR VROM"]; public void InstallCallback1(Action cb, int sl) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.ISettable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.ISettable.cs index 157d544f0a..786df8f812 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.ISettable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.ISettable.cs @@ -1,10 +1,8 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using BizHawk.Common; using BizHawk.Emulation.Common; -using System.ComponentModel; namespace BizHawk.Emulation.Cores.Nintendo.NES { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.iNES.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.iNES.cs index 9f4ba79467..1525f39393 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.iNES.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.iNES.cs @@ -2,8 +2,6 @@ using System; using System.IO; using System.Linq; using System.Text; - -using BizHawk.Common; using BizHawk.Common.NumberExtensions; namespace BizHawk.Emulation.Cores.Nintendo.NES @@ -31,10 +29,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES if ((data[7] & 0x0c) == 0x08) { // process as iNES v2 - CartV2 = new CartInfo(); + CartV2 = new CartInfo + { + prg_size = data[4] | data[9] << 8 & 0xf00, + chr_size = data[5] | data[9] << 4 & 0xf00 + }; - CartV2.prg_size = data[4] | data[9] << 8 & 0xf00; - CartV2.chr_size = data[5] | data[9] << 4 & 0xf00; CartV2.prg_size *= 16; CartV2.chr_size *= 8; @@ -82,10 +82,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES // process as iNES v1 // the DiskDude cleaning is no longer; get better roms - Cart = new CartInfo(); + Cart = new CartInfo + { + prg_size = data[4], + chr_size = data[5] + }; - Cart.prg_size = data[4]; - Cart.chr_size = data[5]; if (Cart.prg_size == 0) Cart.prg_size = 256; Cart.prg_size *= 16; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NESControllers.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NESControllers.cs index 437bd712b7..63ed46dc4c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NESControllers.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NESControllers.cs @@ -1,10 +1,8 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; using BizHawk.Emulation.Common; using BizHawk.Common; -using System.Reflection; using Newtonsoft.Json; namespace BizHawk.Emulation.Cores.Nintendo.NES diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NSFFormat.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NSFFormat.cs index fc761dc043..f5f70b8dd4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NSFFormat.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NSFFormat.cs @@ -1,14 +1,7 @@ using System; -using System.Linq; using System.IO; -using System.Collections.Generic; - -using BizHawk.Common; -using BizHawk.Common.BufferExtensions; using BizHawk.Common.IOExtensions; -using BizHawk.Emulation.Common; - namespace BizHawk.Emulation.Cores.Nintendo.NES { //http://kevtris.org/nes/nsfspec.txt diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.cs index 13b52296db..51144dc343 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.cs @@ -318,30 +318,30 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES byte bg_byte; for (int i = 0; i < 34; i++) { - string str = "bgdata" + i.ToString() + "at"; + string str = "bgdata" + i + "at"; bg_byte = bgdata[i].at; ser.Sync(str, ref bg_byte); bgdata[i].at = bg_byte; - str = "bgdata" + i.ToString() + "nt"; + str = "bgdata" + i + "nt"; bg_byte = bgdata[i].nt; ser.Sync(str, ref bg_byte); bgdata[i].nt = bg_byte; - str = "bgdata" + i.ToString() + "pt0"; + str = "bgdata" + i + "pt0"; bg_byte = bgdata[i].pt_0; ser.Sync(str, ref bg_byte); bgdata[i].pt_0 = bg_byte; - str = "bgdata" + i.ToString() + "pt1"; + str = "bgdata" + i + "pt1"; bg_byte = bgdata[i].pt_1; ser.Sync(str, ref bg_byte); bgdata[i].pt_1 = bg_byte; } byte oam_byte; for (int i = 0; i < 64; i++) { - string str = "oamdata" + i.ToString() + "y"; + string str = "oamdata" + i + "y"; oam_byte = t_oam[i].oam_y; ser.Sync(str, ref oam_byte); t_oam[i].oam_y = oam_byte; - str = "oamdata" + i.ToString() + "ind"; + str = "oamdata" + i + "ind"; oam_byte = t_oam[i].oam_ind; ser.Sync(str, ref oam_byte); t_oam[i].oam_ind = oam_byte; - str = "oamdata" + i.ToString() + "attr"; + str = "oamdata" + i + "attr"; oam_byte = t_oam[i].oam_attr; ser.Sync(str, ref oam_byte); t_oam[i].oam_attr = oam_byte; - str = "oamdata" + i.ToString() + "x"; + str = "oamdata" + i + "x"; oam_byte = t_oam[i].oam_x; ser.Sync(str, ref oam_byte); t_oam[i].oam_x = oam_byte; - str = "oamdata" + i.ToString() + "p0"; + str = "oamdata" + i + "p0"; oam_byte = t_oam[i].patterns_0; ser.Sync(str, ref oam_byte); t_oam[i].patterns_0 = oam_byte; - str = "oamdata" + i.ToString() + "p1"; + str = "oamdata" + i + "p1"; oam_byte = t_oam[i].patterns_1; ser.Sync(str, ref oam_byte); t_oam[i].patterns_1 = oam_byte; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.regs.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.regs.cs index 9393b47a53..f863ef8152 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.regs.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.regs.cs @@ -28,10 +28,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public byte Value { - get - { - return (byte)(color_disable | (show_bg_leftmost << 1) | (show_obj_leftmost << 2) | (show_bg << 3) | (show_obj << 4) | (intense_green << 5) | (intense_blue << 6) | (intense_red << 7)); - } + get => (byte)(color_disable | (show_bg_leftmost << 1) | (show_obj_leftmost << 2) | (show_bg << 3) | (show_obj << 4) | (intense_green << 5) | (intense_blue << 6) | (intense_red << 7)); set { color_disable = (value & 1); @@ -47,7 +44,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } } - public bool PPUON { get { return show_bg_new || show_obj_new; } } + public bool PPUON => show_bg_new || show_obj_new; // this byte is used to simulate open bus reads and writes @@ -60,7 +57,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public struct PPUSTATUS { public int sl; - public bool rendering { get { return sl >= 0 && sl < 241; } } + public bool rendering => sl >= 0 && sl < 241; public int cycle; } @@ -278,10 +275,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public byte Value { - get - { - return (byte)(ppu.ppur._h | (ppu.ppur._v << 1) | (vram_incr32 << 2) | (obj_pattern_hi << 3) | (bg_pattern_hi << 4) | (obj_size_16 << 5) | (ppu_layer << 6) | (vblank_nmi_gen << 7)); - } + get => (byte)(ppu.ppur._h | (ppu.ppur._v << 1) | (vram_incr32 << 2) | (obj_pattern_hi << 3) | (bg_pattern_hi << 4) | (obj_size_16 << 5) | (ppu_layer << 6) | (vblank_nmi_gen << 7)); set { ppu.ppur._h = value & 1; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.run.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.run.cs index 1699e5fa72..0bdd544b3d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.run.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/PPU.run.cs @@ -1,6 +1,5 @@ //TODO - correctly emulate PPU OFF state -using System; using BizHawk.Common; using BizHawk.Common.NumberExtensions; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Unif.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Unif.cs index fb8d69ecda..c9b66f13c3 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Unif.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Unif.cs @@ -111,9 +111,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES chrrom = null; } - public NES.CartInfo CartInfo { get { return ci; } } - public byte[] PRG { get { return prgrom; } } - public byte[] CHR { get { return chrrom; } } - + public NES.CartInfo CartInfo => ci; + public byte[] PRG => prgrom; + public byte[] CHR => chrrom; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/Nes_NTSC_Colors.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/Nes_NTSC_Colors.cs index 07c18fbd64..c5036880d2 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/Nes_NTSC_Colors.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/Nes_NTSC_Colors.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs index e4f746875e..bff14aeb69 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs @@ -221,8 +221,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES if (rendersound) DrainAudio(); - if (_callBack1 != null) _callBack1(); - if (_callBack2 != null) _callBack2(); + _callBack1?.Invoke(); + _callBack2?.Invoke(); return true; } @@ -231,9 +231,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES IntPtr Context; public int Frame { get; private set; } - public string SystemId { get { return "NES"; } } - public bool DeterministicEmulation { get { return true; } } - public string BoardName { get; private set; } + public string SystemId => "NES"; + public bool DeterministicEmulation => true; + public string BoardName { get; } public void ResetCounters() { @@ -242,11 +242,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES LagCount = 0; } - public CoreComm CoreComm - { - get; - private set; - } + public CoreComm CoreComm { get; } #region bootgod diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi.cs index 96783d8f55..804348b2b4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi.cs @@ -1,5 +1,4 @@ using System; -using System.Diagnostics; using System.IO; using System.Collections.Generic; using System.Runtime.InteropServices; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_BRK.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_BRK.cs index 1a4d85e337..75bea89ad8 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_BRK.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_BRK.cs @@ -1,6 +1,4 @@ -using System; - -using BizHawk.Common; +using BizHawk.Common; namespace BizHawk.Emulation.Cores.Nintendo.SNES { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_CMD.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_CMD.cs index 442f25f367..084d2259b8 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_CMD.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_CMD.cs @@ -1,6 +1,4 @@ -using System; - -using BizHawk.Common; +using BizHawk.Common; namespace BizHawk.Emulation.Cores.Nintendo.SNES { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_Enums.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_Enums.cs index e54d51f0c6..9959e0e76b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_Enums.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_Enums.cs @@ -1,8 +1,4 @@ -using System; - -using BizHawk.Common; - -namespace BizHawk.Emulation.Cores.Nintendo.SNES +namespace BizHawk.Emulation.Cores.Nintendo.SNES { unsafe partial class LibsnesApi { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_QUERY.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_QUERY.cs index 62c963911e..a68a11879e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_QUERY.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesApi_QUERY.cs @@ -1,6 +1,4 @@ using System; -using System.Runtime.InteropServices; - using BizHawk.Common; using BizHawk.Emulation.Common; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IEmulator.cs index ba053cb0be..58a0d06476 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IEmulator.cs @@ -1,6 +1,4 @@ -using System.IO; - -using BizHawk.Emulation.Common; +using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Nintendo.SNES { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/SNESGraphicsDecoder.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/SNESGraphicsDecoder.cs index a4e576e979..4248f0caf3 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/SNESGraphicsDecoder.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/SNESGraphicsDecoder.cs @@ -102,12 +102,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES /// /// is this BGMode a mode7 type (mode7, mode7ext, mode7DC) /// - public bool BGModeIsMode7Type { get { return BGModeIsMode7Type(BGMode); } } + public bool BGModeIsMode7Type => BGModeIsMode7Type(BGMode); /// /// Is the layer even enabled? /// - public bool Enabled { get { return Bpp != 0; } } + public bool Enabled => Bpp != 0; /// /// screen and tiledata register values @@ -137,7 +137,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES /// /// Screen size (shape, really.) /// - public ScreenSize ScreenSize { get { return (ScreenSize)SCSIZE; } } + public ScreenSize ScreenSize => (ScreenSize)SCSIZE; /// /// the BPP of the BG, as derived from the current mode @@ -172,7 +172,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES /// /// TileSize; 8 or 16 /// - public int TileSize { get { return TILESIZE == 1 ? 16 : 8; } } + public int TileSize => TILESIZE == 1 ? 16 : 8; /// /// The size of the layer, in tiles @@ -190,13 +190,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES /// /// The size of the layer, in pixels. This has factored in the selection of 8x8 or 16x16 tiles /// - public Dimensions ScreenSizeInPixels - { - get - { - return new Dimensions(ScreenSizeInTiles.Width * TileSize, ScreenSizeInTiles.Height * TileSize); - } - } + public Dimensions ScreenSizeInPixels => new Dimensions(ScreenSizeInTiles.Width * TileSize, ScreenSizeInTiles.Height * TileSize); /// /// returns information about what colors could possibly be used for this bg @@ -208,11 +202,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES public class BGInfos { BGInfo[] bgs = new BGInfo[4] { new BGInfo(1), new BGInfo(2), new BGInfo(3), new BGInfo(4) }; - public BGInfo BG1 { get { return bgs[0]; } } - public BGInfo BG2 { get { return bgs[1]; } } - public BGInfo BG3 { get { return bgs[2]; } } - public BGInfo BG4 { get { return bgs[3]; } } - public BGInfo this[int index] { get { return bgs[index - 1]; } } + public BGInfo BG1 => bgs[0]; + public BGInfo BG2 => bgs[1]; + public BGInfo BG3 => bgs[2]; + public BGInfo BG4 => bgs[3]; + public BGInfo this[int index] => bgs[index - 1]; } public class ModeInfo diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/LibSnes9x.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/LibSnes9x.cs index 444b9733e5..673c94b6c5 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/LibSnes9x.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/LibSnes9x.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Runtime.InteropServices; -using BizHawk.BizInvoke; +using BizHawk.BizInvoke; using BizHawk.Emulation.Cores.Waterbox; namespace BizHawk.Emulation.Cores.Nintendo.SNES9X diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.cs index 2b4f220bf2..8e241e6acd 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.cs @@ -148,20 +148,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk return subnes.palette_compiled; } - public bool BGBaseHigh - { - get { return subnes.ppu.reg_2000.bg_pattern_hi; } - } + public bool BGBaseHigh => subnes.ppu.reg_2000.bg_pattern_hi; - public bool SPBaseHigh - { - get { return subnes.ppu.reg_2000.obj_pattern_hi; } - } + public bool SPBaseHigh => subnes.ppu.reg_2000.obj_pattern_hi; - public bool SPTall - { - get { return subnes.ppu.reg_2000.obj_size_16; } - } + public bool SPTall => subnes.ppu.reg_2000.obj_size_16; public byte[] GetPPUBus() { @@ -173,20 +164,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk return ret; } - public byte[] GetPalRam() - { - return subnes.ppu.PALRAM; - } + public byte[] GetPalRam() => subnes.ppu.PALRAM; - public byte[] GetOam() - { - return subnes.ppu.OAM; - } + public byte[] GetOam() => subnes.ppu.OAM; - public byte PeekPPU(int addr) - { - return subnes.Board.PeekPPU(addr); - } + public byte PeekPPU(int addr) => subnes.Board.PeekPPU(addr); public byte[] GetExTiles() { @@ -194,16 +176,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk { return subnes.Board.VROM ?? subnes.Board.VRAM; } - else - { - throw new InvalidOperationException(); - } + + throw new InvalidOperationException(); } - public bool ExActive - { - get { return subnes.Board is ExROM && (subnes.Board as ExROM).ExAttrActive; } - } + public bool ExActive => subnes.Board is ExROM && (subnes.Board as ExROM).ExAttrActive; public byte[] GetExRam() { @@ -211,17 +188,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk { return (subnes.Board as ExROM).GetExRAMArray(); } - else - { - throw new InvalidOperationException(); - } - } - - public MemoryDomain GetCHRROM() - { - return _memoryDomains["CHR VROM"]; + + throw new InvalidOperationException(); } + public MemoryDomain GetCHRROM() => _memoryDomains["CHR VROM"]; public void InstallCallback1(Action cb, int sl) { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/VB/LibVirtualBoyee.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/VB/LibVirtualBoyee.cs index 9adb61d940..83b154fb92 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/VB/LibVirtualBoyee.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/VB/LibVirtualBoyee.cs @@ -1,12 +1,7 @@ using BizHawk.BizInvoke; using BizHawk.Emulation.Cores.Waterbox; -using System; -using System.Collections.Generic; using System.Drawing; -using System.Linq; using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; namespace BizHawk.Emulation.Cores.Consoles.Nintendo.VB { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/VB/VirtualBoyee.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/VB/VirtualBoyee.cs index 688f15cdcd..9001fa4384 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/VB/VirtualBoyee.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/VB/VirtualBoyee.cs @@ -1,6 +1,4 @@ using BizHawk.Common; -using BizHawk.BizInvoke; -using BizHawk.Common.BufferExtensions; using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Waterbox; using System; @@ -8,11 +6,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Drawing; -using System.IO; using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; namespace BizHawk.Emulation.Cores.Consoles.Nintendo.VB { diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/ADPCM.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/ADPCM.cs index 6e30276330..327c5b1ba5 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/ADPCM.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/ADPCM.cs @@ -30,9 +30,9 @@ namespace BizHawk.Emulation.Cores.PCEngine public bool AdpcmIsPlaying; public bool HalfReached; public bool EndReached; - public bool AdpcmBusyWriting { get { return AdpcmCdDmaRequested; } } - public bool AdpcmBusyReading { get { return ReadPending; } } - public bool AdpcmCdDmaRequested { get { return (Port180B & 3) != 0; } } + public bool AdpcmBusyWriting => AdpcmCdDmaRequested; + public bool AdpcmBusyReading => ReadPending; + public bool AdpcmCdDmaRequested => (Port180B & 3) != 0; // *************************************************************************** diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/VDC.Render.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/VDC.Render.cs index 0ddbd0030a..1be04fb3a0 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/VDC.Render.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/VDC.Render.cs @@ -432,10 +432,7 @@ namespace BizHawk.Emulation.Cores.PCEngine private int[] FrameBuffer = new int[320 * 262]; // IVideoProvider implementation - public int[] GetVideoBuffer() - { - return FrameBuffer; - } + public int[] GetVideoBuffer() => FrameBuffer; public int VirtualWidth => FramePitch; public int VirtualHeight => BufferHeight; @@ -446,19 +443,13 @@ namespace BizHawk.Emulation.Cores.PCEngine public int VsyncNumerator { [FeatureNotImplemented] - get - { - return NullVideo.DefaultVsyncNum; - } + get => NullVideo.DefaultVsyncNum; } public int VsyncDenominator { [FeatureNotImplemented] - get - { - return NullVideo.DefaultVsyncDen; - } + get => NullVideo.DefaultVsyncDen; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/VDC.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/VDC.cs index f6aa768715..388342ecc9 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/VDC.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/VDC.cs @@ -1,7 +1,6 @@ using BizHawk.Common; using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Components.H6280; -using System; namespace BizHawk.Emulation.Cores.PCEngine { diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/VPC.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/VPC.cs index 9cba317c28..3ce8e8b550 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/VPC.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/VPC.cs @@ -526,11 +526,7 @@ namespace BizHawk.Emulation.Cores.PCEngine } // IVideoProvider implementation - public int[] GetVideoBuffer() - { - return FrameBuffer; - } - + public int[] GetVideoBuffer() => FrameBuffer; public int VirtualWidth => FrameWidth; public int VirtualHeight => FrameHeight; public int BufferWidth => FrameWidth; @@ -540,19 +536,13 @@ namespace BizHawk.Emulation.Cores.PCEngine public int VsyncNumerator { [FeatureNotImplemented] - get - { - return NullVideo.DefaultVsyncNum; - } + get => NullVideo.DefaultVsyncNum; } public int VsyncDenominator { [FeatureNotImplemented] - get - { - return NullVideo.DefaultVsyncDen; - } + get => NullVideo.DefaultVsyncDen; } } } diff --git a/BizHawk.Emulation.Cores/Consoles/SNK/DualNeoGeoPort.cs b/BizHawk.Emulation.Cores/Consoles/SNK/DualNeoGeoPort.cs index 814369efc8..0ded3a447d 100644 --- a/BizHawk.Emulation.Cores/Consoles/SNK/DualNeoGeoPort.cs +++ b/BizHawk.Emulation.Cores/Consoles/SNK/DualNeoGeoPort.cs @@ -6,11 +6,7 @@ using BizHawk.Emulation.Cores.Waterbox; using System; using System.Collections.Concurrent; using System.Collections.Generic; -using System.IO; -using System.Linq; using System.Runtime.InteropServices; -using System.Text; -using System.Threading; using System.Threading.Tasks; namespace BizHawk.Emulation.Cores.Consoles.SNK diff --git a/BizHawk.Emulation.Cores/Consoles/SNK/LibNeoGeoPort.cs b/BizHawk.Emulation.Cores/Consoles/SNK/LibNeoGeoPort.cs index 307d7357c7..3f6540253f 100644 --- a/BizHawk.Emulation.Cores/Consoles/SNK/LibNeoGeoPort.cs +++ b/BizHawk.Emulation.Cores/Consoles/SNK/LibNeoGeoPort.cs @@ -1,11 +1,7 @@ using BizHawk.BizInvoke; using BizHawk.Emulation.Cores.Waterbox; using System; -using System.Collections.Generic; -using System.Linq; using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; namespace BizHawk.Emulation.Cores.Consoles.SNK { diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IMemoryDomains.cs index 1ea4505014..a13885a930 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.IMemoryDomains.cs @@ -1,6 +1,4 @@ -using System; - -using System.Collections.Generic; +using System.Collections.Generic; using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Sega.GGHawkLink diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.ISettable.cs b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.ISettable.cs index 2c5f5d8612..bdf7c5c1ef 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.ISettable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLink.ISettable.cs @@ -1,8 +1,4 @@ -using System; -using System.ComponentModel; - -using Newtonsoft.Json; - +using System.ComponentModel; using BizHawk.Common; using BizHawk.Emulation.Common; diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLinkControllers.cs b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLinkControllers.cs index 7c1bc51e16..121fc9e79e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLinkControllers.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/GGHawkLink/GGHawkLinkControllers.cs @@ -1,5 +1,4 @@ -using System; -using System.ComponentModel; +using System.ComponentModel; using System.Linq; using BizHawk.Common; diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/PicoDrive/PicoDrive.cs b/BizHawk.Emulation.Cores/Consoles/Sega/PicoDrive/PicoDrive.cs index 826e3b1298..9f8f73220e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/PicoDrive/PicoDrive.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/PicoDrive/PicoDrive.cs @@ -2,11 +2,7 @@ using BizHawk.Emulation.Cores.Waterbox; using BizHawk.Emulation.DiscSystem; using System; -using System.Collections.Generic; -using System.Linq; using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; using System.IO; using BizHawk.Common; using System.ComponentModel; diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/MemoryMap.EEPROM.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/MemoryMap.EEPROM.cs index 2c7008da75..7343f51510 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/MemoryMap.EEPROM.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/MemoryMap.EEPROM.cs @@ -1,6 +1,4 @@ -using System; - -namespace BizHawk.Emulation.Cores.Sega.MasterSystem +namespace BizHawk.Emulation.Cores.Sega.MasterSystem { public partial class SMS { diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/MemoryMap.Korea.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/MemoryMap.Korea.cs index 5a914b3d95..e4858011c7 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/MemoryMap.Korea.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/MemoryMap.Korea.cs @@ -1,6 +1,4 @@ -using System; - -namespace BizHawk.Emulation.Cores.Sega.MasterSystem +namespace BizHawk.Emulation.Cores.Sega.MasterSystem { public partial class SMS { diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/MemoryMap.Sega.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/MemoryMap.Sega.cs index e6762567b9..28693c73ad 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/MemoryMap.Sega.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/MemoryMap.Sega.cs @@ -1,6 +1,4 @@ -using System; - -namespace BizHawk.Emulation.Cores.Sega.MasterSystem +namespace BizHawk.Emulation.Cores.Sega.MasterSystem { public partial class SMS { @@ -19,7 +17,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem const ushort BankSizeMask = 0x3FFF; const ushort RamSizeMask = 0x1FFF; - bool BiosMapped { get { return (Port3E & 0x40) == 0x40; } } + bool BiosMapped => (Port3E & 0x40) == 0x40; byte ReadMemorySega(ushort address) { diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IEmulator.cs index 5d1b049800..d5a790e844 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IEmulator.cs @@ -197,7 +197,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem public int old_s_L = 0; public int old_s_R = 0; - public bool CanProvideAsync { get { return false; } } + public bool CanProvideAsync => false; public void SetSyncMode(SyncSoundMode mode) { @@ -212,10 +212,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem throw new NotSupportedException("Async not supported"); } - public SyncSoundMode SyncMode - { - get { return SyncSoundMode.Sync; } - } + public SyncSoundMode SyncMode => SyncSoundMode.Sync; public void GetSamplesSync(out short[] samples, out int nsamp) { diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.ISaveRam.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.ISaveRam.cs index be49228c80..20ab96123a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.ISaveRam.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.ISaveRam.cs @@ -8,14 +8,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem { public byte[] CloneSaveRam() { - if (SaveRAM != null) - { - return (byte[])SaveRAM.Clone(); - } - else - { - return null; - } + return (byte[]) SaveRAM?.Clone(); } public void StoreSaveRam(byte[] data) diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IStatable.cs index d7e2df80c6..f64a071d83 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IStatable.cs @@ -63,11 +63,8 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem { YM2413.SyncState(ser); } - - if (EEPROM != null) - { - EEPROM.SyncState(ser); - } + + EEPROM?.SyncState(ser); ser.Sync("Frame", ref _frame); ser.Sync("LagCount", ref _lagCount); diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.Input.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.Input.cs index 5590849b1d..fcb2fd00b4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.Input.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.Input.cs @@ -1,6 +1,4 @@ -using System; - -using BizHawk.Emulation.Common; +using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Sega.MasterSystem { diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/VDP.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/VDP.cs index 41ebaec371..14ee00a980 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/VDP.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/VDP.cs @@ -1,6 +1,4 @@ -using System; - -using BizHawk.Common; +using BizHawk.Common; using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Components.Z80A; @@ -14,7 +12,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem // VDP State public byte[] VRAM = new byte[0x4000]; //16kb video RAM public byte[] CRAM; // SMS = 32 bytes, GG = 64 bytes CRAM - public byte[] Registers = new byte[] { 0x06, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFB, 0xF0, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00 }; + public byte[] Registers = { 0x06, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFB, 0xF0, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00 }; public byte StatusByte; const int Command_VramRead = 0x00; @@ -40,7 +38,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem public bool SpriteLimit; public int IPeriod = 228; - public VdpMode VdpMode { get { return mode; } } + public VdpMode VdpMode => mode; public int FrameHeight = 192; public int ScanLine; @@ -49,22 +47,22 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem public int[] GameGearFrameBuffer = new int[160 * 144]; public int[] OverscanFrameBuffer = null; - public bool Mode1Bit { get { return (Registers[1] & 16) > 0; } } - public bool Mode2Bit { get { return (Registers[0] & 2) > 0; } } - public bool Mode3Bit { get { return (Registers[1] & 8) > 0; } } - public bool Mode4Bit { get { return (Registers[0] & 4) > 0; } } - public bool ShiftSpritesLeft8Pixels { get { return (Registers[0] & 8) > 0; } } - public bool EnableLineInterrupts { get { return (Registers[0] & 16) > 0; } } - public bool LeftBlanking { get { return (Registers[0] & 32) > 0; } } - public bool HorizScrollLock { get { return (Registers[0] & 64) > 0; } } - public bool VerticalScrollLock { get { return (Registers[0] & 128) > 0; } } - public bool EnableDoubledSprites { get { return (Registers[1] & 1) > 0; } } - public bool EnableLargeSprites { get { return (Registers[1] & 2) > 0; } } - public bool EnableFrameInterrupts { get { return (Registers[1] & 32) > 0; } } - public bool DisplayOn { get { return (Registers[1] & 64) > 0; } } - public int SpriteAttributeTableBase { get { return ((Registers[5] >> 1) << 8) & 0x3FFF; } } - public int SpriteTileBase { get { return (Registers[6] & 4) > 0 ? 256 : 0; } } - public byte BackdropColor { get { return (byte)(16 + (Registers[7] & 15)); } } + public bool Mode1Bit => (Registers[1] & 16) > 0; + public bool Mode2Bit => (Registers[0] & 2) > 0; + public bool Mode3Bit => (Registers[1] & 8) > 0; + public bool Mode4Bit => (Registers[0] & 4) > 0; + public bool ShiftSpritesLeft8Pixels => (Registers[0] & 8) > 0; + public bool EnableLineInterrupts => (Registers[0] & 16) > 0; + public bool LeftBlanking => (Registers[0] & 32) > 0; + public bool HorizScrollLock => (Registers[0] & 64) > 0; + public bool VerticalScrollLock => (Registers[0] & 128) > 0; + public bool EnableDoubledSprites => (Registers[1] & 1) > 0; + public bool EnableLargeSprites => (Registers[1] & 2) > 0; + public bool EnableFrameInterrupts => (Registers[1] & 32) > 0; + public bool DisplayOn => (Registers[1] & 64) > 0; + public int SpriteAttributeTableBase => ((Registers[5] >> 1) << 8) & 0x3FFF; + public int SpriteTileBase => (Registers[6] & 4) > 0 ? 256 : 0; + public byte BackdropColor => (byte)(16 + (Registers[7] & 15)); int NameTableBase; int ColorTableBase; @@ -442,15 +440,15 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem { if (mode == VdpMode.SMS && Sms.Settings.DisplayOverscan) return OverscanFrameWidth; - if (mode == MasterSystem.VdpMode.SMS) + if (mode == VdpMode.SMS) return 293; - else if (Sms.Settings.ShowClippedRegions) + if (Sms.Settings.ShowClippedRegions) return 256; - else - return 160; + return 160; } } - public int VirtualHeight { get { return BufferHeight; } } + public int VirtualHeight => BufferHeight; + public int BufferWidth { get @@ -475,10 +473,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem } } - public int BackgroundColor - { - get { return Palette[BackdropColor]; } - } + public int BackgroundColor => Palette[BackdropColor]; public int VsyncNumerator => DisplayType == DisplayType.NTSC ? 60 : 50; diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/FilePiping.cs b/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/FilePiping.cs index 62b68db8f7..d1072d9e35 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/FilePiping.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/FilePiping.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.IO; using System.IO.Pipes; using System.Threading; @@ -35,7 +32,7 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn public FilePiping() { - PipeName = "BizHawk-" + Guid.NewGuid().ToString(); + PipeName = "BizHawk-" + Guid.NewGuid(); } public void Get(Stream s) @@ -47,28 +44,24 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn if (!s.CanWrite) throw new ArgumentException($"{nameof(Stream)} must be readable!"); - using (var evt = new ManualResetEventSlim()) + using var evt = new ManualResetEventSlim(); + thr = new Thread(delegate() { - thr = new Thread(delegate() - { - try - { - using (var srv = new NamedPipeServerStream(PipeName, PipeDirection.In)) - { - evt.Set(); - srv.WaitForConnection(); - srv.CopyTo(s); - //srv.Flush(); - } - } - catch (Exception ee) - { - e = ee; - } - }); - thr.Start(); - evt.Wait(); - } + try + { + using var srv = new NamedPipeServerStream(PipeName, PipeDirection.In); + evt.Set(); + srv.WaitForConnection(); + srv.CopyTo(s); + //srv.Flush(); + } + catch (Exception ee) + { + e = ee; + } + }); + thr.Start(); + evt.Wait(); } public void Offer(Stream s) @@ -80,28 +73,24 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn if (!s.CanRead) throw new ArgumentException($"{nameof(Stream)} must be readable!"); - using (var evt = new ManualResetEventSlim()) + using var evt = new ManualResetEventSlim(); + thr = new Thread(delegate() { - thr = new Thread(delegate() - { - try - { - using (var srv = new NamedPipeServerStream(PipeName, PipeDirection.Out)) - { - evt.Set(); - srv.WaitForConnection(); - s.CopyTo(srv); - srv.WaitForPipeDrain(); - } - } - catch (Exception ee) - { - e = ee; - } - }); - thr.Start(); - evt.Wait(); - } + try + { + using var srv = new NamedPipeServerStream(PipeName, PipeDirection.Out); + evt.Set(); + srv.WaitForConnection(); + s.CopyTo(srv); + srv.WaitForPipeDrain(); + } + catch (Exception ee) + { + e = ee; + } + }); + thr.Start(); + evt.Wait(); } public void Finish() diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/LibSaturnus.cs b/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/LibSaturnus.cs index 7c5aba98e9..8e7ab77599 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/LibSaturnus.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/LibSaturnus.cs @@ -1,11 +1,7 @@ using BizHawk.BizInvoke; using BizHawk.Emulation.Cores.Waterbox; using System; -using System.Collections.Generic; -using System.Linq; using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; namespace BizHawk.Emulation.Cores.Consoles.Sega.Saturn { diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Saturnus.cs b/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Saturnus.cs index e6f964818b..39d8305bbc 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Saturnus.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Saturnus.cs @@ -1,5 +1,4 @@ using BizHawk.Common; -using BizHawk.BizInvoke; using BizHawk.Common.BufferExtensions; using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Waterbox; diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/SaturnusControllerDeck.cs b/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/SaturnusControllerDeck.cs index 5f02e69389..3b9fa7f694 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/SaturnusControllerDeck.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/SaturnusControllerDeck.cs @@ -3,8 +3,6 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; -using System.Text; -using System.Threading.Tasks; using static BizHawk.Emulation.Common.ControllerDefinition; namespace BizHawk.Emulation.Cores.Consoles.Sega.Saturn diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GenDbgHlp.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GenDbgHlp.cs index b3d278cb25..64d0180f0c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GenDbgHlp.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GenDbgHlp.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Runtime.InteropServices; using System.IO; diff --git a/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PPSSPPDll.cs b/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PPSSPPDll.cs index 3af2c759d6..3cbfa6208a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PPSSPPDll.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PPSSPPDll.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Runtime.InteropServices; +using System.Runtime.InteropServices; namespace BizHawk.Emulation.Cores.Sony.PSP { diff --git a/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs b/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs index 327518e667..9219ec02b4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs @@ -62,10 +62,10 @@ namespace BizHawk.Emulation.Cores.Sony.PSP } }; - public ControllerDefinition ControllerDefinition { get { return PSPController; } } - public bool DeterministicEmulation { get { return true; } } - public string SystemId { get { return "PSP"; } } - public CoreComm CoreComm { get; private set; } + public ControllerDefinition ControllerDefinition => PSPController; + public bool DeterministicEmulation => true; + public string SystemId => "PSP"; + public CoreComm CoreComm { get; } PPSSPPDll.LogCB logcallback = null; Queue debugmsgs = new Queue(); @@ -87,7 +87,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSP static PSP attachedcore = null; object glcontext; - public IEmulatorServiceProvider ServiceProvider { get; private set; } + public IEmulatorServiceProvider ServiceProvider { get; } public void Dispose() { @@ -165,29 +165,23 @@ namespace BizHawk.Emulation.Cores.Sony.PSP const int screenwidth = 480; const int screenheight = 272; readonly int[] screenbuffer = new int[screenwidth * screenheight]; - public int[] GetVideoBuffer() { return screenbuffer; } - public int VirtualWidth { get { return screenwidth; } } - public int VirtualHeight { get { return screenheight; } } - public int BufferWidth { get { return screenwidth; } } - public int BufferHeight { get { return screenheight; } } - public int BackgroundColor { get { return unchecked((int)0xff000000); } } + public int[] GetVideoBuffer() => screenbuffer; + public int VirtualWidth => screenwidth; + public int VirtualHeight => screenheight; + public int BufferWidth => screenwidth; + public int BufferHeight => screenheight; + public int BackgroundColor => unchecked((int)0xff000000); public int VsyncNumerator { [FeatureNotImplemented] - get - { - return NullVideo.DefaultVsyncNum; - } + get => NullVideo.DefaultVsyncNum; } public int VsyncDenominator { [FeatureNotImplemented] - get - { - return NullVideo.DefaultVsyncDen; - } + get => NullVideo.DefaultVsyncDen; } readonly short[] audiobuffer = new short[2048 * 2]; @@ -202,10 +196,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSP { } - public bool CanProvideAsync - { - get { return false; } - } + public bool CanProvideAsync => false; public void SetSyncMode(SyncSoundMode mode) { @@ -215,10 +206,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSP } } - public SyncSoundMode SyncMode - { - get { return SyncSoundMode.Sync; } - } + public SyncSoundMode SyncMode => SyncSoundMode.Sync; public void GetSamplesAsync(short[] samples) { diff --git a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.IDebuggable.cs index b71f3223f5..aa4c3127dc 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.IDebuggable.cs @@ -1,8 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; - using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Sony.PSX @@ -81,17 +78,14 @@ namespace BizHawk.Emulation.Cores.Sony.PSX } private readonly MemoryCallbackSystem _memoryCallbacks = new MemoryCallbackSystem(new[] { "System Bus" }); // Note: there is no system bus memory domain, but there's also no hard rule that the memory callback system domains have to correspond to actual domains in MemoryDomains, that could be good, or bad, but something to be careful about - public IMemoryCallbackSystem MemoryCallbacks { get { return _memoryCallbacks; } } + public IMemoryCallbackSystem MemoryCallbacks => _memoryCallbacks; - public bool CanStep(StepType type) { return false; } + public bool CanStep(StepType type) => false; [FeatureNotImplemented] - public void Step(StepType type) { throw new NotImplementedException(); } + public void Step(StepType type) => throw new NotImplementedException(); [FeatureNotImplemented] - public long TotalExecutedCycles - { - get { throw new NotImplementedException(); } - } + public long TotalExecutedCycles => throw new NotImplementedException(); } } diff --git a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.IDisassemblable.cs b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.IDisassemblable.cs index 677a095a64..45b361a75d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.IDisassemblable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.IDisassemblable.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - +using System.Collections.Generic; using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Sony.PSX @@ -23,10 +19,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX } } - public string PCRegisterName - { - get { return "pc"; } - } + public string PCRegisterName => "pc"; public string Disassemble(MemoryDomain m, uint addr, out int length) { diff --git a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.ITraceable.cs b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.ITraceable.cs index c29e954164..cc25c8db5e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.ITraceable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.ITraceable.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Text; using BizHawk.Emulation.Common; diff --git a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs index 7ea9d57fdc..e468c90680 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs @@ -14,7 +14,6 @@ using System; using System.ComponentModel; using System.Runtime.InteropServices; using System.IO; -using System.Linq; using System.Collections.Generic; using System.Text; @@ -429,7 +428,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX List discInterfaces = new List(); DiscInterface currentDiscInterface; - public DisplayType Region { get { return SystemVidStandard == OctoshockDll.eVidStandard.PAL ? DisplayType.PAL : DisplayType.NTSC; } } + public DisplayType Region => SystemVidStandard == OctoshockDll.eVidStandard.PAL ? DisplayType.PAL : DisplayType.NTSC; public OctoshockDll.eRegion SystemRegion { get; private set; } public OctoshockDll.eVidStandard SystemVidStandard { get; private set; } @@ -448,8 +447,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX void Attach() { //attach this core as the current - if (CurrOctoshockCore != null) - CurrOctoshockCore.Dispose(); + CurrOctoshockCore?.Dispose(); CurrOctoshockCore = this; //the psx instance cant be created until the desired region is known, which needs a disc, so we need the dll static attached first @@ -567,7 +565,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX public class ResolutionInfo { public System.Drawing.Size Resolution, Padding; - public System.Drawing.Size Total { get { return System.Drawing.Size.Add(Resolution, Padding); } } + public System.Drawing.Size Total => System.Drawing.Size.Add(Resolution, Padding); } /// @@ -873,19 +871,18 @@ namespace BizHawk.Emulation.Cores.Sony.PSX public IInputCallbackSystem InputCallbacks { [FeatureNotImplemented] - get - { throw new NotImplementedException(); } + get => throw new NotImplementedException(); } [FeatureNotImplemented] - public bool DeterministicEmulation { get { return true; } } + public bool DeterministicEmulation => true; - public int[] GetVideoBuffer() { return frameBuffer; } + public int[] GetVideoBuffer() => frameBuffer; public int VirtualWidth { get; private set; } public int VirtualHeight { get; private set; } public int BufferWidth { get; private set; } public int BufferHeight { get; private set; } - public int BackgroundColor { get { return 0; } } + public int BackgroundColor => 0; public int VsyncNumerator { get; private set; } public int VsyncDenominator { get; private set; } @@ -977,10 +974,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX sbuffcontains = 0; } - public bool CanProvideAsync - { - get { return false; } - } + public bool CanProvideAsync => false; public void SetSyncMode(SyncSoundMode mode) { @@ -990,10 +984,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX } } - public SyncSoundMode SyncMode - { - get { return SyncSoundMode.Sync; } - } + public SyncSoundMode SyncMode => SyncSoundMode.Sync; public void GetSamplesAsync(short[] samples) { diff --git a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/OctoshockFIOConfig.cs b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/OctoshockFIOConfig.cs index d5fd8dedad..bc0ee54f2a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/OctoshockFIOConfig.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/OctoshockFIOConfig.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; - -namespace BizHawk.Emulation.Cores.Sony.PSX +namespace BizHawk.Emulation.Cores.Sony.PSX { /// /// Represents a user's view of what equipment is plugged into the PSX FIO @@ -48,7 +45,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX /// /// Total number of connected memcards /// - public int NumMemcards { get { return (Memcards[0] ? 1 : 0) + (Memcards[1] ? 1 : 0); } } + public int NumMemcards => (Memcards[0] ? 1 : 0) + (Memcards[1] ? 1 : 0); internal void PopulateFrom(OctoshockFIOConfigUser userConfig) { diff --git a/BizHawk.Emulation.Cores/Consoles/WonderSwan/BizSwan.cs b/BizHawk.Emulation.Cores/Consoles/WonderSwan/BizSwan.cs index 6fa82e83a6..f6a889adc6 100644 --- a/BizHawk.Emulation.Cores/Consoles/WonderSwan/BizSwan.cs +++ b/BizHawk.Emulation.Cores/Consoles/WonderSwan/BizSwan.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Text; using System.Runtime.InteropServices; using BizHawk.Emulation.Common; diff --git a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs index 31c740dd6f..f73be1eb83 100644 --- a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs +++ b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs @@ -50,7 +50,7 @@ namespace BizHawk.Emulation.Cores.WonderSwan } } - public IEmulatorServiceProvider ServiceProvider { get; private set; } + public IEmulatorServiceProvider ServiceProvider { get; } public void Dispose() { @@ -83,7 +83,7 @@ namespace BizHawk.Emulation.Cores.WonderSwan return true; } - public CoreComm CoreComm { get; private set; } + public CoreComm CoreComm { get; } public void ResetCounters() { @@ -98,16 +98,16 @@ namespace BizHawk.Emulation.Cores.WonderSwan public int LagCount { get; set; } public bool IsLagFrame { get; set; } - public string SystemId { get { return "WSWAN"; } } - public bool DeterministicEmulation { get; private set; } + public string SystemId => "WSWAN"; + public bool DeterministicEmulation { get; } #region Debugging private readonly InputCallbackSystem _inputCallbacks = new InputCallbackSystem(); - public IInputCallbackSystem InputCallbacks { get { return _inputCallbacks; } } + public IInputCallbackSystem InputCallbacks => _inputCallbacks; private readonly MemoryCallbackSystem _memorycallbacks = new MemoryCallbackSystem(new[] { "System Bus" }); // This isn't an actual memory domain in this core (yet), but there's nothing that enforces that it has to be - public IMemoryCallbackSystem MemoryCallbacks { get { return _memorycallbacks; } } + public IMemoryCallbackSystem MemoryCallbacks => _memorycallbacks; public IDictionary GetCpuFlagsAndRegisters() { @@ -127,13 +127,13 @@ namespace BizHawk.Emulation.Cores.WonderSwan throw new NotImplementedException(); } - public bool CanStep(StepType type) { return false; } + public bool CanStep(StepType type) => false; [FeatureNotImplemented] - public void Step(StepType type) { throw new NotImplementedException(); } + public void Step(StepType type) => throw new NotImplementedException(); [FeatureNotImplemented] - public long TotalExecutedCycles { get { throw new NotImplementedException(); } } + public long TotalExecutedCycles => throw new NotImplementedException(); BizSwan.MemoryCallback ReadCallbackD; BizSwan.MemoryCallback WriteCallbackD; @@ -203,16 +203,13 @@ namespace BizHawk.Emulation.Cores.WonderSwan private int[] vbuff = new int[224 * 144]; - public int[] GetVideoBuffer() - { - return vbuff; - } + public int[] GetVideoBuffer() => vbuff; - public int VirtualWidth { get { return BufferWidth; } } - public int VirtualHeight { get { return BufferHeight; } } + public int VirtualWidth => BufferWidth; + public int VirtualHeight => BufferHeight; public int BufferWidth { get; private set; } public int BufferHeight { get; private set; } - public int BackgroundColor { get { return unchecked((int)0xff000000); } } + public int BackgroundColor => unchecked((int)0xff000000); public int VsyncNumerator => 3072000; // master CPU clock, also pixel clock public int VsyncDenominator => (144 + 15) * (224 + 32); // 144 vislines, 15 vblank lines; 224 vispixels, 32 hblank pixels diff --git a/BizHawk.Emulation.Cores/FileID.cs b/BizHawk.Emulation.Cores/FileID.cs index 8519aec6f7..9a4511a2e0 100644 --- a/BizHawk.Emulation.Cores/FileID.cs +++ b/BizHawk.Emulation.Cores/FileID.cs @@ -2,8 +2,6 @@ using System.IO; using System.Collections.Generic; -using BizHawk.Common; - //HOW TO USE //we dont expect anyone to use this fully yet. It's just over-engineered for future use. //for now, just use it when you truly dont know what to do with a file. diff --git a/BizHawk.Emulation.Cores/Libretro/LibretroApi.cs b/BizHawk.Emulation.Cores/Libretro/LibretroApi.cs index ac346002c3..10da3fbc28 100644 --- a/BizHawk.Emulation.Cores/Libretro/LibretroApi.cs +++ b/BizHawk.Emulation.Cores/Libretro/LibretroApi.cs @@ -4,13 +4,7 @@ //(the bridge wraps libretro API and presents a very different interface) using System; -using System.Diagnostics; -using System.IO; -using System.IO.Pipes; -using System.Collections.Generic; using System.Runtime.InteropServices; -using System.IO.MemoryMappedFiles; - using BizHawk.Common; namespace BizHawk.Emulation.Cores.Libretro @@ -48,7 +42,7 @@ namespace BizHawk.Emulation.Cores.Libretro { T GetTypedDelegate(string proc) where T : Delegate => (T) Marshal.GetDelegateForFunctionPointer(instanceDll.GetProcAddrOrThrow(proc), typeof(T)); - InstanceName = "libretro_" + Guid.NewGuid().ToString(); + InstanceName = "libretro_" + Guid.NewGuid(); var pipeName = InstanceName; @@ -202,11 +196,9 @@ namespace BizHawk.Emulation.Cores.Libretro public fixed ulong buf_size[(int)BufId.BufId_Num]; //actually a size_t //utilities - public bool GetBoolValue() { return value != 0; } //should this be here or by the other helpers? I dont know + public bool GetBoolValue() => value != 0; // should this be here or by the other helpers? I dont know } - public retro_system_av_info AVInfo { get { return comm->env.retro_system_av_info; } } - + public retro_system_av_info AVInfo => comm->env.retro_system_av_info; } //class - } diff --git a/BizHawk.Emulation.Cores/Libretro/LibretroApi_BRK.cs b/BizHawk.Emulation.Cores/Libretro/LibretroApi_BRK.cs index 98c89e17e1..1a0dab0fac 100644 --- a/BizHawk.Emulation.Cores/Libretro/LibretroApi_BRK.cs +++ b/BizHawk.Emulation.Cores/Libretro/LibretroApi_BRK.cs @@ -1,8 +1,4 @@ -using System; - -using BizHawk.Common; - -namespace BizHawk.Emulation.Cores.Libretro +namespace BizHawk.Emulation.Cores.Libretro { unsafe partial class LibretroApi { diff --git a/BizHawk.Emulation.Cores/Libretro/LibretroApi_CMD.cs b/BizHawk.Emulation.Cores/Libretro/LibretroApi_CMD.cs index 21ceffb8b6..d5f4945247 100644 --- a/BizHawk.Emulation.Cores/Libretro/LibretroApi_CMD.cs +++ b/BizHawk.Emulation.Cores/Libretro/LibretroApi_CMD.cs @@ -1,8 +1,4 @@ -using System; - -using BizHawk.Common; - -namespace BizHawk.Emulation.Cores.Libretro +namespace BizHawk.Emulation.Cores.Libretro { unsafe partial class LibretroApi { diff --git a/BizHawk.Emulation.Cores/Libretro/LibretroApi_Delegates.cs b/BizHawk.Emulation.Cores/Libretro/LibretroApi_Delegates.cs index 98487983d6..2586fb027d 100644 --- a/BizHawk.Emulation.Cores/Libretro/LibretroApi_Delegates.cs +++ b/BizHawk.Emulation.Cores/Libretro/LibretroApi_Delegates.cs @@ -1,7 +1,4 @@ -using System; -using System.Runtime.InteropServices; - -namespace BizHawk.Emulation.Cores.Libretro +namespace BizHawk.Emulation.Cores.Libretro { } diff --git a/BizHawk.Emulation.Cores/Libretro/LibretroApi_Enums.cs b/BizHawk.Emulation.Cores/Libretro/LibretroApi_Enums.cs index 35da284c5a..756e2c0893 100644 --- a/BizHawk.Emulation.Cores/Libretro/LibretroApi_Enums.cs +++ b/BizHawk.Emulation.Cores/Libretro/LibretroApi_Enums.cs @@ -1,7 +1,5 @@ using System; -using BizHawk.Common; - namespace BizHawk.Emulation.Cores.Libretro { unsafe partial class LibretroApi diff --git a/BizHawk.Emulation.Cores/Libretro/LibretroApi_QUERY.cs b/BizHawk.Emulation.Cores/Libretro/LibretroApi_QUERY.cs index f0dd8d5fd8..7d4a8de7df 100644 --- a/BizHawk.Emulation.Cores/Libretro/LibretroApi_QUERY.cs +++ b/BizHawk.Emulation.Cores/Libretro/LibretroApi_QUERY.cs @@ -1,7 +1,5 @@ using System; -using BizHawk.Common; - namespace BizHawk.Emulation.Cores.Libretro { unsafe partial class LibretroApi diff --git a/BizHawk.Emulation.Cores/Libretro/LibretroApi_SIG.cs b/BizHawk.Emulation.Cores/Libretro/LibretroApi_SIG.cs index 2fe71a5fb5..7453a53bc7 100644 --- a/BizHawk.Emulation.Cores/Libretro/LibretroApi_SIG.cs +++ b/BizHawk.Emulation.Cores/Libretro/LibretroApi_SIG.cs @@ -1,8 +1,4 @@ -using System; - -using BizHawk.Common; - -namespace BizHawk.Emulation.Cores.Libretro +namespace BizHawk.Emulation.Cores.Libretro { unsafe partial class LibretroApi { diff --git a/BizHawk.Emulation.Cores/Libretro/LibretroApi_Structs.cs b/BizHawk.Emulation.Cores/Libretro/LibretroApi_Structs.cs index 817e9e8aec..1fd15cf945 100644 --- a/BizHawk.Emulation.Cores/Libretro/LibretroApi_Structs.cs +++ b/BizHawk.Emulation.Cores/Libretro/LibretroApi_Structs.cs @@ -1,12 +1,5 @@ using System; -using System.Diagnostics; -using System.IO; -using System.IO.Pipes; -using System.Collections.Generic; using System.Runtime.InteropServices; -using System.IO.MemoryMappedFiles; - -using BizHawk.Common; namespace BizHawk.Emulation.Cores.Libretro { diff --git a/BizHawk.Emulation.Cores/Libretro/LibretroCore.cs b/BizHawk.Emulation.Cores/Libretro/LibretroCore.cs index c27d7324ee..54b8174666 100644 --- a/BizHawk.Emulation.Cores/Libretro/LibretroCore.cs +++ b/BizHawk.Emulation.Cores/Libretro/LibretroCore.cs @@ -71,8 +71,7 @@ namespace BizHawk.Emulation.Cores.Libretro //api.CMD_unload_cartridge(); //api.CMD_term(); - if(resampler != null) - resampler.Dispose(); + resampler?.Dispose(); api.Dispose(); @@ -131,20 +130,20 @@ namespace BizHawk.Emulation.Cores.Libretro return new Dictionary(); } - public IInputCallbackSystem InputCallbacks { get { return _inputCallbacks; } } + public IInputCallbackSystem InputCallbacks => _inputCallbacks; private readonly InputCallbackSystem _inputCallbacks = new InputCallbackSystem(); public ITraceable Tracer { get; private set; } public IMemoryCallbackSystem MemoryCallbacks { get; private set; } - public bool CanStep(StepType type) { return false; } + public bool CanStep(StepType type) => false; [FeatureNotImplemented] - public void Step(StepType type) { throw new NotImplementedException(); } + public void Step(StepType type) => throw new NotImplementedException(); [FeatureNotImplemented] - public void SetCpuRegister(string register, int value) { throw new NotImplementedException(); } + public void SetCpuRegister(string register, int value) => throw new NotImplementedException(); [FeatureNotImplemented] - public long TotalExecutedCycles { get { throw new NotImplementedException(); } } + public long TotalExecutedCycles => throw new NotImplementedException(); private IController _controller; @@ -170,7 +169,7 @@ namespace BizHawk.Emulation.Cores.Libretro } //video provider - int IVideoProvider.BackgroundColor { get { return 0; } } + int IVideoProvider.BackgroundColor => 0; int[] IVideoProvider.GetVideoBuffer() { return vidBuffer; } public int VirtualWidth @@ -180,10 +179,9 @@ namespace BizHawk.Emulation.Cores.Libretro var dar = api.AVInfo.geometry.aspect_ratio; if(dar<=0) return vidWidth; - else if (dar > 1.0f) + if (dar > 1.0f) return (int)(vidHeight * dar); - else - return vidWidth; + return vidWidth; } } public int VirtualHeight @@ -195,8 +193,7 @@ namespace BizHawk.Emulation.Cores.Libretro return vidHeight; if (dar < 1.0f) return (int)(vidWidth / dar); - else - return vidHeight; + return vidHeight; } } @@ -205,8 +202,8 @@ namespace BizHawk.Emulation.Cores.Libretro SetVideoBuffer(api.comm->env.fb_width, api.comm->env.fb_height); } - int IVideoProvider.BufferWidth { get { return vidWidth; } } - int IVideoProvider.BufferHeight { get { return vidHeight; } } + int IVideoProvider.BufferWidth => vidWidth; + int IVideoProvider.BufferHeight => vidHeight; public int VsyncNumerator { get; private set; } public int VsyncDenominator { get; private set; } @@ -298,10 +295,10 @@ namespace BizHawk.Emulation.Cores.Libretro } public int LagCount { get; set; } public bool IsLagFrame { get; set; } - public string SystemId { get { return "Libretro"; } } - public bool DeterministicEmulation { get { return false; } } + public string SystemId => "Libretro"; + public bool DeterministicEmulation => false; - #region ISaveRam + #region ISaveRam //TODO - terrible things will happen if this changes at runtime byte[] saverambuff = new byte[0]; diff --git a/BizHawk.Emulation.Cores/Libretro/LibretroCoreSettings.cs b/BizHawk.Emulation.Cores/Libretro/LibretroCoreSettings.cs index 9662662fda..d46bfd8e48 100644 --- a/BizHawk.Emulation.Cores/Libretro/LibretroCoreSettings.cs +++ b/BizHawk.Emulation.Cores/Libretro/LibretroCoreSettings.cs @@ -1,4 +1,3 @@ -using System; using Newtonsoft.Json; using BizHawk.Common; diff --git a/BizHawk.Emulation.Cores/Libretro/LibretroCore_Description.cs b/BizHawk.Emulation.Cores/Libretro/LibretroCore_Description.cs index 8c7adf477c..f6828c52f0 100644 --- a/BizHawk.Emulation.Cores/Libretro/LibretroCore_Description.cs +++ b/BizHawk.Emulation.Cores/Libretro/LibretroCore_Description.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; namespace BizHawk.Emulation.Cores.Libretro @@ -46,7 +45,7 @@ namespace BizHawk.Emulation.Cores.Libretro public string Name; public string Description; public string[] Options; - public string DefaultOption { get { return Options[0]; } } + public string DefaultOption => Options[0]; public override string ToString() => $"{Name} ({Description}) = ({string.Join("|", Options)})"; } diff --git a/BizHawk.Emulation.Cores/Libretro/LibretroCore_InputCallbacks.cs b/BizHawk.Emulation.Cores/Libretro/LibretroCore_InputCallbacks.cs index 45e3dbca7a..5358fd180a 100644 --- a/BizHawk.Emulation.Cores/Libretro/LibretroCore_InputCallbacks.cs +++ b/BizHawk.Emulation.Cores/Libretro/LibretroCore_InputCallbacks.cs @@ -1,16 +1,4 @@ -using System; -using System.IO; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Runtime.InteropServices; -using Newtonsoft.Json; - -using BizHawk.Common; -using BizHawk.Emulation.Common; -using BizHawk.Common.BufferExtensions; - -namespace BizHawk.Emulation.Cores.Libretro +namespace BizHawk.Emulation.Cores.Libretro { partial class LibretroCore { diff --git a/BizHawk.Emulation.Cores/Properties/AssemblyInfo.cs b/BizHawk.Emulation.Cores/Properties/AssemblyInfo.cs index b11a364526..209b53e7aa 100644 --- a/BizHawk.Emulation.Cores/Properties/AssemblyInfo.cs +++ b/BizHawk.Emulation.Cores/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/BizHawk.Emulation.Cores/SideBySideVideo.cs b/BizHawk.Emulation.Cores/SideBySideVideo.cs index e624f69a41..564bff1152 100644 --- a/BizHawk.Emulation.Cores/SideBySideVideo.cs +++ b/BizHawk.Emulation.Cores/SideBySideVideo.cs @@ -1,9 +1,4 @@ using BizHawk.Emulation.Common; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace BizHawk.Emulation.Cores { diff --git a/BizHawk.Emulation.Cores/Sound/CDAudio.cs b/BizHawk.Emulation.Cores/Sound/CDAudio.cs index db892d3901..25a2c99073 100644 --- a/BizHawk.Emulation.Cores/Sound/CDAudio.cs +++ b/BizHawk.Emulation.Cores/Sound/CDAudio.cs @@ -1,6 +1,5 @@ using System; using BizHawk.Common; -using BizHawk.Emulation.Common; using BizHawk.Emulation.DiscSystem; // The state of the cd player is quantized to the frame level. diff --git a/BizHawk.Emulation.Cores/Sound/DualSyncSound.cs b/BizHawk.Emulation.Cores/Sound/DualSyncSound.cs index fd61031f22..25a37a607b 100644 --- a/BizHawk.Emulation.Cores/Sound/DualSyncSound.cs +++ b/BizHawk.Emulation.Cores/Sound/DualSyncSound.cs @@ -1,9 +1,5 @@ using BizHawk.Emulation.Common; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace BizHawk.Emulation.Cores.Sound { diff --git a/BizHawk.Emulation.Cores/Sound/SN76489sms.cs b/BizHawk.Emulation.Cores/Sound/SN76489sms.cs index 4e708f801a..95d397abcc 100644 --- a/BizHawk.Emulation.Cores/Sound/SN76489sms.cs +++ b/BizHawk.Emulation.Cores/Sound/SN76489sms.cs @@ -1,6 +1,4 @@ -using System; - -using BizHawk.Common; +using BizHawk.Common; using BizHawk.Common.NumberExtensions; namespace BizHawk.Emulation.Cores.Components diff --git a/BizHawk.Emulation.Cores/Sound/SyncSoundMixer.cs b/BizHawk.Emulation.Cores/Sound/SyncSoundMixer.cs index ce2d84af44..e3bc37285e 100644 --- a/BizHawk.Emulation.Cores/Sound/SyncSoundMixer.cs +++ b/BizHawk.Emulation.Cores/Sound/SyncSoundMixer.cs @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; using System.Linq; -using BizHawk.Common; namespace BizHawk.Emulation.Cores.Components { diff --git a/BizHawk.Emulation.Cores/Sound/YM2413.cs b/BizHawk.Emulation.Cores/Sound/YM2413.cs index f06c4fc875..003f2335d8 100644 --- a/BizHawk.Emulation.Cores/Sound/YM2413.cs +++ b/BizHawk.Emulation.Cores/Sound/YM2413.cs @@ -7,7 +7,6 @@ using System; using BizHawk.Common; -using BizHawk.Emulation.Cores.Components; namespace BizHawk.Emulation.Cores.Components { @@ -420,14 +419,15 @@ namespace BizHawk.Emulation.Cores.Components dphaseTable[fnum, block, ML] = RATE_ADJUST(((fnum * mltable[ML]) << (int)block) >> (20 - DP_BITS)); } - static double dB2(double x) { return ((x) * 2); } + static double dB2(double x)=> x * 2; static void makeTllTable() { - double[] kltable = new double[] { - dB2 (0.000), dB2 (9.000), dB2 (12.000), dB2 (13.875), dB2 (15.000), dB2 (16.125), dB2 (16.875), dB2 (17.625), - dB2 (18.000), dB2 (18.750), dB2 (19.125), dB2 (19.500), dB2 (19.875), dB2 (20.250), dB2 (20.625), dB2 (21.000) - }; + double[] kltable = + { + dB2 (0.000), dB2 (9.000), dB2 (12.000), dB2 (13.875), dB2 (15.000), dB2 (16.125), dB2 (16.875), dB2 (17.625), + dB2 (18.000), dB2 (18.750), dB2 (19.125), dB2 (19.500), dB2 (19.875), dB2 (20.250), dB2 (20.625), dB2 (21.000) + }; int tmp; int fnum, block, TL, KL; @@ -1111,10 +1111,11 @@ namespace BizHawk.Emulation.Cores.Components /* EG */ static uint S2E(double x) { return (SL2EG((uint)(x / SL_STEP)) << (EG_DP_BITS - EG_BITS)); } - static uint[] SL = new[] { - S2E (0.0), S2E (3.0), S2E (6.0), S2E (9.0), S2E (12.0), S2E (15.0), S2E (18.0), S2E (21.0), - S2E (24.0), S2E (27.0), S2E (30.0), S2E (33.0), S2E (36.0), S2E (39.0), S2E (42.0), S2E (48.0) - }; + static uint[] SL = + { + S2E (0.0), S2E (3.0), S2E (6.0), S2E (9.0), S2E (12.0), S2E (15.0), S2E (18.0), S2E (21.0), + S2E (24.0), S2E (27.0), S2E (30.0), S2E (33.0), S2E (36.0), S2E (39.0), S2E (42.0), S2E (48.0) + }; static void calc_envelope(OPLL_SLOT slot, int lfo) { @@ -1686,8 +1687,8 @@ namespace BizHawk.Emulation.Cores.Components static void calc_stereo(OPLL opll, int[] output) { - int[] b = new[] { 0, 0, 0, 0 }; /* Ignore, Right, Left, Center */ - int[] r = new[] { 0, 0, 0, 0 }; /* Ignore, Right, Left, Center */ + int[] b = { 0, 0, 0, 0 }; /* Ignore, Right, Left, Center */ + int[] r = { 0, 0, 0, 0 }; /* Ignore, Right, Left, Center */ int i; update_ampm(opll); diff --git a/BizHawk.Emulation.Cores/Sound/YM2612.cs b/BizHawk.Emulation.Cores/Sound/YM2612.cs index 5d091bd1f6..a880d1a7c0 100644 --- a/BizHawk.Emulation.Cores/Sound/YM2612.cs +++ b/BizHawk.Emulation.Cores/Sound/YM2612.cs @@ -2,8 +2,6 @@ using System.Collections.Generic; using System.IO; -using BizHawk.Emulation.Cores.Components; - namespace BizHawk.Emulation.Cores.Components { // ====================================================================== @@ -449,12 +447,12 @@ namespace BizHawk.Emulation.Cores.Components int TimerALastReset, TimerBLastReset; byte TimerControl27; - bool TimerALoad { get { return (TimerControl27 & 1) != 0; } } - bool TimerBLoad { get { return (TimerControl27 & 2) != 0; } } - bool TimerAEnable { get { return (TimerControl27 & 4) != 0; } } - bool TimerBEnable { get { return (TimerControl27 & 8) != 0; } } - bool TimerAReset { get { return (TimerControl27 & 16) != 0; } } - bool TimerBReset { get { return (TimerControl27 & 32) != 0; } } + bool TimerALoad => (TimerControl27 & 1) != 0; + bool TimerBLoad => (TimerControl27 & 2) != 0; + bool TimerAEnable => (TimerControl27 & 4) != 0; + bool TimerBEnable => (TimerControl27 & 8) != 0; + bool TimerAReset => (TimerControl27 & 16) != 0; + bool TimerBReset => (TimerControl27 & 32) != 0; void InitTimers() { @@ -998,9 +996,9 @@ namespace BizHawk.Emulation.Cores.Components } } - public int Normalized10BitSL { get { return slTable[SL_SustainLevel]; } } - public int Normalized10BitTL { get { return TL_TotalLevel << 3; } } - public int AdjustedEGOutput { get { return Math.Min(egAttenuation + Normalized10BitTL, 1023); } } + public int Normalized10BitSL => slTable[SL_SustainLevel]; + public int Normalized10BitTL => TL_TotalLevel << 3; + public int AdjustedEGOutput => Math.Min(egAttenuation + Normalized10BitTL, 1023); } public sealed class Channel diff --git a/BizHawk.Emulation.Cores/Waterbox/CustomSaverammer.cs b/BizHawk.Emulation.Cores/Waterbox/CustomSaverammer.cs index ae1834f235..f0f0fbd4fd 100644 --- a/BizHawk.Emulation.Cores/Waterbox/CustomSaverammer.cs +++ b/BizHawk.Emulation.Cores/Waterbox/CustomSaverammer.cs @@ -1,9 +1,5 @@ using BizHawk.Emulation.Common; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace BizHawk.Emulation.Cores.Waterbox { diff --git a/BizHawk.Emulation.Cores/Waterbox/ElfRunner.cs b/BizHawk.Emulation.Cores/Waterbox/ElfRunner.cs index bf25788023..17f68d3ebc 100644 --- a/BizHawk.Emulation.Cores/Waterbox/ElfRunner.cs +++ b/BizHawk.Emulation.Cores/Waterbox/ElfRunner.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; using System.Runtime.InteropServices; using ELFSharp.ELF; using ELFSharp.ELF.Sections; @@ -10,8 +9,6 @@ using System.Reflection; using BizHawk.Common; using System.Security.Cryptography; using System.IO; -using System.Collections.Concurrent; -using System.Threading; using BizHawk.Emulation.Common; using BizHawk.BizInvoke; @@ -413,8 +410,8 @@ namespace BizHawk.Emulation.Cores.Waterbox ms.CopyTo(bw.BaseStream); } - if (_heap != null) _heap.SaveStateBinary(bw); - if (_sealedheap != null) _sealedheap.SaveStateBinary(bw); + _heap?.SaveStateBinary(bw); + _sealedheap?.SaveStateBinary(bw); bw.Write(MAGIC); } finally @@ -444,13 +441,13 @@ namespace BizHawk.Emulation.Cores.Waterbox WaterboxUtils.CopySome(br.BaseStream, ms, len); } - if (_heap != null) _heap.LoadStateBinary(br); - if (_sealedheap != null) _sealedheap.LoadStateBinary(br); + _heap?.LoadStateBinary(br); + _sealedheap?.LoadStateBinary(br); if (br.ReadUInt64() != MAGIC) throw new InvalidOperationException("Magic not magic enough!"); // the syscall trampolines were overwritten in loadstate (they're in .bss), and if we're cross-session, - // are no longer valid. cores must similiarly resend any external pointers they gave the core. + // are no longer valid. cores must similarly resend any external pointers they gave the core. ConnectAllClibPatches(); } finally @@ -465,11 +462,9 @@ namespace BizHawk.Emulation.Cores.Waterbox private byte[] HashSection(ulong ptr, ulong len) { - using (var h = SHA1.Create()) - { - var ms = _base.GetStream(ptr, len, false); - return h.ComputeHash(ms); - } + using var h = SHA1.Create(); + var ms = _base.GetStream(ptr, len, false); + return h.ComputeHash(ms); } #endregion diff --git a/BizHawk.Emulation.Cores/Waterbox/Heap.cs b/BizHawk.Emulation.Cores/Waterbox/Heap.cs index 9e8f94976c..e1a0823b9f 100644 --- a/BizHawk.Emulation.Cores/Waterbox/Heap.cs +++ b/BizHawk.Emulation.Cores/Waterbox/Heap.cs @@ -1,10 +1,8 @@ using BizHawk.BizInvoke; using BizHawk.Emulation.Common; using System; -using System.Collections.Generic; using System.IO; using System.Linq; -using System.Text; namespace BizHawk.Emulation.Cores.Waterbox { diff --git a/BizHawk.Emulation.Cores/Waterbox/LibWaterboxCore.cs b/BizHawk.Emulation.Cores/Waterbox/LibWaterboxCore.cs index 85f843beb9..f20246814a 100644 --- a/BizHawk.Emulation.Cores/Waterbox/LibWaterboxCore.cs +++ b/BizHawk.Emulation.Cores/Waterbox/LibWaterboxCore.cs @@ -2,11 +2,7 @@ using BizHawk.BizInvoke; using BizHawk.Emulation.Common; using System; -using System.Collections.Generic; -using System.Linq; using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; namespace BizHawk.Emulation.Cores.Waterbox { diff --git a/BizHawk.Emulation.Cores/Waterbox/MapHeap.cs b/BizHawk.Emulation.Cores/Waterbox/MapHeap.cs index e28ba4785b..2504ca6eb4 100644 --- a/BizHawk.Emulation.Cores/Waterbox/MapHeap.cs +++ b/BizHawk.Emulation.Cores/Waterbox/MapHeap.cs @@ -2,8 +2,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.IO; using System.Runtime.InteropServices; using BizHawk.BizInvoke; diff --git a/BizHawk.Emulation.Cores/Waterbox/PeRunner.cs b/BizHawk.Emulation.Cores/Waterbox/PeRunner.cs index 0bf48dbcad..f598a1029c 100644 --- a/BizHawk.Emulation.Cores/Waterbox/PeRunner.cs +++ b/BizHawk.Emulation.Cores/Waterbox/PeRunner.cs @@ -1,14 +1,11 @@ using BizHawk.Common; using BizHawk.BizInvoke; using BizHawk.Emulation.Common; -using PeNet; using System; using System.Collections.Generic; using System.IO; -using System.IO.Compression; using System.Linq; using System.Runtime.InteropServices; -using System.Text; namespace BizHawk.Emulation.Cores.Waterbox { @@ -1011,10 +1008,8 @@ namespace BizHawk.Emulation.Cores.Waterbox byte[] data; if (File.Exists(gzpath)) { - using (var fs = new FileStream(gzpath, FileMode.Open, FileAccess.Read)) - { - data = Util.DecompressGzipFile(fs); - } + using var fs = new FileStream(gzpath, FileMode.Open, FileAccess.Read); + data = Util.DecompressGzipFile(fs); } else { @@ -1129,8 +1124,8 @@ namespace BizHawk.Emulation.Cores.Waterbox { pe.SealImportsAndTakeXorSnapshot(); } - if (_mmapheap != null) - _mmapheap.Memory.SaveXorSnapshot(); + + _mmapheap?.Memory.SaveXorSnapshot(); } } diff --git a/BizHawk.Emulation.Cores/Waterbox/Swappable.cs b/BizHawk.Emulation.Cores/Waterbox/Swappable.cs index dc04aceea3..a84431ffb7 100644 --- a/BizHawk.Emulation.Cores/Waterbox/Swappable.cs +++ b/BizHawk.Emulation.Cores/Waterbox/Swappable.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; -using System.Text; using System.Threading; namespace BizHawk.Emulation.Cores.Waterbox @@ -70,17 +69,11 @@ namespace BizHawk.Emulation.Cores.Waterbox #endif public Swappable Loaded { - get - { - // if somehow an object died without being disposed, - // the MemoryBlock finalizer will have unloaded the memory - // and so we can treat it as if no Swappable was attached - return (Swappable)LoadedRef.Target; - } - set - { - LoadedRef.Target = value; - } + // if somehow an object died without being disposed, + // the MemoryBlock finalizer will have unloaded the memory + // and so we can treat it as if no Swappable was attached + get => (Swappable)LoadedRef.Target; + set => LoadedRef.Target = value; } } @@ -98,8 +91,7 @@ namespace BizHawk.Emulation.Cores.Waterbox #endif if (_currentLockInfo.Loaded != this) { - if (_currentLockInfo.Loaded != null) - _currentLockInfo.Loaded.DeactivateInternal(); + _currentLockInfo.Loaded?.DeactivateInternal(); _currentLockInfo.Loaded = null; ActivateInternal(); _currentLockInfo.Loaded = this; diff --git a/BizHawk.Emulation.Cores/Waterbox/WaterboxUtils.cs b/BizHawk.Emulation.Cores/Waterbox/WaterboxUtils.cs index 27584b1a0b..8157daaa4f 100644 --- a/BizHawk.Emulation.Cores/Waterbox/WaterboxUtils.cs +++ b/BizHawk.Emulation.Cores/Waterbox/WaterboxUtils.cs @@ -1,9 +1,6 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; using System.Security.Cryptography; -using System.Text; namespace BizHawk.Emulation.Cores.Waterbox { @@ -25,18 +22,14 @@ namespace BizHawk.Emulation.Cores.Waterbox public static byte[] Hash(byte[] data) { - using (var h = SHA1.Create()) - { - return h.ComputeHash(data); - } + using var h = SHA1.Create(); + return h.ComputeHash(data); } public static byte[] Hash(Stream s) { - using (var h = SHA1.Create()) - { - return h.ComputeHash(s); - } + using var h = SHA1.Create(); + return h.ComputeHash(s); } public static unsafe void ZeroMemory(IntPtr mem, long length) @@ -57,16 +50,16 @@ namespace BizHawk.Emulation.Cores.Waterbox /// /// system page size /// - public static int PageSize { get; private set; } + public static int PageSize { get; } /// /// bitshift corresponding to PageSize /// - public static int PageShift { get; private set; } + public static int PageShift { get; } /// /// bitmask corresponding to PageSize /// - public static ulong PageMask { get; private set; } + public static ulong PageMask { get; } static WaterboxUtils() { @@ -122,32 +115,28 @@ namespace BizHawk.Emulation.Cores.Waterbox { if (IntPtr.Size == 8) return (IntPtr)(long)l; - else - return (IntPtr)(int)l; + return (IntPtr)(int)l; } public static UIntPtr UU(ulong l) { if (UIntPtr.Size == 8) return (UIntPtr)l; - else - return (UIntPtr)(uint)l; + return (UIntPtr)(uint)l; } public static IntPtr SS(long l) { if (IntPtr.Size == 8) return (IntPtr)l; - else - return (IntPtr)(int)l; + return (IntPtr)(int)l; } public static UIntPtr SU(long l) { if (UIntPtr.Size == 8) return (UIntPtr)(ulong)l; - else - return (UIntPtr)(uint)l; + return (UIntPtr)(uint)l; } } } diff --git a/BizHawk.sln.DotSettings b/BizHawk.sln.DotSettings index a84748d623..cf3f701ce2 100644 --- a/BizHawk.sln.DotSettings +++ b/BizHawk.sln.DotSettings @@ -206,6 +206,7 @@ True True True + True True True True @@ -231,6 +232,7 @@ True True True + True True True True