set get only properties in Emulation.Cores, and a few other simplfiications

This commit is contained in:
adelikat 2020-02-18 11:11:59 -06:00
parent 2ccf03fd44
commit 54ba1e12eb
20 changed files with 104 additions and 137 deletions

View File

@ -85,8 +85,8 @@ namespace BizHawk.Emulation.Cores.Arcades.MAME
#region Properties
public CoreComm CoreComm { get; private set; }
public IEmulatorServiceProvider ServiceProvider { get; private set; }
public CoreComm CoreComm { get; }
public IEmulatorServiceProvider ServiceProvider { get; }
public ControllerDefinition ControllerDefinition => MAMEController;
public string SystemId => "MAME";
public int[] GetVideoBuffer() => _frameBuffer;

View File

@ -16,7 +16,7 @@ namespace BizHawk.Emulation.Cores.Computers.MSX
set => _isLag = value;
}
public IInputCallbackSystem InputCallbacks { get; private set; }
public IInputCallbackSystem InputCallbacks { get; } = new InputCallbackSystem();
public int _lagCount = 0;
public bool _lagged = true;

View File

@ -77,18 +77,16 @@ namespace BizHawk.Emulation.Cores.Computers.MSX
SetupMemoryDomains();
InputCallbacks = new InputCallbackSystem();
Header_Length = LibMSX.MSX_getheaderlength(MSX_Pntr);
Disasm_Length = LibMSX.MSX_getdisasmlength(MSX_Pntr);
Reg_String_Length = LibMSX.MSX_getregstringlength(MSX_Pntr);
StringBuilder new_header = new StringBuilder(Header_Length);
LibMSX.MSX_getheader(MSX_Pntr, new_header, Header_Length);
var newHeader = new StringBuilder(Header_Length);
LibMSX.MSX_getheader(MSX_Pntr, newHeader, Header_Length);
Console.WriteLine(Header_Length + " " + Disasm_Length + " " + Reg_String_Length);
Tracer = new TraceBuffer { Header = new_header.ToString() };
Tracer = new TraceBuffer { Header = newHeader.ToString() };
var serviceProvider = ServiceProvider as BasicServiceProvider;
serviceProvider.Register<ITraceable>(Tracer);

View File

@ -79,8 +79,8 @@ namespace BizHawk.Emulation.Cores.ColecoVision
ser.EndSection();
}
public IPort Port1 { get; private set; }
public IPort Port2 { get; private set; }
public IPort Port1 { get; }
public IPort Port2 { get; }
private static Dictionary<string, Type> _controllerTypes = null;

View File

