This commit is contained in:
adelikat 2017-04-27 12:01:37 -05:00
parent 8eb9d68fa6
commit 0765b559a1
1 changed files with 37 additions and 37 deletions

View File

@ -50,7 +50,7 @@ namespace BizHawk.Emulation.Common
} }
_frameBufferClear = true; _frameBufferClear = true;
Array.Clear(FrameBuffer, 0, 256 * 192); Array.Clear(_frameBuffer, 0, 256 * 192);
return; return;
} }
@ -59,15 +59,15 @@ namespace BizHawk.Emulation.Common
{ {
for (int i = 0; i < 256 * 192; i++) for (int i = 0; i < 256 * 192; i++)
{ {
byte b = (byte)Rand.Next(); byte b = (byte)_rand.Next();
FrameBuffer[i] = Colors.ARGB(b, (byte)(255 - b), 0, 255); _frameBuffer[i] = Colors.ARGB(b, (byte)(255 - b), 0, 255);
} }
} }
else else
{ {
for (int i = 0; i < 256 * 192; i++) for (int i = 0; i < 256 * 192; i++)
{ {
FrameBuffer[i] = Colors.Luminosity((byte)Rand.Next()); _frameBuffer[i] = Colors.Luminosity((byte)_rand.Next());
} }
} }
@ -99,7 +99,7 @@ namespace BizHawk.Emulation.Common
public int[] GetVideoBuffer() public int[] GetVideoBuffer()
{ {
return FrameBuffer; return _frameBuffer;
} }
public int VirtualWidth => 256; public int VirtualWidth => 256;
@ -124,7 +124,7 @@ namespace BizHawk.Emulation.Common
} }
nsamp = 735; nsamp = 735;
samples = SampleBuffer; samples = _sampleBuffer;
if (!_settings.SnowyDisplay) if (!_settings.SnowyDisplay)
{ {
return; return;
@ -194,9 +194,9 @@ namespace BizHawk.Emulation.Common
#endregion #endregion
private readonly int[] FrameBuffer = new int[256 * 192]; private readonly int[] _frameBuffer = new int[256 * 192];
private readonly short[] SampleBuffer = new short[735 * 2]; private readonly short[] _sampleBuffer = new short[735 * 2];
private readonly Random Rand = new Random(); private readonly Random _rand = new Random();
private bool _frameBufferClear = true; private bool _frameBufferClear = true;
@ -256,11 +256,10 @@ namespace BizHawk.Emulation.Common
private int _sample2; private int _sample2;
private int _delta; private int _delta;
private int _idx = 0; private int _idx;
private bool _top = false; private bool _top;
private int _samplectr = 0;
private int _samplectr;
public short Next() public short Next()
{ {
@ -340,8 +339,8 @@ namespace BizHawk.Emulation.Common
private readonly List<string> _lines = new List<string>(); private readonly List<string> _lines = new List<string>();
private readonly Bell _bell = new Bell(); private readonly Bell _bell = new Bell();
private int _lineIdx = 0; private int _lineIdx;
private int _deadtime = 0; private int _deadtime;
public Pleg() public Pleg()
{ {
@ -360,9 +359,9 @@ namespace BizHawk.Emulation.Common
{ {
foreach (var s in _sinMen) foreach (var s in _sinMen)
{ {
if (s.c == c && s.n == n && !s.fading) if (s.C == c && s.N == n && !s.Fading)
{ {
s.fading = true; s.Fading = true;
} }
} }
} }
@ -374,7 +373,7 @@ namespace BizHawk.Emulation.Common
return; return;
} }
var s = new SinMan(1500, n) { c = c, n = n }; var s = new SinMan(1500, n) { C = c, N = n };
_sinMen.Add(s); _sinMen.Add(s);
} }
@ -456,16 +455,23 @@ namespace BizHawk.Emulation.Common
internal class SinMan internal class SinMan
{ {
public int c; private readonly double _freq;
public int n;
double theta; private double _theta;
double freq; private double _amp;
double amp;
public bool fading = false; public SinMan(int amp, int note)
{
_amp = amp;
_freq = GetFreq(note);
}
public bool Done => amp < 2.0; public int C { get; set; }
public int N { get; set; }
public bool Fading { get; set; }
public bool Done => _amp < 2.0;
private static double GetFreq(int note) private static double GetFreq(int note)
{ {
@ -474,26 +480,20 @@ namespace BizHawk.Emulation.Common
public short Next() public short Next()
{ {
short result = (short)(Math.Sin(theta) * amp); short result = (short)(Math.Sin(_theta) * _amp);
theta += freq * Math.PI / 22050.0; _theta += _freq * Math.PI / 22050.0;
if (theta >= Math.PI * 2.0) if (_theta >= Math.PI * 2.0)
{ {
theta -= Math.PI * 2.0; _theta -= Math.PI * 2.0;
} }
if (fading) if (Fading)
{ {
amp *= 0.87; _amp *= 0.87;
} }
return result; return result;
} }
public SinMan(int amp, int note)
{
this.amp = amp;
this.freq = GetFreq(note);
}
} }
#endregion #endregion