make fields readonly where possible

This commit is contained in:
adelikat 2020-12-15 16:00:48 -06:00
parent 213729550d
commit b83556fc6f
150 changed files with 392 additions and 392 deletions

View File

@ -37,7 +37,7 @@ namespace BizHawk.Client.Common
private readonly Queue<short> buffer = new Queue<short>(MaxExcessSamples); private readonly Queue<short> buffer = new Queue<short>(MaxExcessSamples);
private int SamplesInOneFrame = 1470; private int SamplesInOneFrame = 1470;
private int TargetExtraSamples = 882; private readonly int TargetExtraSamples = 882;
private const int MaxExcessSamples = 4096; private const int MaxExcessSamples = 4096;
/// <summary> /// <summary>

View File

@ -22,7 +22,7 @@ namespace BizHawk.Client.Common
private readonly WorkingDictionary<string, bool> _buttons = new WorkingDictionary<string, bool>(); private readonly WorkingDictionary<string, bool> _buttons = new WorkingDictionary<string, bool>();
private readonly WorkingDictionary<string, int> _buttonStarts = new WorkingDictionary<string, int>(); private readonly WorkingDictionary<string, int> _buttonStarts = new WorkingDictionary<string, int>();
private bool _autofire = true; private readonly bool _autofire = true;
public int On { get; set; } public int On { get; set; }
public int Off { get; set; } public int Off { get; set; }

View File

@ -49,7 +49,7 @@ namespace BizHawk.Common
} }
} }
private static MethodInfo ArrayEqualsGeneric = typeof(DeepEquality).GetMethod("ArrayEquals", BindingFlags.NonPublic | BindingFlags.Static); private static readonly MethodInfo ArrayEqualsGeneric = typeof(DeepEquality).GetMethod("ArrayEquals", BindingFlags.NonPublic | BindingFlags.Static);
/// <summary>test if two objects <paramref name="o1"/> and <paramref name="o2"/> are equal, field-by-field (with deep inspection of each field)</summary> /// <summary>test if two objects <paramref name="o1"/> and <paramref name="o2"/> are equal, field-by-field (with deep inspection of each field)</summary>
/// <exception cref="InvalidOperationException"><paramref name="o1"/> is an array with rank > 1 or is a non-zero-indexed array</exception> /// <exception cref="InvalidOperationException"><paramref name="o1"/> is an array with rank > 1 or is a non-zero-indexed array</exception>

View File

@ -63,7 +63,7 @@ namespace BizHawk.Common
public static Stream HACK_LOG_STREAM; public static Stream HACK_LOG_STREAM;
private static readonly bool LogToConsole = false; private static readonly bool LogToConsole = false;
private static bool LogToFile = false; private static readonly bool LogToFile = false;
private const string LogFilename = "bizhawk.txt"; private const string LogFilename = "bizhawk.txt";
private static StreamWriter writer; private static StreamWriter writer;

View File

