use inline out variables in Emulation.Cores

This commit is contained in:
adelikat 2020-02-18 15:10:29 -06:00
parent 4e03e14eea
commit cdcc1eabde
27 changed files with 43 additions and 96 deletions

View File

@ -104,9 +104,8 @@ namespace BizHawk.Emulation.Cores.Components.M6502
};
}
int length;
string rawbytes = "";
string disasm = Disassemble(PC, out length);
string disasm = Disassemble(PC, out var length);
for (int i = 0; i < length; i++)
{

View File

@ -144,9 +144,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
// get samples from all the providers
foreach (var sp in SoundProviders)
{
int sampCount;
short[] samp;
sp.SoundProvider.GetSamplesSync(out samp, out sampCount);
sp.SoundProvider.GetSamplesSync(out var samp, out var sampCount);
sp.NSamp = sampCount;
sp.Buffer = samp;
}

View File

@ -132,8 +132,7 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII
case JsonToken.Float:
return Convert.ToInt32(_v);
case JsonToken.String:
int i;
if (int.TryParse(_v.ToString(), out i))
if (int.TryParse(_v.ToString(), out var i))
{
return i;
}

View File

@ -222,9 +222,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Media
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);
var diskData = ConvertSectorToGcr(sectorData, (byte)j, (byte)(i + 1), formatA, formatB, StandardSectorGapLength[DensityTable[i]], errorType, out var bitsWritten);
trackMem.Write(diskData, 0, diskData.Length);
trackLengthBits += bitsWritten;
}

View File

@ -155,8 +155,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
// if such a game is being played, tell the user and disable it
if (dict.ContainsKey("No_HS"))
{
bool no_hs;
bool.TryParse(dict["No_HS"], out no_hs);
bool.TryParse(dict["No_HS"], out var no_hs);
if (no_hs)
{

View File

@ -39,10 +39,9 @@ namespace BizHawk.Emulation.Cores.Consoles.NEC.PCFX
}
}).ToArray();
List<ControlDefUnMerger> tmp;
Definition = ControllerDefinitionMerger.GetMerged(
_devices.Select(d => d.Definition),
out tmp);
out var tmp);
_cdums = tmp.ToArray();
Definition.Name = "PC-FX Controller";

View File

