7800: remove BufferElement because it annoys me. (Also gains a small speed increase, ~4%?). Remove "Copyright © Microsoft 2012" from the default AssemblyInfo.cs

This commit is contained in:
goyuken 2012-12-16 16:57:16 +00:00
parent f8c9bd98f9
commit 17f0f66ed7
13 changed files with 55 additions and 46 deletions

View File

@ -274,13 +274,13 @@ namespace BizHawk.Emulation
{
unsafe
{
fixed (BufferElement* src_ = framebuffer.VideoBuffer)
fixed (byte* src_ = framebuffer.VideoBuffer)
{
fixed (int* dst_ = vidbuffer)
{
fixed (int* pal = TIATables.NTSCPalette)
{
byte* src = (byte*)src_;
byte* src = src_;
int* dst = dst_;
for (int i = 0; i < vidbuffer.Length; i++)
{
@ -307,9 +307,8 @@ namespace BizHawk.Emulation
int nsampin = framebuffer.SoundBufferByteLength;
unsafe
{
fixed (BufferElement* src_ = framebuffer.SoundBuffer)
fixed (byte* src = framebuffer.SoundBuffer)
{
byte* src = (byte*)src_;
for (int i = 0; i < nsampin; i++)
{
// the buffer values don't really get very large at all,

View File

@ -1,5 +1,20 @@
namespace EMU7800.Core
{
/*
* why this sucks:
* A read costs 3 shifts and an or. A write costs 2 shifts. Additional shifts are
* needed elsewhere to figure out which item in a BufferElement[] to access. Because
* the encapsulation is for a BufferElement and not a whole array of them, code elsewhere
* is gunked up with 'BufferElement.SIZE' shifts. If the 32 bit "alias" was actually used,
* there might be some purpose to this code: but it's only used for a ZeroMemory()
* replacement. Every use of BufferElement in the code is a BufferElement[] used as a gunked
* up replacement for a byte[].
*
* A small speed increase was observed hacking this out; but my motivation was more about cleaness
* and stomping out bad ideas.
*/
/*
/// <summary>
/// Frames are composed of <see cref="BufferElement"/>s,
/// that group bytes into machine words for efficient array processing.
@ -52,4 +67,5 @@
_data = 0;
}
}
*/
}

View File

@ -55,6 +55,7 @@ namespace EMU7800.Core
return _binaryReader.ReadDouble();
}
/*
public BufferElement ReadBufferElement()
{
var be = new BufferElement();
@ -62,6 +63,7 @@ namespace EMU7800.Core
be[i] = ReadByte();
return be;
}
*/
public byte[] ReadBytes()
{

View File

@ -93,7 +93,7 @@ namespace EMU7800.Core
{
pos += frameBuffer.VideoBufferByteLength;
}
frameBuffer.VideoBuffer[pos >> BufferElement.SHIFT][pos++] = back;
frameBuffer.VideoBuffer[pos++] = back;
}
}
}
@ -160,7 +160,7 @@ namespace EMU7800.Core
}
if (((fdata >> j) & 1) != 0)
{
frameBuffer.VideoBuffer[pos >> BufferElement.SHIFT][pos] = fore;
frameBuffer.VideoBuffer[pos] = fore;
}
}
xoffset += 5;

View File

@ -12,7 +12,7 @@ namespace EMU7800.Core
/// <summary>
/// Number of <see cref="BufferElement"/>s that represent <c>VisiblePitch</c>.
/// </summary>
public int VideoBufferElementVisiblePitch { get; private set; }
//public int VideoBufferElementVisiblePitch { get; private set; }
/// <summary>
/// Number of visible scan lines.
@ -27,7 +27,7 @@ namespace EMU7800.Core
/// <summary>
/// The number of <see cref="BufferElement"/>s contained by <c>VideoBuffer</c>
/// </summary>
public int VideoBufferElementLength { get; private set; }
//public int VideoBufferElementLength { get; private set; }
/// <summary>
/// The number of bytes contained by <c>SoundBuffer</c>.
@ -37,17 +37,17 @@ namespace EMU7800.Core
/// <summary>
/// The number of <see cref="BufferElement"/>s contained by <c>SoundBuffer</c>
/// </summary>
public int SoundBufferElementLength { get; private set; }
//public int SoundBufferElementLength { get; private set; }
/// <summary>
/// The buffer containing computed pixel data.
/// </summary>
public BufferElement[] VideoBuffer { get; private set; }
public byte[] VideoBuffer { get; private set; }
/// <summary>
/// The buffer containing computed PCM audio data.
/// </summary>
public BufferElement[] SoundBuffer { get; private set; }
public byte[] SoundBuffer { get; private set; }
#region Constructors
@ -63,15 +63,15 @@ namespace EMU7800.Core
throw new ArgumentException("scanLines must be non-negative.");
VisiblePitch = visiblePitch;
VideoBufferElementVisiblePitch = VisiblePitch >> BufferElement.SHIFT;
//VideoBufferElementVisiblePitch = VisiblePitch >> BufferElement.SHIFT;
Scanlines = scanLines;
VideoBufferByteLength = VisiblePitch * Scanlines;
VideoBufferElementLength = VideoBufferElementVisiblePitch * Scanlines;
//VideoBufferElementLength = VideoBufferElementVisiblePitch * Scanlines;
SoundBufferByteLength = Scanlines << 1;
SoundBufferElementLength = SoundBufferByteLength >> BufferElement.SHIFT;
//SoundBufferElementLength = SoundBufferByteLength >> BufferElement.SHIFT;
VideoBuffer = new BufferElement[VideoBufferElementLength + (64 >> BufferElement.SHIFT)];
SoundBuffer = new BufferElement[SoundBufferElementLength + (64 >> BufferElement.SHIFT)];
VideoBuffer = new byte[VideoBufferByteLength + 64];
SoundBuffer = new byte[SoundBufferByteLength + 64];
}
#endregion

View File

@ -220,8 +220,8 @@ namespace EMU7800.Core
_FrameBuffer = frameBuffer;
FrameNumber++;
for (var i = 0; i < _FrameBuffer.SoundBufferElementLength; i++)
_FrameBuffer.SoundBuffer[i].ClearAll();
for (var i = 0; i < _FrameBuffer.SoundBufferByteLength; i++)
_FrameBuffer.SoundBuffer[i] = 0;
}
/// <summary>

View File

@ -731,19 +731,14 @@ namespace EMU7800.Core
void OutputLineRAM()
{
var bufferElement = new BufferElement();
var fbi = ((Scanline + 1) * M.FrameBuffer.VideoBufferElementVisiblePitch) % M.FrameBuffer.VideoBufferElementLength;
var fbi = ((Scanline + 1) * M.FrameBuffer.VisiblePitch) % M.FrameBuffer.VideoBufferByteLength;
for (int i = 0, s = 0; i < M.FrameBuffer.VideoBufferElementVisiblePitch; i++)
for (int i = 0; i < M.FrameBuffer.VisiblePitch; i++)
{
for (var j = 0; j < BufferElement.SIZE; j++, s++)
{
var colorIndex = LineRAM[s];
bufferElement[j] = Registers[BACKGRND + ((colorIndex & 3) == 0 ? 0 : colorIndex)];
}
M.FrameBuffer.VideoBuffer[fbi] = bufferElement;
if (++fbi == M.FrameBuffer.VideoBufferElementLength)
fbi = 0;
var colorIndex = LineRAM[i];
M.FrameBuffer.VideoBuffer[fbi++] = Registers[BACKGRND + ((colorIndex & 3) == 0 ? 0 : colorIndex)];
if (fbi == M.FrameBuffer.VideoBufferByteLength)
fbi = 0;
}
for (var i = 0; i < LineRAM.Length; i++)

View File

@ -314,7 +314,7 @@ namespace EMU7800.Core
for (var ch = 0; ch < 4; ch++)
sample += _outvol[ch];
M.FrameBuffer.SoundBuffer[_bufferIndex >> BufferElement.SHIFT][_bufferIndex++] += sample;
M.FrameBuffer.SoundBuffer[_bufferIndex++] += sample;
count--;
continue;

View File

@ -54,11 +54,13 @@ namespace EMU7800.Core
_binaryWriter.Write(value);
}
/*
public void Write(BufferElement bufferElement)
{
for (var i = 0; i < BufferElement.SIZE; i++)
Write(bufferElement[i]);
}
*/
public void Write(byte[] bytes)
{

View File

@ -162,7 +162,7 @@ namespace EMU7800.Core
int FrameBufferIndex;
// bytes are batched here for writing to the FrameBuffer
BufferElement FrameBufferElement;
//BufferElement FrameBufferElement;
// signals when to start an HMOVE
ulong StartHMOVEClock;
@ -505,14 +505,9 @@ namespace EMU7800.Core
if (HSync >= 68)
{
var i = FrameBufferIndex++;
FrameBufferElement[i] = fbyte;
if ((i & BufferElement.MASK) == BufferElement.MASK)
{
M.FrameBuffer.VideoBuffer[i >> BufferElement.SHIFT] = FrameBufferElement;
if (FrameBufferIndex == M.FrameBuffer.VideoBufferByteLength)
FrameBufferIndex = 0;
}
M.FrameBuffer.VideoBuffer[FrameBufferIndex++] = fbyte;
if (FrameBufferIndex == M.FrameBuffer.VideoBufferByteLength)
FrameBufferIndex = 0;
if (HSync == 227)
ScanLine++;
}
@ -1218,13 +1213,13 @@ namespace EMU7800.Core
M = m;
TIASound = input.ReadTIASound(M, CPU_TICKS_PER_AUDIO_SAMPLE);
input.CheckVersion(1);
input.CheckVersion(2);
RegW = input.ReadExpectedBytes(0x40);
HSync = input.ReadInt32();
HMoveCounter = input.ReadInt32();
ScanLine = input.ReadInt32();
FrameBufferIndex = input.ReadInt32();
FrameBufferElement = input.ReadBufferElement();
//FrameBufferElement = input.ReadBufferElement();
StartHMOVEClock = input.ReadUInt64();
HMoveLatch = input.ReadBoolean();
StartClock = input.ReadUInt64();
@ -1278,13 +1273,13 @@ namespace EMU7800.Core
output.Write(TIASound);
output.WriteVersion(1);
output.WriteVersion(2);
output.Write(RegW);
output.Write(HSync);
output.Write(HMoveCounter);
output.Write(ScanLine);
output.Write(FrameBufferIndex);
output.Write(FrameBufferElement);
//output.Write(FrameBufferElement);
output.Write(StartHMOVEClock);
output.Write(HMoveLatch);
output.Write(StartClock);

View File

@ -309,7 +309,7 @@ namespace EMU7800.Core
ProcessChannel(1);
}
M.FrameBuffer.SoundBuffer[BufferIndex >> BufferElement.SHIFT][BufferIndex] += (byte)(OutputVol[0] + OutputVol[1]);
M.FrameBuffer.SoundBuffer[BufferIndex] += (byte)(OutputVol[0] + OutputVol[1]);
}
}

View File

@ -8,9 +8,9 @@ using System.Runtime.InteropServices;
[assembly: AssemblyTitle("EMU7800")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("EMU7800")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2012")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]