@ -36,7 +36,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision
};
}
public byte Read(IController c, bool left_mode, bool updateWheel, float wheelAngle)
public byte Read(IController c, bool leftMode, bool updateWheel, float wheelAngle)
{
return 0x7F; // needs checking
}
@ -50,10 +50,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision
public int PortNum { get; }
public float UpdateWheel(IController c)
{
return 0;
}
public float UpdateWheel(IController c) => 0;
}
[DisplayName("ColecoVision Basic Controller")]
@ -76,36 +73,36 @@ namespace BizHawk.Emulation.Cores.ColecoVision
{
if (leftMode)
{
byte retval = 0x7F;
if (c.IsPressed(Definition.BoolButtons[0])) retval &= 0xFE;
if (c.IsPressed(Definition.BoolButtons[1])) retval &= 0xFD;
if (c.IsPressed(Definition.BoolButtons[2])) retval &= 0xFB;
if (c.IsPressed(Definition.BoolButtons[3])) retval &= 0xF7;
if (c.IsPressed(Definition.BoolButtons[4])) retval &= 0x3F;
return retval;
byte retVal = 0x7F;
if (c.IsPressed(Definition.BoolButtons[0])) retVal &= 0xFE;
if (c.IsPressed(Definition.BoolButtons[1])) retVal &= 0xFD;
if (c.IsPressed(Definition.BoolButtons[2])) retVal &= 0xFB;
if (c.IsPressed(Definition.BoolButtons[3])) retVal &= 0xF7;
if (c.IsPressed(Definition.BoolButtons[4])) retVal &= 0x3F;
return retVal;
}
else
{
byte retval = 0xF;
byte retVal = 0xF;
// 0x00;
if (c.IsPressed(Definition.BoolButtons[14])) retval = 0x01;
if (c.IsPressed(Definition.BoolButtons[10])) retval = 0x02;
if (c.IsPressed(Definition.BoolButtons[11])) retval = 0x03;
if (c.IsPressed(Definition.BoolButtons[14])) retVal = 0x01;
if (c.IsPressed(Definition.BoolButtons[10])) retVal = 0x02;
if (c.IsPressed(Definition.BoolButtons[11])) retVal = 0x03;
// 0x04;
if (c.IsPressed(Definition.BoolButtons[13])) retval = 0x05;
if (c.IsPressed(Definition.BoolButtons[16])) retval = 0x06;
if (c.IsPressed(Definition.BoolButtons[8])) retval = 0x07;
if (c.IsPressed(Definition.BoolButtons[13])) retVal = 0x05;
if (c.IsPressed(Definition.BoolButtons[16])) retVal = 0x06;
if (c.IsPressed(Definition.BoolButtons[8])) retVal = 0x07;
// 0x08;
if (c.IsPressed(Definition.BoolButtons[17])) retval = 0x09;
if (c.IsPressed(Definition.BoolButtons[6])) retval = 0x0A;
if (c.IsPressed(Definition.BoolButtons[15])) retval = 0x0B;
if (c.IsPressed(Definition.BoolButtons[9])) retval = 0x0C;
if (c.IsPressed(Definition.BoolButtons[7])) retval = 0x0D;
if (c.IsPressed(Definition.BoolButtons[12])) retval = 0x0E;
if (c.IsPressed(Definition.BoolButtons[17])) retVal = 0x09;
if (c.IsPressed(Definition.BoolButtons[6])) retVal = 0x0A;
if (c.IsPressed(Definition.BoolButtons[15])) retVal = 0x0B;
if (c.IsPressed(Definition.BoolButtons[9])) retVal = 0x0C;
if (c.IsPressed(Definition.BoolButtons[7])) retVal = 0x0D;
if (c.IsPressed(Definition.BoolButtons[12])) retVal = 0x0E;
if (c.IsPressed(Definition.BoolButtons[5]) == false) retval |= 0x40;
retval |= 0x30; // always set these bits
return retval;
if (c.IsPressed(Definition.BoolButtons[5]) == false) retVal |= 0x40;
retVal |= 0x30; // always set these bits
return retVal;
}
}
@ -124,10 +121,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision
"Key 6", "Key 7", "Key 8", "Key 9", "Pound", "Star"
};
public float UpdateWheel(IController c)
{
return 0;
}
public float UpdateWheel(IController c) => 0;
}
[DisplayName("Turbo Controller")]
@ -154,24 +148,14 @@ namespace BizHawk.Emulation.Cores.ColecoVision
{
if (leftMode)
{
byte retval = 0x4F;
byte retVal = 0x4F;
if (c.IsPressed(Definition.BoolButtons[0])) retval &= 0x3F;
if (c.IsPressed(Definition.BoolButtons[0])) retVal &= 0x3F;
float x = c.GetFloat(Definition.FloatControls[0]);
float y = c.GetFloat(Definition.FloatControls[1]);
float angle;
if (updateWheel)
{
angle = wheelAngle;
}
else
{
angle = CalcDirection(x, y);
}
var angle = updateWheel ? wheelAngle : CalcDirection(x, y);
byte temp2 = 0;
@ -198,16 +182,12 @@ namespace BizHawk.Emulation.Cores.ColecoVision
}
retval |= temp2;
retVal |= temp2;
return retval;
return retVal;
}
else
{
byte retval = 0x7F;
return retval;
}
return 0x7F;
}
public void SyncState(Serializer ser)
@ -245,7 +225,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision
{
float x = c.GetFloat(Definition.FloatControls[0]);
float y = c.GetFloat(Definition.FloatControls[1]);
return CalcDirection(x, y);
return CalcDirection(x, y);
}
}
@ -265,34 +245,25 @@ namespace BizHawk.Emulation.Cores.ColecoVision
};
}
public int PortNum { get; private set; }
public int PortNum { get; }
public ControllerDefinition Definition { get; private set; }
public ControllerDefinition Definition { get; }
public byte Read(IController c, bool left_mode, bool updateWheel, float wheelAngle)
{
if (left_mode)
{
byte retval = 0x4F;
if (c.IsPressed(Definition.BoolButtons[0])) retval &= 0xFE;
if (c.IsPressed(Definition.BoolButtons[1])) retval &= 0xFD;
if (c.IsPressed(Definition.BoolButtons[2])) retval &= 0xFB;
if (c.IsPressed(Definition.BoolButtons[3])) retval &= 0xF7;
if (c.IsPressed(Definition.BoolButtons[4])) retval &= 0x3F;
byte retVal = 0x4F;
if (c.IsPressed(Definition.BoolButtons[0])) retVal &= 0xFE;
if (c.IsPressed(Definition.BoolButtons[1])) retVal &= 0xFD;
if (c.IsPressed(Definition.BoolButtons[2])) retVal &= 0xFB;
if (c.IsPressed(Definition.BoolButtons[3])) retVal &= 0xF7;
if (c.IsPressed(Definition.BoolButtons[4])) retVal &= 0x3F;
float x = c.GetFloat(Definition.FloatControls[0]);
float y = c.GetFloat(Definition.FloatControls[1]);
float angle;
if (updateWheel)
{
angle = wheelAngle;
}
else
{
angle = CalcDirection(x, y);
}
var angle = updateWheel ? wheelAngle : CalcDirection(x, y);
byte temp2 = 0;
@ -318,36 +289,36 @@ namespace BizHawk.Emulation.Cores.ColecoVision
temp2 = 0x00;
}
retval |= temp2;
retVal |= temp2;
return retval;
return retVal;
}
else
{
byte retval = 0xF;
byte retVal = 0xF;
// 0x00;
if (c.IsPressed(Definition.BoolButtons[14])) retval = 0x01;
if (c.IsPressed(Definition.BoolButtons[10])) retval = 0x02;
if (c.IsPressed(Definition.BoolButtons[11])) retval = 0x03;
if (c.IsPressed(Definition.BoolButtons[14])) retVal = 0x01;
if (c.IsPressed(Definition.BoolButtons[10])) retVal = 0x02;
if (c.IsPressed(Definition.BoolButtons[11])) retVal = 0x03;
// 0x04;
if (c.IsPressed(Definition.BoolButtons[13])) retval = 0x05;
if (c.IsPressed(Definition.BoolButtons[16])) retval = 0x06;
if (c.IsPressed(Definition.BoolButtons[8])) retval = 0x07;
if (c.IsPressed(Definition.BoolButtons[13])) retVal = 0x05;
if (c.IsPressed(Definition.BoolButtons[16])) retVal = 0x06;
if (c.IsPressed(Definition.BoolButtons[8])) retVal = 0x07;
// 0x08;
if (c.IsPressed(Definition.BoolButtons[17])) retval = 0x09;
if (c.IsPressed(Definition.BoolButtons[6])) retval = 0x0A;
if (c.IsPressed(Definition.BoolButtons[15])) retval = 0x0B;
if (c.IsPressed(Definition.BoolButtons[9])) retval = 0x0C;
if (c.IsPressed(Definition.BoolButtons[7])) retval = 0x0D;
if (c.IsPressed(Definition.BoolButtons[12])) retval = 0x0E;
if (c.IsPressed(Definition.BoolButtons[17])) retVal = 0x09;
if (c.IsPressed(Definition.BoolButtons[6])) retVal = 0x0A;
if (c.IsPressed(Definition.BoolButtons[15])) retVal = 0x0B;
if (c.IsPressed(Definition.BoolButtons[9])) retVal = 0x0C;
if (c.IsPressed(Definition.BoolButtons[7])) retVal = 0x0D;
if (c.IsPressed(Definition.BoolButtons[12])) retVal = 0x0E;
// extra buttons for SAC
if (c.IsPressed(Definition.BoolButtons[18])) retval = 0x04;
if (c.IsPressed(Definition.BoolButtons[19])) retval = 0x08;
if (c.IsPressed(Definition.BoolButtons[18])) retVal = 0x04;
if (c.IsPressed(Definition.BoolButtons[19])) retVal = 0x08;
if (c.IsPressed(Definition.BoolButtons[5]) == false) retval |= 0x40;
retval |= 0x30; // always set these bits
return retval;
if (c.IsPressed(Definition.BoolButtons[5]) == false) retVal |= 0x40;
retVal |= 0x30; // always set these bits
return retVal;
}
}

