more misc cleanup and removing some usings that should have been removed when moving things from one project to another

This commit is contained in:
adelikat 2013-11-15 01:52:03 +00:00
parent 00308de99a
commit e606429219
23 changed files with 1687 additions and 1716 deletions

View File

@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Common.Components.CP1610
private bool FlagS, FlagC, FlagZ, FlagO, FlagI, FlagD, IntRM, BusRq, BusAk, Interruptible, Interrupted; private bool FlagS, FlagC, FlagZ, FlagO, FlagI, FlagD, IntRM, BusRq, BusAk, Interruptible, Interrupted;
//private bool MSync; //private bool MSync;
private ushort[] Register = new ushort[8]; private readonly ushort[] Register = new ushort[8];
private ushort RegisterSP { get { return Register[6]; } set { Register[6] = value; } } private ushort RegisterSP { get { return Register[6]; } set { Register[6] = value; } }
private ushort RegisterPC { get { return Register[7]; } set { Register[7] = value; } } private ushort RegisterPC { get { return Register[7]; } set { Register[7] = value; } }
@ -21,7 +21,7 @@ namespace BizHawk.Emulation.Common.Components.CP1610
public Func<ushort, ushort, bool> WriteMemory; public Func<ushort, ushort, bool> WriteMemory;
private static bool Logging = true; private static bool Logging = true;
private static StreamWriter Log; private static readonly StreamWriter Log;
static CP1610() static CP1610()
{ {

View File

@ -185,7 +185,7 @@ namespace BizHawk.Emulation.Common.Components.CP1610
// Unknown opcode. // Unknown opcode.
throw new ArgumentException(); throw new ArgumentException();
} }
RegisterPC = (ushort)addr; RegisterPC = addr;
cycles = 12; cycles = 12;
Interruptible = true; Interruptible = true;
break; break;

View File

