From 77598ce2b2249e92b23e07d2ea92b0c1c2dd12da Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 16 Feb 2020 13:25:44 -0600 Subject: [PATCH] GBHawkLink cores - opt out of text states --- .../GBHawkLink/GBHawkLink.IStatable.cs | 20 ++---------- .../Nintendo/GBHawkLink/GBHawkLink.cs | 4 +-- .../GBHawkLink3x/GBHawkLink3x.IStatable.cs | 24 +++----------- .../Nintendo/GBHawkLink3x/GBHawkLink3x.cs | 6 ++-- .../GBHawkLink4x/GBHawkLink4x.IStatable.cs | 32 ++++--------------- .../Nintendo/GBHawkLink4x/GBHawkLink4x.cs | 14 +++----- 6 files changed, 24 insertions(+), 76 deletions(-) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IStatable.cs index d965d68d48..f1cc19acad 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.IStatable.cs @@ -5,24 +5,10 @@ using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink { - public partial class GBHawkLink : ITextStatable + public partial class GBHawkLink : IStatable { - private readonly ITextStatable _lStates; - private readonly ITextStatable _rStates; - - public void SaveStateText(TextWriter writer) - { - _lStates.SaveStateText(writer); - _rStates.SaveStateText(writer); - SyncState(new Serializer(writer)); - } - - public void LoadStateText(TextReader reader) - { - _lStates.LoadStateText(reader); - _rStates.LoadStateText(reader); - SyncState(new Serializer(reader)); - } + private readonly IStatable _lStates; + private readonly IStatable _rStates; public void SaveStateBinary(BinaryWriter bw) { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.cs index d1b2db5789..d9185bd68e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink/GBHawkLink.cs @@ -74,8 +74,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink ServiceProvider = ser; - _lStates = (ITextStatable)L.ServiceProvider.GetService(); - _rStates = (ITextStatable)R.ServiceProvider.GetService(); + _lStates = L.ServiceProvider.GetService(); + _rStates = R.ServiceProvider.GetService(); SetupMemoryDomains(); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.IStatable.cs index 5c3cff8386..4fc865f809 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.IStatable.cs @@ -4,27 +4,11 @@ using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x { - public partial class GBHawkLink3x : ITextStatable + public partial class GBHawkLink3x : IStatable { - private readonly ITextStatable _lStates; - private readonly ITextStatable _cStates; - private readonly ITextStatable _rStates; - - public void SaveStateText(TextWriter writer) - { - _lStates.SaveStateText(writer); - _cStates.SaveStateText(writer); - _rStates.SaveStateText(writer); - SyncState(new Serializer(writer)); - } - - public void LoadStateText(TextReader reader) - { - _lStates.LoadStateText(reader); - _cStates.LoadStateText(reader); - _rStates.LoadStateText(reader); - SyncState(new Serializer(reader)); - } + private readonly IStatable _lStates; + private readonly IStatable _cStates; + private readonly IStatable _rStates; public void SaveStateBinary(BinaryWriter bw) { diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.cs index 7c9bf9d46a..2d15b5af95 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink3x/GBHawkLink3x.cs @@ -77,9 +77,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink3x _tracer = new TraceBuffer { Header = L.cpu.TraceHeader }; ser.Register(_tracer); - _lStates = (ITextStatable)L.ServiceProvider.GetService(); - _cStates = (ITextStatable)C.ServiceProvider.GetService(); - _rStates = (ITextStatable)R.ServiceProvider.GetService(); + _lStates = L.ServiceProvider.GetService(); + _cStates = C.ServiceProvider.GetService(); + _rStates = R.ServiceProvider.GetService(); SetupMemoryDomains(); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.IStatable.cs index f968aadc84..a4537ea7a9 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.IStatable.cs @@ -5,30 +5,12 @@ using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x { - public partial class GBHawkLink4x : ITextStatable + public partial class GBHawkLink4x : IStatable { - private readonly ITextStatable _aStates; - private readonly ITextStatable _bStates; - private readonly ITextStatable _cStates; - private readonly ITextStatable _dStates; - - public void SaveStateText(TextWriter writer) - { - _aStates.SaveStateText(writer); - _bStates.SaveStateText(writer); - _cStates.SaveStateText(writer); - _dStates.SaveStateText(writer); - SyncState(new Serializer(writer)); - } - - public void LoadStateText(TextReader reader) - { - _aStates.LoadStateText(reader); - _bStates.LoadStateText(reader); - _cStates.LoadStateText(reader); - _dStates.LoadStateText(reader); - SyncState(new Serializer(reader)); - } + private readonly IStatable _aStates; + private readonly IStatable _bStates; + private readonly IStatable _cStates; + private readonly IStatable _dStates; public void SaveStateBinary(BinaryWriter bw) { @@ -52,8 +34,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x 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(); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.cs index 398c24db3f..54fda07bc9 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawkLink4x/GBHawkLink4x.cs @@ -1,8 +1,4 @@ -using System; - -using BizHawk.Emulation.Common; - -using BizHawk.Emulation.Cores.Nintendo.GBHawk; +using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x { @@ -94,10 +90,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink4x ServiceProvider = ser; - _aStates = (ITextStatable)A.ServiceProvider.GetService(); - _bStates = (ITextStatable)B.ServiceProvider.GetService(); - _cStates = (ITextStatable)C.ServiceProvider.GetService(); - _dStates = (ITextStatable)D.ServiceProvider.GetService(); + _aStates = A.ServiceProvider.GetService(); + _bStates = B.ServiceProvider.GetService(); + _cStates = C.ServiceProvider.GetService(); + _dStates = D.ServiceProvider.GetService(); SetupMemoryDomains();