From c2f549d02c5801217267bd298c104021c2b19cfd Mon Sep 17 00:00:00 2001 From: CasualPokePlayer <50538166+CasualPokePlayer@users.noreply.github.com> Date: Tue, 30 Apr 2024 22:44:06 -0700 Subject: [PATCH] Move zstd wrapping code to BizHawk.Common thanks delegate* --- .../FrameworkZipWriter.cs | 30 ++-- .../rewind/ZwinderBuffer.cs | 1 - .../savestates/ZipStateLoader.cs | 24 ++-- src/BizHawk.Common/zstd/LibZstd.cs | 131 ++++++++++++++++++ .../zstd/Zstd.cs | 69 +++++---- src/BizHawk.Emulation.Common/zstd/LibZstd.cs | 62 --------- .../Computers/AmstradCPC/AmstradCPC.cs | 10 +- .../Computers/SinclairSpectrum/ZXSpectrum.cs | 10 +- .../Consoles/Atari/jaguar/VirtualJaguar.cs | 1 + .../Waterbox/WaterboxHost.cs | 9 +- 10 files changed, 207 insertions(+), 140 deletions(-) create mode 100644 src/BizHawk.Common/zstd/LibZstd.cs rename src/{BizHawk.Emulation.Common => BizHawk.Common}/zstd/Zstd.cs (84%) delete mode 100644 src/BizHawk.Emulation.Common/zstd/LibZstd.cs diff --git a/src/BizHawk.Client.Common/FrameworkZipWriter.cs b/src/BizHawk.Client.Common/FrameworkZipWriter.cs index c9e65ca9e9a..48bdfdd8033 100644 --- a/src/BizHawk.Client.Common/FrameworkZipWriter.cs +++ b/src/BizHawk.Client.Common/FrameworkZipWriter.cs @@ -2,13 +2,13 @@ using System.IO; using System.IO.Compression; -using BizHawk.Emulation.Common; +using BizHawk.Common; namespace BizHawk.Client.Common { public class FrameworkZipWriter : IZipWriter { - private ZipArchive _archive; + private ZipArchive _archive; private Zstd _zstd; private readonly CompressionLevel _level; private readonly int _zstdCompressionLevel; @@ -22,11 +22,11 @@ public FrameworkZipWriter(string path, int compressionLevel) else if (compressionLevel < 5) _level = CompressionLevel.Fastest; else - _level = CompressionLevel.Optimal; - - _zstd = new(); - // compressionLevel ranges from 0 to 9 - // normal compression level range for zstd is 1 to 19 + _level = CompressionLevel.Optimal; + + _zstd = new(); + // compressionLevel ranges from 0 to 9 + // normal compression level range for zstd is 1 to 19 _zstdCompressionLevel = compressionLevel * 2 + 1; } @@ -35,13 +35,13 @@ public void WriteItem(string name, Action callback, bool zstdCompress) using var stream = _archive.CreateEntry(name, _level).Open(); if (zstdCompress) - { - using var z = _zstd.CreateZstdCompressionStream(stream, _zstdCompressionLevel); - callback(z); + { + using var z = _zstd.CreateZstdCompressionStream(stream, _zstdCompressionLevel); + callback(z); } else - { - callback(stream); + { + callback(stream); } } @@ -54,9 +54,9 @@ public void Dispose() } if (_zstd != null) - { - _zstd.Dispose(); - _zstd = null; + { + _zstd.Dispose(); + _zstd = null; } } } diff --git a/src/BizHawk.Client.Common/rewind/ZwinderBuffer.cs b/src/BizHawk.Client.Common/rewind/ZwinderBuffer.cs index 8ac7c1f822c..079ebf418de 100644 --- a/src/BizHawk.Client.Common/rewind/ZwinderBuffer.cs +++ b/src/BizHawk.Client.Common/rewind/ZwinderBuffer.cs @@ -4,7 +4,6 @@ using System.Linq; using BizHawk.Common; -using BizHawk.Emulation.Common; namespace BizHawk.Client.Common { diff --git a/src/BizHawk.Client.Common/savestates/ZipStateLoader.cs b/src/BizHawk.Client.Common/savestates/ZipStateLoader.cs index 74848e3adf2..b7141e839fd 100644 --- a/src/BizHawk.Client.Common/savestates/ZipStateLoader.cs +++ b/src/BizHawk.Client.Common/savestates/ZipStateLoader.cs @@ -4,7 +4,7 @@ using System.IO.Compression; using System.Linq; -using BizHawk.Emulation.Common; +using BizHawk.Common; namespace BizHawk.Client.Common { @@ -91,13 +91,13 @@ public static ZipStateLoader LoadAndDetect(string filename, bool isMovieLoad = f ret._zip = new ZipArchive(new FileStream(filename, FileMode.Open, FileAccess.Read), ZipArchiveMode.Read); ret.PopulateEntries(); if (isMovieLoad) - { - if (!ret.GetLump(BinaryStateLump.ZipVersion, false, ret.ReadZipVersion, false)) - { - // movies before 1.0.2 did not include the BizState 1.0 file, don't strictly error in this case - ret._ver = new Version(1, 0, 0); - Console.WriteLine("Read a zipstate of version {0}", ret._ver); - } + { + if (!ret.GetLump(BinaryStateLump.ZipVersion, false, ret.ReadZipVersion, false)) + { + // movies before 1.0.2 did not include the BizState 1.0 file, don't strictly error in this case + ret._ver = new Version(1, 0, 0); + Console.WriteLine("Read a zipstate of version {0}", ret._ver); + } } else if (!ret.GetLump(BinaryStateLump.ZipVersion, false, ret.ReadZipVersion, false)) { @@ -123,16 +123,16 @@ public bool GetLump(BinaryStateLump lump, bool abort, Action callb { if (_entriesByName.TryGetValue(lump.ReadName, out var e)) { - using var zs = e.Open(); - + using var zs = e.Open(); + if (isZstdCompressed && _ver.Build > 1) { using var z = _zstd.CreateZstdDecompressionStream(zs); callback(z, e.Length); } else - { - callback(zs, e.Length); + { + callback(zs, e.Length); } return true; diff --git a/src/BizHawk.Common/zstd/LibZstd.cs b/src/BizHawk.Common/zstd/LibZstd.cs new file mode 100644 index 00000000000..e257dbd7f3f --- /dev/null +++ b/src/BizHawk.Common/zstd/LibZstd.cs @@ -0,0 +1,131 @@ +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace BizHawk.Common +{ + public static unsafe class LibZstd + { + static LibZstd() + { + var resolver = new DynamicLibraryImportResolver( + OSTailoredCode.IsUnixHost ? "libzstd.so.1" : "libzstd.dll", hasLimitedLifetime: false); + ZSTD_isError = (delegate* unmanaged[Cdecl])resolver.GetProcAddrOrThrow(nameof(ZSTD_isError)); + ZSTD_getErrorName = (delegate* unmanaged[Cdecl])resolver.GetProcAddrOrThrow(nameof(ZSTD_getErrorName)); + ZSTD_minCLevel = (delegate* unmanaged[Cdecl])resolver.GetProcAddrOrThrow(nameof(ZSTD_minCLevel)); + ZSTD_maxCLevel = (delegate* unmanaged[Cdecl])resolver.GetProcAddrOrThrow(nameof(ZSTD_maxCLevel)); + ZSTD_createCStream = (delegate* unmanaged[Cdecl])resolver.GetProcAddrOrThrow(nameof(ZSTD_createCStream)); + ZSTD_freeCStream = (delegate* unmanaged[Cdecl])resolver.GetProcAddrOrThrow(nameof(ZSTD_freeCStream)); + ZSTD_initCStream = (delegate* unmanaged[Cdecl])resolver.GetProcAddrOrThrow(nameof(ZSTD_initCStream)); + ZSTD_compressStream = (delegate* unmanaged[Cdecl])resolver.GetProcAddrOrThrow(nameof(ZSTD_compressStream)); + ZSTD_flushStream = (delegate* unmanaged[Cdecl])resolver.GetProcAddrOrThrow(nameof(ZSTD_flushStream)); + ZSTD_endStream = (delegate* unmanaged[Cdecl])resolver.GetProcAddrOrThrow(nameof(ZSTD_endStream)); + ZSTD_createDStream = (delegate* unmanaged[Cdecl])resolver.GetProcAddrOrThrow(nameof(ZSTD_createDStream)); + ZSTD_freeDStream = (delegate* unmanaged[Cdecl])resolver.GetProcAddrOrThrow(nameof(ZSTD_freeDStream)); + ZSTD_initDStream = (delegate* unmanaged[Cdecl])resolver.GetProcAddrOrThrow(nameof(ZSTD_initDStream)); + ZSTD_decompressStream = (delegate* unmanaged[Cdecl])resolver.GetProcAddrOrThrow(nameof(ZSTD_decompressStream)); + } + + private static readonly delegate* unmanaged[Cdecl] ZSTD_isError; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static uint IsError(nuint code) => ZSTD_isError(code); + + private static readonly delegate* unmanaged[Cdecl] ZSTD_getErrorName; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static IntPtr GetErrorName(nuint code) => ZSTD_getErrorName(code); + + private static readonly delegate* unmanaged[Cdecl] ZSTD_minCLevel; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static int MinCLevel() => ZSTD_minCLevel(); + + private static readonly delegate* unmanaged[Cdecl] ZSTD_maxCLevel; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static int MaxCLevel() => ZSTD_maxCLevel(); + + [StructLayout(LayoutKind.Sequential)] + public struct StreamBuffer + { + public IntPtr Ptr; + public nuint Size; + public nuint Pos; + } + + private static readonly delegate* unmanaged[Cdecl] ZSTD_createCStream; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static IntPtr CreateCStream() => ZSTD_createCStream(); + + private static readonly delegate* unmanaged[Cdecl] ZSTD_freeCStream; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static nuint FreeCStream(IntPtr zcs) => ZSTD_freeCStream(zcs); + + private static readonly delegate* unmanaged[Cdecl] ZSTD_initCStream; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static nuint InitCStream(IntPtr zcs, int compressionLevel) => ZSTD_initCStream(zcs, compressionLevel); + + private static readonly delegate* unmanaged[Cdecl] ZSTD_compressStream; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static nuint CompressStream(IntPtr zcs, ref StreamBuffer output, ref StreamBuffer input) + { + fixed (StreamBuffer* outputPtr = &output, inputPtr = &input) + { + return ZSTD_compressStream(zcs, outputPtr, inputPtr); + } + } + + private static readonly delegate* unmanaged[Cdecl] ZSTD_flushStream; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static nuint FlushStream(IntPtr zcs, ref StreamBuffer output) + { + fixed (StreamBuffer* outputPtr = &output) + { + return ZSTD_flushStream(zcs, outputPtr); + } + } + + private static readonly delegate* unmanaged[Cdecl] ZSTD_endStream; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static nuint EndStream(IntPtr zcs, ref StreamBuffer output) + { + fixed (StreamBuffer* outputPtr = &output) + { + return ZSTD_endStream(zcs, outputPtr); + } + } + + private static readonly delegate* unmanaged[Cdecl] ZSTD_createDStream; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static IntPtr CreateDStream() => ZSTD_createDStream(); + + private static readonly delegate* unmanaged[Cdecl] ZSTD_freeDStream; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static nuint FreeDStream(IntPtr zds) => ZSTD_freeDStream(zds); + + private static readonly delegate* unmanaged[Cdecl] ZSTD_initDStream; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static nuint InitDStream(IntPtr zds) => ZSTD_initDStream(zds); + + private static readonly delegate* unmanaged[Cdecl] ZSTD_decompressStream; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static nuint DecompressStream(IntPtr zds, ref StreamBuffer output, ref StreamBuffer input) + { + fixed (StreamBuffer* outputPtr = &output, inputPtr = &input) + { + return ZSTD_decompressStream(zds, outputPtr, inputPtr); + } + } + } +} diff --git a/src/BizHawk.Emulation.Common/zstd/Zstd.cs b/src/BizHawk.Common/zstd/Zstd.cs similarity index 84% rename from src/BizHawk.Emulation.Common/zstd/Zstd.cs rename to src/BizHawk.Common/zstd/Zstd.cs index ea7932ad53c..5dc0fa1ad11 100644 --- a/src/BizHawk.Emulation.Common/zstd/Zstd.cs +++ b/src/BizHawk.Common/zstd/Zstd.cs @@ -2,10 +2,9 @@ using System.IO; using System.Runtime.InteropServices; -using BizHawk.BizInvoke; -using BizHawk.Common; +// ReSharper disable MemberCanBePrivate.Local -namespace BizHawk.Emulation.Common +namespace BizHawk.Common { public sealed class Zstd : IDisposable { @@ -14,11 +13,11 @@ private sealed class ZstdCompressionStreamContext : IDisposable public readonly IntPtr Zcs; public readonly byte[] InputBuffer; - public readonly GCHandle InputHandle; + public GCHandle InputHandle; public LibZstd.StreamBuffer Input; public readonly byte[] OutputBuffer; - public readonly GCHandle OutputHandle; + public GCHandle OutputHandle; public LibZstd.StreamBuffer Output; // TODO: tweak these sizes @@ -32,7 +31,7 @@ private sealed class ZstdCompressionStreamContext : IDisposable public ZstdCompressionStreamContext() { - Zcs = _lib.ZSTD_createCStream(); + Zcs = LibZstd.CreateCStream(); InputBuffer = new byte[INPUT_BUFFER_SIZE]; InputHandle = GCHandle.Alloc(InputBuffer, GCHandleType.Pinned); @@ -57,13 +56,13 @@ public ZstdCompressionStreamContext() InUse = false; } - private bool _disposed = false; + private bool _disposed; public void Dispose() { if (!_disposed) { - _lib.ZSTD_freeCStream(Zcs); + LibZstd.FreeCStream(Zcs); InputHandle.Free(); OutputHandle.Free(); _disposed = true; @@ -77,7 +76,7 @@ public void InitContext(int compressionLevel) throw new InvalidOperationException("Cannot init context still in use!"); } - _lib.ZSTD_initCStream(Zcs, compressionLevel); + LibZstd.InitCStream(Zcs, compressionLevel); Input.Size = Input.Pos = Output.Pos = 0; InUse = true; } @@ -94,7 +93,7 @@ public ZstdCompressionStream(Stream baseStream, ZstdCompressionStreamContext ctx _ctx = ctx; } - private bool _disposed = false; + private bool _disposed; protected override void Dispose(bool disposing) { @@ -103,7 +102,7 @@ protected override void Dispose(bool disposing) Flush(); while (true) { - var n = _lib.ZSTD_endStream(_ctx.Zcs, ref _ctx.Output); + var n = LibZstd.EndStream(_ctx.Zcs, ref _ctx.Output); CheckError(n); InternalFlush(); if (n == 0) @@ -146,7 +145,7 @@ public override void Flush() { while (_ctx.Input.Pos < _ctx.Input.Size) { - CheckError(_lib.ZSTD_compressStream(_ctx.Zcs, ref _ctx.Output, ref _ctx.Input)); + CheckError(LibZstd.CompressStream(_ctx.Zcs, ref _ctx.Output, ref _ctx.Input)); while (true) { if (_ctx.Output.Pos == ZstdCompressionStreamContext.OUTPUT_BUFFER_SIZE) @@ -154,7 +153,7 @@ public override void Flush() InternalFlush(); } - var n = _lib.ZSTD_flushStream(_ctx.Zcs, ref _ctx.Output); + var n = LibZstd.FlushStream(_ctx.Zcs, ref _ctx.Output); CheckError(n); if (n == 0) { @@ -188,7 +187,7 @@ public override void Write(byte[] buffer, int offset, int count) var n = Math.Min(count, (int)(ZstdCompressionStreamContext.INPUT_BUFFER_SIZE - _ctx.Input.Size)); Marshal.Copy(buffer, offset, _ctx.Input.Ptr + (int)_ctx.Input.Size, n); offset += n; - _ctx.Input.Size += (ulong)n; + _ctx.Input.Size += (uint)n; count -= n; } } @@ -199,11 +198,11 @@ private sealed class ZstdDecompressionStreamContext : IDisposable public readonly IntPtr Zds; public readonly byte[] InputBuffer; - public readonly GCHandle InputHandle; + public GCHandle InputHandle; public LibZstd.StreamBuffer Input; public readonly byte[] OutputBuffer; - public readonly GCHandle OutputHandle; + public GCHandle OutputHandle; public LibZstd.StreamBuffer Output; // TODO: tweak these sizes @@ -217,7 +216,7 @@ private sealed class ZstdDecompressionStreamContext : IDisposable public ZstdDecompressionStreamContext() { - Zds = _lib.ZSTD_createDStream(); + Zds = LibZstd.CreateDStream(); InputBuffer = new byte[INPUT_BUFFER_SIZE]; InputHandle = GCHandle.Alloc(InputBuffer, GCHandleType.Pinned); @@ -242,13 +241,13 @@ public ZstdDecompressionStreamContext() InUse = false; } - private bool _disposed = false; + private bool _disposed; public void Dispose() { if (!_disposed) { - _lib.ZSTD_freeDStream(Zds); + LibZstd.FreeDStream(Zds); InputHandle.Free(); OutputHandle.Free(); _disposed = true; @@ -262,7 +261,7 @@ public void InitContext() throw new InvalidOperationException("Cannot init context still in use!"); } - _lib.ZSTD_initDStream(Zds); + LibZstd.InitDStream(Zds); Input.Size = Input.Pos = Output.Pos = 0; InUse = true; } @@ -279,7 +278,7 @@ public ZstdDecompressionStream(Stream baseStream, ZstdDecompressionStreamContext _ctx = ctx; } - private bool _disposed = false; + private bool _disposed; protected override void Dispose(bool disposing) { @@ -313,7 +312,7 @@ public override long Position public override void Flush() => throw new NotImplementedException(); - private ulong _outputConsumed = 0; + private ulong _outputConsumed; public override int Read(byte[] buffer, int offset, int count) { @@ -322,12 +321,12 @@ public override int Read(byte[] buffer, int offset, int count) { var inputConsumed = _baseStream.Read(_ctx.InputBuffer, (int)_ctx.Input.Size, (int)(ZstdDecompressionStreamContext.INPUT_BUFFER_SIZE - _ctx.Input.Size)); - _ctx.Input.Size += (ulong)inputConsumed; + _ctx.Input.Size += (uint)inputConsumed; // avoid interop in case compression cannot be done if (_ctx.Output.Pos < ZstdDecompressionStreamContext.OUTPUT_BUFFER_SIZE && _ctx.Input.Pos < _ctx.Input.Size) { - CheckError(_lib.ZSTD_decompressStream(_ctx.Zds, ref _ctx.Output, ref _ctx.Input)); + CheckError(LibZstd.DecompressStream(_ctx.Zds, ref _ctx.Output, ref _ctx.Input)); } var outputToConsume = Math.Min(n, (int)(_ctx.Output.Pos - _outputConsumed)); Marshal.Copy(_ctx.Output.Ptr + (int)_outputConsumed, buffer, offset, outputToConsume); @@ -338,7 +337,8 @@ public override int Read(byte[] buffer, int offset, int count) if (_outputConsumed == ZstdDecompressionStreamContext.OUTPUT_BUFFER_SIZE) { // all the buffer is consumed, kick these back to the beginning - _ctx.Output.Pos = _outputConsumed = 0; + _outputConsumed = 0; + _ctx.Output.Pos = 0; } if (_ctx.Input.Pos == ZstdDecompressionStreamContext.INPUT_BUFFER_SIZE) @@ -368,26 +368,19 @@ public override void Write(byte[] buffer, int offset, int count) => throw new NotImplementedException(); } - private static readonly LibZstd _lib; - public static int MinCompressionLevel { get; } - public static int MaxCompressionLevel { get; } static Zstd() { - var resolver = new DynamicLibraryImportResolver( - OSTailoredCode.IsUnixHost ? "libzstd.so.1" : "libzstd.dll", hasLimitedLifetime: false); - _lib = BizInvoker.GetInvoker(resolver, CallingConventionAdapters.Native); - - MinCompressionLevel = _lib.ZSTD_minCLevel(); - MaxCompressionLevel = _lib.ZSTD_maxCLevel(); + MinCompressionLevel = LibZstd.MinCLevel(); + MaxCompressionLevel = LibZstd.MaxCLevel(); } private ZstdCompressionStreamContext? _compressionStreamContext; private ZstdDecompressionStreamContext? _decompressionStreamContext; - private bool _disposed = false; + private bool _disposed; public void Dispose() { @@ -399,11 +392,11 @@ public void Dispose() } } - private static void CheckError(ulong code) + private static void CheckError(nuint code) { - if (_lib.ZSTD_isError(code) != 0) + if (LibZstd.IsError(code) != 0) { - throw new Exception($"ZSTD ERROR: {Marshal.PtrToStringAnsi(_lib.ZSTD_getErrorName(code))}"); + throw new Exception($"ZSTD ERROR: {Marshal.PtrToStringAnsi(LibZstd.GetErrorName(code))}"); } } diff --git a/src/BizHawk.Emulation.Common/zstd/LibZstd.cs b/src/BizHawk.Emulation.Common/zstd/LibZstd.cs deleted file mode 100644 index 572284ec004..00000000000 --- a/src/BizHawk.Emulation.Common/zstd/LibZstd.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -using BizHawk.BizInvoke; - -namespace BizHawk.Emulation.Common -{ - public abstract class LibZstd - { - private const CallingConvention cc = CallingConvention.Cdecl; - - [BizImport(cc)] - public abstract uint ZSTD_isError(ulong code); - - [BizImport(cc)] - public abstract IntPtr ZSTD_getErrorName(ulong code); - - [BizImport(cc)] - public abstract int ZSTD_minCLevel(); - - [BizImport(cc)] - public abstract int ZSTD_maxCLevel(); - - [StructLayout(LayoutKind.Sequential)] - public struct StreamBuffer - { - public IntPtr Ptr; - public ulong Size; - public ulong Pos; - } - - [BizImport(cc)] - public abstract IntPtr ZSTD_createCStream(); - - [BizImport(cc)] - public abstract ulong ZSTD_freeCStream(IntPtr zcs); - - [BizImport(cc)] - public abstract ulong ZSTD_initCStream(IntPtr zcs, int compressionLevel); - - [BizImport(cc)] - public abstract ulong ZSTD_compressStream(IntPtr zcs, ref StreamBuffer output, ref StreamBuffer input); - - [BizImport(cc)] - public abstract ulong ZSTD_flushStream(IntPtr zcs, ref StreamBuffer output); - - [BizImport(cc)] - public abstract ulong ZSTD_endStream(IntPtr zcs, ref StreamBuffer output); - - [BizImport(cc)] - public abstract IntPtr ZSTD_createDStream(); - - [BizImport(cc)] - public abstract ulong ZSTD_freeDStream(IntPtr zds); - - [BizImport(cc)] - public abstract ulong ZSTD_initDStream(IntPtr zds); - - [BizImport(cc)] - public abstract ulong ZSTD_decompressStream(IntPtr zds, ref StreamBuffer output, ref StreamBuffer input); - } -} diff --git a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.cs b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.cs index 760bb98a7c5..c7a2f07cd8e 100644 --- a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.cs +++ b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/AmstradCPC.cs @@ -1,11 +1,13 @@ -using BizHawk.Emulation.Common; -using BizHawk.Emulation.Cores.Components.Z80A; -using BizHawk.Emulation.Cores.Properties; -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; +using BizHawk.Common; +using BizHawk.Emulation.Common; +using BizHawk.Emulation.Cores.Components.Z80A; +using BizHawk.Emulation.Cores.Properties; + namespace BizHawk.Emulation.Cores.Computers.AmstradCPC { /// diff --git a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.cs b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.cs index d4460aa83a5..282e8fdd36e 100644 --- a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.cs +++ b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.cs @@ -1,10 +1,12 @@ -using BizHawk.Emulation.Common; -using BizHawk.Emulation.Cores.Components.Z80A; -using BizHawk.Emulation.Cores.Properties; -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; + +using BizHawk.Common; +using BizHawk.Emulation.Common; +using BizHawk.Emulation.Cores.Components.Z80A; +using BizHawk.Emulation.Cores.Properties; using BizHawk.Emulation.Cores.Components; namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum diff --git a/src/BizHawk.Emulation.Cores/Consoles/Atari/jaguar/VirtualJaguar.cs b/src/BizHawk.Emulation.Cores/Consoles/Atari/jaguar/VirtualJaguar.cs index 77fb6dbd874..94830007ac1 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Atari/jaguar/VirtualJaguar.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Atari/jaguar/VirtualJaguar.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Runtime.InteropServices; +using BizHawk.Common; using BizHawk.Common.CollectionExtensions; using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Properties; diff --git a/src/BizHawk.Emulation.Cores/Waterbox/WaterboxHost.cs b/src/BizHawk.Emulation.Cores/Waterbox/WaterboxHost.cs index 956c86da758..cfe81d3f87f 100644 --- a/src/BizHawk.Emulation.Cores/Waterbox/WaterboxHost.cs +++ b/src/BizHawk.Emulation.Cores/Waterbox/WaterboxHost.cs @@ -1,10 +1,11 @@ -using BizHawk.Common; -using BizHawk.BizInvoke; -using BizHawk.Emulation.Common; -using System; +using System; using System.IO; using System.Runtime.InteropServices; +using BizHawk.Common; +using BizHawk.BizInvoke; +using BizHawk.Emulation.Common; + using static BizHawk.Emulation.Cores.Waterbox.WaterboxHostNative; namespace BizHawk.Emulation.Cores.Waterbox