misc cleanups in emulator core service logic

This commit is contained in:
adelikat 2020-01-11 13:19:12 -06:00
parent 46d0818f09
commit f83261c116
118 changed files with 621 additions and 875 deletions

View File

@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using BizHawk.Common.NumberExtensions;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Calculators

View File

@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Cores.Calculators
public ControllerDefinition ControllerDefinition => TI83Controller;
public bool FrameAdvance(IController controller, bool render, bool rendersound)
public bool FrameAdvance(IController controller, bool render, bool renderSound)
{
_controller = controller;
_lagged = true;
@ -48,7 +48,7 @@ namespace BizHawk.Emulation.Cores.Calculators
TIM_1_int = true;
_cpu.FlagI = true;
}
}
}
}
Frame++;
@ -65,8 +65,8 @@ namespace BizHawk.Emulation.Cores.Calculators
public int Frame
{
get { return _frame; }
private set { _frame = value; }
get => _frame;
private set => _frame = value;
}
public string SystemId => "TI83";

View File

@ -10,16 +10,16 @@ namespace BizHawk.Emulation.Cores.Calculators
public int LagCount
{
get { return _lagCount; }
set { _lagCount = value; }
get => _lagCount;
set => _lagCount = value;
}
public IInputCallbackSystem InputCallbacks { get; } = new InputCallbackSystem();
public bool IsLagFrame
{
get { return _isLag; }
set { _isLag = value; }
get => _isLag;
set => _isLag = value;
}
}
}

View File