@ -619,20 +619,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x
public void GetSamplesSync(out short[] samples, out int nsamp)
{
short[] temp_samp_A;
short[] temp_samp_B;
short[] temp_samp_C;
short[] temp_samp_D;
int nsamp_A;
int nsamp_B;
int nsamp_C;
int nsamp_D;
A.audio.GetSamplesSync(out temp_samp_A, out nsamp_A);
B.audio.GetSamplesSync(out temp_samp_B, out nsamp_B);
C.audio.GetSamplesSync(out temp_samp_C, out nsamp_C);
D.audio.GetSamplesSync(out temp_samp_D, out nsamp_D);
A.audio.GetSamplesSync(out var temp_samp_A, out var nsamp_A);
B.audio.GetSamplesSync(out short[] temp_samp_B, out var nsamp_B);
C.audio.GetSamplesSync(out var temp_samp_C, out var nsamp_C);
D.audio.GetSamplesSync(out var temp_samp_D, out var nsamp_D);
if (Link4xSettings.AudioSet == GBLink4xSettings.AudioSrc.A)
{

View File

@ -16,8 +16,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
public override string Disassemble(MemoryDomain m, uint addr, out int length)
{
ushort tmp;
string ret = LR35902.Disassemble((ushort)addr, a => m.PeekByte(a), out tmp);
string ret = LR35902.Disassemble((ushort)addr, a => m.PeekByte(a), out var tmp);
length = tmp;
return ret;
}

View File

@ -1007,8 +1007,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi
public void DetachPlugin(m64p_plugin_type type)
{
AttachedPlugin plugin;
if (plugins.TryGetValue(type, out plugin))
if (plugins.TryGetValue(type, out var plugin))
{
plugins.Remove(type);
m64pCoreDetachPlugin(type);

View File

@ -107,8 +107,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public void Transfer(string s)
{
string why;
if (!ValidString(s, out why))
if (!ValidString(s, out var why))
throw new InvalidOperationException(why);
Reset();

View File

@ -438,10 +438,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public override byte ReadPRG(int addr)
{
bool ram;
byte ret;
int offs = addr & 0x1fff;
int bank = PRGGetBank(addr, out ram);
int bank = PRGGetBank(addr, out var ram);
if (ram)
ret = ReadWRAMActual(bank, offs);
@ -463,10 +462,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public byte PeekPRG(int addr)
{
bool ram;
byte ret;
int offs = addr & 0x1fff;
int bank = PRGGetBank(addr, out ram);
int bank = PRGGetBank(addr, out var ram);
if (ram)
ret = ReadWRAMActual(bank, offs);
@ -479,8 +477,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public override void WritePRG(int addr, byte value)
{
bool ram;
int bank = PRGGetBank(addr, out ram);
int bank = PRGGetBank(addr, out var ram);
if (ram)
WriteWRAMActual(bank, addr & 0x1fff, value);
}

View File

@ -781,8 +781,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
string Name = ((MapperPropAttribute)attrib).Name ?? field.Name;
string Value;
if (board.InitialRegisterValues.TryGetValue(Name, out Value))
if (board.InitialRegisterValues.TryGetValue(Name, out var Value))
{
try
{

View File

@ -138,8 +138,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
this.Left = Left;
this.Right = Right;
List<ControlDefUnMerger> cdum;
Definition = ControllerDefinitionMerger.GetMerged(new[] { Left.GetDefinition(), Right.GetDefinition() }, out cdum);
Definition = ControllerDefinitionMerger.GetMerged(new[] { Left.GetDefinition(), Right.GetDefinition() }, out var cdum);
LeftU = cdum[0];
RightU = cdum[1];
@ -684,9 +683,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public FamicomDeck(IFamicomExpansion ExpSlot, LightgunDelegate PPUCallback)
{
Player3 = ExpSlot;
List<ControlDefUnMerger> cdum;
Definition = ControllerDefinitionMerger.GetMerged(
new[] { Player1.GetDefinition(), Player2.GetDefinition(), Player3.GetDefinition() }, out cdum);
new[] { Player1.GetDefinition(), Player2.GetDefinition(), Player3.GetDefinition() }, out var cdum);
Definition.BoolButtons.Add("P2 Microphone");
Player1U = cdum[0];
Player2U = cdum[1];

View File

@ -23,8 +23,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
void TryAdd(Stream s, string key)
{
byte[] data;
if (!chunks.TryGetValue(key, out data))
if (!chunks.TryGetValue(key, out var data))
return;
s.Write(data, 0, data.Length);
}
@ -64,9 +63,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
ci.prg_size = (short)(prgrom.Length / 1024);
ci.chr_size = (short)(chrrom.Length / 1024);
byte[] tmp;
if (chunks.TryGetValue("MIRR", out tmp))
if (chunks.TryGetValue("MIRR", out var tmp))
{
switch (tmp[0])
{

View File

@ -55,8 +55,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
float g = to_float * inp[1];
float b = to_float * inp[2];
float y, i, q;
RGB_TO_YIQ(r, g, b, out y, out i, out q);
RGB_TO_YIQ(r, g, b, out float y, out var i, out var q);
if (tint > 0 && color < 0x0d)
{

View File

@ -203,8 +203,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
if (controller.IsPressed("Reset"))
QN.qn_reset(Context, false);
int j1, j2;
SetPads(controller, out j1, out j2);
SetPads(controller, out var j1, out var j2);
if (Tracer.Enabled)
QN.qn_set_tracecb(Context, _traceCb);

View File

@ -29,8 +29,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
public byte* QUERY_get_memory_data(SNES_MEMORY id)
{
string name = QUERY_MemoryNameForId(id);
IntPtr ret;
_sharedMemoryBlocks.TryGetValue(name, out ret);
_sharedMemoryBlocks.TryGetValue(name, out var ret);
return (byte*)ret;
}

View File

@ -59,8 +59,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
Factory(ss.RightPort, ss)
};
List<ControlDefUnMerger> tmp;
Definition = ControllerDefinitionMerger.GetMerged(_ports.Select(p => p.Definition), out tmp);
Definition = ControllerDefinitionMerger.GetMerged(_ports.Select(p => p.Definition), out var tmp);
_mergers = tmp.ToArray();
// add buttons that the core itself will handle

View File

@ -552,8 +552,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
// zero 07-jul-2015 - I may have broken this
int totalLbaLength = disc.Session1.LeadoutLBA;
byte m, s, f;
DiscUtils.Convert_LBA_To_AMSF(totalLbaLength + 150, out m, out s, out f);
DiscUtils.Convert_LBA_To_AMSF(totalLbaLength + 150, out var m, out var s, out var f);
DataIn.Clear();
DataIn.Enqueue(m.BinToBCD());
@ -577,8 +576,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
else
lbaPos = tracks[track].LBA;
byte m, s, f;
DiscUtils.Convert_LBA_To_AMSF(lbaPos, out m, out s, out f);
DiscUtils.Convert_LBA_To_AMSF(lbaPos, out var m, out var s, out var f);
DataIn.Clear();
DataIn.Enqueue(m.BinToBCD());

View File

@ -352,11 +352,8 @@ namespace BizHawk.Emulation.Cores.Sega.GGHawkLink
short[] temp_samp_L = new short[735 * 2];
short[] temp_samp_R = new short[735 * 2];
int nsamp_L = 735;
int nsamp_R = 735;
L.GetSamplesSync(out temp_samp_L, out nsamp_L);
R.GetSamplesSync(out temp_samp_R, out nsamp_L);
L.GetSamplesSync(out temp_samp_L, out int nsamp_L);
R.GetSamplesSync(out temp_samp_R, out int nsamp_R);
if (linkSettings.AudioSet == GGLinkSettings.AudioSrc.Left)
{

View File

@ -49,9 +49,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.Saturn
.ToArray();
_data = new byte[count * DataSize];
List<ControlDefUnMerger> cdum;
Definition = ControllerDefinitionMerger.GetMerged(_devices.Select(d => d.Definition),
out cdum);
out var cdum);
_unmerger = cdum.ToArray();
}

View File

@ -90,8 +90,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
if (discInterfaces.Count != 0)
{
//determine region of one of the discs
OctoshockDll.ShockDiscInfo discInfo;
OctoshockDll.shock_AnalyzeDisc(discInterfaces[0].OctoshockHandle, out discInfo);
OctoshockDll.shock_AnalyzeDisc(discInterfaces[0].OctoshockHandle, out var discInfo);
//try to acquire the appropriate firmware
if (discInfo.region == OctoshockDll.eRegion.EU) firmwareRegion = "E";
@ -928,10 +927,8 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
unsafe void SetMemoryDomains()
{
var mmd = new List<MemoryDomain>();
IntPtr ptr;
int size;
OctoshockDll.shock_GetMemData(psx, out ptr, out size, OctoshockDll.eMemType.MainRAM);
OctoshockDll.shock_GetMemData(psx, out var ptr, out var size, OctoshockDll.eMemType.MainRAM);
mmd.Add(new MemoryDomainIntPtr("MainRAM", MemoryDomain.Endian.Little, ptr, size, true, 4));
OctoshockDll.shock_GetMemData(psx, out ptr, out size, OctoshockDll.eMemType.GPURAM);

View File

@ -167,8 +167,7 @@ namespace BizHawk.Emulation.Cores
if(job.Extension != null)
{
//first test everything associated with this extension
ExtensionInfo handler = null;
if (ExtensionHandlers.TryGetValue(ext, out handler))
if (ExtensionHandlers.TryGetValue(ext, out var handler))
{
foreach (var del in handler.Testers)
{

View File

@ -37,10 +37,8 @@ namespace BizHawk.Emulation.Cores.Sound
public void Fetch()
{
int nsampl, nsampr;
short[] sampl, sampr;
_left.GetSamplesSync(out sampl, out nsampl);
_right.GetSamplesSync(out sampr, out nsampr);
_left.GetSamplesSync(out var sampl, out int nsampl);
_right.GetSamplesSync(out var sampr, out var nsampr);
int n = Math.Min(nsampl + _leftOverflowCount, nsampr + _rightOverflowCount);

View File

@ -183,8 +183,7 @@ namespace BizHawk.Emulation.Cores.Components
void Part1_WriteRegister(byte register, byte value)
{
int chan, oper;
GetChanOpP1(register, out chan, out oper);
GetChanOpP1(register, out var chan, out var oper);
switch (register & 0xF0)
{
@ -203,8 +202,7 @@ namespace BizHawk.Emulation.Cores.Components
void Part2_WriteRegister(byte register, byte value)
{
int chan, oper;
GetChanOpP2(register, out chan, out oper);
GetChanOpP2(register, out var chan, out var oper);
switch (register & 0xF0)
{

View File

@ -511,8 +511,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
[BizExport(CallingConvention.Cdecl, EntryPoint = "n2")]
public int Open(string path, int flags, int mode)
{
IFileObject o;
if (!_availableFiles.TryGetValue(path, out o))
if (!_availableFiles.TryGetValue(path, out var o))
return -1;
if (_openFiles.Contains(o))
return -1;
@ -760,8 +759,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
private T RemoveFileInternal<T>(string name)
where T : IFileObject
{
IFileObject o;
if (!_availableFiles.TryGetValue(name, out o))
if (!_availableFiles.TryGetValue(name, out var o))
throw new InvalidOperationException("File was never registered!");
if (o.GetType() != typeof(T))
throw new InvalidOperationException("Object was not a the right kind of file");
@ -1107,8 +1105,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
// but it breaks xor state verification, so when we seal, nuke it.
// this could be the responsibility of something else other than the PeRunner; I am not sure yet...
IImportResolver libco;
if (_exports.TryGetValue("libco.so", out libco))
if (_exports.TryGetValue("libco.so", out var libco))
{
Console.WriteLine("Calling co_clean()...");
CallingConventionAdapters.Waterbox.GetDelegateForFunctionPointer<Action>(libco.GetProcAddrOrThrow("co_clean"))();

View File

@ -247,8 +247,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
// NB: Hints are not the same as Ordinals
foreach (var import in _pe.ImportedFunctions)
{
Dictionary<string, IntPtr> module;
if (!ImportsByModule.TryGetValue(import.DLL, out module))
if (!ImportsByModule.TryGetValue(import.DLL, out var module))
{
module = new Dictionary<string, IntPtr>();
ImportsByModule.Add(import.DLL, module);
@ -260,8 +259,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
module.Add(import.Name, Z.US(dest));
}
Section midipix;
if (_sectionsByName.TryGetValue(".midipix", out midipix))
if (_sectionsByName.TryGetValue(".midipix", out Section midipix))
{
var dataOffset = midipix.DiskStart;
CtorList = Z.SS(BitConverter.ToInt64(fileData, (int)(dataOffset + 0x30)) + LoadOffset);
@ -313,8 +311,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
if (_everythingSealed && _imports != null)
Memory.Protect(_imports.Start, _imports.Size, MemoryBlockBase.Protection.RW);
Dictionary<string, IntPtr> imports;
if (ImportsByModule.TryGetValue(moduleName, out imports))
if (ImportsByModule.TryGetValue(moduleName, out var imports))
{
foreach (var kvp in imports)
{