View File

@ -132,9 +132,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
/// <summary>
/// set in the ROM internal header
/// </summary>
public string GameCode { get; private set; }
public string GameCode { get; }
public CoreComm CoreComm { get; private set; }
public CoreComm CoreComm { get; }
public void Dispose()
{

View File

@ -472,7 +472,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi
DebugStep m64pDebugStep;
// DLL handles
public IntPtr CoreDll { get; private set; }
public IntPtr CoreDll { get; }
public mupen64plusApi(N64 bizhawkCore, byte[] rom, VideoPluginSettings video_settings, int SaveType, int CoreType, bool DisableExpansionSlot)
{

View File

@ -4,7 +4,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
public partial class NES : IDriveLight
{
public bool DriveLightEnabled { get; private set; }
public bool DriveLightEnabled { get; }
public bool DriveLightOn { get; private set; }
}

View File

@ -779,7 +779,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
}
}
private ITraceable Tracer { get; set; }
private ITraceable Tracer { get; }
}
}

View File

@ -82,7 +82,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
static readonly LibQuickNES QN;
static readonly DynamicLibraryImportResolver Resolver;
public IEmulatorServiceProvider ServiceProvider { get; private set; }
public IEmulatorServiceProvider ServiceProvider { get; }
#region FPU precision

View File