@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Cores.Calculators
{
private readonly Dictionary<string, MemoryDomainByteArray> _byteArrayDomains = new Dictionary<string, MemoryDomainByteArray>();
private IMemoryDomains _memoryDomains;
private bool _memoryDomainsInit = false;
private bool _memoryDomainsInit;
private void SetupMemoryDomains()
{
@ -20,13 +20,19 @@ namespace BizHawk.Emulation.Cores.Calculators
(addr) =>
{
if (addr < 0 || addr >= 65536)
{
throw new ArgumentOutOfRangeException();
}
return _cpu.ReadMemory((ushort)addr);
},
(addr, value) =>
{
if (addr < 0 || addr >= 65536)
{
throw new ArgumentOutOfRangeException();
}
_cpu.WriteMemory((ushort)addr, value);
}, 1);
@ -35,7 +41,7 @@ namespace BizHawk.Emulation.Cores.Calculators
SyncAllByteArrayDomains();
_memoryDomains = new MemoryDomainList(_byteArrayDomains.Values.Concat(domains).ToList());
(ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(_memoryDomains);
((BasicServiceProvider) ServiceProvider).Register(_memoryDomains);
_memoryDomainsInit = true;
}

View File

@ -4,16 +4,16 @@ namespace BizHawk.Emulation.Cores.Calculators
{
public partial class TI83 : ISettable<TI83.TI83Settings, object>
{
private TI83Settings Settings;
private TI83Settings _settings;
public TI83Settings GetSettings()
{
return Settings.Clone();
return _settings.Clone();
}
public bool PutSettings(TI83Settings o)
{
Settings = o;
_settings = o;
return false;
}
@ -29,13 +29,8 @@ namespace BizHawk.Emulation.Cores.Calculators
public class TI83Settings
{
public uint BGColor = 0x889778;
public uint ForeColor = 0x36412D;
public TI83Settings()
{
}
public uint BGColor { get; set; } = 0x889778;
public uint ForeColor { get; set; } = 0x36412D;
public TI83Settings Clone()
{

View File

@ -40,12 +40,11 @@ namespace BizHawk.Emulation.Cores.Calculators
private void SyncState(Serializer ser)
{
byte[] core = null;
if (ser.IsWriter)
{
var ms = new MemoryStream();
ms.Close();
core = ms.ToArray();
ms.ToArray();
}
_cpu.SyncState(ser);

View File

@ -22,19 +22,19 @@ namespace BizHawk.Emulation.Cores.Calculators
for (int x = 0; x < 96; x++)
{
int offset = (y * 96) + x;
int bufbyte = offset >> 3;
int bufbit = offset & 7;
int bit = (_vram[bufbyte] >> (7 - bufbit)) & 1;
int buffByte = offset >> 3;
int buffBit = offset & 7;
int bit = (_vram[buffByte] >> (7 - buffBit)) & 1;
if (bit == 0)
{
unchecked
{
pixels[i++] = (int)Settings.BGColor;
pixels[i++] = (int)_settings.BGColor;
}
}
else
{
pixels[i++] = (int)Settings.ForeColor;
pixels[i++] = (int)_settings.ForeColor;
}
}
}

View File

@ -9,11 +9,7 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII
{
public string Cpu
{
get
{
return "6502";
}
get => "6502";
set
{
}

View File

@ -14,9 +14,9 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII
public bool DeterministicEmulation => true;
public bool FrameAdvance(IController controller, bool render, bool rendersound)
public bool FrameAdvance(IController controller, bool render, bool renderSound)
{
FrameAdv(controller, render, rendersound);
FrameAdv(controller, render, renderSound);
return true;
}

View File

@ -8,8 +8,8 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII
public bool IsLagFrame
{
get { return _machine.Lagged; }
set { _machine.Lagged = value; }
get => _machine.Lagged;
set => _machine.Lagged = value;
}
public IInputCallbackSystem InputCallbacks { get; } = new InputCallbackSystem();

View File

@ -56,7 +56,7 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII
domains.Add(systemBusDomain);
_memoryDomains = new MemoryDomainList(domains);
(ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(_memoryDomains);
((BasicServiceProvider) ServiceProvider).Register(_memoryDomains);
}
private IMemoryDomains _memoryDomains;

View File

@ -5,8 +5,6 @@ using BizHawk.Emulation.Common;
using Jellyfish.Virtu;
using Newtonsoft.Json;
using Newtonsoft.Json.Bson;
using Newtonsoft.Json.Linq;
namespace BizHawk.Emulation.Cores.Computers.AppleII
{

View File

@ -4,10 +4,7 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII
{
public partial class AppleII : IVideoProvider
{
public int[] GetVideoBuffer()
{
return _machine.Video.VideoService.fb;
}
public int[] GetVideoBuffer() => _machine.Video.VideoService.fb;
// put together, these describe a metric on the screen
// they should define the smallest size that the buffer can be placed inside such that:
@ -22,19 +19,13 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII
public int VsyncNumerator
{
[FeatureNotImplemented] // TODO: precise numbers or confirm the default is okay
get
{
return NullVideo.DefaultVsyncNum;
}
get => NullVideo.DefaultVsyncNum;
}
public int VsyncDenominator
{
[FeatureNotImplemented] // TODO: precise numbers or confirm the default is okay
get
{
return NullVideo.DefaultVsyncDen;
}
get => NullVideo.DefaultVsyncDen;
}
}
}

View File

@ -39,9 +39,9 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
{
var currentSelectedDisassemblable = _selectedDisassemblable;
_selectedDisassemblable = GetAvailableDisassemblables().FirstOrDefault(d => d.Cpu == value) ?? currentSelectedDisassemblable;
if (_selectedDisassemblable is IDebuggable)
if (_selectedDisassemblable is IDebuggable debuggable)
{
_selectedDebuggable = _selectedDisassemblable as IDebuggable;
_selectedDebuggable = debuggable;
}
}
}

View File

@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
public ControllerDefinition ControllerDefinition => C64ControllerDefinition;
public bool FrameAdvance(IController controller, bool render, bool rendersound)
public bool FrameAdvance(IController controller, bool render, bool renderSound)
{
_board.Controller = controller;

View File

@ -6,14 +6,14 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
{
public bool IsLagFrame
{
get { return _isLagFrame; }
set { _isLagFrame = value; }
get => _isLagFrame;
set => _isLagFrame = value;
}
public int LagCount
{
get { return _lagCount; }
set { _lagCount = value; }
get => _lagCount;
set => _lagCount = value;
}
public IInputCallbackSystem InputCallbacks { get; }

View File

@ -3,7 +3,7 @@ using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Computers.Commodore64
{
// adelikat: changing settings to default object until there are actually settings, as the ui depends on it to know if there are any settings avaialable
// adelikat: changing settings to default object until there are actually settings, as the ui depends on it to know if there are any settings available
public partial class C64 : ISettable<C64.C64Settings, C64.C64SyncSettings>
{
public C64Settings GetSettings()

View File

@ -317,7 +317,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
_mapper.Core = this;
_lagcount = 0;
_lagCount = 0;
Cpu = new MOS6502X<CpuLink>(new CpuLink(this));
if (_game["PAL"])

View File

@ -9,7 +9,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
public ControllerDefinition ControllerDefinition => _controllerDeck.Definition;
public bool FrameAdvance(IController controller, bool render, bool rendersound)
public bool FrameAdvance(IController controller, bool render, bool renderSound)
{
_controller = controller;
@ -58,20 +58,20 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
else
{
throw new Exception("ERROR: Unable to resolve Frame. Please Report.");
}
}
}
}
_tia.New_Frame = false;
if (rendersound == false)
if (renderSound == false)
{
_tia.AudioClocks = 0; // we need this here since the async sound provider won't check in this case
}
if (_islag)
{
_lagcount++;
_lagCount++;
}
_tia.LineCount = 0;
@ -90,7 +90,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
public void ResetCounters()
{
_frame = 0;
_lagcount = 0;
_lagCount = 0;
_islag = false;
}

View File

@ -6,19 +6,19 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
{
public int LagCount
{
get { return _lagcount; }
set { _lagcount = value; }
get => _lagCount;
set => _lagCount = value;
}
public bool IsLagFrame
{
get { return _islag; }
set { _islag = value; }
get => _islag;
set => _islag = value;
}
public IInputCallbackSystem InputCallbacks { get; } = new InputCallbackSystem();
private bool _islag = true;
private int _lagcount;
private int _lagCount;
}
}

View File

@ -9,7 +9,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
{
internal IMemoryDomains MemoryDomains;
private readonly Dictionary<string, MemoryDomainByteArray> _byteArrayDomains = new Dictionary<string, MemoryDomainByteArray>();
private bool _memoryDomainsInit = false;
private bool _memoryDomainsInit;
private void SetupMemoryDomains()
{
@ -48,7 +48,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
SyncAllByteArrayDomains();
MemoryDomains = new MemoryDomainList(_byteArrayDomains.Values.Concat(domains).ToList());
(ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(MemoryDomains);
((BasicServiceProvider)ServiceProvider).Register(MemoryDomains);
_memoryDomainsInit = true;
}
@ -57,9 +57,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
{
SyncByteArrayDomain("Main RAM", _ram);
if (_mapper is mDPC)
if (_mapper is mDPC dpc)
{
SyncByteArrayDomain("DPC", (_mapper as mDPC).DspData);
SyncByteArrayDomain("DPC", dpc.DspData);
}
}

View File

@ -101,8 +101,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
[DefaultValue(24)]
public int NTSCTopLine
{
get { return _ntscTopLine; }
set { _ntscTopLine = Math.Min(64, Math.Max(value, 0)); }
get => _ntscTopLine;
set => _ntscTopLine = Math.Min(64, Math.Max(value, 0));
}
[DisplayName("NTSC Bottom Line")]
@ -110,8 +110,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
[DefaultValue(248)]
public int NTSCBottomLine
{
get { return _ntscBottomLine; }
set { _ntscBottomLine = Math.Min(260, Math.Max(value, 192)); }
get => _ntscBottomLine;
set => _ntscBottomLine = Math.Min(260, Math.Max(value, 192));
}
[DisplayName("PAL Top Line")]
@ -119,8 +119,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
[DefaultValue(24)]
public int PALTopLine
{
get { return _palTopLine; }
set { _palTopLine = Math.Min(64, Math.Max(value, 0)); }
get => _palTopLine;
set => _palTopLine = Math.Min(64, Math.Max(value, 0));
}
[DisplayName("PAL Bottom Line")]
@ -128,8 +128,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
[DefaultValue(296)]
public int PALBottomLine
{
get { return _palBottomLine; }
set { _palBottomLine = Math.Min(310, Math.Max(value, 192)); }
get => _palBottomLine;
set => _palBottomLine = Math.Min(310, Math.Max(value, 192));
}
[DisplayName("Background Color")]

View File

@ -43,7 +43,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
ser.BeginSection("A2600");
Cpu.SyncState(ser);
ser.Sync("ram", ref _ram, false);
ser.Sync("Lag", ref _lagcount);
ser.Sync("Lag", ref _lagCount);
ser.Sync("Frame", ref _frame);
ser.Sync("IsLag", ref _islag);
ser.Sync(nameof(cyc_counter), ref cyc_counter);

View File

@ -443,12 +443,12 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
private static bool ContainsAny(byte[] rom, IEnumerable<byte[]> signatures)
{
return signatures.Any(signature => rom.FindBytes(signature));
return signatures.Any(rom.FindBytes);
}
private static bool ContainsAll(byte[] rom, IEnumerable<byte[]> signatures)
{
return signatures.All(signature => rom.FindBytes(signature));
return signatures.All(rom.FindBytes);
}
}
}

View File

@ -67,9 +67,6 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
throw new NotImplementedException();
}
public long TotalExecutedCycles
{
get { return cpu.TotalExecutedCycles; }
}
public long TotalExecutedCycles => cpu.TotalExecutedCycles;
}
}

View File

@ -57,7 +57,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
public bool slow_access = false;
public int slow_countdown;
public bool FrameAdvance(IController controller, bool render, bool rendersound)
public bool FrameAdvance(IController controller, bool render, bool renderSound)
{
if (_tracer.Enabled)
{
@ -77,16 +77,16 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
HardReset();
}
_islag = true;
_isLag = true;
GetControllerState(controller);
GetConsoleState(controller);
maria.RunFrame();
if (_islag)
if (_isLag)
{
_lagcount++;
_lagCount++;
}
return true;
@ -322,8 +322,8 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
public void ResetCounters()
{
_frame = 0;
_lagcount = 0;
_islag = false;
_lagCount = 0;
_isLag = false;
}
public CoreComm CoreComm { get; }

View File

@ -6,19 +6,19 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
{
public int LagCount
{
get { return _lagcount; }
set { _lagcount = value; }
get => _lagCount;
set => _lagCount = value;
}
public bool IsLagFrame
{
get { return _islag; }
set { _islag = value; }
get => _isLag;
set => _isLag = value;
}
public IInputCallbackSystem InputCallbacks { get; } = new InputCallbackSystem();
public bool _islag = true;
private int _lagcount;
public bool _isLag = true;
private int _lagCount;
}
}

View File

@ -1,14 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections.Generic;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
{
public partial class A7800Hawk
{
private IMemoryDomains MemoryDomains;
private IMemoryDomains _memoryDomains;
public void SetupMemoryDomains()
{
@ -65,8 +62,8 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
1)
};
MemoryDomains = new MemoryDomainList(domains);
(ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(MemoryDomains);
_memoryDomains = new MemoryDomainList(domains);
((BasicServiceProvider) ServiceProvider).Register(_memoryDomains);
}
private byte PeekSystemBus(long addr)

View File

@ -15,12 +15,6 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
Buffer.BlockCopy(data, 0, _hsram, 0, data.Length);
}
public bool SaveRamModified
{
get
{
return (_hsbios != null);
}
}
public bool SaveRamModified => (_hsbios != null);
}
}

View File

@ -56,17 +56,14 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
[JsonIgnore]
public string Filter
{
get { return _Filter; }
set
{
_Filter = value;
}
get => _Filter;
set => _Filter = value;
}
[JsonIgnore]
public string Port1
{
get { return _port1; }
get => _port1;
set
{
if (!A7800HawkControllerDeck.ValidControllerTypes.ContainsKey(value))
@ -81,7 +78,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
[JsonIgnore]
public string Port2
{
get { return _port2; }
get => _port2;
set
{
if (!A7800HawkControllerDeck.ValidControllerTypes.ContainsKey(value))

View File

@ -48,9 +48,9 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
pokey.SyncState(ser);
ser.BeginSection("Atari7800");
ser.Sync("Lag", ref _lagcount);
ser.Sync("Lag", ref _lagCount);
ser.Sync("Frame", ref _frame);
ser.Sync("IsLag", ref _islag);
ser.Sync("IsLag", ref _isLag);
_controllerDeck.SyncState(ser);
ser.Sync(nameof(A7800_control_register), ref A7800_control_register);

View File

@ -34,7 +34,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
var registerAddr = (ushort)(addr & 0x0007);
if (registerAddr == 0x00)
{
Core._islag = false;
Core._isLag = false;
// Read Output reg A
// Combine readings from player 1 and player 2
@ -53,7 +53,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
if (registerAddr == 0x02)
{
Core._islag = false;
Core._isLag = false;
// Read Output reg B
byte temp = Core.con_state;

View File

@ -1,6 +1,4 @@
using System;
// X = don't care
// X = don't care
/*
1. TIA 0000 00XX 0000 0000 - 0000 00XX 0001 1111
2. MARIA 0000 00XX 0010 0000 - 0000 00XX 0011 1111
@ -30,13 +28,12 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
{
return 0xFF; // TODO: what to return here?
}
else
{
slow_access = true;
return tia.ReadMemory((ushort)(addr & 0x1F), false);
}
slow_access = true;
return tia.ReadMemory((ushort)(addr & 0x1F), false);
}
else if ((addr & 0xFCE0) == 0x20)
if ((addr & 0xFCE0) == 0x20)
{
if ((A7800_control_register & 0x2) > 0)
{
@ -47,54 +44,61 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
return 0x80; // TODO: What if Maria is off?
}
}
else if ((addr & 0xFF80) == 0x280)
if ((addr & 0xFF80) == 0x280)
{
slow_access = true;
return m6532.ReadMemory(addr, false);
}
else if ((addr & 0xFE80) == 0x480)
if ((addr & 0xFE80) == 0x480)
{
slow_access = true;
return RAM_6532[addr & 0x7F];
}
else if ((addr >= 0x1800) && (addr < 0x2800))
if ((addr >= 0x1800) && (addr < 0x2800))
{
return RAM[addr -0x1800];
}
else if ((addr >= 0x40) && (addr < 0x100))
if ((addr >= 0x40) && (addr < 0x100))
{
// RAM block 0
return RAM[addr - 0x40 + 0x840];
}
else if ((addr >= 0x140) && (addr < 0x200))
if ((addr >= 0x140) && (addr < 0x200))
{
// RAM block 1
return RAM[addr - 0x140 + 0x940];
}
else if ((addr >= 0x2800) && (addr < 0x3000))
if ((addr >= 0x2800) && (addr < 0x3000))
{
// this mirror evidently does not exist on hardware despite being in the documentation
return 0xFF;// RAM[(addr & 0x7FF) + 0x800];
}
else if ((addr >= 0x3000) && (addr < 0x4000))
if ((addr >= 0x3000) && (addr < 0x4000))
{
// could be either RAM mirror or ROM
return mapper.ReadMemory(addr);
}
else if ((addr >= 0x400) && (addr < 0x480))
if ((addr >= 0x400) && (addr < 0x480))
{
// cartridge space available
return mapper.ReadMemory(addr);
}
else if ((addr >= 0x500) && (addr < 0x1800))
if ((addr >= 0x500) && (addr < 0x1800))
{
// cartridge space available
return mapper.ReadMemory(addr);
}
else
{
return mapper.ReadMemory(addr);
}
return mapper.ReadMemory(addr);
}
public void WriteMemory(ushort addr, byte value)

View File

@ -93,7 +93,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
{
if ((Core.m6532._outputB & 0x04) == 0 && (Core.m6532._ddRb & 0x04) == 0x04)
{
Core._islag = false;
Core._isLag = false;
return (byte)(Core.p1_fire_2x & 0x80);
}
else
@ -106,7 +106,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
{
if ((Core.m6532._outputB & 0x04) == 0 && (Core.m6532._ddRb & 0x04) == 0x04)
{
Core._islag = false;
Core._isLag = false;
return (byte)((Core.p1_fire_2x & 0x40)<<1);
}
else
@ -119,7 +119,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
{
if ((Core.m6532._outputB & 0x10) == 0 && (Core.m6532._ddRb & 0x10) == 0x10)
{
Core._islag = false;
Core._isLag = false;
return (byte)(Core.p2_fire_2x & 0x80);
}
else
@ -132,7 +132,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
{
if ((Core.m6532._outputB & 0x10) == 0 && (Core.m6532._ddRb & 0x10) == 0x10)
{
Core._islag = false;
Core._isLag = false;
return (byte)((Core.p2_fire_2x & 0x40)<<1);
}
else
@ -143,7 +143,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
if (maskedAddr == 0x0C) // INPT4
{
Core._islag = false;
Core._isLag = false;
if (!Core.p1_is_2button)
{
@ -168,7 +168,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
if (maskedAddr == 0x0D) // INPT5
{
Core._islag = false;
Core._isLag = false;
if (!Core.p2_is_2button)
{
if (!Core.p2_is_lightgun)

View File

@ -14,7 +14,7 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx
public IInputCallbackSystem InputCallbacks
{
[FeatureNotImplemented]
get { throw new NotImplementedException(); }
get => throw new NotImplementedException();
}
}
}

View File

@ -14,16 +14,12 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx
new MemoryDomainIntPtr("RAM", MemoryDomain.Endian.Little, LibLynx.GetRamPointer(Core), 65536, true, 2)
};
IntPtr p;
int s;
if (LibLynx.GetSaveRamPtr(Core, out s, out p))
if (LibLynx.GetSaveRamPtr(Core, out var s, out var p))
{
mms.Add(new MemoryDomainIntPtr("Save RAM", MemoryDomain.Endian.Little, p, s, true, 2));
}
IntPtr p0, p1;
int s0, s1;
LibLynx.GetReadOnlyCartPtrs(Core, out s0, out p0, out s1, out p1);
LibLynx.GetReadOnlyCartPtrs(Core, out var s0, out var p0, out var s1, out var p1);
if (s0 > 0 && p0 != IntPtr.Zero)
{
mms.Add(new MemoryDomainIntPtr("Cart A", MemoryDomain.Endian.Little, p0, s0, false, 2));
@ -35,7 +31,7 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx
}
_memoryDomains = new MemoryDomainList(mms);
(ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(_memoryDomains);
((BasicServiceProvider) ServiceProvider).Register(_memoryDomains);
}
private IMemoryDomains _memoryDomains;

View File

@ -9,9 +9,7 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx
{
public byte[] CloneSaveRam()
{
int size;
IntPtr data;
if (!LibLynx.GetSaveRamPtr(Core, out size, out data))
if (!LibLynx.GetSaveRamPtr(Core, out var size, out var data))
{
return null;
}
@ -21,31 +19,21 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx
return ret;
}
public void StoreSaveRam(byte[] srcdata)
public void StoreSaveRam(byte[] srcData)
{
int size;
IntPtr data;
if (!LibLynx.GetSaveRamPtr(Core, out size, out data))
if (!LibLynx.GetSaveRamPtr(Core, out var size, out var data))
{
throw new InvalidOperationException();
}
if (size != srcdata.Length)
if (size != srcData.Length)
{
throw new ArgumentOutOfRangeException();
}
Marshal.Copy(srcdata, 0, data, size);
Marshal.Copy(srcData, 0, data, size);
}
public bool SaveRamModified
{
get
{
int unused;
IntPtr unused2;
return LibLynx.GetSaveRamPtr(Core, out unused, out unused2);
}
}
public bool SaveRamModified => LibLynx.GetSaveRamPtr(Core, out int unused, out IntPtr unused2);
}
}

View File

@ -5,15 +5,15 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx
{
public partial class Lynx : ISoundProvider
{
private readonly short[] _soundbuff = new short[2048];
private int _numsamp;
private readonly short[] _soundBuff = new short[2048];
private int _numSamp;
public bool CanProvideAsync => false;
public void GetSamplesSync(out short[] samples, out int nsamp)
{
samples = _soundbuff;
nsamp = _numsamp;
samples = _soundBuff;
nsamp = _numSamp;
}
public void DiscardSamples()

View File

@ -38,13 +38,13 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx
public void SaveStateBinary(BinaryWriter writer)
{
if (!LibLynx.BinStateSave(Core, _savebuff, _savebuff.Length))
if (!LibLynx.BinStateSave(Core, _saveBuff, _saveBuff.Length))
{
throw new InvalidOperationException($"Core's {nameof(LibLynx.BinStateSave)}() returned false!");
}
writer.Write(_savebuff.Length);
writer.Write(_savebuff);
writer.Write(_saveBuff.Length);
writer.Write(_saveBuff);
// other variables
writer.Write(IsLagFrame);
@ -55,13 +55,13 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx
public void LoadStateBinary(BinaryReader reader)
{
int length = reader.ReadInt32();
if (length != _savebuff.Length)
if (length != _saveBuff.Length)
{
throw new InvalidOperationException("Save buffer size mismatch!");
}
reader.Read(_savebuff, 0, length);
if (!LibLynx.BinStateLoad(Core, _savebuff, _savebuff.Length))
reader.Read(_saveBuff, 0, length);
if (!LibLynx.BinStateLoad(Core, _saveBuff, _saveBuff.Length))
{
throw new InvalidOperationException($"Core's {nameof(LibLynx.BinStateLoad)}() returned false!");
}
@ -74,22 +74,22 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx
public byte[] SaveStateBinary()
{
using var ms = new MemoryStream(_savebuff2, true);
using var ms = new MemoryStream(_saveBuff2, true);
using var bw = new BinaryWriter(ms);
SaveStateBinary(bw);
bw.Flush();
if (ms.Position != _savebuff2.Length)
if (ms.Position != _saveBuff2.Length)
{
throw new InvalidOperationException();
}
ms.Close();
return _savebuff2;
return _saveBuff2;
}
private readonly JsonSerializer _ser = new JsonSerializer { Formatting = Formatting.Indented };
private readonly byte[] _savebuff;
private readonly byte[] _savebuff2;
private readonly byte[] _saveBuff;
private readonly byte[] _saveBuff2;
private class TextStateData
{

View File

@ -7,12 +7,9 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx
private const int Width = 160;
private const int Height = 102;
private readonly int[] _videobuff = new int[Width * Height];
private readonly int[] _videoBuff = new int[Width * Height];
public int[] GetVideoBuffer()
{
return _videobuff;
}
public int[] GetVideoBuffer() => _videoBuff;
public int VirtualWidth => BufferWidth;

View File

@ -92,8 +92,8 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx
Core = LibLynx.Create(realfile, realfile.Length, bios, bios.Length, pagesize0, pagesize1, false);
try
{
_savebuff = new byte[LibLynx.BinStateSize(Core)];
_savebuff2 = new byte[_savebuff.Length + 13];
_saveBuff = new byte[LibLynx.BinStateSize(Core)];
_saveBuff2 = new byte[_saveBuff.Length + 13];
int rot = game.OptionPresent("rotate") ? int.Parse(game.OptionValue("rotate")) : 0;
LibLynx.SetRotation(Core, rot);
@ -128,9 +128,9 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx
LibLynx.Reset(Core);
}
int samples = _soundbuff.Length;
IsLagFrame = LibLynx.Advance(Core, GetButtons(controller), _videobuff, _soundbuff, ref samples);
_numsamp = samples / 2; // sound provider wants number of sample pairs
int samples = _soundBuff.Length;
IsLagFrame = LibLynx.Advance(Core, GetButtons(controller), _videoBuff, _soundBuff, ref samples);
_numSamp = samples / 2; // sound provider wants number of sample pairs
if (IsLagFrame)
{
LagCount++;

View File

@ -1,10 +1,6 @@
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Waterbox;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BizHawk.Emulation.Cores.Consoles.Belogic
{

View File

@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using BizHawk.Common.NumberExtensions;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.ColecoVision

View File

@ -70,8 +70,8 @@ namespace BizHawk.Emulation.Cores.ColecoVision
change2 = -(float)((ControllerDeck.temp_wheel2 + (360 - ControllerDeck.wheel2)) / 1.25);
}
int changes_1 = change1 > 0 ? (int)Math.Floor(change1) : (int)Math.Ceiling(change1);
int changes_2 = change2 > 0 ? (int)Math.Floor(change2) : (int)Math.Ceiling(change2);
int changes1 = change1 > 0 ? (int)Math.Floor(change1) : (int)Math.Ceiling(change1);
int changes2 = change2 > 0 ? (int)Math.Floor(change2) : (int)Math.Ceiling(change2);
for (int scanLine = 0; scanLine < 262; scanLine++)
{
@ -88,10 +88,10 @@ namespace BizHawk.Emulation.Cores.ColecoVision
for (int i = 0; i < 228; i++)
{
PSG.generate_sound(1);
if (use_SGM) { SGM_sound.generate_sound(1); }
if (use_SGM) { SGM_sound.generate_sound(1); }
_cpu.ExecuteOne();
// pick out sound samples from the sound devies twice per scanline
// pick out sound samples from the sound devices twice per scanline
int v = PSG.Sample();
if (use_SGM)
@ -111,31 +111,31 @@ namespace BizHawk.Emulation.Cores.ColecoVision
// starting from scanline 20, changes to the wheel are added once per scanline (up to 144)
if (scanLine > 20)
{
if (changes_1 != 0)
if (changes1 != 0)
{
if (changes_1 > 0)
if (changes1 > 0)
{
ControllerDeck.temp_wheel1 = (float)((ControllerDeck.temp_wheel1 + 1.25) % 360);
changes_1--;
changes1--;
}
else
{
ControllerDeck.temp_wheel1 = (float)((ControllerDeck.temp_wheel1 - 1.25) % 360);
changes_1++;
changes1++;
}
}
if (changes_2 != 0)
if (changes2 != 0)
{
if (changes_2 > 0)
if (changes2 > 0)
{
ControllerDeck.temp_wheel2 = (float)((ControllerDeck.temp_wheel2 + 1.25) % 360);
changes_2--;
changes2--;
}
else
{
ControllerDeck.temp_wheel2 = (float)((ControllerDeck.temp_wheel2 - 1.25) % 360);
changes_2++;
changes2++;
}
}
}

View File

@ -7,20 +7,20 @@ namespace BizHawk.Emulation.Cores.ColecoVision
{
public int LagCount
{
get { return _lagCount; }
set { _lagCount = value; }
get => _lagCount;
set => _lagCount = value;
}
public bool IsLagFrame
{
get { return _isLag; }
set { _isLag = value; }
get => _isLag;
set => _isLag = value;
}
public IInputCallbackSystem InputCallbacks
{
[FeatureNotImplemented]
get { throw new NotImplementedException(); }
get => throw new NotImplementedException();
}
private int _lagCount = 0;

View File

@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision
{
public partial class ColecoVision
{
private MemoryDomainList memoryDomains;
private MemoryDomainList _memoryDomains;
private readonly Dictionary<string, MemoryDomainByteArray> _byteArrayDomains = new Dictionary<string, MemoryDomainByteArray>();
private bool _memoryDomainsInit = false;
@ -48,8 +48,8 @@ namespace BizHawk.Emulation.Cores.ColecoVision
SyncAllByteArrayDomains();
memoryDomains = new MemoryDomainList(_byteArrayDomains.Values.Concat(domains).ToList());
(ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(memoryDomains);
_memoryDomains = new MemoryDomainList(_byteArrayDomains.Values.Concat(domains).ToList());
((BasicServiceProvider)ServiceProvider).Register<IMemoryDomains>(_memoryDomains);
_memoryDomainsInit = true;
}

View File

@ -54,11 +54,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision
[JsonIgnore]
public string Port1
{
get
{
return _port1;
}
get => _port1;
set
{
if (!ColecoVisionControllerDeck.ValidControllerTypes.ContainsKey(value))
@ -73,11 +69,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision
[JsonIgnore]
public string Port2
{
get
{
return _port2;
}
get => _port2;
set
{
if (!ColecoVisionControllerDeck.ValidControllerTypes.ContainsKey(value))

View File

@ -6,8 +6,8 @@ namespace BizHawk.Emulation.Cores.ColecoVision
{
public partial class ColecoVision : ISoundProvider
{
private SN76489col PSG;
private AY_3_8910_SGM SGM_sound;
private readonly SN76489col PSG;
private readonly AY_3_8910_SGM SGM_sound;
private readonly BlipBuffer _blip = new BlipBuffer(4096);
@ -47,7 +47,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision
for (int i = 0; i < nsamp * 2; i += 2)
{
samples[i + 1] = samples[i];
}
}
}
public void GetSamples(short[] samples)

View File

@ -49,7 +49,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision
}
_cpu.SyncState(ser);
ser.BeginSection("Coleco");
ser.BeginSection("Coleco");
_vdp.SyncState(ser);
ControllerDeck.SyncState(ser);
PSG.SyncState(ser);

View File

@ -7,14 +7,11 @@ namespace BizHawk.Emulation.Cores.Intellivision
{
public string Cpu
{
get { return "CP1610"; }
get => "CP1610";
set { }
}
public string PCRegisterName
{
get { return "PC"; }
}
public string PCRegisterName => "PC";
public IEnumerable<string> AvailableCpus
{

View File

@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
public ControllerDefinition ControllerDefinition => _controllerDeck.Definition;
public bool FrameAdvance(IController controller, bool render, bool rendersound)
public bool FrameAdvance(IController controller, bool render, bool renderSound)
{
if (_tracer.Enabled)
{
@ -31,7 +31,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
_cpu.PendingCycles = 14934 - 3791 + _cpu.GetPendingCycles();
_stic.Sr1 = true;
_islag = true;
_isLag = true;
bool activeDisplay = _stic.active_display;
@ -110,9 +110,9 @@ namespace BizHawk.Emulation.Cores.Intellivision
_stic.in_vb_2 = false;
if (_islag)
if (_isLag)
{
_lagcount++;
_lagCount++;
}
if (controller.IsPressed("Power"))
@ -137,7 +137,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
public void ResetCounters()
{
_frame = 0;
_lagcount = 0;
_lagCount = 0;
}
public CoreComm CoreComm { get; }

View File

@ -6,33 +6,19 @@ namespace BizHawk.Emulation.Cores.Intellivision
{
public int LagCount
{
get
{
return _lagcount;
}
set
{
_lagcount = value;
}
get => _lagCount;
set => _lagCount = value;
}
public bool IsLagFrame
{
get
{
return _islag;
}
set
{
_islag = value;
}
get => _isLag;
set => _isLag = value;
}
public IInputCallbackSystem InputCallbacks { get; } = new InputCallbackSystem();
private bool _islag;
private int _lagcount;
private bool _isLag;
private int _lagCount;
}
}

View File

@ -1,6 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Intellivision
@ -63,7 +61,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
};
MemoryDomains = new MemoryDomainList(domains);
(ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(MemoryDomains);
((BasicServiceProvider) ServiceProvider).Register(MemoryDomains);
}
private byte PeekSystemBus(long addr)

View File

@ -50,7 +50,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
[JsonIgnore]
public string Port1
{
get { return _port1; }
get => _port1;
set
{
if (!IntellivisionControllerDeck.ValidControllerTypes.ContainsKey(value))
@ -65,7 +65,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
[JsonIgnore]
public string Port2
{
get { return _port2; }
get => _port2;
set
{
if (!IntellivisionControllerDeck.ValidControllerTypes.ContainsKey(value))

View File

@ -53,8 +53,8 @@ namespace BizHawk.Emulation.Cores.Intellivision
ser.Sync(nameof(ExecutiveRom), ref ExecutiveRom, false);
ser.Sync(nameof(GraphicsRom), ref GraphicsRom, false);
ser.Sync(nameof(GraphicsRam), ref GraphicsRam, false);
ser.Sync("islag", ref _islag);
ser.Sync("lagcount", ref _lagcount);
ser.Sync("islag", ref _isLag);
ser.Sync("lagcount", ref _lagCount);
_cpu.SyncState(ser);
_stic.SyncState(ser);

View File

@ -42,14 +42,14 @@
if (addr==0x01FE)
{
if (!peek)
_islag = false;
_isLag = false;
return _psg.Register[14];
}
if (addr == 0x01FF)
{
if (!peek)
_islag = false;
_isLag = false;
return _psg.Register[15];
}
break;

View File

@ -35,13 +35,10 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
public IMemoryCallbackSystem MemoryCallbacks
{
[FeatureNotImplemented]
get { throw new NotImplementedException(); }
get => throw new NotImplementedException();
}
[FeatureNotImplemented]
public long TotalExecutedCycles
{
get { throw new NotImplementedException(); }
}
public long TotalExecutedCycles => throw new NotImplementedException();
}
}

View File

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections.Generic;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Components.M6502;
@ -11,19 +8,13 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
{
public string Cpu
{
get
{
return "6502";
}
get => "6502";
set
{
}
}
public string PCRegisterName
{
get { return "PC"; }
}
public string PCRegisterName => "PC";
public IEnumerable<string> AvailableCpus
{

View File

@ -11,7 +11,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
public IInputCallbackSystem InputCallbacks
{
[FeatureNotImplemented]
get { throw new NotImplementedException(); }
get => throw new NotImplementedException();
}
}
}

View File

@ -52,7 +52,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
}, 1));
_memoryDomains = new MemoryDomainList(mm);
(ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(_memoryDomains);
((BasicServiceProvider) ServiceProvider).Register(_memoryDomains);
}
private IMemoryDomains _memoryDomains;

View File

@ -1,56 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Nintendo.NES;
using System.Runtime.InteropServices;
namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
{
public partial class QuickNES : INESPPUViewable
{
// todo: don't just call the callbacks at the end of frame; use the scanline info
private Action CB1;
private Action CB2;
private Action _callBack1;
private Action _callBack2;
public int[] GetPalette()
{
return VideoPalette;
}
public int[] GetPalette() => _videoPalette;
private byte R2000 { get { return QN.qn_get_reg2000(Context); } }
private byte R2000 => QN.qn_get_reg2000(Context);
public bool BGBaseHigh
{
get { return (R2000 & 0x10) != 0; }
}
public bool BGBaseHigh => (R2000 & 0x10) != 0;
public bool SPBaseHigh
{
get { return (R2000 & 0x08) != 0; }
}
public bool SPBaseHigh => (R2000 & 0x08) != 0;
public bool SPTall
{
get { return (R2000 & 0x20) != 0; }
}
public bool SPTall => (R2000 & 0x20) != 0;
private byte[] ppubusbuf = new byte[0x3000];
private readonly byte[] ppubusbuf = new byte[0x3000];
public byte[] GetPPUBus()
{
QN.qn_peek_ppubus(Context, ppubusbuf);
return ppubusbuf;
}
private byte[] palrambuf = new byte[0x20];
private readonly byte[] palrambuf = new byte[0x20];
public byte[] GetPalRam()
{
Marshal.Copy(QN.qn_get_palmem(Context), palrambuf, 0, 0x20);
return palrambuf;
}
byte[] oambuf = new byte[0x100];
private readonly byte[] oambuf = new byte[0x100];
public byte[] GetOam()
{
Marshal.Copy(QN.qn_get_oammem(Context), oambuf, 0, 0x100);
@ -68,10 +53,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
throw new InvalidOperationException();
}
public bool ExActive
{
get { return false; }
}
public bool ExActive => false;
public byte[] GetExRam()
{
@ -85,22 +67,22 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
public void InstallCallback1(Action cb, int sl)
{
CB1 = cb;
_callBack1 = cb;
}
public void InstallCallback2(Action cb, int sl)
{
CB2 = cb;
_callBack2 = cb;
}
public void RemoveCallback1()
{
CB1 = null;
_callBack1 = null;
}
public void RemoveCallback2()
{
CB2 = null;
_callBack2 = null;
}
}
}

View File

@ -6,8 +6,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
{
public byte[] CloneSaveRam()
{
LibQuickNES.ThrowStringError(QN.qn_battery_ram_save(Context, SaveRamBuff, SaveRamBuff.Length));
return (byte[])SaveRamBuff.Clone();
LibQuickNES.ThrowStringError(QN.qn_battery_ram_save(Context, _saveRamBuff, _saveRamBuff.Length));
return (byte[])_saveRamBuff.Clone();
}
public void StoreSaveRam(byte[] data)
@ -15,21 +15,15 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
LibQuickNES.ThrowStringError(QN.qn_battery_ram_load(Context, data, data.Length));
}
public bool SaveRamModified
{
get
{
return QN.qn_has_battery_ram(Context);
}
}
public bool SaveRamModified => QN.qn_has_battery_ram(Context);
private byte[] SaveRamBuff;
private byte[] _saveRamBuff;
private void InitSaveRamBuff()
{
int size = 0;
LibQuickNES.ThrowStringError(QN.qn_battery_ram_size(Context, ref size));
SaveRamBuff = new byte[size];
_saveRamBuff = new byte[size];
}
}
}

View File

@ -46,7 +46,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
/// <summary>
/// the syncsettings that this run of emulation is using (was passed to ctor)
/// </summary>
private QuickNESSyncSettings _syncSettings;
private readonly QuickNESSyncSettings _syncSettings;
/// <summary>
/// the syncsettings that were requested but won't be used yet
@ -60,8 +60,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
[DisplayName("Visible Sprites")]
public int NumSprites
{
get { return _NumSprites; }
set { _NumSprites = Math.Min(64, Math.Max(0, value)); }
get => _NumSprites;
set => _NumSprites = Math.Min(64, Math.Max(0, value));
}
[JsonIgnore]
@ -80,15 +80,22 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
[Browsable(false)]
public byte[] Palette
{
get { return _Palette; }
get => _Palette;
set
{
if (value == null)
{
throw new ArgumentNullException();
else if (value.Length == 64 * 8 * 3)
}
if (value.Length == 64 * 8 * 3)
{
_Palette = value;
}
else
{
throw new ArgumentOutOfRangeException();
}
}
}
@ -120,7 +127,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
if (nColors == 512)
{
//just copy the palette directly
// just copy the palette directly
for (int c = 0; c < nColors; c++)
{
_Palette[c * 3 + 0] = pal[c, 0];
@ -130,7 +137,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
}
else
{
//use quickNES's deemph calculator
// use quickNES's deemph calculator
for (int c = 0; c < 64; c++)
{
int a = c & 63;
@ -183,7 +190,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
public static bool NeedsReboot(QuickNESSyncSettings x, QuickNESSyncSettings y)
{
// the core can handle dynamic plugging and unplugging, but that changes
// the controllerdefinition, and we're not ready for that
// the ControllerDefinition, and we're not ready for that
return !DeepEquality.DeepEquals(x, y);
}
}

View File

@ -5,19 +5,16 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
{
public partial class QuickNES : ISoundProvider
{
private short[] MonoBuff = new short[1024];
private short[] StereoBuff = new short[2048];
private int NumSamples = 0;
private readonly short[] _monoBuff = new short[1024];
private readonly short[] _stereoBuff = new short[2048];
private int _numSamples;
public bool CanProvideAsync
{
get { return false; }
}
public bool CanProvideAsync => false;
public void GetSamplesSync(out short[] samples, out int nsamp)
{
samples = StereoBuff;
nsamp = NumSamples;
samples = _stereoBuff;
nsamp = _numSamples;
}
public void DiscardSamples()
@ -33,10 +30,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
}
}
public SyncSoundMode SyncMode
{
get { return SyncSoundMode.Sync; }
}
public SyncSoundMode SyncMode => SyncSoundMode.Sync;
public void GetSamplesAsync(short[] samples)
{
@ -50,14 +44,14 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
private void DrainAudio()
{
NumSamples = QN.qn_read_audio(Context, MonoBuff, MonoBuff.Length);
_numSamples = QN.qn_read_audio(Context, _monoBuff, _monoBuff.Length);
unsafe
{
fixed (short* _src = &MonoBuff[0], _dst = &StereoBuff[0])
fixed (short* _src = &_monoBuff[0], _dst = &_stereoBuff[0])
{
short* src = _src;
short* dst = _dst;
for (int i = 0; i < NumSamples; i++)
for (int i = 0; i < _numSamples; i++)
{
*dst++ = *src;
*dst++ = *src++;

View File

@ -1,6 +1,5 @@
using System;
using System.IO;
using BizHawk.Common.BufferExtensions;
using BizHawk.Emulation.Common;
@ -8,44 +7,48 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
{
public partial class QuickNES : IStatable
{
public bool BinarySaveStatesPreferred { get { return true; } }
public bool BinarySaveStatesPreferred => true;
public void SaveStateText(System.IO.TextWriter writer)
public void SaveStateText(TextWriter writer)
{
CheckDisposed();
var temp = SaveStateBinary();
temp.SaveAsHexFast(writer);
}
public void LoadStateText(System.IO.TextReader reader)
public void LoadStateText(TextReader reader)
{
CheckDisposed();
string hex = reader.ReadLine();
byte[] state = new byte[hex.Length / 2];
state.ReadFromHexFast(hex);
LoadStateBinary(new System.IO.BinaryReader(new System.IO.MemoryStream(state)));
LoadStateBinary(new BinaryReader(new MemoryStream(state)));
}
public void SaveStateBinary(System.IO.BinaryWriter writer)
public void SaveStateBinary(BinaryWriter writer)
{
CheckDisposed();
LibQuickNES.ThrowStringError(QN.qn_state_save(Context, SaveStateBuff, SaveStateBuff.Length));
writer.Write(SaveStateBuff.Length);
writer.Write(SaveStateBuff);
LibQuickNES.ThrowStringError(QN.qn_state_save(Context, _saveStateBuff, _saveStateBuff.Length));
writer.Write(_saveStateBuff.Length);
writer.Write(_saveStateBuff);
// other variables
writer.Write(IsLagFrame);
writer.Write(LagCount);
writer.Write(Frame);
}
public void LoadStateBinary(System.IO.BinaryReader reader)
public void LoadStateBinary(BinaryReader reader)
{
CheckDisposed();
int len = reader.ReadInt32();
if (len != SaveStateBuff.Length)
if (len != _saveStateBuff.Length)
{
throw new InvalidOperationException("Unexpected savestate buffer length!");
reader.Read(SaveStateBuff, 0, SaveStateBuff.Length);
LibQuickNES.ThrowStringError(QN.qn_state_load(Context, SaveStateBuff, SaveStateBuff.Length));
}
reader.Read(_saveStateBuff, 0, _saveStateBuff.Length);
LibQuickNES.ThrowStringError(QN.qn_state_load(Context, _saveStateBuff, _saveStateBuff.Length));
// other variables
IsLagFrame = reader.ReadBoolean();
LagCount = reader.ReadInt32();
@ -55,25 +58,28 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
public byte[] SaveStateBinary()
{
CheckDisposed();
var ms = new System.IO.MemoryStream(SaveStateBuff2, true);
var bw = new System.IO.BinaryWriter(ms);
var ms = new MemoryStream(_saveStateBuff2, true);
var bw = new BinaryWriter(ms);
SaveStateBinary(bw);
bw.Flush();
if (ms.Position != SaveStateBuff2.Length)
if (ms.Position != _saveStateBuff2.Length)
{
throw new InvalidOperationException("Unexpected savestate length!");
}
bw.Close();
return SaveStateBuff2;
return _saveStateBuff2;
}
private byte[] SaveStateBuff;
private byte[] SaveStateBuff2;
private byte[] _saveStateBuff;
private byte[] _saveStateBuff2;
private void InitSaveStateBuff()
{
int size = 0;
LibQuickNES.ThrowStringError(QN.qn_state_size(Context, ref size));
SaveStateBuff = new byte[size];
SaveStateBuff2 = new byte[size + 13];
_saveStateBuff = new byte[size];
_saveStateBuff2 = new byte[size + 13];
}
}
}

View File

@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
{
public TraceBuffer Tracer { get; private set; }
private LibQuickNES.TraceCallback _tracecb;
private LibQuickNES.TraceCallback _traceCb;
private const string TraceHeader = "6502: PC, mnemonic, operands, registers (A, X, Y, P, SP)";
@ -26,10 +26,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
ushort pc = (ushort)s[4];
byte p = (byte)s[5];
byte opcode = (byte)s[6];
int notused = 0;
string opcodeStr = MOS6502X.Disassemble(pc, out notused, (address) => _memoryDomains.SystemBus.PeekByte(address));
string opcodeStr = MOS6502X.Disassemble(pc, out _, address => _memoryDomains.SystemBus.PeekByte(address));
Tracer.Put(new TraceInfo
{
@ -46,8 +43,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
private void ConnectTracer()
{
Tracer = new TraceBuffer { Header = TraceHeader };
(ServiceProvider as BasicServiceProvider).Register<ITraceable>(Tracer);
_tracecb = new LibQuickNES.TraceCallback(MakeTrace);
((BasicServiceProvider) ServiceProvider).Register<ITraceable>(Tracer);
_traceCb = MakeTrace;
}
}
}

View File

@ -6,47 +6,35 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
{
public int BufferWidth { get; private set; }
public int BufferHeight { get; private set; }
public int BackgroundColor { get { return unchecked((int)0xff000000); } }
public int BackgroundColor => unchecked((int)0xff000000);
public int VsyncNumerator => 39375000;
public int VsyncDenominator => 655171;
public int[] GetVideoBuffer()
{
return VideoOutput;
}
public int[] GetVideoBuffer() =>_videoOutput;
public int VirtualWidth
{
get { return (int)(BufferWidth * 1.146); }
}
public int VirtualWidth => (int)(BufferWidth * 1.146);
public int VirtualHeight
{
get { return BufferHeight; }
}
public int VirtualHeight => BufferHeight;
private int[] VideoOutput = new int[256 * 240];
private int[] VideoPalette = new int[512];
private readonly int[] _videoOutput = new int[256 * 240];
private readonly int[] _videoPalette = new int[512];
private int cropleft = 0;
private int cropright = 0;
private int croptop = 0;
private int cropbottom = 0;
private int _cropLeft, _cropRight, _cropTop, _cropBottom;
private void RecalculateCrops()
{
cropright = cropleft = _settings.ClipLeftAndRight ? 8 : 0;
cropbottom = croptop = _settings.ClipTopAndBottom ? 8 : 0;
BufferWidth = 256 - cropleft - cropright;
BufferHeight = 240 - croptop - cropbottom;
_cropRight = _cropLeft = _settings.ClipLeftAndRight ? 8 : 0;
_cropBottom = _cropTop = _settings.ClipTopAndBottom ? 8 : 0;
BufferWidth = 256 - _cropLeft - _cropRight;
BufferHeight = 240 - _cropTop - _cropBottom;
}
private void CalculatePalette()
{
for (int i = 0; i < 512; i++)
{
VideoPalette[i] =
_videoPalette[i] =
_settings.Palette[i * 3] << 16 |
_settings.Palette[i * 3 + 1] << 8 |
_settings.Palette[i * 3 + 2] |
@ -56,7 +44,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
private void Blit()
{
QN.qn_blit(Context, VideoOutput, VideoPalette, cropleft, croptop, cropright, cropbottom);
QN.qn_blit(Context, _videoOutput, _videoPalette, _cropLeft, _cropTop, _cropRight, _cropBottom);
}
}
}

View File

@ -206,7 +206,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
SetPads(controller, out j1, out j2);
if (Tracer.Enabled)
QN.qn_set_tracecb(Context, _tracecb);
QN.qn_set_tracecb(Context, _traceCb);
else
QN.qn_set_tracecb(Context, null);
@ -221,8 +221,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
if (rendersound)
DrainAudio();
if (CB1 != null) CB1();
if (CB2 != null) CB2();
if (_callBack1 != null) _callBack1();
if (_callBack2 != null) _callBack2();
return true;
}

View File

@ -9,8 +9,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
{
public IDictionary<string, RegisterValue> GetCpuFlagsAndRegisters()
{
LibsnesApi.CPURegs regs;
Api.QUERY_peek_cpu_regs(out regs);
Api.QUERY_peek_cpu_regs(out var regs);
bool fn = (regs.p & 0x80) != 0;
bool fv = (regs.p & 0x40) != 0;
@ -71,9 +70,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
}
[FeatureNotImplemented]
public long TotalExecutedCycles
{
get { throw new NotImplementedException(); }
}
public long TotalExecutedCycles => throw new NotImplementedException();
}
}

View File

@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
public ControllerDefinition ControllerDefinition => _controllerDeck.Definition;
public bool FrameAdvance(IController controller, bool render, bool rendersound)
public bool FrameAdvance(IController controller, bool render, bool renderSound)
{
_controller = controller;
@ -37,7 +37,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
}
// speedup when sound rendering is not needed
Api.QUERY_set_audio_sample(rendersound ? _soundcb : null);
Api.QUERY_set_audio_sample(renderSound ? _soundcb : null);
bool resetSignal = controller.IsPressed("Reset");
if (resetSignal)
@ -75,7 +75,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
_timeFrameCounter++;
Api.CMD_run();
// once upon a time we forwarded messages frmo bsnes here, by checking for queued text messages, but I don't think it's needed any longer
// once upon a time we forwarded messages from bsnes here, by checking for queued text messages, but I don't think it's needed any longer
if (IsLagFrame)
{
LagCount++;
@ -86,8 +86,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
public int Frame
{
get { return _timeFrameCounter; }
private set { _timeFrameCounter = value; }
get => _timeFrameCounter;
private set => _timeFrameCounter = value;
}
public string SystemId { get; }

View File

@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
{
private readonly List<MemoryDomain> _memoryDomainList = new List<MemoryDomain>();
private IMemoryDomains _memoryDomains;
private LibsnesApi.SNES_MAPPER? _mapper = null;
private LibsnesApi.SNES_MAPPER? _mapper;
// works for WRAM, garbage for anything else
private static int? FakeBusMap(int addr)
@ -76,22 +76,22 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
_memoryDomains = new MemoryDomainList(_memoryDomainList);
(ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(_memoryDomains);
((BasicServiceProvider) ServiceProvider).Register(_memoryDomains);
}
private unsafe void MakeMemoryDomain(string name, LibsnesApi.SNES_MEMORY id, MemoryDomain.Endian endian, int byteSize = 1)
{
int size = Api.QUERY_get_memory_size(id);
// if this type of memory isnt available, dont make the memory domain (most commonly save ram)
// if this type of memory isn't available, don't make the memory domain (most commonly save ram)
if (size == 0)
{
return;
}
byte* blockptr = Api.QUERY_get_memory_data(id);
byte* blockPtr = Api.QUERY_get_memory_data(id);
var md = new MemoryDomainIntPtrMonitor(name, MemoryDomain.Endian.Little, (IntPtr)blockptr, size,
var md = new MemoryDomainIntPtrMonitor(name, MemoryDomain.Endian.Little, (IntPtr)blockPtr, size,
id != LibsnesApi.SNES_MEMORY.CARTRIDGE_ROM, // hack: for just this one memory area, it will be readonly
byteSize, Api);
@ -106,7 +106,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
throw new InvalidOperationException();
}
byte* blockptr = Api.QUERY_get_memory_data(LibsnesApi.SNES_MEMORY.WRAM);
byte* blockPtr = Api.QUERY_get_memory_data(LibsnesApi.SNES_MEMORY.WRAM);
var md = new MemoryDomainDelegate("System Bus", 0x1000000, MemoryDomain.Endian.Little,
addr =>
@ -116,7 +116,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
var a = FakeBusMap((int)addr);
if (a.HasValue)
{
return blockptr[a.Value];
return blockPtr[a.Value];
}
return FakeBusRead((int)addr);
@ -128,7 +128,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
{
var a = FakeBusMap((int)addr);
if (a.HasValue)
blockptr[a.Value] = val;
blockPtr[a.Value] = val;
}
}, wordSize: 2);
_memoryDomainList.Add(md);

View File

@ -4,17 +4,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
{
public partial class LibsnesCore : IRegionable
{
public DisplayType Region
{
get
{
if (Api.Region == LibsnesApi.SNES_REGION.NTSC)
{
return DisplayType.NTSC;
}
return DisplayType.PAL;
}
}
public DisplayType Region => Api.Region == LibsnesApi.SNES_REGION.NTSC
? DisplayType.NTSC
: DisplayType.PAL;
}
}

View File

@ -16,9 +16,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
public bool PutSettings(SnesSettings o)
{
bool refreshneeded = o.Palette != _settings.Palette;
bool refreshNeeded = o.Palette != _settings.Palette;
_settings = o;
if (refreshneeded)
if (refreshNeeded)
{
RefreshPalette();
}

View File

@ -1,6 +1,4 @@
using System;
using System.IO;
using System.IO;
using BizHawk.Common.BufferExtensions;
using BizHawk.Emulation.Common;

View File

@ -14,10 +14,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
public int BackgroundColor => 0;
public int[] GetVideoBuffer()
{
return _videoBuffer;
}
public int[] GetVideoBuffer() => _videoBuffer;
public int VsyncNumerator { get; }
public int VsyncDenominator { get; }

View File

@ -1,10 +1,7 @@
using System;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Waterbox;
using BizHawk.Common.BizInvoke;
using System.Runtime.InteropServices;
using System.IO;
using BizHawk.Common.BufferExtensions;
using System.ComponentModel;
using BizHawk.Common;
using System.Collections.Generic;

View File

@ -64,9 +64,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk
[FeatureNotImplemented]
public void Step(StepType type) { throw new NotImplementedException(); }
public long TotalExecutedCycles
{
get { return subnes.cpu.TotalExecutedCycles; }
}
public long TotalExecutedCycles => subnes.cpu.TotalExecutedCycles;
}
}

View File

@ -1,7 +1,5 @@
using System;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Nintendo.NES;
namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk
{
@ -11,7 +9,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk
public ControllerDefinition ControllerDefinition => subnes.ControllerDefinition;
public bool FrameAdvance(IController controller, bool render, bool rendersound)
public bool FrameAdvance(IController controller, bool render, bool renderSound)
{
//Console.WriteLine("-----------------------FRAME-----------------------");
if (_tracer.Enabled)
@ -39,7 +37,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk
reset_cycle = controller.GetFloat("Reset Cycle");
reset_cycle_int = (int)Math.Floor(reset_cycle);
_islag = true;
_isLag = true;
subnes.alt_lag = true;
InputCallbacks.Call();
@ -55,11 +53,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk
subnes.cpu.ext_ppu_cycle = current_cycle;
}
_islag = subnes.alt_lag;
_isLag = subnes.alt_lag;
if (_islag)
if (_isLag)
{
_lagcount++;
_lagCount++;
VBL_CNT++;
}
@ -102,8 +100,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk
public void ResetCounters()
{
_frame = 0;
_lagcount = 0;
_islag = false;
_lagCount = 0;
_isLag = false;
}
public CoreComm CoreComm { get; }

View File

@ -6,19 +6,19 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk
{
public int LagCount
{
get { return _lagcount; }
set { _lagcount = value; }
get => _lagCount;
set => _lagCount = value;
}
public bool IsLagFrame
{
get { return _islag; }
set { _islag = value; }
get => _isLag;
set => _isLag = value;
}
public IInputCallbackSystem InputCallbacks { get; } = new InputCallbackSystem();
public bool _islag = true;
private int _lagcount;
public bool _isLag = true;
private int _lagCount;
}
}

View File

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections.Generic;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk

View File

@ -18,24 +18,27 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk
public byte[] CloneSaveRam()
{
if (subnes.Board is NES.FDS)
return (subnes.Board as NES.FDS).ReadSaveRam();
if (subnes.Board is NES.FDS fds)
{
return fds.ReadSaveRam();
}
if (subnes.Board == null || subnes.Board.SaveRam == null)
return null;
return (byte[])subnes.Board.SaveRam.Clone();
return (byte[]) subnes.Board?.SaveRam?.Clone();
}
public void StoreSaveRam(byte[] data)
{
if (subnes.Board is NES.FDS)
if (subnes.Board is NES.FDS fds)
{
(subnes.Board as NES.FDS).StoreSaveRam(data);
fds.StoreSaveRam(data);
return;
}
if (subnes.Board == null || subnes.Board.SaveRam == null)
if (subnes.Board?.SaveRam == null)
{
return;
}
Array.Copy(data, subnes.Board.SaveRam, data.Length);
}
}

View File

@ -2,7 +2,6 @@
using BizHawk.Common;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Nintendo.NES;
namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk
{
@ -38,8 +37,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk
public byte[] SaveStateBinary()
{
MemoryStream ms = new MemoryStream();
BinaryWriter bw = new BinaryWriter(ms);
using var ms = new MemoryStream();
using var bw = new BinaryWriter(ms);
SaveStateBinary(bw);
bw.Flush();
return ms.ToArray();
@ -49,9 +48,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk
private void SyncState(Serializer ser)
{
ser.Sync("Lag", ref _lagcount);
ser.Sync("Lag", ref _lagCount);
ser.Sync("Frame", ref _frame);
ser.Sync("IsLag", ref _islag);
ser.Sync("IsLag", ref _isLag);
ser.Sync(nameof(pass_a_frame), ref pass_a_frame);
ser.Sync(nameof(reset_frame), ref reset_frame);
ser.Sync(nameof(pass_new_input), ref pass_new_input);

View File

@ -102,8 +102,8 @@ namespace BizHawk.Emulation.Cores.PCEngine
CDLMappingApplyRange(mm, "Battery RAM", 0xf7, BRAM.Length);
}
var rammirrors = new HuC6280.MemMapping { Name = "Main Memory", Offs = 0 };
mm[0xf9] = mm[0xfa] = mm[0xfb] = rammirrors;
var ramMirrors = new HuC6280.MemMapping { Name = "Main Memory", Offs = 0 };
mm[0xf9] = mm[0xfa] = mm[0xfb] = ramMirrors;
CDLMappingApplyRange(mm, "Main Memory", 0xf8, Ram.Length);

View File

@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
public ControllerDefinition ControllerDefinition => _controllerDeck.Definition;
public bool FrameAdvance(IController controller, bool render, bool rendersound)
public bool FrameAdvance(IController controller, bool render, bool renderSound)
{
_controller = controller;
_lagged = true;
@ -45,8 +45,8 @@ namespace BizHawk.Emulation.Cores.PCEngine
public int Frame
{
get { return _frame; }
set { _frame = value; }
get => _frame;
set => _frame = value;
}
public string SystemId { get; }

View File

@ -6,20 +6,17 @@ namespace BizHawk.Emulation.Cores.PCEngine
{
public int LagCount
{
get { return _lagCount; }
set { _lagCount = value; }
get => _lagCount;
set => _lagCount = value;
}
public bool IsLagFrame
{
get { return _isLag; }
set { _isLag = value; }
get => _isLag;
set => _isLag = value;
}
public IInputCallbackSystem InputCallbacks
{
get { return _inputCallbacks; }
}
public IInputCallbackSystem InputCallbacks => _inputCallbacks;
private readonly InputCallbackSystem _inputCallbacks = new InputCallbackSystem();
private int _lagCount;

View File

@ -8,15 +8,15 @@ namespace BizHawk.Emulation.Cores.PCEngine
{
public sealed partial class PCEngine
{
private Dictionary<string, MemoryDomainByteArray> _byteArrayDomains = new Dictionary<string, MemoryDomainByteArray>();
private bool _memoryDomainsInit = false;
private readonly Dictionary<string, MemoryDomainByteArray> _byteArrayDomains = new Dictionary<string, MemoryDomainByteArray>();
private bool _memoryDomainsInit;
private MemoryDomainList _memoryDomains;
private void SetupMemoryDomains()
{
var domains = new List<MemoryDomain>(2);
var SystemBusDomain = new MemoryDomainDelegate("System Bus (21 bit)", 0x200000, MemoryDomain.Endian.Little,
var systemBusDomain = new MemoryDomainDelegate("System Bus (21 bit)", 0x200000, MemoryDomain.Endian.Little,
(addr) =>
{
if (addr < 0 || addr >= 0x200000)
@ -30,9 +30,9 @@ namespace BizHawk.Emulation.Cores.PCEngine
Cpu.WriteMemory21((int)addr, value);
},
wordSize: 2);
domains.Add(SystemBusDomain);
domains.Add(systemBusDomain);
var CpuBusDomain = new MemoryDomainDelegate("System Bus", 0x10000, MemoryDomain.Endian.Little,
var cpuBusDomain = new MemoryDomainDelegate("System Bus", 0x10000, MemoryDomain.Endian.Little,
(addr) =>
{
if (addr < 0 || addr >= 0x10000)
@ -46,14 +46,16 @@ namespace BizHawk.Emulation.Cores.PCEngine
Cpu.WriteMemory((ushort)addr, value);
},
wordSize: 2);
domains.Add(CpuBusDomain);
domains.Add(cpuBusDomain);
SyncAllByteArrayDomains();
_memoryDomains = new MemoryDomainList(domains.Concat(_byteArrayDomains.Values).ToList());
_memoryDomains.SystemBus = CpuBusDomain;
_memoryDomains.MainMemory = _byteArrayDomains["Main Memory"];
(ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(_memoryDomains);
_memoryDomains = new MemoryDomainList(domains.Concat(_byteArrayDomains.Values).ToList())
{
SystemBus = cpuBusDomain, MainMemory = _byteArrayDomains["Main Memory"]
};
((BasicServiceProvider) ServiceProvider).Register<IMemoryDomains>(_memoryDomains);
_memoryDomainsInit = true;
}

View File

@ -9,14 +9,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
public byte[] CloneSaveRam()
{
if (BRAM != null)
{
return (byte[])BRAM.Clone();
}
else
{
return null;
}
return (byte[]) BRAM?.Clone();
}
public void StoreSaveRam(byte[] data)

View File

@ -1,18 +1,11 @@
using BizHawk.Common;
using BizHawk.Common.BizInvoke;
using BizHawk.Common.BufferExtensions;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Waterbox;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace BizHawk.Emulation.Cores.Consoles.SNK
{

View File

@ -27,17 +27,17 @@ namespace BizHawk.Emulation.Cores.Sega.GGHawkLink
public void NewCDL(ICodeDataLog cdl)
{
cdl["ROM"] = new byte[MemoryDomains["ROM"].Size];
cdl["Main RAM"] = new byte[MemoryDomains["Main RAM"].Size];
cdl["ROM"] = new byte[_memoryDomains["ROM"].Size];
cdl["Main RAM"] = new byte[_memoryDomains["Main RAM"].Size];
if (MemoryDomains.Has("Save RAM"))
if (_memoryDomains.Has("Save RAM"))
{
cdl["Save RAM"] = new byte[MemoryDomains["Save RAM"].Size];
cdl["Save RAM"] = new byte[_memoryDomains["Save RAM"].Size];
}
if (MemoryDomains.Has("Cart (Volatile) RAM"))
if (_memoryDomains.Has("Cart (Volatile) RAM"))
{
cdl["Cart (Volatile) RAM"] = new byte[MemoryDomains["Cart (Volatile) RAM"].Size];
cdl["Cart (Volatile) RAM"] = new byte[_memoryDomains["Cart (Volatile) RAM"].Size];
}
cdl.SubType = "SMS";

View File

@ -144,9 +144,6 @@ namespace BizHawk.Emulation.Cores.Sega.GGHawkLink
throw new NotImplementedException();
}
public long TotalExecutedCycles
{
get { return (long)L.Cpu.TotalExecutedCycles; }
}
public long TotalExecutedCycles => L.Cpu.TotalExecutedCycles;
}
}

View File

@ -12,7 +12,7 @@ namespace BizHawk.Emulation.Cores.Sega.GGHawkLink
public int L_NMI_CD, R_NMI_CD;
public bool FrameAdvance(IController controller, bool render, bool rendersound)
public bool FrameAdvance(IController controller, bool render, bool renderSound)
{
//Console.WriteLine("-----------------------FRAME-----------------------");
if (_tracer.Enabled)
@ -31,32 +31,32 @@ namespace BizHawk.Emulation.Cores.Sega.GGHawkLink
HardReset();
}
bool cablediscosignalNew = controller.IsPressed("Toggle Cable");
if (cablediscosignalNew && !_cablediscosignal)
bool cableDiscoSignalNew = controller.IsPressed("Toggle Cable");
if (cableDiscoSignalNew && !_cablediscosignal)
{
_cableconnected ^= true;
Console.WriteLine("Cable connect status to {0}", _cableconnected);
}
_cablediscosignal = cablediscosignalNew;
_cablediscosignal = cableDiscoSignalNew;
_islag = true;
_isLag = true;
GetControllerState(controller);
do_frame(controller, render, rendersound);
DoFrame(controller, render, renderSound);
_islag = L._isLag;
_isLag = L._isLag;
if (_islag)
if (_isLag)
{
_lagcount++;
_lagCount++;
}
return true;
}
public void do_frame(IController controller, bool render, bool rendersound)
private void DoFrame(IController controller, bool render, bool renderSound)
{
L.start_pressed = controller.IsPressed("P1 Start");
R.start_pressed = controller.IsPressed("P2 Start");
@ -280,8 +280,8 @@ namespace BizHawk.Emulation.Cores.Sega.GGHawkLink
public void ResetCounters()
{
_frame = 0;
_lagcount = 0;
_islag = false;
_lagCount = 0;
_isLag = false;
}
public CoreComm CoreComm { get; }

View File

@ -6,19 +6,19 @@ namespace BizHawk.Emulation.Cores.Sega.GGHawkLink
{
public int LagCount
{
get { return _lagcount; }
set { _lagcount = value; }
get => _lagCount;
set => _lagCount = value;
}
public bool IsLagFrame
{
get { return _islag; }
set { _islag = value; }
get => _isLag;
set => _isLag = value;
}
public IInputCallbackSystem InputCallbacks { get; } = new InputCallbackSystem();
public bool _islag = true;
private int _lagcount;
public bool _isLag = true;
private int _lagCount;
}
}

View File

@ -7,7 +7,7 @@ namespace BizHawk.Emulation.Cores.Sega.GGHawkLink
{
public partial class GGHawkLink
{
private IMemoryDomains MemoryDomains;
private IMemoryDomains _memoryDomains;
public void SetupMemoryDomains()
{
@ -73,18 +73,18 @@ namespace BizHawk.Emulation.Cores.Sega.GGHawkLink
if (L.SaveRAM != null)
{
var CartRamL = new MemoryDomainByteArray("Cart RAM L", MemoryDomain.Endian.Little, L.SaveRAM, true, 1);
domains.Add(CartRamL);
var cartRamL = new MemoryDomainByteArray("Cart RAM L", MemoryDomain.Endian.Little, L.SaveRAM, true, 1);
domains.Add(cartRamL);
}
if (R.SaveRAM != null)
{
var CartRamR = new MemoryDomainByteArray("Cart RAM R", MemoryDomain.Endian.Little, R.SaveRAM, true, 1);
domains.Add(CartRamR);
var cartRamR = new MemoryDomainByteArray("Cart RAM R", MemoryDomain.Endian.Little, R.SaveRAM, true, 1);
domains.Add(cartRamR);
}
MemoryDomains = new MemoryDomainList(domains);
(ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(MemoryDomains);
_memoryDomains = new MemoryDomainList(domains);
((BasicServiceProvider) ServiceProvider).Register(_memoryDomains);
}
private byte PeekSystemBusL(long addr)

View File

@ -9,21 +9,21 @@ namespace BizHawk.Emulation.Cores.Sega.GGHawkLink
{
if ((L.SaveRAM != null) || (R.SaveRAM != null))
{
int Len1 = 0;
int Len2 = 0;
int len1 = 0;
int len2 = 0;
int index = 0;
if (L.SaveRAM != null)
{
Len1 = L.SaveRAM.Length;
len1 = L.SaveRAM.Length;
}
if (R.SaveRAM != null)
{
Len2 = R.SaveRAM.Length;
len2 = R.SaveRAM.Length;
}
byte[] temp = new byte[Len1 + Len2];
byte[] temp = new byte[len1 + len2];
if (L.SaveRAM != null)
{
@ -45,23 +45,21 @@ namespace BizHawk.Emulation.Cores.Sega.GGHawkLink
return temp;
}
else
{
return null;
}
return null;
}
public void StoreSaveRam(byte[] data)
{
if ((L.SaveRAM != null) && (R.SaveRAM == null))
if (L.SaveRAM != null && R.SaveRAM == null)
{
Buffer.BlockCopy(data, 0, L.SaveRAM, 0, L.SaveRAM.Length);
}
else if ((R.SaveRAM != null) && (L.SaveRAM == null))
else if (R.SaveRAM != null && L.SaveRAM == null)
{
Buffer.BlockCopy(data, 0, R.SaveRAM, 0, R.SaveRAM.Length);
}
else if ((R.SaveRAM != null) && (L.SaveRAM != null))
else if (R.SaveRAM != null && L.SaveRAM != null)
{
Buffer.BlockCopy(data, 0, L.SaveRAM, 0, L.SaveRAM.Length);
Buffer.BlockCopy(data, L.SaveRAM.Length, R.SaveRAM, 0, R.SaveRAM.Length);
@ -70,12 +68,6 @@ namespace BizHawk.Emulation.Cores.Sega.GGHawkLink
Console.WriteLine("loading SRAM here");
}
public bool SaveRamModified
{
get
{
return linkSyncSettings.Use_SRAM;
}
}
public bool SaveRamModified => linkSyncSettings.Use_SRAM;
}
}

View File

@ -53,9 +53,9 @@ namespace BizHawk.Emulation.Cores.Sega.GGHawkLink
private void SyncState(Serializer ser)
{
ser.Sync("Lag", ref _lagcount);
ser.Sync("Lag", ref _lagCount);
ser.Sync("Frame", ref _frame);
ser.Sync("IsLag", ref _islag);
ser.Sync("IsLag", ref _isLag);
ser.Sync(nameof(_cableconnected), ref _cableconnected);
ser.Sync(nameof(_cablediscosignal), ref _cablediscosignal);
ser.Sync(nameof(do_r_next), ref do_r_next);

View File

@ -1,7 +1,4 @@
using System;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Sega.MasterSystem;
namespace BizHawk.Emulation.Cores.Sega.GGHawkLink
@ -81,8 +78,8 @@ namespace BizHawk.Emulation.Cores.Sega.GGHawkLink
public bool LinkConnected
{
get { return _cableconnected; }
set { _cableconnected = value; }
get => _cableconnected;
set => _cableconnected = value;
}
private void ExecFetch(ushort addr)

View File

@ -1,11 +1,7 @@
using BizHawk.Common.BizInvoke;
using BizHawk.Emulation.Cores.Waterbox;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace BizHawk.Emulation.Cores.Consoles.Sega.PicoDrive
{

View File

@ -13,7 +13,6 @@ using System.Linq;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace BizHawk.Emulation.Cores.Consoles.Sega.Saturn
{
@ -51,12 +50,10 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.Saturn
if (Encoding.ASCII.GetString(buff, 0, 16) != "SEGA SEGASATURN ")
return false;
using (var sha256 = SHA256.Create())
{
sha256.ComputeHash(buff, 0x100, 0xd00);
if (sha256.Hash.BytesToHexString() != "96B8EA48819CFA589F24C40AA149C224C420DCCF38B730F00156EFE25C9BBC8F")
return false;
}
using var sha256 = SHA256.Create();
sha256.ComputeHash(buff, 0x100, 0xd00);
if (sha256.Hash.BytesToHexString() != "96B8EA48819CFA589F24C40AA149C224C420DCCF38B730F00156EFE25C9BBC8F")
return false;
}
return true;
}

View File

@ -16,12 +16,12 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
public void NewCDL(ICodeDataLog cdl)
{
cdl["MD CART"] = new byte[MemoryDomains["MD CART"].Size];
cdl["68K RAM"] = new byte[MemoryDomains["68K RAM"].Size];
cdl["Z80 RAM"] = new byte[MemoryDomains["Z80 RAM"].Size];
cdl["MD CART"] = new byte[_memoryDomains["MD CART"].Size];
cdl["68K RAM"] = new byte[_memoryDomains["68K RAM"].Size];
cdl["Z80 RAM"] = new byte[_memoryDomains["Z80 RAM"].Size];
if (MemoryDomains.Has("SRAM"))
cdl["SRAM"] = new byte[MemoryDomains["SRAM"].Size];
if (_memoryDomains.Has("SRAM"))
cdl["SRAM"] = new byte[_memoryDomains["SRAM"].Size];
cdl.SubType = "GEN";
cdl.SubVer = 0;

View File

@ -8,19 +8,13 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
{
public string Cpu
{
get
{
return "M68000";
}
get => "M68000";
set
{
}
}
public string PCRegisterName
{
get { return "M68K PC"; }
}
public string PCRegisterName => "M68K PC";
public IEnumerable<string> AvailableCpus
{
@ -40,6 +34,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
}
// TODO: refactor MC6800's disassembler to be a static call
private MC68000 _disassemblerInstance = new MC68000();
private readonly MC68000 _disassemblerInstance = new MC68000();
}
}

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