From 734dd9297d2e35972107b3519b0321af1aeb05d2 Mon Sep 17 00:00:00 2001 From: adelikat Date: Tue, 18 Feb 2020 13:56:44 -0600 Subject: [PATCH] cleanup GBHawkLink4x --- .../GBHawkLink4x.IMemoryDomains.cs | 32 +++++----- .../GBHawkLink4x/GBHawkLink4x.ISaveRam.cs | 18 +++--- .../GBHawkLink4x/GBHawkLink4x.ISettable.cs | 30 ++------- .../Nintendo/GBHawkLink4x/GBHawkLink4x.cs | 64 +++++++++---------- 4 files changed, 60 insertions(+), 84 deletions(-) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.IMemoryDomains.cs index 98f30e794b..b0eb4dda3c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.IMemoryDomains.cs @@ -72,29 +72,29 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x "System Bus A", 0X10000, MemoryDomain.Endian.Little, - addr => PeekSystemBusA(addr), - (addr, value) => PokeSystemBusA(addr, value), + PeekSystemBusA, + PokeSystemBusA, 1), new MemoryDomainDelegate( "System Bus B", 0X10000, MemoryDomain.Endian.Little, - addr => PeekSystemBusB(addr), - (addr, value) => PokeSystemBusB(addr, value), + PeekSystemBusB, + PokeSystemBusB, 1), new MemoryDomainDelegate( "System Bus C", 0X10000, MemoryDomain.Endian.Little, - addr => PeekSystemBusC(addr), - (addr, value) => PokeSystemBusC(addr, value), + PeekSystemBusC, + PokeSystemBusC, 1), new MemoryDomainDelegate( "System Bus D", 0X10000, MemoryDomain.Endian.Little, - addr => PeekSystemBusD(addr), - (addr, value) => PokeSystemBusD(addr, value), + PeekSystemBusD, + PokeSystemBusD, 1), new MemoryDomainDelegate( "ROM A", @@ -156,26 +156,26 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x if (A.cart_RAM != null) { - var CartRamA = new MemoryDomainByteArray("Cart RAM L", MemoryDomain.Endian.Little, A.cart_RAM, true, 1); - domains.Add(CartRamA); + var cartRamA = new MemoryDomainByteArray("Cart RAM L", MemoryDomain.Endian.Little, A.cart_RAM, true, 1); + domains.Add(cartRamA); } if (B.cart_RAM != null) { - var CartRamB = new MemoryDomainByteArray("Cart RAM B", MemoryDomain.Endian.Little, B.cart_RAM, true, 1); - domains.Add(CartRamB); + var cartRamB = new MemoryDomainByteArray("Cart RAM B", MemoryDomain.Endian.Little, B.cart_RAM, true, 1); + domains.Add(cartRamB); } if (C.cart_RAM != null) { - var CartRamC = new MemoryDomainByteArray("Cart RAM C", MemoryDomain.Endian.Little, C.cart_RAM, true, 1); - domains.Add(CartRamC); + var cartRamC = new MemoryDomainByteArray("Cart RAM C", MemoryDomain.Endian.Little, C.cart_RAM, true, 1); + domains.Add(cartRamC); } if (D.cart_RAM != null) { - var CartRamD = new MemoryDomainByteArray("Cart RAM D", MemoryDomain.Endian.Little, D.cart_RAM, true, 1); - domains.Add(CartRamD); + var cartRamD = new MemoryDomainByteArray("Cart RAM D", MemoryDomain.Endian.Little, D.cart_RAM, true, 1); + domains.Add(cartRamD); } MemoryDomains = new MemoryDomainList(domains); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.ISaveRam.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.ISaveRam.cs index 7f99865062..3568c63652 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.ISaveRam.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.ISaveRam.cs @@ -9,33 +9,33 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x { if (A.cart_RAM != null || B.cart_RAM != null || C.cart_RAM != null || D.cart_RAM != null) { - int Len1 = 0; - int Len2 = 0; - int Len3 = 0; - int Len4 = 0; + int len1 = 0; + int len2 = 0; + int len3 = 0; + int len4 = 0; int index = 0; if (A.cart_RAM != null) { - Len1 = A.cart_RAM.Length; + len1 = A.cart_RAM.Length; } if (B.cart_RAM != null) { - Len2 = B.cart_RAM.Length; + len2 = B.cart_RAM.Length; } if (C.cart_RAM != null) { - Len3 = C.cart_RAM.Length; + len3 = C.cart_RAM.Length; } if (D.cart_RAM != null) { - Len4 = D.cart_RAM.Length; + len4 = D.cart_RAM.Length; } - byte[] temp = new byte[Len1 + Len2 + Len3 + Len4]; + byte[] temp = new byte[len1 + len2 + len3 + len4]; if (A.cart_RAM != null) { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.ISettable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.ISettable.cs index eb684c6ad0..af99fdab41 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.ISettable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.ISettable.cs @@ -10,15 +10,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x { public partial class GBHawkLink4x : IEmulator, IStatable, ISettable { - public GBLink4xSettings GetSettings() - { - return Link4xSettings.Clone(); - } + public GBLink4xSettings GetSettings() => Link4xSettings.Clone(); - public GBLink4xSyncSettings GetSyncSettings() - { - return Link4xSyncSettings.Clone(); - } + public GBLink4xSyncSettings GetSyncSettings() => Link4xSyncSettings.Clone(); public bool PutSettings(GBLink4xSettings o) { @@ -72,15 +66,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x [DefaultValue(AudioSrc.A)] public AudioSrc AudioSet { get; set; } - public GBLink4xSettings Clone() - { - return (GBLink4xSettings)MemberwiseClone(); - } + public GBLink4xSettings Clone() => (GBLink4xSettings)MemberwiseClone(); - public GBLink4xSettings() - { - SettingsUtil.SetDefaultValues(this); - } + public GBLink4xSettings() => SettingsUtil.SetDefaultValues(this); } public class GBLink4xSyncSettings @@ -212,15 +200,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x [JsonIgnore] public ushort _DivInitialTime_D = 8; - public GBLink4xSyncSettings Clone() - { - return (GBLink4xSyncSettings)MemberwiseClone(); - } + public GBLink4xSyncSettings Clone() => (GBLink4xSyncSettings)MemberwiseClone(); - public GBLink4xSyncSettings() - { - SettingsUtil.SetDefaultValues(this); - } + public GBLink4xSyncSettings() => SettingsUtil.SetDefaultValues(this); public static bool NeedsReboot(GBLink4xSyncSettings x, GBLink4xSyncSettings y) { return !DeepEquality.DeepEquals(x, y); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.cs index 207d98f852..3e421eb570 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.cs @@ -41,52 +41,52 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x CoreComm = comm; - var temp_set_A = new GBHawk.GBHawk.GBSettings(); - var temp_set_B = new GBHawk.GBHawk.GBSettings(); - var temp_set_C = new GBHawk.GBHawk.GBSettings(); - var temp_set_D = new GBHawk.GBHawk.GBSettings(); + var tempSetA = new GBHawk.GBHawk.GBSettings(); + var tempSetB = new GBHawk.GBHawk.GBSettings(); + var tempSetC = new GBHawk.GBHawk.GBSettings(); + var tempSetD = new GBHawk.GBHawk.GBSettings(); - var temp_sync_A = new GBHawk.GBHawk.GBSyncSettings(); - var temp_sync_B = new GBHawk.GBHawk.GBSyncSettings(); - var temp_sync_C = new GBHawk.GBHawk.GBSyncSettings(); - var temp_sync_D = new GBHawk.GBHawk.GBSyncSettings(); + var tempSyncA = new GBHawk.GBHawk.GBSyncSettings(); + var tempSyncB = new GBHawk.GBHawk.GBSyncSettings(); + var tempSyncC = new GBHawk.GBHawk.GBSyncSettings(); + var tempSyncD = new GBHawk.GBHawk.GBSyncSettings(); - temp_sync_A.ConsoleMode = Link4xSyncSettings.ConsoleMode_A; - temp_sync_B.ConsoleMode = Link4xSyncSettings.ConsoleMode_B; - temp_sync_C.ConsoleMode = Link4xSyncSettings.ConsoleMode_C; - temp_sync_D.ConsoleMode = Link4xSyncSettings.ConsoleMode_D; + tempSyncA.ConsoleMode = Link4xSyncSettings.ConsoleMode_A; + tempSyncB.ConsoleMode = Link4xSyncSettings.ConsoleMode_B; + tempSyncC.ConsoleMode = Link4xSyncSettings.ConsoleMode_C; + tempSyncD.ConsoleMode = Link4xSyncSettings.ConsoleMode_D; - temp_sync_A.GBACGB = Link4xSyncSettings.GBACGB; - temp_sync_B.GBACGB = Link4xSyncSettings.GBACGB; - temp_sync_C.GBACGB = Link4xSyncSettings.GBACGB; - temp_sync_D.GBACGB = Link4xSyncSettings.GBACGB; + tempSyncA.GBACGB = Link4xSyncSettings.GBACGB; + tempSyncB.GBACGB = Link4xSyncSettings.GBACGB; + tempSyncC.GBACGB = Link4xSyncSettings.GBACGB; + tempSyncD.GBACGB = Link4xSyncSettings.GBACGB; - temp_sync_A.RTCInitialTime = Link4xSyncSettings.RTCInitialTime_A; - temp_sync_B.RTCInitialTime = Link4xSyncSettings.RTCInitialTime_B; - temp_sync_C.RTCInitialTime = Link4xSyncSettings.RTCInitialTime_C; - temp_sync_D.RTCInitialTime = Link4xSyncSettings.RTCInitialTime_D; - temp_sync_A.RTCOffset = Link4xSyncSettings.RTCOffset_A; - temp_sync_B.RTCOffset = Link4xSyncSettings.RTCOffset_B; - temp_sync_C.RTCOffset = Link4xSyncSettings.RTCOffset_C; - temp_sync_D.RTCOffset = Link4xSyncSettings.RTCOffset_D; + tempSyncA.RTCInitialTime = Link4xSyncSettings.RTCInitialTime_A; + tempSyncB.RTCInitialTime = Link4xSyncSettings.RTCInitialTime_B; + tempSyncC.RTCInitialTime = Link4xSyncSettings.RTCInitialTime_C; + tempSyncD.RTCInitialTime = Link4xSyncSettings.RTCInitialTime_D; + tempSyncA.RTCOffset = Link4xSyncSettings.RTCOffset_A; + tempSyncB.RTCOffset = Link4xSyncSettings.RTCOffset_B; + tempSyncC.RTCOffset = Link4xSyncSettings.RTCOffset_C; + tempSyncD.RTCOffset = Link4xSyncSettings.RTCOffset_D; A = new GBHawk.GBHawk(new CoreComm(comm.ShowMessage, comm.Notify) { CoreFileProvider = comm.CoreFileProvider }, - game_A, rom_A, temp_set_A, temp_sync_A); + game_A, rom_A, tempSetA, tempSyncA); B = new GBHawk.GBHawk(new CoreComm(comm.ShowMessage, comm.Notify) { CoreFileProvider = comm.CoreFileProvider }, - game_B, rom_B, temp_set_B, temp_sync_B); + game_B, rom_B, tempSetB, tempSyncB); C = new GBHawk.GBHawk(new CoreComm(comm.ShowMessage, comm.Notify) { CoreFileProvider = comm.CoreFileProvider }, - game_C, rom_C, temp_set_C, temp_sync_C); + game_C, rom_C, tempSetC, tempSyncC); D = new GBHawk.GBHawk(new CoreComm(comm.ShowMessage, comm.Notify) { CoreFileProvider = comm.CoreFileProvider }, - game_D, rom_D, temp_set_D, temp_sync_D); + game_D, rom_D, tempSetD, tempSyncD); ser.Register(this); ser.Register(this); _tracer = new TraceBuffer { Header = A.cpu.TraceHeader }; - ser.Register(_tracer); + ser.Register(_tracer); ServiceProvider = ser; @@ -115,11 +115,5 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x private readonly GBHawkLink4xControllerDeck _controllerDeck; private readonly ITraceable _tracer; - - private void ExecFetch(ushort addr) - { - uint flags = (uint)(MemoryCallbackFlags.AccessExecute); - MemoryCallbacks.CallMemoryCallbacks(addr, 0, flags, "System Bus"); - } } }