@ -13,12 +13,12 @@ namespace BizHawk.Emulation.Common
{ {
public static class Database public static class Database
{ {
private static Dictionary<string, CompactGameInfo> DB = new Dictionary<string, CompactGameInfo>(); private static readonly Dictionary<string, CompactGameInfo> DB = new Dictionary<string, CompactGameInfo>();
/// <summary> /// <summary>
/// blocks until the DB is done loading /// blocks until the DB is done loading
/// </summary> /// </summary>
private static EventWaitHandle acquire = new EventWaitHandle(false, EventResetMode.ManualReset); private static readonly EventWaitHandle acquire = new EventWaitHandle(false, EventResetMode.ManualReset);
private static string RemoveHashType(string hash) private static string RemoveHashType(string hash)
{ {

View File

@ -163,12 +163,12 @@ namespace BizHawk.Emulation.Cores.Arcades.MAME
public IInputCallbackSystem InputCallbacks => throw new NotImplementedException(); public IInputCallbackSystem InputCallbacks => throw new NotImplementedException();
private SyncSettings _syncSettings; private SyncSettings _syncSettings;
private Thread _mameThread; private readonly Thread _mameThread;
private ManualResetEvent _mameStartupComplete = new ManualResetEvent(false); private readonly ManualResetEvent _mameStartupComplete = new ManualResetEvent(false);
private ManualResetEvent _mameFrameComplete = new ManualResetEvent(false); private readonly ManualResetEvent _mameFrameComplete = new ManualResetEvent(false);
private ManualResetEvent _memoryAccessComplete = new ManualResetEvent(false); private readonly ManualResetEvent _memoryAccessComplete = new ManualResetEvent(false);
private AutoResetEvent _mamePeriodicComplete = new AutoResetEvent(false); private readonly AutoResetEvent _mamePeriodicComplete = new AutoResetEvent(false);
private SortedDictionary<string, string> _fieldsPorts = new SortedDictionary<string, string>(); private readonly SortedDictionary<string, string> _fieldsPorts = new SortedDictionary<string, string>();
private SortedDictionary<string, string> _romHashes = new SortedDictionary<string, string>(); private SortedDictionary<string, string> _romHashes = new SortedDictionary<string, string>();
private IController _controller = NullController.Instance; private IController _controller = NullController.Instance;
private IMemoryDomains _memoryDomains; private IMemoryDomains _memoryDomains;
@ -177,15 +177,15 @@ namespace BizHawk.Emulation.Cores.Arcades.MAME
private int _systemBusAddressShift = 0; private int _systemBusAddressShift = 0;
private bool _memAccess = false; private bool _memAccess = false;
private int[] _frameBuffer = new int[0]; private int[] _frameBuffer = new int[0];
private Queue<short> _audioSamples = new Queue<short>(); private readonly Queue<short> _audioSamples = new Queue<short>();
private decimal _dAudioSamples = 0; private decimal _dAudioSamples = 0;
private int _sampleRate = 44100; private readonly int _sampleRate = 44100;
private int _numSamples = 0; private int _numSamples = 0;
private bool _paused = true; private bool _paused = true;
private bool _exiting = false; private bool _exiting = false;
private bool _frameDone = true; private bool _frameDone = true;
private string _gameDirectory; private readonly string _gameDirectory;
private string _gameFilename; private readonly string _gameFilename;
private string _gameName = "Arcade"; private string _gameName = "Arcade";
private string _loadFailure = ""; private string _loadFailure = "";
private LibMAME.PeriodicCallbackDelegate _periodicCallback; private LibMAME.PeriodicCallbackDelegate _periodicCallback;

View File

@ -60,7 +60,7 @@ namespace BizHawk.Emulation.Cores.Components.CP1610
public Func<ushort, bool, ushort> ReadMemory; public Func<ushort, bool, ushort> ReadMemory;
public Func<ushort, ushort, bool, bool> WriteMemory; public Func<ushort, ushort, bool, bool> WriteMemory;
private static bool Logging = false; private static readonly bool Logging = false;
private static readonly StreamWriter Log; private static readonly StreamWriter Log;
public void SyncState(Serializer ser) public void SyncState(Serializer ser)

View File

@ -6,7 +6,7 @@ namespace BizHawk.Emulation.Cores.Components.I8048
{ {
public sealed partial class I8048 public sealed partial class I8048
{ {
static string[] table = static readonly string[] table =
{ {
"NOP", // 00 "NOP", // 00
"???", // 01 "???", // 01

View File

@ -56,7 +56,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902
OP }; OP };
} }
private static ushort[] INT_vectors = { 0x40, 0x48, 0x50, 0x58, 0x60, 0x00 }; private static readonly ushort[] INT_vectors = { 0x40, 0x48, 0x50, 0x58, 0x60, 0x00 };
public ushort int_src; public ushort int_src;
public byte int_clear; public byte int_clear;

View File

@ -7,7 +7,7 @@ namespace BizHawk.Emulation.Cores.Components.LR35902
// adapted from the information at http://www.pastraiser.com/cpu/gameboy/gameboy_opcodes.html // adapted from the information at http://www.pastraiser.com/cpu/gameboy/gameboy_opcodes.html
public sealed partial class LR35902 public sealed partial class LR35902
{ {
static string[] table = static readonly string[] table =
{ {
"NOP", // 00 "NOP", // 00
"LD BC,d16", // 01 "LD BC,d16", // 01

View File

@ -6,7 +6,7 @@ namespace BizHawk.Emulation.Cores.Components.MC6800
{ {
public sealed partial class MC6800 public sealed partial class MC6800
{ {
static string[] table = static readonly string[] table =
{ {
"???", // 00 "???", // 00
"NOP", // 01 "NOP", // 01

View File

@ -6,7 +6,7 @@ namespace BizHawk.Emulation.Cores.Components.MC6809
{ {
public sealed partial class MC6809 public sealed partial class MC6809
{ {
static string[] table = static readonly string[] table =
{ {
"NEG DP+i8", // 00 "NEG DP+i8", // 00
"???", // 01 "???", // 01
@ -266,7 +266,7 @@ namespace BizHawk.Emulation.Cores.Components.MC6809
"ST U,ex16", // ff "ST U,ex16", // ff
}; };
static string[] table2 = static readonly string[] table2 =
{ {
"???", // 00 "???", // 00
"???", // 01 "???", // 01
@ -526,7 +526,7 @@ namespace BizHawk.Emulation.Cores.Components.MC6809
"ST SP,ex16", // ff "ST SP,ex16", // ff
}; };
static string[] table3 = static readonly string[] table3 =
{ {
"???", // 00 "???", // 00
"???", // 01 "???", // 01

View File

@ -30,7 +30,7 @@ namespace BizHawk.Emulation.Cores.Components.M6502
// CompiledMicrocode[i] = (short)temp[i]; // CompiledMicrocode[i] = (short)temp[i];
} }
static Uop[][] Microcode = static readonly Uop[][] Microcode =
{ {
//0x00 //0x00
/*BRK [implied]*/ new Uop[] { Uop.Fetch2, Uop.PushPCH, Uop.PushPCL, Uop.PushP_BRK, Uop.FetchPCLVector, Uop.FetchPCHVector, Uop.End_SuppressInterrupt }, /*BRK [implied]*/ new Uop[] { Uop.Fetch2, Uop.PushPCH, Uop.PushPCL, Uop.PushP_BRK, Uop.FetchPCLVector, Uop.FetchPCHVector, Uop.End_SuppressInterrupt },

View File

@ -21,7 +21,7 @@ namespace BizHawk.Emulation.Cores.Components.W65816
{ {
public string Cpu { get; set; } public string Cpu { get; set; }
W65816 disassemblerCpu = new W65816(); readonly W65816 disassemblerCpu = new W65816();
public IEnumerable<string> AvailableCpus public IEnumerable<string> AvailableCpus
{ {

View File

@ -158,7 +158,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
public string Media { get; set; } public string Media { get; set; }
public string OtherMisc { get; set; } public string OtherMisc { get; set; }
Dictionary<string, string> Data = new Dictionary<string, string>(); readonly Dictionary<string, string> Data = new Dictionary<string, string>();
public static CPCMachineMetaData GetMetaObject(MachineType type) public static CPCMachineMetaData GetMetaObject(MachineType type)
{ {

View File

@ -43,7 +43,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
/// <summary> /// <summary>
/// Array that holds state information for each possible drive /// Array that holds state information for each possible drive
/// </summary> /// </summary>
private DriveState[] DriveStates = new DriveState[4]; private readonly DriveState[] DriveStates = new DriveState[4];
/// <summary> /// <summary>
/// Initialization / reset of the floppy drive subsystem /// Initialization / reset of the floppy drive subsystem
@ -283,7 +283,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
/// <summary> /// <summary>
/// The parent controller /// The parent controller
/// </summary> /// </summary>
private NECUPD765 FDC; private readonly NECUPD765 FDC;
/// <summary> /// <summary>
/// TRUE if we are on track 0 /// TRUE if we are on track 0

View File

@ -36,7 +36,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
* MK flag * MK flag
* SK flag * SK flag
* */ * */
private string[] workingArr = new string[3]; private readonly string[] workingArr = new string[3];
private void BuildCSVLine() private void BuildCSVLine()
{ {

View File

@ -16,7 +16,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
/// </summary> /// </summary>
public class AmstradGateArray : IPortIODevice, IVideoProvider public class AmstradGateArray : IPortIODevice, IVideoProvider
{ {
private CPCBase _machine; private readonly CPCBase _machine;
private Z80A CPU => _machine.CPU; private Z80A CPU => _machine.CPU;
private CRCT_6845 CRCT => _machine.CRCT; private CRCT_6845 CRCT => _machine.CRCT;
//private CRTDevice CRT => _machine.CRT; //private CRTDevice CRT => _machine.CRT;
@ -679,18 +679,18 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
/// <summary> /// <summary>
/// The current character line we are working from /// The current character line we are working from
/// </summary> /// </summary>
private CharacterLine CurrentLine; private readonly CharacterLine CurrentLine;
/// <summary> /// <summary>
/// List of screen lines as they are built up /// List of screen lines as they are built up
/// </summary> /// </summary>
private List<CharacterLine> ScreenLines = new List<CharacterLine>(); private readonly List<CharacterLine> ScreenLines = new List<CharacterLine>();
/// <summary> /// <summary>
/// Pixel value lookups for every scanline byte value /// Pixel value lookups for every scanline byte value
/// Based on the lookup at https://github.com/gavinpugh/xnacpc /// Based on the lookup at https://github.com/gavinpugh/xnacpc
/// </summary> /// </summary>
private int[][] ByteLookup = new int[4][]; private readonly int[][] ByteLookup = new int[4][];
private void InitByteLookup() private void InitByteLookup()
{ {
int pix; int pix;

View File

@ -364,14 +364,14 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
/// http://www.cantrell.org.uk/david/tech/cpc/cpc-firmware/firmware.pdf /// 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) /// (The defaults values given here are those programmed by the firmware ROM after a cold/warm boot of the CPC/Plus)
/// </summary> /// </summary>
private byte[] RegDefaults = { 63, 40, 46, 112, 38, 0, 25, 30, 0, 7, 0, 0, 48, 0, 192, 7, 0, 0 }; private readonly byte[] RegDefaults = { 63, 40, 46, 112, 38, 0, 25, 30, 0, 7, 0, 0, 48, 0, 192, 7, 0, 0 };
/// <summary> /// <summary>
/// Register masks /// Register masks
/// 0 = WRITE /// 0 = WRITE
/// 1 = READ /// 1 = READ
/// </summary> /// </summary>
private byte[] CPCMask = { 255, 255, 255, 255, 127, 31, 127, 126, 3, 31, 31, 31, 63, 255, 63, 255, 63, 255 }; private readonly byte[] CPCMask = { 255, 255, 255, 255, 127, 31, 127, 126, 3, 31, 31, 31, 63, 255, 63, 255, 63, 255 };
/// <summary> /// <summary>
/// Horizontal Character Count /// Horizontal Character Count

View File

@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
/// </summary> /// </summary>
public class CRTDevice : IVideoProvider public class CRTDevice : IVideoProvider
{ {
private CPCBase _machine; private readonly CPCBase _machine;
private CRCT_6845 CRCT => _machine.CRCT; private CRCT_6845 CRCT => _machine.CRCT;
private AmstradGateArray GateArray => _machine.GateArray; private AmstradGateArray GateArray => _machine.GateArray;
@ -250,7 +250,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
/// <summary> /// <summary>
/// The calling CRT device /// The calling CRT device
/// </summary> /// </summary>
private CRTDevice CRT; private readonly CRTDevice CRT;
public ScanLine(CRTDevice crt) public ScanLine(CRTDevice crt)
{ {

View File

@ -11,7 +11,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
/// </summary> /// </summary>
public class PPI_8255 : IPortIODevice public class PPI_8255 : IPortIODevice
{ {
private CPCBase _machine; private readonly CPCBase _machine;
private CRCT_6845 CRTC => _machine.CRCT; private CRCT_6845 CRTC => _machine.CRCT;
private AmstradGateArray GateArray => _machine.GateArray; private AmstradGateArray GateArray => _machine.GateArray;
private IPSG PSG => _machine.AYDevice; private IPSG PSG => _machine.AYDevice;

View File

@ -16,7 +16,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
/// <summary> /// <summary>
/// The emulated machine (passed in via constructor) /// The emulated machine (passed in via constructor)
/// </summary> /// </summary>
private CPCBase _machine; private readonly CPCBase _machine;
private IKeyboard _keyboard => _machine.KeyboardDevice; private IKeyboard _keyboard => _machine.KeyboardDevice;
private int _tStatesPerFrame; private int _tStatesPerFrame;
@ -409,7 +409,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
/// <summary> /// <summary>
/// The frequency of the AY chip /// The frequency of the AY chip
/// </summary> /// </summary>
private static int _chipFrequency = 1000000; // 1773400; private static readonly int _chipFrequency = 1000000; // 1773400;
/// <summary> /// <summary>
/// The rendering resolution of the chip /// The rendering resolution of the chip
@ -504,7 +504,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
/// <summary> /// <summary>
/// Panning table list /// Panning table list
/// </summary> /// </summary>
private static List<uint[]> PanTabs = new List<uint[]> private static readonly List<uint[]> PanTabs = new List<uint[]>
{ {
// MONO // MONO
new uint[] { 50,50, 50,50, 50,50 }, new uint[] { 50,50, 50,50, 50,50 },
@ -540,7 +540,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
/// <summary> /// <summary>
/// Volume table to be used /// Volume table to be used
/// </summary> /// </summary>
private static uint[] AYVolumes = private static readonly uint[] AYVolumes =
{ {
0x0000,0x0000,0x0340,0x0340,0x04C0,0x04C0,0x06F2,0x06F2, 0x0000,0x0000,0x0340,0x0340,0x04C0,0x04C0,0x06F2,0x06F2,
0x0A44,0x0A44,0x0F13,0x0F13,0x1510,0x1510,0x227E,0x227E, 0x0A44,0x0A44,0x0F13,0x0F13,0x1510,0x1510,0x227E,0x227E,

View File

@ -53,7 +53,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
/// <summary> /// <summary>
/// The parent emulated machine /// The parent emulated machine
/// </summary> /// </summary>
private CPCBase _machine; private readonly CPCBase _machine;
/// <summary> /// <summary>
/// The last pulse /// The last pulse

View File

@ -6,23 +6,23 @@
/// </summary> /// </summary>
public abstract partial class CPCBase public abstract partial class CPCBase
{ {
string Play = "Play Tape"; readonly string Play = "Play Tape";
string Stop = "Stop Tape"; readonly string Stop = "Stop Tape";
string RTZ = "RTZ Tape"; readonly string RTZ = "RTZ Tape";
string Record = "Record Tape"; readonly string Record = "Record Tape";
string NextTape = "Insert Next Tape"; readonly string NextTape = "Insert Next Tape";
string PrevTape = "Insert Previous Tape"; readonly string PrevTape = "Insert Previous Tape";
string NextBlock = "Next Tape Block"; readonly string NextBlock = "Next Tape Block";
string PrevBlock = "Prev Tape Block"; readonly string PrevBlock = "Prev Tape Block";
string TapeStatus = "Get Tape Status"; readonly string TapeStatus = "Get Tape Status";
string NextDisk = "Insert Next Disk"; readonly string NextDisk = "Insert Next Disk";
string PrevDisk = "Insert Previous Disk"; readonly string PrevDisk = "Insert Previous Disk";
string EjectDisk = "Eject Current Disk"; readonly string EjectDisk = "Eject Current Disk";
string DiskStatus = "Get Disk Status"; readonly string DiskStatus = "Get Disk Status";
string HardResetStr = "Power"; readonly string HardResetStr = "Power";
string SoftResetStr = "Reset"; readonly string SoftResetStr = "Reset";
bool pressed_Play = false; bool pressed_Play = false;
bool pressed_Stop = false; bool pressed_Stop = false;

View File

@ -16,7 +16,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
public int Z80ClockSpeed = 4000000; public int Z80ClockSpeed = 4000000;
public int FrameLength = 79872; public int FrameLength = 79872;
private CPCBase _machine; private readonly CPCBase _machine;
private Z80A CPU => _machine.CPU; private Z80A CPU => _machine.CPU;
private CRCT_6845 CRCT => _machine.CRCT; private CRCT_6845 CRCT => _machine.CRCT;
private IPSG PSG => _machine.AYDevice; private IPSG PSG => _machine.AYDevice;
@ -190,13 +190,13 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
} }
} }
private int[] PenColours; private readonly int[] PenColours;
private int CurrentPen; private int CurrentPen;
private int ScreenMode; private int ScreenMode;
private int INTScanlineCnt; private int INTScanlineCnt;
//private int VSYNCDelyCnt; //private int VSYNCDelyCnt;
private int[][] Lookup = new int[4][]; private readonly int[][] Lookup = new int[4][];
//private bool DoModeUpdate; //private bool DoModeUpdate;

View File

@ -13,7 +13,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
/// <summary> /// <summary>
/// The type of serializer /// The type of serializer
/// </summary> /// </summary>
private MediaConverterType _formatType = MediaConverterType.CDT; private readonly MediaConverterType _formatType = MediaConverterType.CDT;
public override MediaConverterType FormatType => _formatType; public override MediaConverterType FormatType => _formatType;
/// <summary> /// <summary>
@ -39,9 +39,9 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
/// <summary> /// <summary>
/// Object to keep track of loops - this assumes there is only one loop at a time /// Object to keep track of loops - this assumes there is only one loop at a time
/// </summary> /// </summary>
private List<KeyValuePair<int, int>> _loopCounter = new List<KeyValuePair<int, int>>(); private readonly List<KeyValuePair<int, int>> _loopCounter = new List<KeyValuePair<int, int>>();
private DatacorderDevice _datacorder; private readonly DatacorderDevice _datacorder;
public CdtConverter(DatacorderDevice _tapeDevice) public CdtConverter(DatacorderDevice _tapeDevice)
{ {

View File

@ -59,7 +59,7 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII
private readonly List<byte[]> _romSet = new List<byte[]>(); private readonly List<byte[]> _romSet = new List<byte[]>();
private readonly ITraceable _tracer; private readonly ITraceable _tracer;
private Components _machine; private readonly Components _machine;
private byte[] _disk1; private byte[] _disk1;
private readonly byte[] _appleIIRom; private readonly byte[] _appleIIRom;
private readonly byte[] _diskIIRom; private readonly byte[] _diskIIRom;

View File

@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII
public class EmptyPeripheralCard : IPeripheralCard public class EmptyPeripheralCard : IPeripheralCard
{ {
// TODO: make readonly once json isn't used // TODO: make readonly once json isn't used
private Video _video; private readonly Video _video;
// TODO: remove when json isn't used // TODO: remove when json isn't used
public EmptyPeripheralCard() { } public EmptyPeripheralCard() { }

View File

@ -26,8 +26,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Cartridge
{ {
private int _bankOffset = 63 << 13; private int _bankOffset = 63 << 13;
private int[] _banksA = new int[64 << 13]; // 8000 private readonly int[] _banksA = new int[64 << 13]; // 8000
private int[] _banksB = new int[64 << 13]; // A000 private readonly int[] _banksB = new int[64 << 13]; // A000
private readonly int[] _originalMediaA; // 8000 private readonly int[] _originalMediaA; // 8000
private readonly int[] _originalMediaB; // A000 private readonly int[] _originalMediaB; // A000

View File

@ -12,7 +12,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
public bool Display; public bool Display;
public bool Dma; public bool Dma;
public bool Enable; public bool Enable;
public int Index; public readonly int Index;
public int Loaded; public int Loaded;
public int Mc; public int Mc;
public int Mcbase; public int Mcbase;

View File

@ -114,20 +114,20 @@ namespace BizHawk.Emulation.Cores.Computers.MSX
// Machine resources // Machine resources
private IController _controller = NullController.Instance; private IController _controller = NullController.Instance;
private ControllerDefinition current_controller = null; private readonly ControllerDefinition current_controller = null;
private int _frame = 0; private int _frame = 0;
public DisplayType Region => DisplayType.NTSC; public DisplayType Region => DisplayType.NTSC;
private ITraceable Tracer; private readonly ITraceable Tracer;
private LibMSX.TraceCallback tracecb; private LibMSX.TraceCallback tracecb;
// these will be constant values assigned during core construction // these will be constant values assigned during core construction
private int Header_Length; private int Header_Length;
private int Disasm_Length; private readonly int Disasm_Length;
private int Reg_String_Length; private readonly int Reg_String_Length;
private void MakeTrace(int t) private void MakeTrace(int t)
{ {
@ -144,7 +144,7 @@ namespace BizHawk.Emulation.Cores.Computers.MSX
}); });
} }
private MemoryCallbackSystem _memorycallbacks = new MemoryCallbackSystem(new[] { "System Bus" }); private readonly MemoryCallbackSystem _memorycallbacks = new MemoryCallbackSystem(new[] { "System Bus" });
public IMemoryCallbackSystem MemoryCallbacks => _memorycallbacks; public IMemoryCallbackSystem MemoryCallbacks => _memorycallbacks;
} }
} }

View File

@ -43,7 +43,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
/// <summary> /// <summary>
/// Array that holds state information for each possible drive /// Array that holds state information for each possible drive
/// </summary> /// </summary>
private DriveState[] DriveStates = new DriveState[4]; private readonly DriveState[] DriveStates = new DriveState[4];
/// <summary> /// <summary>
/// Initialization / reset of the floppy drive subsystem /// Initialization / reset of the floppy drive subsystem
@ -283,7 +283,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
/// <summary> /// <summary>
/// The parent controller /// The parent controller
/// </summary> /// </summary>
private NECUPD765 FDC; private readonly NECUPD765 FDC;
/// <summary> /// <summary>
/// TRUE if we are on track 0 /// TRUE if we are on track 0

View File

@ -36,7 +36,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
* MK flag * MK flag
* SK flag * SK flag
* */ * */
private string[] workingArr = new string[3]; private readonly string[] workingArr = new string[3];
private void BuildCSVLine() private void BuildCSVLine()
{ {

View File

@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
public class CursorJoystick : IJoystick public class CursorJoystick : IJoystick
{ {
//private int _joyLine; //private int _joyLine;
private SpectrumBase _machine; private readonly SpectrumBase _machine;
public CursorJoystick(SpectrumBase machine, int playerNumber) public CursorJoystick(SpectrumBase machine, int playerNumber)
{ {
@ -28,7 +28,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
}.ToArray(); }.ToArray();
} }
private List<string> btnLookups = new List<string> private readonly List<string> btnLookups = new List<string>
{ {
"Key 5", // left "Key 5", // left
"Key 8", // right "Key 8", // right

View File

@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
public class SinclairJoystick1 : IJoystick public class SinclairJoystick1 : IJoystick
{ {
//private int _joyLine; //private int _joyLine;
private SpectrumBase _machine; private readonly SpectrumBase _machine;
public SinclairJoystick1(SpectrumBase machine, int playerNumber) public SinclairJoystick1(SpectrumBase machine, int playerNumber)
{ {
@ -28,7 +28,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
}.ToArray(); }.ToArray();
} }
private List<string> btnLookups = new List<string> private readonly List<string> btnLookups = new List<string>
{ {
"Key 1", // left "Key 1", // left
"Key 2", // right "Key 2", // right

View File

@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
public class SinclairJoystick2 : IJoystick public class SinclairJoystick2 : IJoystick
{ {
//private int _joyLine; //private int _joyLine;
private SpectrumBase _machine; private readonly SpectrumBase _machine;
public SinclairJoystick2(SpectrumBase machine, int playerNumber) public SinclairJoystick2(SpectrumBase machine, int playerNumber)
{ {
@ -28,7 +28,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
}.ToArray(); }.ToArray();
} }
private List<string> btnLookups = new List<string> private readonly List<string> btnLookups = new List<string>
{ {
"Key 6", // left "Key 6", // left
"Key 7", // right "Key 7", // right

View File

@ -20,7 +20,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
/// <summary> /// <summary>
/// The emulated machine (passed in via constructor) /// The emulated machine (passed in via constructor)
/// </summary> /// </summary>
private SpectrumBase _machine; private readonly SpectrumBase _machine;
private int _tStatesPerFrame; private int _tStatesPerFrame;
private int _sampleRate; private int _sampleRate;
@ -401,7 +401,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
/// <summary> /// <summary>
/// The frequency of the AY chip /// The frequency of the AY chip
/// </summary> /// </summary>
private static int _chipFrequency = 1773400; private static readonly int _chipFrequency = 1773400;
/// <summary> /// <summary>
/// The rendering resolution of the chip /// The rendering resolution of the chip
@ -496,7 +496,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
/// <summary> /// <summary>
/// Panning table list /// Panning table list
/// </summary> /// </summary>
private static List<uint[]> PanTabs = new List<uint[]> private static readonly List<uint[]> PanTabs = new List<uint[]>
{ {
// MONO // MONO
new uint[] { 50,50, 50,50, 50,50 }, new uint[] { 50,50, 50,50, 50,50 },
@ -532,7 +532,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
/// <summary> /// <summary>
/// Volume table to be used /// Volume table to be used
/// </summary> /// </summary>
private static uint[] AYVolumes = private static readonly uint[] AYVolumes =
{ {
0x0000,0x0000,0x0340,0x0340,0x04C0,0x04C0,0x06F2,0x06F2, 0x0000,0x0000,0x0340,0x0340,0x04C0,0x04C0,0x06F2,0x06F2,
0x0A44,0x0A44,0x0F13,0x0F13,0x1510,0x1510,0x227E,0x227E, 0x0A44,0x0A44,0x0F13,0x0F13,0x1510,0x1510,0x227E,0x227E,

View File

@ -9,8 +9,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
/// </summary> /// </summary>
public class CPUMonitor public class CPUMonitor
{ {
private SpectrumBase _machine; private readonly SpectrumBase _machine;
private Z80A _cpu; private readonly Z80A _cpu;
public MachineType machineType = MachineType.ZXSpectrum48; public MachineType machineType = MachineType.ZXSpectrum48;
/// <summary> /// <summary>

View File

@ -9,23 +9,23 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
/// </summary> /// </summary>
public abstract partial class SpectrumBase public abstract partial class SpectrumBase
{ {
string Play = "Play Tape"; readonly string Play = "Play Tape";
string Stop = "Stop Tape"; readonly string Stop = "Stop Tape";
string RTZ = "RTZ Tape"; readonly string RTZ = "RTZ Tape";
string Record = "Record Tape"; readonly string Record = "Record Tape";
string NextTape = "Insert Next Tape"; readonly string NextTape = "Insert Next Tape";
string PrevTape = "Insert Previous Tape"; readonly string PrevTape = "Insert Previous Tape";
string NextBlock = "Next Tape Block"; readonly string NextBlock = "Next Tape Block";
string PrevBlock = "Prev Tape Block"; readonly string PrevBlock = "Prev Tape Block";
string TapeStatus = "Get Tape Status"; readonly string TapeStatus = "Get Tape Status";
string NextDisk = "Insert Next Disk"; readonly string NextDisk = "Insert Next Disk";
string PrevDisk = "Insert Previous Disk"; readonly string PrevDisk = "Insert Previous Disk";
string EjectDisk = "Eject Current Disk"; readonly string EjectDisk = "Eject Current Disk";
string DiskStatus = "Get Disk Status"; readonly string DiskStatus = "Get Disk Status";
string HardResetStr = "Power"; readonly string HardResetStr = "Power";
string SoftResetStr = "Reset"; readonly string SoftResetStr = "Reset";
bool pressed_Play; bool pressed_Play;
bool pressed_Stop; bool pressed_Stop;

View File

@ -253,7 +253,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
/// <summary> /// <summary>
/// The ULA device /// The ULA device
/// </summary> /// </summary>
private ULA _ula; private readonly ULA _ula;
/// <summary> /// <summary>
/// Array of rendercycle entries /// Array of rendercycle entries

View File

@ -12,7 +12,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
/// </summary> /// </summary>
public partial class SZX public partial class SZX
{ {
private SpectrumBase _machine; private readonly SpectrumBase _machine;
private Z80A _cpu => _machine.CPU; private Z80A _cpu => _machine.CPU;

View File

@ -14,7 +14,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
/// <summary> /// <summary>
/// The type of serializer /// The type of serializer
/// </summary> /// </summary>
private MediaConverterType _formatType = MediaConverterType.CSW; private readonly MediaConverterType _formatType = MediaConverterType.CSW;
public override MediaConverterType FormatType => _formatType; public override MediaConverterType FormatType => _formatType;
/// <summary> /// <summary>
@ -32,7 +32,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
/// </summary> /// </summary>
public override bool IsWriter => false; public override bool IsWriter => false;
private DatacorderDevice _datacorder; private readonly DatacorderDevice _datacorder;
public CswConverter(DatacorderDevice _tapeDevice) public CswConverter(DatacorderDevice _tapeDevice)
{ {

View File

@ -14,7 +14,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
/// <summary> /// <summary>
/// The type of serializer /// The type of serializer
/// </summary> /// </summary>
private MediaConverterType _formatType = MediaConverterType.PZX; private readonly MediaConverterType _formatType = MediaConverterType.PZX;
public override MediaConverterType FormatType => _formatType; public override MediaConverterType FormatType => _formatType;
/// <summary> /// <summary>
@ -42,7 +42,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
/// </summary> /// </summary>
private List<KeyValuePair<int, int>> _loopCounter = new List<KeyValuePair<int, int>>(); private List<KeyValuePair<int, int>> _loopCounter = new List<KeyValuePair<int, int>>();
private DatacorderDevice _datacorder; private readonly DatacorderDevice _datacorder;
public PzxConverter(DatacorderDevice _tapeDevice) public PzxConverter(DatacorderDevice _tapeDevice)
{ {

View File

@ -14,7 +14,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
/// <summary> /// <summary>
/// The type of serializer /// The type of serializer
/// </summary> /// </summary>
private MediaConverterType _formatType = MediaConverterType.TAP; private readonly MediaConverterType _formatType = MediaConverterType.TAP;
public override MediaConverterType FormatType => _formatType; public override MediaConverterType FormatType => _formatType;
/// <summary> /// <summary>
@ -27,7 +27,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
/// </summary> /// </summary>
public override bool IsWriter => false; public override bool IsWriter => false;
private DatacorderDevice _datacorder; private readonly DatacorderDevice _datacorder;
public TapConverter(DatacorderDevice _tapeDevice) public TapConverter(DatacorderDevice _tapeDevice)
{ {

View File

@ -13,7 +13,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
/// <summary> /// <summary>
/// The type of serializer /// The type of serializer
/// </summary> /// </summary>
private MediaConverterType _formatType = MediaConverterType.TZX; private readonly MediaConverterType _formatType = MediaConverterType.TZX;
public override MediaConverterType FormatType => _formatType; public override MediaConverterType FormatType => _formatType;
/// <summary> /// <summary>
@ -39,9 +39,9 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
/// <summary> /// <summary>
/// Object to keep track of loops - this assumes there is only one loop at a time /// Object to keep track of loops - this assumes there is only one loop at a time
/// </summary> /// </summary>
private List<KeyValuePair<int, int>> _loopCounter = new List<KeyValuePair<int, int>>(); private readonly List<KeyValuePair<int, int>> _loopCounter = new List<KeyValuePair<int, int>>();
private DatacorderDevice _datacorder; private readonly DatacorderDevice _datacorder;
public TzxConverter(DatacorderDevice _tapeDevice) public TzxConverter(DatacorderDevice _tapeDevice)
{ {

View File

@ -14,7 +14,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
/// <summary> /// <summary>
/// The type of serializer /// The type of serializer
/// </summary> /// </summary>
private MediaConverterType _formatType = MediaConverterType.WAV; private readonly MediaConverterType _formatType = MediaConverterType.WAV;
public override MediaConverterType FormatType => _formatType; public override MediaConverterType FormatType => _formatType;
/// <summary> /// <summary>
@ -31,7 +31,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
/// Position counter /// Position counter
/// </summary> /// </summary>
//private int _position = 0; //private int _position = 0;
private DatacorderDevice _datacorder; private readonly DatacorderDevice _datacorder;
public WavConverter(DatacorderDevice _tapeDevice) public WavConverter(DatacorderDevice _tapeDevice)
{ {

View File

@ -8,8 +8,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
/// </summary> /// </summary>
public class WavStreamReader public class WavStreamReader
{ {
private Stream m_stream; private readonly Stream m_stream;
private WavHeader m_header = new WavHeader(); private readonly WavHeader m_header = new WavHeader();
public WavStreamReader(Stream stream) public WavStreamReader(Stream stream)
{ {

View File

@ -234,7 +234,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
public string Media { get; set; } public string Media { get; set; }
public string OtherMisc { get; set; } public string OtherMisc { get; set; }
private Dictionary<string, string> Data = new Dictionary<string, string>(); private readonly Dictionary<string, string> Data = new Dictionary<string, string>();
/// <summary> /// <summary>
/// Detailed info to be displayed within the settings UIs /// Detailed info to be displayed within the settings UIs

View File

@ -168,12 +168,12 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
public bool DiagRom = false; public bool DiagRom = false;
private List<string> diagRoms = new List<string> private readonly List<string> diagRoms = new List<string>
{ {
@"\DiagROM.v28", @"\DiagROM.v28",
@"\zx-diagnostics\testrom.bin" @"\zx-diagnostics\testrom.bin"
}; };
private int diagIndex = 1; private readonly int diagIndex = 1;
internal CoreComm CoreComm { get; } internal CoreComm CoreComm { get; }

View File

@ -58,7 +58,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
public int NominalNumScanlines => _pal ? 312 : 262; public int NominalNumScanlines => _pal ? 312 : 262;
private int[] _scanlinebuffer = new int[ScreenWidth * MaxScreenHeight]; private readonly int[] _scanlinebuffer = new int[ScreenWidth * MaxScreenHeight];
private int[] _palette; private int[] _palette;

View File

@ -24,7 +24,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
// technically there is no limit on the number of graphics objects, but since dma is automatically killed // technically there is no limit on the number of graphics objects, but since dma is automatically killed
// at the end of a scanline, we have an effective limit // at the end of a scanline, we have an effective limit
GFX_Object[] GFX_Objects = new GFX_Object[128]; readonly GFX_Object[] GFX_Objects = new GFX_Object[128];
public byte[,] line_ram = new byte[2, 320]; public byte[,] line_ram = new byte[2, 320];
byte temp_check = 0; byte temp_check = 0;

View File

@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Belogic
public class Uzem : WaterboxCore public class Uzem : WaterboxCore
{ {
private LibUzem _uze; private LibUzem _uze;
private bool _mouseEnabled; private readonly bool _mouseEnabled;
[CoreConstructor("UZE")] [CoreConstructor("UZE")]
public Uzem(CoreComm comm, byte[] rom) public Uzem(CoreComm comm, byte[] rom)

View File

@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
/// </summary> /// </summary>
public partial class ChannelF : ISoundProvider public partial class ChannelF : ISoundProvider
{ {
private double SampleRate = 44100; private readonly double SampleRate = 44100;
private int SamplesPerFrame; private int SamplesPerFrame;
private double Period; private double Period;
private double CyclesPerSample; private double CyclesPerSample;
@ -16,7 +16,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
private int tone = 0; private int tone = 0;
private double[] tone_freqs = { 0, 1000, 500, 120 }; private readonly double[] tone_freqs = { 0, 1000, 500, 120 };
#pragma warning disable CS0414 #pragma warning disable CS0414
private double amplitude = 0; private double amplitude = 0;
private double decay = 0.998; private double decay = 0.998;

View File

@ -12,8 +12,8 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
public bool DeterministicEmulation { get; set; } public bool DeterministicEmulation { get; set; }
private static double cpuFreq = 1.7897725; private static readonly double cpuFreq = 1.7897725;
private static double refreshRate = 60; private static readonly double refreshRate = 60;
public int ClockPerFrame; public int ClockPerFrame;
public int FrameClock = 0; public int FrameClock = 0;

View File

@ -43,7 +43,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
private int _y; private int _y;
private int _arm; private int _arm;
private int[] frameBuffer = new int[128 * 64]; private readonly int[] frameBuffer = new int[128 * 64];
private void BuildFrame() private void BuildFrame()
{ {

View File

@ -96,7 +96,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
"S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW",
}; };
private static byte[] HandControllerButtons = private static readonly byte[] HandControllerButtons =
{ {
0x60, // OUTPUT_ACTION_BUTTON_BOTTOM_LEFT 0x60, // OUTPUT_ACTION_BUTTON_BOTTOM_LEFT
0xC0, // OUTPUT_ACTION_BUTTON_BOTTOM_RIGHT 0xC0, // OUTPUT_ACTION_BUTTON_BOTTOM_RIGHT
@ -177,7 +177,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
"Key 6", "Key 7", "Key 8", "Key 9", "Enter", "Clear" "Key 6", "Key 7", "Key 8", "Key 9", "Enter", "Clear"
}; };
private static byte[] BoolControllerButtons = private static readonly byte[] BoolControllerButtons =
{ {
0x60, // OUTPUT_ACTION_BUTTON_BOTTOM_LEFT 0x60, // OUTPUT_ACTION_BUTTON_BOTTOM_LEFT
0xC0, // OUTPUT_ACTION_BUTTON_BOTTOM_RIGHT 0xC0, // OUTPUT_ACTION_BUTTON_BOTTOM_RIGHT
@ -217,7 +217,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
private const int Deadzone = 50; private const int Deadzone = 50;
private static byte[] FloatControllerButtons = private static readonly byte[] FloatControllerButtons =
{ {
0x02, // E 0x02, // E
0x06, // ENE 0x06, // ENE

View File

@ -22,7 +22,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
public Func<ushort, bool, ushort> ReadMemory; public Func<ushort, bool, ushort> ReadMemory;
public Func<ushort, ushort, bool, bool> WriteMemory; public Func<ushort, ushort, bool, bool> WriteMemory;
private static int BORDER_OFFSET=176*8; private static readonly int BORDER_OFFSET=176*8;
public int[] BGBuffer = new int[159 * 96]; public int[] BGBuffer = new int[159 * 96];
public int[] FrameBuffer = new int[176 * 208]; public int[] FrameBuffer = new int[176 * 208];

View File

@ -76,7 +76,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
public byte undoc_6C, undoc_72, undoc_73, undoc_74, undoc_75, undoc_76, undoc_77; public byte undoc_6C, undoc_72, undoc_73, undoc_74, undoc_75, undoc_76, undoc_77;
public byte[] _bios; public byte[] _bios;
public readonly byte[] _rom; public readonly byte[] _rom;
public readonly byte[] header = new byte[0x50]; public readonly byte[] header = new byte[0x50];
public byte[] cart_RAM; public byte[] cart_RAM;
@ -98,7 +98,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
public Audio audio; public Audio audio;
public SerialPort serialport; public SerialPort serialport;
private static byte[] GBA_override = { 0xFF, 0x00, 0xCD, 0x03, 0x35, 0xAA, 0x31, 0x90, 0x94, 0x00, 0x00, 0x00, 0x00 }; private static readonly byte[] GBA_override = { 0xFF, 0x00, 0xCD, 0x03, 0x35, 0xAA, 0x31, 0x90, 0x94, 0x00, 0x00, 0x00, 0x00 };
[CoreConstructor("GB")] [CoreConstructor("GB")]
[CoreConstructor("GBC")] [CoreConstructor("GBC")]

View File

@ -10,6 +10,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
public IInputCallbackSystem InputCallbacks => _inputCallbacks; public IInputCallbackSystem InputCallbacks => _inputCallbacks;
private InputCallbackSystem _inputCallbacks = new InputCallbackSystem(); private readonly InputCallbackSystem _inputCallbacks = new InputCallbackSystem();
} }
} }

View File

@ -74,7 +74,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
_cablediscosignal = reader.ReadBoolean(); _cablediscosignal = reader.ReadBoolean();
} }
private JsonSerializer ser = new JsonSerializer { Formatting = Formatting.Indented }; private readonly JsonSerializer ser = new JsonSerializer { Formatting = Formatting.Indented };
private class DGBSerialized private class DGBSerialized
{ {

View File

@ -38,8 +38,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
const ushort SerialIRQAddress = 0x58; const ushort SerialIRQAddress = 0x58;
Gameboy gb; readonly Gameboy gb;
PrinterCallback callback; readonly PrinterCallback callback;
LibGambatte.LinkCallback linkCallback; LibGambatte.LinkCallback linkCallback;
CommandState command_state; CommandState command_state;
@ -47,12 +47,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
bool compression; bool compression;
ushort length_left; ushort length_left;
byte[] command_data = new byte[GB_PRINTER_MAX_COMMAND_LENGTH]; readonly byte[] command_data = new byte[GB_PRINTER_MAX_COMMAND_LENGTH];
ushort command_length; ushort command_length;
ushort checksum; ushort checksum;
byte status; byte status;
byte[] image = new byte[160 * 200]; readonly byte[] image = new byte[160 * 200];
ushort image_offset; ushort image_offset;
byte compression_run_lenth; byte compression_run_lenth;

View File

@ -31,9 +31,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy
/// </summary> /// </summary>
private const int TICKSPERSECOND_SGB = 2147727; private const int TICKSPERSECOND_SGB = 2147727;
private LibSameboy _core; private readonly LibSameboy _core;
private bool _cgb; private readonly bool _cgb;
private bool _sgb; private readonly bool _sgb;
[CoreConstructor("SGB")] [CoreConstructor("SGB")]
public Sameboy(byte[] rom, CoreComm comm, Settings settings, SyncSettings syncSettings, bool deterministic) public Sameboy(byte[] rom, CoreComm comm, Settings settings, SyncSettings syncSettings, bool deterministic)
@ -304,7 +304,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy
public bool IsCGBMode() => _cgb; public bool IsCGBMode() => _cgb;
private GPUMemoryAreas _gpuMemory; private readonly GPUMemoryAreas _gpuMemory;
public GPUMemoryAreas GetGPU() => _gpuMemory; public GPUMemoryAreas GetGPU() => _gpuMemory;
private ScanlineCallback _scanlineCallback; private ScanlineCallback _scanlineCallback;

View File

@ -9,7 +9,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
{ {
public partial class N64 public partial class N64
{ {
private List<MemoryDomain> _memoryDomains = new List<MemoryDomain>(); private readonly List<MemoryDomain> _memoryDomains = new List<MemoryDomain>();
private IMemoryDomains MemoryDomains; private IMemoryDomains MemoryDomains;

View File

@ -51,6 +51,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
Frame = reader.ReadInt32(); Frame = reader.ReadInt32();
} }
private byte[] SaveStatePrivateBuff = new byte[16788288 + 1024]; private readonly byte[] SaveStatePrivateBuff = new byte[16788288 + 1024];
} }
} }

View File

@ -154,11 +154,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
private bool _pendingThreadTerminate; private bool _pendingThreadTerminate;
private DisplayType _display_type = DisplayType.NTSC; private readonly DisplayType _display_type = DisplayType.NTSC;
private Action _pendingThreadAction; private Action _pendingThreadAction;
private bool _disableExpansionSlot = true; private readonly bool _disableExpansionSlot = true;
public IEmulatorServiceProvider ServiceProvider { get; } public IEmulatorServiceProvider ServiceProvider { get; }

View File

@ -11,7 +11,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
/// </summary> /// </summary>
private mupen64plusAudioApi api; private mupen64plusAudioApi api;
private mupen64plusApi coreAPI; private readonly mupen64plusApi coreAPI;
/// <summary> /// <summary>
/// Buffer for audio data /// Buffer for audio data

View File

@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
{ {
private int[] frameBuffer; private int[] frameBuffer;
private mupen64plusVideoApi api; private mupen64plusVideoApi api;
private mupen64plusApi coreAPI; private readonly mupen64plusApi coreAPI;
public bool IsVIFrame; public bool IsVIFrame;

View File

@ -16,7 +16,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi
/// <returns>The size of the mupen64plus audio buffer</returns> /// <returns>The size of the mupen64plus audio buffer</returns>
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate int GetBufferSize(); private delegate int GetBufferSize();
GetBufferSize dllGetBufferSize; readonly GetBufferSize dllGetBufferSize;
/// <summary> /// <summary>
/// Gets the audio buffer from mupen64plus, and then clears it /// Gets the audio buffer from mupen64plus, and then clears it
@ -24,7 +24,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi
/// <param name="dest">The buffer to fill with samples</param> /// <param name="dest">The buffer to fill with samples</param>
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void ReadAudioBuffer(short[] dest); private delegate void ReadAudioBuffer(short[] dest);
ReadAudioBuffer dllReadAudioBuffer; readonly ReadAudioBuffer dllReadAudioBuffer;
/// <summary> /// <summary>
/// Gets the current audio rate from mupen64plus /// Gets the current audio rate from mupen64plus
@ -32,7 +32,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi
/// <returns>The current audio rate</returns> /// <returns>The current audio rate</returns>
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate int GetAudioRate(); private delegate int GetAudioRate();
GetAudioRate dllGetAudioRate; readonly GetAudioRate dllGetAudioRate;
/// <summary> /// <summary>
/// Loads native functions and attaches itself to the core /// Loads native functions and attaches itself to the core

View File

@ -19,11 +19,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi
bool disposed = false; bool disposed = false;
Thread m64pEmulator; readonly Thread m64pEmulator;
AutoResetEvent m64pEvent = new AutoResetEvent(false); readonly AutoResetEvent m64pEvent = new AutoResetEvent(false);
AutoResetEvent m64pContinueEvent = new AutoResetEvent(false); AutoResetEvent m64pContinueEvent = new AutoResetEvent(false);
ManualResetEvent m64pStartupComplete = new ManualResetEvent(false); readonly ManualResetEvent m64pStartupComplete = new ManualResetEvent(false);
bool event_frameend = false; bool event_frameend = false;
bool event_breakpoint = false; bool event_breakpoint = false;
@ -978,7 +978,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi
public DynamicLibraryImportResolver dllThinWrapper; public DynamicLibraryImportResolver dllThinWrapper;
public PluginShutdown dllShutdown; public PluginShutdown dllShutdown;
} }
Dictionary<m64p_plugin_type, AttachedPlugin> plugins = new Dictionary<m64p_plugin_type, AttachedPlugin>();
readonly Dictionary<m64p_plugin_type, AttachedPlugin> plugins = new Dictionary<m64p_plugin_type, AttachedPlugin>();
public IntPtr AttachPlugin(m64p_plugin_type type, string PluginName) public IntPtr AttachPlugin(m64p_plugin_type type, string PluginName)
{ {

View File

@ -13,7 +13,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi
/// <param name="inputCallback">The delegate to use</param> /// <param name="inputCallback">The delegate to use</param>
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void SetInputCallback(InputCallback inputCallback); private delegate void SetInputCallback(InputCallback inputCallback);
SetInputCallback InpSetInputCallback; readonly SetInputCallback InpSetInputCallback;
/// <summary> /// <summary>
/// Callback to use when mupen64plus wants input /// Callback to use when mupen64plus wants input
@ -41,7 +41,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi
/// <param name="type">Type id according to (well documented... hurr hurr) mupen api</param> /// <param name="type">Type id according to (well documented... hurr hurr) mupen api</param>
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void SetControllerPakType(int controller, int type); public delegate void SetControllerPakType(int controller, int type);
SetControllerPakType InpSetControllerPakType; readonly SetControllerPakType InpSetControllerPakType;
/// <summary> /// <summary>
/// Connects and disconnects controllers /// Connects and disconnects controllers
@ -50,7 +50,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi
/// <param name="connected">1 if controller should be connected, 0 if controller should be disconnected</param> /// <param name="connected">1 if controller should be connected, 0 if controller should be disconnected</param>
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void SetControllerConnected(int controller, int connected); delegate void SetControllerConnected(int controller, int connected);
SetControllerConnected InpSetControllerConnected; readonly SetControllerConnected InpSetControllerConnected;
/// <summary> /// <summary>
/// Event fired when mupen changes rumble pak status /// Event fired when mupen changes rumble pak status

View File

@ -18,7 +18,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi
/// <param name="buffer">Which buffer to read: 0 = front, 1 = back</param> /// <param name="buffer">Which buffer to read: 0 = front, 1 = back</param>
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void ReadScreen2(int[] framebuffer, ref int width, ref int height, int buffer); private delegate void ReadScreen2(int[] framebuffer, ref int width, ref int height, int buffer);
ReadScreen2 GFXReadScreen2; readonly ReadScreen2 GFXReadScreen2;
/// <summary> /// <summary>
/// Gets the width and height of the mupen64plus framebuffer /// Gets the width and height of the mupen64plus framebuffer
@ -29,9 +29,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi
/// <param name="buffer">Which buffer to read: 0 = front, 1 = back</param> /// <param name="buffer">Which buffer to read: 0 = front, 1 = back</param>
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void ReadScreen2Res(IntPtr dummy, ref int width, ref int height, int buffer); private delegate void ReadScreen2Res(IntPtr dummy, ref int width, ref int height, int buffer);
ReadScreen2Res GFXReadScreen2Res; readonly ReadScreen2Res GFXReadScreen2Res;
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate int GetScreenTextureID(); private delegate int GetScreenTextureID();
GetScreenTextureID GFXGetScreenTextureID; GetScreenTextureID GFXGetScreenTextureID;

View File

@ -26,7 +26,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public bool recalculate = false; public bool recalculate = false;
NES nes; readonly NES nes;
public APU(NES nes, APU old, bool pal) public APU(NES nes, APU old, bool pal)
{ {
this.nes = nes; this.nes = nes;
@ -43,25 +43,25 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
} }
} }
static int[] DMC_RATE_NTSC = { 428, 380, 340, 320, 286, 254, 226, 214, 190, 160, 142, 128, 106, 84, 72, 54 }; static readonly int[] DMC_RATE_NTSC = { 428, 380, 340, 320, 286, 254, 226, 214, 190, 160, 142, 128, 106, 84, 72, 54 };
static int[] DMC_RATE_PAL = { 398, 354, 316, 298, 276, 236, 210, 198, 176, 148, 132, 118, 98, 78, 66, 50 }; static readonly int[] DMC_RATE_PAL = { 398, 354, 316, 298, 276, 236, 210, 198, 176, 148, 132, 118, 98, 78, 66, 50 };
static int[] LENGTH_TABLE = { 10, 254, 20, 2, 40, 4, 80, 6, 160, 8, 60, 10, 14, 12, 26, 14, 12, 16, 24, 18, 48, 20, 96, 22, 192, 24, 72, 26, 16, 28, 32, 30 }; static readonly int[] LENGTH_TABLE = { 10, 254, 20, 2, 40, 4, 80, 6, 160, 8, 60, 10, 14, 12, 26, 14, 12, 16, 24, 18, 48, 20, 96, 22, 192, 24, 72, 26, 16, 28, 32, 30 };
static byte[,] PULSE_DUTY = { static readonly byte[,] PULSE_DUTY = {
{0,1,0,0,0,0,0,0}, // (12.5%) {0,1,0,0,0,0,0,0}, // (12.5%)
{0,1,1,0,0,0,0,0}, // (25%) {0,1,1,0,0,0,0,0}, // (25%)
{0,1,1,1,1,0,0,0}, // (50%) {0,1,1,1,1,0,0,0}, // (50%)
{1,0,0,1,1,1,1,1}, // (25% negated (75%)) {1,0,0,1,1,1,1,1}, // (25% negated (75%))
}; };
static byte[] TRIANGLE_TABLE = static readonly byte[] TRIANGLE_TABLE =
{ {
15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
}; };
static int[] NOISE_TABLE_NTSC = static readonly int[] NOISE_TABLE_NTSC =
{ {
4, 8, 16, 32, 64, 96, 128, 160, 202, 254, 380, 508, 762, 1016, 2034, 4068 4, 8, 16, 32, 64, 96, 128, 160, 202, 254, 380, 508, 762, 1016, 2034, 4068
}; };
static int[] NOISE_TABLE_PAL = static readonly int[] NOISE_TABLE_PAL =
{ {
4, 7, 14, 30, 60, 88, 118, 148, 188, 236, 354, 472, 708, 944, 1890, 3778 4, 7, 14, 30, 60, 88, 118, 148, 188, 236, 354, 472, 708, 944, 1890, 3778
}; };
@ -70,7 +70,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{ {
public PulseUnit(APU apu, int unit) { this.unit = unit; this.apu = apu; } public PulseUnit(APU apu, int unit) { this.unit = unit; this.apu = apu; }
public int unit; public int unit;
APU apu; readonly APU apu;
// reg0 // reg0
int duty_cnt, env_loop, env_constant, env_cnt_value; int duty_cnt, env_loop, env_constant, env_cnt_value;
@ -309,7 +309,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public sealed class NoiseUnit public sealed class NoiseUnit
{ {
APU apu; readonly APU apu;
// reg0 (sweep) // reg0 (sweep)
int env_cnt_value, env_loop, env_constant; int env_cnt_value, env_loop, env_constant;
@ -331,7 +331,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
int env_output, env_start_flag, env_divider, env_counter; int env_output, env_start_flag, env_divider, env_counter;
bool noise_bit = true; bool noise_bit = true;
int[] NOISE_TABLE; readonly int[] NOISE_TABLE;
public NoiseUnit(APU apu, bool pal) public NoiseUnit(APU apu, bool pal)
{ {
@ -508,7 +508,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
int seq = 0; int seq = 0;
public int sample; public int sample;
APU apu; readonly APU apu;
public TriangleUnit(APU apu) { this.apu = apu; } public TriangleUnit(APU apu) { this.apu = apu; }
public void SyncState(Serializer ser) public void SyncState(Serializer ser)
@ -648,8 +648,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
sealed class DMCUnit sealed class DMCUnit
{ {
APU apu; readonly APU apu;
int[] DMC_RATE; readonly int[] DMC_RATE;
public DMCUnit(APU apu, bool pal) public DMCUnit(APU apu, bool pal)
{ {
this.apu = apu; this.apu = apu;
@ -940,7 +940,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public PulseUnit[] pulse = new PulseUnit[2]; public PulseUnit[] pulse = new PulseUnit[2];
public TriangleUnit triangle; public TriangleUnit triangle;
public NoiseUnit noise; public NoiseUnit noise;
DMCUnit dmc; readonly DMCUnit dmc;
bool irq_pending; bool irq_pending;
bool dmc_irq; bool dmc_irq;
@ -959,14 +959,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
dmc.Fetch(); dmc.Fetch();
} }
int[][] sequencer_lut = new int[2][]; readonly int[][] sequencer_lut = new int[2][];
static int[][] sequencer_lut_ntsc = { static readonly int[][] sequencer_lut_ntsc = {
new[]{7457,14913,22371,29830}, new[]{7457,14913,22371,29830},
new[]{7457,14913,22371,29830,37282} new[]{7457,14913,22371,29830,37282}
}; };
static int[][] sequencer_lut_pal = { static readonly int[][] sequencer_lut_pal = {
new[]{8313,16627,24939,33254}, new[]{8313,16627,24939,33254},
new[]{8313,16627,24939,33254,41566} new[]{8313,16627,24939,33254,41566}
}; };

View File

@ -42,7 +42,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
byte jump2_outer_bank; // needed to select between banks in 512K jump2 board byte jump2_outer_bank; // needed to select between banks in 512K jump2 board
//regenerable state //regenerable state
int[] prg_banks_16k = new int[2]; readonly int[] prg_banks_16k = new int[2];
//state //state
int prg_reg_16k; int prg_reg_16k;

View File

@ -6,7 +6,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
internal sealed class GameGenie : NesBoardBase internal sealed class GameGenie : NesBoardBase
{ {
static byte[] PatternTables = new byte[256]; static readonly byte[] PatternTables = new byte[256];
static GameGenie() static GameGenie()
{ {

View File

@ -9,7 +9,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
private int prg_mask_16; private int prg_mask_16;
private byte[] sec = { 0, 3, 1, 5, 6, 7, 2, 4 }; private readonly byte[] sec = { 0, 3, 1, 5, 6, 7, 2, 4 };
public override bool Configure(EDetectionOrigin origin) public override bool Configure(EDetectionOrigin origin)
{ {

View File

@ -7,7 +7,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{ {
private byte[] EXPREGS = new byte[8]; private byte[] EXPREGS = new byte[8];
private byte[] sec = { 0, 3, 1, 5, 6, 7, 2, 4 }; private readonly byte[] sec = { 0, 3, 1, 5, 6, 7, 2, 4 };
public override bool Configure(EDetectionOrigin origin) public override bool Configure(EDetectionOrigin origin)
{ {

View File

@ -41,11 +41,11 @@
} }
} }
static byte[] scramble_table = { 0, 3, 1, 5, 6, 7, 2, 4 }; static readonly byte[] scramble_table = { 0, 3, 1, 5, 6, 7, 2, 4 };
static int scramble_A000(byte val)
private static int scramble_A000(byte val)
{ {
return (val & ~0x7) | scramble_table[val & 0x7]; return (val & ~0x7) | scramble_table[val & 0x7];
} }
} }
} }

View File

@ -12,7 +12,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
private int prg_mask_8k, chr_mask_1k; private int prg_mask_8k, chr_mask_1k;
private byte[] regs_sec = { 0, 2, 5, 3, 6, 1, 7, 4 }; private readonly byte[] regs_sec = { 0, 2, 5, 3, 6, 1, 7, 4 };
/* /*
* I'm not sure where these matrices originated from, but they don't seem to be needed * I'm not sure where these matrices originated from, but they don't seem to be needed

View File

@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public byte[] prg_regs_8k = new byte[4]; public byte[] prg_regs_8k = new byte[4];
private int prg_mask_8k, chr_mask_1k; private int prg_mask_8k, chr_mask_1k;
private byte[] regs_sec = { 0, 6, 3, 7, 5, 2, 4, 1 }; private readonly byte[] regs_sec = { 0, 6, 3, 7, 5, 2, 4, 1 };
public override bool Configure(EDetectionOrigin origin) public override bool Configure(EDetectionOrigin origin)

View File

@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
private int prg_mask_8k, chr_mask_1k; private int prg_mask_8k, chr_mask_1k;
private byte[] regs_sec = { 0, 2, 6, 1, 7, 3, 4, 5 }; private readonly byte[] regs_sec = { 0, 2, 6, 1, 7, 3, 4, 5 };
public override bool Configure(EDetectionOrigin origin) public override bool Configure(EDetectionOrigin origin)
{ {

View File

@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
bool swap; bool swap;
private static int[] lut = { 4, 3, 5, 3, 6, 3, 7, 3 }; private static readonly int[] lut = { 4, 3, 5, 3, 6, 3, 7, 3 };
public override bool Configure(EDetectionOrigin origin) public override bool Configure(EDetectionOrigin origin)
{ {

View File

@ -33,7 +33,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
master.SyncIRQ(flag); master.SyncIRQ(flag);
} }
Mapper116 master; readonly Mapper116 master;
} }

View File

@ -14,7 +14,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
int prg_mask; int prg_mask;
int chr_mask; int chr_mask;
int prg; int prg;
int[] chr = new int[8]; readonly int[] chr = new int[8];
public override bool Configure(EDetectionOrigin origin) public override bool Configure(EDetectionOrigin origin)
{ {

View File

@ -18,7 +18,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
return true; return true;
} }
private List<List<byte>> prg_perm = new List<List<byte>> private readonly List<List<byte>> prg_perm = new List<List<byte>>
{ {
new List<byte> { 0, 1, 2, 3, }, new List<byte> { 0, 1, 2, 3, },
new List<byte> { 3, 2, 1, 0, }, new List<byte> { 3, 2, 1, 0, },
@ -26,7 +26,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
new List<byte> { 3, 1, 2, 0, }, new List<byte> { 3, 1, 2, 0, },
}; };
private List<List<byte>> chr_perm = new List<List<byte>> private readonly List<List<byte>> chr_perm = new List<List<byte>>
{ {
new List<byte> { 0, 1, 2, 3, 4, 5, 6, 7, }, new List<byte> { 0, 1, 2, 3, 4, 5, 6, 7, },
new List<byte> { 0, 2, 1, 3, 4, 6, 5, 7, }, new List<byte> { 0, 2, 1, 3, 4, 6, 5, 7, },

View File

@ -33,12 +33,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
/// <summary> /// <summary>
/// the bankswitch values to be used before the INIT routine is called /// the bankswitch values to be used before the INIT routine is called
/// </summary> /// </summary>
byte[] InitBankSwitches = new byte[8]; readonly byte[] InitBankSwitches = new byte[8];
/// <summary> /// <summary>
/// An image of the entire PRG space where the unmapped files are located /// An image of the entire PRG space where the unmapped files are located
/// </summary> /// </summary>
byte[] FakePRG = new byte[32768]; readonly byte[] FakePRG = new byte[32768];
//------------------------------ //------------------------------
//state //state
@ -240,7 +240,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
//3FF3 - PatchVectors=false //3FF3 - PatchVectors=false
//3FF4 - PatchVectors=true //3FF4 - PatchVectors=true
byte[] NSFROM = new byte[0x23] readonly byte[] NSFROM = new byte[0x23]
{ {
//@NMIVector //@NMIVector
//Suspend vector patching //Suspend vector patching

View File

@ -23,7 +23,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
//state //state
int[] prg_banks_8k = new int[4]; int[] prg_banks_8k = new int[4];
int[] chr_banks_1k = new int[12]; int[] chr_banks_1k = new int[12];
bool[] vram_enable = new bool[3]; readonly bool[] vram_enable = new bool[3];
int irq_counter; int irq_counter;
bool irq_enabled; bool irq_enabled;

View File

@ -102,7 +102,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
ser.Sync(nameof(ch), ref ch); ser.Sync(nameof(ch), ref ch);
} }
Action<int> enqueuer; readonly Action<int> enqueuer;
public Namco163Audio(Action<int> enqueuer) public Namco163Audio(Action<int> enqueuer)
{ {

View File

@ -96,7 +96,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
// security reading index for tko boxing // security reading index for tko boxing
int tko_security = 0; int tko_security = 0;
static byte[] TKO = { 0xFF, 0xBF, 0xB7, 0x97, 0x97, 0x17, 0x57, 0x4F, 0x6F, 0x6B, 0xEB, 0xA9, 0xB1, 0x90, 0x94, 0x14, static readonly 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}; 0x56, 0x4E, 0x6F, 0x6B, 0xEB, 0xA9, 0xB1, 0x90, 0xD4, 0x5C, 0x3E, 0x26, 0x87, 0x83, 0x13, 0x51};
public override void SyncState(Serializer ser) public override void SyncState(Serializer ser)

View File

@ -13,7 +13,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
//state //state
byte prg_reg; byte prg_reg;
int[] prg_banks_8k = new int[4]; readonly int[] prg_banks_8k = new int[4];
int[] chr_banks_4k = new int[4]; int[] chr_banks_4k = new int[4];
int[] chr_latches = new int[2]; int[] chr_latches = new int[2];

View File

@ -16,7 +16,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
/// <summary> /// <summary>
/// true if 256byte /// true if 256byte
/// </summary> /// </summary>
bool Big; readonly bool Big;
byte[] rom; byte[] rom;
/// <summary>aux circuitry? D7 of data byte</summary> /// <summary>aux circuitry? D7 of data byte</summary>

View File

@ -6,18 +6,20 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
//AKA mapper 64 //AKA mapper 64
internal sealed class TENGEN_800032 : NesBoardBase internal sealed class TENGEN_800032 : NesBoardBase
{ {
//configuration // configuration
int prg_bank_mask_8k; int prg_bank_mask_8k;
int chr_bank_mask_1k; int chr_bank_mask_1k;
//regenerable state // regenerable state
int[] prg_banks_8k = new int[4]; readonly int[] prg_banks_8k = new int[4];
int[] chr_banks_1k = new int[8]; readonly int[] chr_banks_1k = new int[8];
//state
// state
int[] regs = new int[16]; int[] regs = new int[16];
int address; int address;
bool chr_1k, chr_mode, prg_mode; bool chr_1k, chr_mode, prg_mode;
//irq
// irq
int irq_countdown; int irq_countdown;
int a12_old; int a12_old;
int irq_reload, irq_counter; int irq_reload, irq_counter;
@ -191,7 +193,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
return Rom[addr]; return Rom[addr];
} }
public override byte ReadPpu(int addr) public override byte ReadPpu(int addr)
{ {
if (addr < 0x2000) if (addr < 0x2000)
@ -328,6 +329,5 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
a12_old = a12; a12_old = a12;
} }
} }
} }

View File

@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
private byte[] prg_regs_8k = new byte[4]; private byte[] prg_regs_8k = new byte[4];
private byte[] chr_regs_1k = new byte[8]; private byte[] chr_regs_1k = new byte[8];
private bool ChrMode; private bool ChrMode;
private bool[] wramenable = new bool[3]; private readonly bool[] wramenable = new bool[3];
public override void SyncState(Serializer ser) public override void SyncState(Serializer ser)
{ {

View File

@ -14,7 +14,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
private int _reg; private int _reg;
private int DipswitchMask = 3; private readonly int DipswitchMask = 3;
private bool Prg16kMode => _reg.Bit(7); private bool Prg16kMode => _reg.Bit(7);

View File

@ -11,11 +11,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
private int _reg = 0xFF; private int _reg = 0xFF;
private bool _isRom2 = true; private bool _isRom2 = true;
private int _prgMaskRom1 = 7; private readonly int _prgMaskRom1 = 7;
private int _prgMaskRom2 = 1; private readonly int _prgMaskRom2 = 1;
private int _wramPage = 0x3E000; private readonly int _wramPage = 0x3E000;
private int _rom2Offset = 0x40000; private readonly int _rom2Offset = 0x40000;
public override bool Configure(EDetectionOrigin origin) public override bool Configure(EDetectionOrigin origin)
{ {

View File

@ -300,7 +300,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
int latched; int latched;
// communicate with APU // communicate with APU
Action<int> enqueuer; readonly Action<int> enqueuer;
// true if V has been written and we need to check to change something // true if V has been written and we need to check to change something
bool volumeChangePending; bool volumeChangePending;

View File

@ -13,7 +13,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
//state //state
int[] prg_banks_8k = new int[4]; int[] prg_banks_8k = new int[4];
int[] chr_banks_4k = new int[2]; int[] chr_banks_4k = new int[2];
int[] chr_regs_4k = new int[2]; readonly int[] chr_regs_4k = new int[2];
//the VS actually does have 2 KB of nametable address space //the VS actually does have 2 KB of nametable address space
//let's make the extra space here, instead of in the main NES to avoid confusion //let's make the extra space here, instead of in the main NES to avoid confusion

View File

@ -66,7 +66,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
private bool extrabig_chr = false; private bool extrabig_chr = false;
//state //state
private int[] prg_bank_reg_8k = new int[2]; private readonly int[] prg_bank_reg_8k = new int[2];
public int[] chr_bank_reg_1k = new int[16]; public int[] chr_bank_reg_1k = new int[16];
private bool _prgMode; private bool _prgMode;
public byte[] prg_banks_8k = new byte[4]; public byte[] prg_banks_8k = new byte[4];

View File

@ -13,11 +13,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
// what did i do in a previous life to deserve this? // what did i do in a previous life to deserve this?
// given the bottom four bits of $b003, and a 1K address region in PPU $0000:$3fff, // given the bottom four bits of $b003, and a 1K address region in PPU $0000:$3fff,
static byte[] Banks = new byte[16 * 16]; // which of the 8 chr regs is used to determine the bank here? static readonly byte[] Banks = new byte[16 * 16]; // which of the 8 chr regs is used to determine the bank here?
static byte[] Masks = new byte[16 * 16]; // what is the resulting 8 bit chr reg value ANDed with? static readonly byte[] Masks = new byte[16 * 16]; // what is the resulting 8 bit chr reg value ANDed with?
static byte[] A10s = new byte[16 * 16]; // and then what is it ORed with? static readonly byte[] A10s = new byte[16 * 16]; // and then what is it ORed with?
static byte[] PTables = static readonly byte[] PTables =
{ {
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
0x80,0xc0,0x81,0xc1,0x82,0xc2,0x83,0xc3, 0x80,0xc0,0x81,0xc1,0x82,0xc2,0x83,0xc3,
@ -113,7 +113,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
//state //state
int prg_bank_16k, prg_bank_8k; int prg_bank_16k, prg_bank_8k;
byte[] prg_banks_8k = new byte[4]; readonly byte[] prg_banks_8k = new byte[4];
byte[] chr_banks_1k = new byte[8]; byte[] chr_banks_1k = new byte[8];
bool irq_mode; bool irq_mode;
bool irq_enabled, irq_pending, irq_autoen; bool irq_enabled, irq_pending, irq_autoen;

View File

@ -10,12 +10,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{ {
public class BootGodDb public class BootGodDb
{ {
/// <summary> /// <summary>
/// blocks until the DB is done loading /// blocks until the DB is done loading
/// </summary> /// </summary>
static EventWaitHandle acquire; static EventWaitHandle acquire;
bool validate = true; readonly bool validate = true;
private readonly Bag<string, CartInfo> _sha1Table = new Bag<string, CartInfo>(); private readonly Bag<string, CartInfo> _sha1Table = new Bag<string, CartInfo>();

View File

@ -146,7 +146,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
int latchedoutput; int latchedoutput;
Action<int> SendDiff; readonly Action<int> SendDiff;
public FDSAudio(Action<int> SendDiff) public FDSAudio(Action<int> SendDiff)
{ {

Some files were not shown because too many files have changed in this diff Show More