@ -49,7 +49,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
private readonly ILibsnesController[] _ports;
private readonly ControlDefUnMerger[] _mergers;
public ControllerDefinition Definition { get; private set; }
public ControllerDefinition Definition { get; }
public LibsnesControllerDeck(LibsnesCore.SnesSyncSettings ss)
{

View File

@ -219,22 +219,22 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
public class OAMInfo
{
public int Index { private set; get; }
public int X { private set; get; }
public int Y { private set; get; }
public int Tile { private set; get; }
public int Name { private set; get; }
public int Table { private set; get; }
public int Palette { private set; get; }
public int Priority { private set; get; }
public bool VFlip { private set; get; }
public bool HFlip { private set; get; }
public int Size { private set; get; }
public int Index { get; }
public int X { get; }
public int Y { get; }
public int Tile { get; }
public int Name { get; }
public int Table { get; }
public int Palette { get; }
public int Priority { get; }
public bool VFlip { get; }
public bool HFlip { get; }
public int Size { get; }
/// <summary>
/// tiledata address
/// </summary>
public int Address { private set; get; }
public int Address { get; }
public OAMInfo(SNESGraphicsDecoder dec, ScreenInfo si, int num)
{

View File

@ -243,7 +243,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.PicoDrive
#region IDriveLight
public bool DriveLightEnabled { get; private set; }
public bool DriveLightEnabled { get; }
public bool DriveLightOn { get; private set; }
#endregion

View File

@ -16,7 +16,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
set => _isLag = value;
}
public IInputCallbackSystem InputCallbacks { get; private set; }
public IInputCallbackSystem InputCallbacks { get; } = new InputCallbackSystem();
public int _lagCount = 0;
public bool _lagged = true;

View File

@ -192,8 +192,6 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
//this manages the linkage between the cpu and mapper callbacks so it needs running before bootup is complete
((ICodeDataLogger)this).SetCDL(null);
InputCallbacks = new InputCallbackSystem();
Tracer = new TraceBuffer { Header = Cpu.TraceHeader };
var serviceProvider = ServiceProvider as BasicServiceProvider;

View File

@ -79,9 +79,9 @@ namespace BizHawk.Emulation.Cores.Libretro
vidBufferHandle.Free();
}
public CoreComm CoreComm { get; private set; }
public CoreComm CoreComm { get; }
public RetroDescription Description { get; private set; }
public RetroDescription Description { get; }
public bool LoadData(byte[] data, string id)
{
@ -123,7 +123,7 @@ namespace BizHawk.Emulation.Cores.Libretro
(ServiceProvider as BasicServiceProvider).Register<ISoundProvider>(resampler);
}
public IEmulatorServiceProvider ServiceProvider { get; private set; }
public IEmulatorServiceProvider ServiceProvider { get; }
public IDictionary<string, RegisterValue> GetCpuFlagsAndRegisters()
{
@ -285,7 +285,7 @@ namespace BizHawk.Emulation.Cores.Libretro
return definition;
}
public ControllerDefinition ControllerDefinition { get; private set; }
public ControllerDefinition ControllerDefinition { get; }
int timeFrameCounter;
public int Frame

View File

@ -378,7 +378,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
[AttributeUsage(AttributeTargets.Method)]
private class CLibPatchAttribute : Attribute
{
public string NativeName { get; private set; }
public string NativeName { get; }
public CLibPatchAttribute(string nativeName)
{
NativeName = nativeName;

View File

@ -15,7 +15,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
/// <summary>
/// name, used in identifying errors
/// </summary>
public string Name { get; private set; }
public string Name { get; }
/// <summary>
/// total number of bytes used
/// </summary>

View File

@ -17,7 +17,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
/// <summary>
/// name, used in identifying errors
/// </summary>
public string Name { get; private set; }
public string Name { get; }
/// <summary>
/// total number of bytes allocated

View File

@ -51,22 +51,22 @@ namespace BizHawk.Emulation.Cores.Waterbox
private readonly byte[] _fileHash;
public ulong Size { get; }
public ulong Start { get; private set; }
public ulong Start { get; }
public long LoadOffset { get; private set; }
public long LoadOffset { get; }
public MemoryBlockBase Memory { get; private set; }
public IntPtr EntryPoint { get; private set; }
public IntPtr EntryPoint { get; }
/// <summary>
/// for midipix-built PEs, pointer to the construtors to run during init
/// for midipix-built PEs, pointer to the constructors to run during init
/// </summary>
public IntPtr CtorList { get; private set; }
public IntPtr CtorList { get; }
/// <summary>
/// for midipix-build PEs, pointer to the destructors to run during fini
/// </summary>
public IntPtr DtorList { get; private set; }
public IntPtr DtorList { get; }
// true if the seal process has completed, including .idata and .sealed set to readonly,
// xorstate taken