@ -12,8 +12,8 @@ namespace BizHawk.Emulation.Common.Components.M6502
/// </summary> /// </summary>
public class MOS6502XDouble public class MOS6502XDouble
{ {
MOS6502X m; readonly MOS6502X m;
MOS6502X_CPP n; readonly MOS6502X_CPP n;
public MOS6502XDouble(Action<System.Runtime.InteropServices.GCHandle> DisposeBuilder) public MOS6502XDouble(Action<System.Runtime.InteropServices.GCHandle> DisposeBuilder)
{ {

View File

@ -7,27 +7,27 @@ namespace BizHawk.Emulation.Common.Components.M6502
{ {
public static class MOS6502X_DLL public static class MOS6502X_DLL
{ {
[UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate byte ReadMemoryD(ushort addr); public delegate byte ReadMemoryD(ushort addr);
[UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void WriteMemoryD(ushort addr, byte value); public delegate void WriteMemoryD(ushort addr, byte value);
[DllImport("MOS6502XNative.dll", CallingConvention = CallingConvention.Cdecl)] [DllImport("MOS6502XNative.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr Create(); internal static extern IntPtr Create();
[DllImport("MOS6502XNative.dll", CallingConvention = CallingConvention.Cdecl)] [DllImport("MOS6502XNative.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void Destroy(IntPtr ptr); internal static extern void Destroy(IntPtr ptr);
[DllImport("MOS6502XNative.dll", CallingConvention = CallingConvention.ThisCall, EntryPoint = "?Reset@MOS6502X@@QAEXXZ")] [DllImport("MOS6502XNative.dll", CallingConvention = CallingConvention.ThisCall, EntryPoint = "?Reset@MOS6502X@@QAEXXZ")]
public static extern void Reset(IntPtr ptr); internal static extern void Reset(IntPtr ptr);
[DllImport("MOS6502XNative.dll", CallingConvention = CallingConvention.ThisCall, EntryPoint = "?NESSoftReset@MOS6502X@@QAEXXZ")] [DllImport("MOS6502XNative.dll", CallingConvention = CallingConvention.ThisCall, EntryPoint = "?NESSoftReset@MOS6502X@@QAEXXZ")]
public static extern void NESSoftReset(IntPtr ptr); internal static extern void NESSoftReset(IntPtr ptr);
[DllImport("MOS6502XNative.dll", CallingConvention = CallingConvention.ThisCall, EntryPoint = "?ExecuteOne@MOS6502X@@QAEXXZ")] [DllImport("MOS6502XNative.dll", CallingConvention = CallingConvention.ThisCall, EntryPoint = "?ExecuteOne@MOS6502X@@QAEXXZ")]
public static extern void ExecuteOne(IntPtr ptr); internal static extern void ExecuteOne(IntPtr ptr);
[DllImport("MOS6502XNative.dll", CallingConvention = CallingConvention.ThisCall, EntryPoint = "?SetTrampolines@MOS6502X@@QAEXP6AEG@Z0P6AXGE@Z@Z")] [DllImport("MOS6502XNative.dll", CallingConvention = CallingConvention.ThisCall, EntryPoint = "?SetTrampolines@MOS6502X@@QAEXP6AEG@Z0P6AXGE@Z@Z")]
public static extern void SetTrampolines(IntPtr ptr, ReadMemoryD Read, ReadMemoryD DummyRead, WriteMemoryD Write); internal static extern void SetTrampolines(IntPtr ptr, ReadMemoryD Read, ReadMemoryD DummyRead, WriteMemoryD Write);
} }
/// <summary> /// <summary>
@ -213,8 +213,6 @@ namespace BizHawk.Emulation.Common.Components.M6502
DisposeBuilder(h2); DisposeBuilder(h2);
DisposeBuilder(h3); DisposeBuilder(h3);
} }
} }
} }

View File

@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection;
using System.Text; using System.Text;
namespace BizHawk.Emulation.Common namespace BizHawk.Emulation.Common
@ -123,7 +122,7 @@ namespace BizHawk.Emulation.Common
public class InputCallbackSystem public class InputCallbackSystem
{ {
private List<Action> _list = new List<Action>(); private readonly List<Action> _list = new List<Action>();
public void Add(Action action) public void Add(Action action)
{ {
@ -159,14 +158,14 @@ namespace BizHawk.Emulation.Common
public class MemoryCallbackSystem public class MemoryCallbackSystem
{ {
private List<Action> _reads = new List<Action>(); private readonly List<Action> _reads = new List<Action>();
private List<uint?> _readAddrs = new List<uint?>(); private readonly List<uint?> _readAddrs = new List<uint?>();
private List<Action> _writes = new List<Action>(); private readonly List<Action> _writes = new List<Action>();
private List<uint?> _writeAddrs = new List<uint?>(); private readonly List<uint?> _writeAddrs = new List<uint?>();
private List<Action> _executes = new List<Action>(); private readonly List<Action> _executes = new List<Action>();
private List<uint> _execAddrs = new List<uint>(); private readonly List<uint> _execAddrs = new List<uint>();
public void AddRead(Action function, uint? addr) public void AddRead(Action function, uint? addr)
{ {

View File

@ -105,7 +105,7 @@ namespace BizHawk.Emulation.Common
public class MemoryDomainList : ReadOnlyCollection<MemoryDomain> public class MemoryDomainList : ReadOnlyCollection<MemoryDomain>
{ {
private int _mainMemoryIndex = 0; private readonly int _mainMemoryIndex;
public MemoryDomainList(IList<MemoryDomain> domains) public MemoryDomainList(IList<MemoryDomain> domains)
: base(domains) : base(domains)

View File

@ -4,7 +4,6 @@ using System.Globalization;
using System.IO; using System.IO;
using BizHawk.Common; using BizHawk.Common;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Common.Components namespace BizHawk.Emulation.Common.Components
{ {
@ -30,15 +29,15 @@ namespace BizHawk.Emulation.Common.Components
public PSGChannel[] Channels = new PSGChannel[8]; public PSGChannel[] Channels = new PSGChannel[8];
public byte VoiceLatch; public byte VoiceLatch;
byte WaveTableWriteOffset; private byte WaveTableWriteOffset;
Queue<QueuedCommand> commands = new Queue<QueuedCommand>(256); private readonly Queue<QueuedCommand> commands = new Queue<QueuedCommand>(256);
long frameStartTime, frameStopTime; private long frameStartTime, frameStopTime;
const int SampleRate = 44100; const int SampleRate = 44100;
const int PsgBase = 3580000; const int PsgBase = 3580000;
static byte[] LogScale = { 0, 0, 10, 10, 13, 13, 16, 16, 20, 20, 26, 26, 32, 32, 40, 40, 51, 51, 64, 64, 81, 81, 102, 102, 128, 128, 161, 161, 203, 203, 255, 255 }; static readonly byte[] LogScale = { 0, 0, 10, 10, 13, 13, 16, 16, 20, 20, 26, 26, 32, 32, 40, 40, 51, 51, 64, 64, 81, 81, 102, 102, 128, 128, 161, 161, 203, 203, 255, 255 };
static byte[] VolumeReductionTable = { 0x1F, 0x1D, 0x1B, 0x19, 0x17, 0x15, 0x13, 0x10, 0x0F, 0x0D, 0x0B, 0x09, 0x07, 0x05, 0x03, 0x00 }; static readonly byte[] VolumeReductionTable = { 0x1F, 0x1D, 0x1B, 0x19, 0x17, 0x15, 0x13, 0x10, 0x0F, 0x0D, 0x0B, 0x09, 0x07, 0x05, 0x03, 0x00 };
public byte MainVolumeLeft; public byte MainVolumeLeft;
public byte MainVolumeRight; public byte MainVolumeRight;
@ -49,8 +48,10 @@ namespace BizHawk.Emulation.Common.Components
MaxVolume = short.MaxValue; MaxVolume = short.MaxValue;
Waves.InitWaves(); Waves.InitWaves();
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
{
Channels[i] = new PSGChannel(); Channels[i] = new PSGChannel();
} }
}
public void BeginFrame(long cycles) public void BeginFrame(long cycles)
{ {

View File

@ -1,8 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BizHawk.Common; using BizHawk.Common;
namespace BizHawk.Emulation.Common.Components namespace BizHawk.Emulation.Common.Components
@ -12,19 +8,19 @@ namespace BizHawk.Emulation.Common.Components
class Pulse class Pulse
{ {
// regs // regs
int V; private int V;
int T; private int T;
int L; private int L;
int D; private int D;
bool LenCntDisable; private bool LenCntDisable;
bool ConstantVolume; private bool ConstantVolume;
bool Enable; private bool Enable;
// envelope // envelope
bool estart; private bool estart;
int etime; private int etime;
int ecount; private int ecount;
// length // length
static int[] lenlookup = private static readonly int[] lenlookup =
{ {
10,254, 20, 2, 40, 4, 80, 6, 160, 8, 60, 10, 14, 12, 26, 14, 10,254, 20, 2, 40, 4, 80, 6, 160, 8, 60, 10, 14, 12, 26, 14,
12, 16, 24, 18, 48, 20, 96, 22, 192, 24, 72, 26, 16, 28, 32, 30 12, 16, 24, 18, 48, 20, 96, 22, 192, 24, 72, 26, 16, 28, 32, 30
@ -32,18 +28,18 @@ namespace BizHawk.Emulation.Common.Components
int length; int length;
// pulse // pulse
int sequence; private int sequence;
static int[,] sequencelookup = private static readonly int[,] sequencelookup =
{ {
{0,0,0,0,0,0,0,1}, {0,0,0,0,0,0,0,1},
{0,0,0,0,0,0,1,1}, {0,0,0,0,0,0,1,1},
{0,0,0,0,1,1,1,1}, {0,0,0,0,1,1,1,1},
{1,1,1,1,1,1,0,0} {1,1,1,1,1,1,0,0}
}; };
int clock; private int clock;
int output; private int output;
public Action<int> SendDiff; private readonly Action<int> SendDiff;
public Pulse(Action<int> SendDiff) public Pulse(Action<int> SendDiff)
{ {
@ -165,7 +161,7 @@ namespace BizHawk.Emulation.Common.Components
} }
} }
Pulse[] pulse = new Pulse[2]; private readonly Pulse[] pulse = new Pulse[2];
/// <summary> /// <summary>
/// ///
@ -245,15 +241,15 @@ namespace BizHawk.Emulation.Common.Components
RaiseIRQ(PCMEnableIRQ && PCMIRQTriggered); RaiseIRQ(PCMEnableIRQ && PCMIRQTriggered);
} }
Action<bool> RaiseIRQ; private readonly Action<bool> RaiseIRQ;
const int framereload = 7458; // ??? const int framereload = 7458; // ???
int frame = 0; private int frame;
bool PCMRead; private bool PCMRead;
bool PCMEnableIRQ; private bool PCMEnableIRQ;
bool PCMIRQTriggered; private bool PCMIRQTriggered;
byte PCMVal; private byte PCMVal;
byte PCMNextVal; private byte PCMNextVal;
public void SyncState(Serializer ser) public void SyncState(Serializer ser)
{ {
@ -288,14 +284,14 @@ namespace BizHawk.Emulation.Common.Components
} }
if (PCMNextVal != PCMVal) if (PCMNextVal != PCMVal)
{ {
enqueuer(20 * (int)(PCMVal - PCMNextVal)); enqueuer(20 * (PCMVal - PCMNextVal));
PCMVal = PCMNextVal; PCMVal = PCMNextVal;
} }
} }
Action<int> enqueuer; private readonly Action<int> enqueuer;
void PulseAddDiff(int value) private void PulseAddDiff(int value)
{ {
enqueuer(value * 370); enqueuer(value * 370);
//Console.WriteLine(value); //Console.WriteLine(value);

View File

@ -3,8 +3,6 @@ using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
using BizHawk.Emulation.Common;
// TODO the freq->note translation should be moved to a separate utility class. // TODO the freq->note translation should be moved to a separate utility class.
namespace BizHawk.Emulation.Common.Components namespace BizHawk.Emulation.Common.Components
@ -26,7 +24,7 @@ namespace BizHawk.Emulation.Common.Components
public bool Right = true; public bool Right = true;
const int SampleRate = 44100; const int SampleRate = 44100;
static byte[] LogScale = { 0, 10, 13, 16, 20, 26, 32, 40, 51, 64, 81, 102, 128, 161, 203, 255 }; private static readonly byte[] LogScale = { 0, 10, 13, 16, 20, 26, 32, 40, 51, 64, 81, 102, 128, 161, 203, 255 };
public void Mix(short[] samples, int start, int len, int maxVolume) public void Mix(short[] samples, int start, int len, int maxVolume)
{ {
@ -52,7 +50,7 @@ namespace BizHawk.Emulation.Common.Components
public Channel[] Channels = new Channel[4]; public Channel[] Channels = new Channel[4];
public byte PsgLatch; public byte PsgLatch;
Queue<QueuedCommand> commands = new Queue<QueuedCommand>(256); private readonly Queue<QueuedCommand> commands = new Queue<QueuedCommand>(256);
int frameStartTime, frameStopTime; int frameStartTime, frameStopTime;
const int PsgBase = 111861; const int PsgBase = 111861;

View File

@ -1,8 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BizHawk.Common; using BizHawk.Common;
namespace BizHawk.Emulation.Common.Components namespace BizHawk.Emulation.Common.Components
@ -16,15 +12,15 @@ namespace BizHawk.Emulation.Common.Components
{ {
class Pulse class Pulse
{ {
Action<int> SendDiff; private readonly Action<int> SendDiff;
// regs // regs
int Period; private int Period;
bool Disable; private bool Disable;
int Volume; private int Volume;
// state // state
int clock; private int clock;
int sequence; private int sequence;
int output; private int output;
public void SyncState(Serializer ser) public void SyncState(Serializer ser)
{ {
@ -45,7 +41,10 @@ namespace BizHawk.Emulation.Common.Components
{ {
int newout = 1; int newout = 1;
if (!Disable) if (!Disable)
{
newout = sequence; newout = sequence;
}
newout *= Volume; newout *= Volume;
if (newout != output) if (newout != output)
{ {
@ -87,7 +86,7 @@ namespace BizHawk.Emulation.Common.Components
} }
int RegNum; int RegNum;
Pulse[] pulse = new Pulse[3]; readonly Pulse[] pulse = new Pulse[3];
public void RegSelect(byte val) public void RegSelect(byte val)
{ {
@ -132,8 +131,8 @@ namespace BizHawk.Emulation.Common.Components
ser.EndSection(); ser.EndSection();
} }
Action<int> enqueuer; private readonly Action<int> enqueuer;
void PulseAddDiff(int val) private void PulseAddDiff(int val)
{ {
enqueuer(val * 250); enqueuer(val * 250);
} }
@ -142,13 +141,17 @@ namespace BizHawk.Emulation.Common.Components
{ {
this.enqueuer = enqueuer; this.enqueuer = enqueuer;
for (int i = 0; i < pulse.Length; i++) for (int i = 0; i < pulse.Length; i++)
{
pulse[i] = new Pulse(PulseAddDiff); pulse[i] = new Pulse(PulseAddDiff);
} }
}
public void Clock() public void Clock()
{ {
for (int i = 0; i < pulse.Length; i++) foreach (Pulse p in pulse)
pulse[i].Clock(); {
p.Clock();
}
} }
} }
} }

View File

@ -1,7 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace BizHawk.Emulation.Common namespace BizHawk.Emulation.Common
@ -9,7 +6,7 @@ namespace BizHawk.Emulation.Common
/// <summary> /// <summary>
/// wrapper around blargg's unmanaged blip_buf /// wrapper around blargg's unmanaged blip_buf
/// </summary> /// </summary>
public class BlipBuffer : IDisposable public sealed class BlipBuffer : IDisposable
{ {
// this is transitional only. if the band-limited synthesis idea works out, i'll // this is transitional only. if the band-limited synthesis idea works out, i'll
// make a managed MIT implementation // make a managed MIT implementation

View File

@ -1,7 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Common namespace BizHawk.Emulation.Common
{ {
// Generates SEMI-synchronous sound, or "buffered asynchronous" sound. // Generates SEMI-synchronous sound, or "buffered asynchronous" sound.
@ -34,10 +32,10 @@ namespace BizHawk.Emulation.Common
{ {
public ISoundProvider BaseSoundProvider; public ISoundProvider BaseSoundProvider;
Queue<short> buffer = new Queue<short>(4096); readonly Queue<short> buffer = new Queue<short>(4096);
int SamplesInOneFrame = 1470; private int SamplesInOneFrame = 1470;
int TargetExtraSamples = 882; private int TargetExtraSamples = 882;
const int MaxExcessSamples = 4096; const int MaxExcessSamples = 4096;
/// <summary> /// <summary>
@ -72,11 +70,15 @@ namespace BizHawk.Emulation.Common
BaseSoundProvider.GetSamples(mySamples); BaseSoundProvider.GetSamples(mySamples);
for (int i = 0; i < mySamples.Length; i++) foreach (short s in mySamples)
buffer.Enqueue(mySamples[i]); {
buffer.Enqueue(s);
}
for (int i = 0; i < samples.Length; i++) for (int i = 0; i < samples.Length; i++)
{
samples[i] = buffer.Dequeue(); samples[i] = buffer.Dequeue();
} }
} }
} }
}

View File

@ -1,16 +1,11 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Common namespace BizHawk.Emulation.Common
{ {
/// <summary> /// <summary>
/// implements a DC block filter on top of an ISoundProvider. rather simple. /// implements a DC block filter on top of an ISoundProvider. rather simple.
/// </summary> /// </summary>
public class DCFilter : ISoundProvider, ISyncSoundProvider sealed public class DCFilter : ISoundProvider, ISyncSoundProvider
{ {
/* /*
* A note about accuracy: * A note about accuracy:
@ -78,7 +73,7 @@ namespace BizHawk.Emulation.Common
PushThroughSamples(samples, samples, length); PushThroughSamples(samples, samples, length);
} }
void PushThroughSamples(short[] samplesin, short[] samplesout, int length) private void PushThroughSamples(short[] samplesin, short[] samplesout, int length)
{ {
for (int i = 0; i < length; i += 2) for (int i = 0; i < length; i += 2)
{ {

View File

@ -1,9 +1,6 @@
// C# port of C-based 3-band equalizer (C) Neil C / Etanza Systems / 2006 // C# port of C-based 3-band equalizer (C) Neil C / Etanza Systems / 2006
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BizHawk.Emulation.Common namespace BizHawk.Emulation.Common
{ {

View File

@ -1,8 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Common namespace BizHawk.Emulation.Common
{ {
/// <summary> /// <summary>
@ -10,8 +8,8 @@ namespace BizHawk.Emulation.Common
/// </summary> /// </summary>
public class MetaspuAsync : ISoundProvider public class MetaspuAsync : ISoundProvider
{ {
ISynchronizingAudioBuffer buffer; private readonly ISynchronizingAudioBuffer buffer;
ISyncSoundProvider input; private readonly ISyncSoundProvider input;
public MetaspuAsync(ISyncSoundProvider input, ESynchMethod method) public MetaspuAsync(ISyncSoundProvider input, ESynchMethod method)
{ {
buffer = Metaspu.metaspu_construct(method); buffer = Metaspu.metaspu_construct(method);
@ -49,7 +47,7 @@ namespace BizHawk.Emulation.Common
{ {
} }
short[] pullBuffer = new short[1470]; private readonly short[] pullBuffer = new short[1470];
public void PullSamples(ISoundProvider source) public void PullSamples(ISoundProvider source)
{ {
Array.Clear(pullBuffer, 0, 1470); Array.Clear(pullBuffer, 0, 1470);
@ -124,7 +122,7 @@ namespace BizHawk.Emulation.Common
} }
//adjustobuf(200,1000) //adjustobuf(200,1000)
bool mixqueue_go = false; bool mixqueue_go;
public void clear() public void clear()
{ {
@ -177,7 +175,7 @@ namespace BizHawk.Emulation.Common
return done; return done;
} }
Adjustobuf adjustobuf; private readonly Adjustobuf adjustobuf;
class Adjustobuf class Adjustobuf
{ {
public Adjustobuf(int _minLatency, int _maxLatency) public Adjustobuf(int _minLatency, int _maxLatency)

View File

@ -1,5 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Common namespace BizHawk.Emulation.Common
{ {
@ -7,7 +6,7 @@ namespace BizHawk.Emulation.Common
public sealed class SoundMixer : ISoundProvider public sealed class SoundMixer : ISoundProvider
{ {
List<ISoundProvider> SoundProviders; private readonly List<ISoundProvider> SoundProviders;
public SoundMixer(params ISoundProvider[] soundProviders) public SoundMixer(params ISoundProvider[] soundProviders)
{ {
@ -41,8 +40,10 @@ namespace BizHawk.Emulation.Common
{ {
int eachVolume = short.MaxValue / SoundProviders.Count; int eachVolume = short.MaxValue / SoundProviders.Count;
foreach (var source in SoundProviders) foreach (var source in SoundProviders)
{
source.MaxVolume = eachVolume; source.MaxVolume = eachVolume;
} }
}
// Not actually supported on mixer. // Not actually supported on mixer.
public int MaxVolume { get; set; } public int MaxVolume { get; set; }

View File

@ -1,11 +1,6 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Common namespace BizHawk.Emulation.Common
{ {
/// <summary> /// <summary>
@ -259,29 +254,29 @@ namespace BizHawk.Emulation.Common
/// <summary> /// <summary>
/// opaque pointer to state /// opaque pointer to state
/// </summary> /// </summary>
IntPtr st = IntPtr.Zero; private IntPtr st = IntPtr.Zero;
/// <summary> /// <summary>
/// function to call to dispatch output /// function to call to dispatch output
/// </summary> /// </summary>
Action<short[], int> drainer; private readonly Action<short[], int> drainer;
// TODO: this size is roughly based on how big you can make the buffer before the snes resampling (32040.5 -> 44100) gets screwed up // TODO: this size is roughly based on how big you can make the buffer before the snes resampling (32040.5 -> 44100) gets screwed up
short[] inbuf = new short[512]; //[8192]; // [512]; private short[] inbuf = new short[512]; //[8192]; // [512];
short[] outbuf; private short[] outbuf;
// for ISyncSoundProvider // for ISyncSoundProvider
short[] outbuf2 = new short[16]; private short[] outbuf2 = new short[16];
int outbuf2pos = 0; private int outbuf2pos = 0;
// to accept an ISyncSoundProvder input // to accept an ISyncSoundProvder input
ISyncSoundProvider input; private readonly ISyncSoundProvider input;
/// <summary> /// <summary>
/// in buffer position in samples (not sample pairs) /// in buffer position in samples (not sample pairs)
/// </summary> /// </summary>
int inbufpos = 0; private int inbufpos = 0;
/// <summary> /// <summary>
/// throw an exception based on error state /// throw an exception based on error state
@ -327,10 +322,7 @@ namespace BizHawk.Emulation.Common
if (drainer != null && input != null) if (drainer != null && input != null)
throw new ArgumentException("Can't autofetch without being an ISyncSoundProvider?"); throw new ArgumentException("Can't autofetch without being an ISyncSoundProvider?");
if (drainer != null) this.drainer = drainer ?? InternalDrain;
this.drainer = drainer;
else
this.drainer = InternalDrain;
this.input = input; this.input = input;
outbuf = new short[inbuf.Length * ratioden / rationum / 2 * 2 + 128]; outbuf = new short[inbuf.Length * ratioden / rationum / 2 * 2 + 128];

View File

@ -1,8 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BizHawk.Common; using BizHawk.Common;
namespace BizHawk.Emulation.Common.Components namespace BizHawk.Emulation.Common.Components

View File

@ -7,7 +7,6 @@
using System; using System;
using BizHawk.Common; using BizHawk.Common;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Common.Components namespace BizHawk.Emulation.Common.Components
{ {

View File

@ -1,10 +1,7 @@
using System; using System;
using System.Diagnostics;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Common.Components namespace BizHawk.Emulation.Common.Components
{ {
// ====================================================================== // ======================================================================
@ -81,7 +78,7 @@ namespace BizHawk.Emulation.Common.Components
bool DacEnable; bool DacEnable;
byte DacValue; byte DacValue;
Queue<QueuedCommand> commands = new Queue<QueuedCommand>(); readonly Queue<QueuedCommand> commands = new Queue<QueuedCommand>();
const int Slot1 = 0; const int Slot1 = 0;
const int Slot2 = 2; const int Slot2 = 2;
@ -752,7 +749,9 @@ namespace BizHawk.Emulation.Common.Components
if (op.SL_SustainLevel == 0) // If Sustain Level is 0, we skip Decay and go straight to Sustain phase. if (op.SL_SustainLevel == 0) // If Sustain Level is 0, we skip Decay and go straight to Sustain phase.
op.EnvelopeState = EnvelopeState.Sustain; op.EnvelopeState = EnvelopeState.Sustain;
} else { }
else
{
// Regular Key-On // Regular Key-On
op.EnvelopeState = EnvelopeState.Attack; op.EnvelopeState = EnvelopeState.Attack;