namespace EMU7800.Core
{
///
/// Frames are composed of s,
/// that group bytes into machine words for efficient array processing.
/// Bytes are packed in logical little endian order.
///
public struct BufferElement
{
///
/// The number of bytes contained within a .
///
public const int SIZE = 4; // 2^SHIFT
///
/// The mask value applied against a byte array index to access the individual bytes within a .
///
public const int MASK = 3; // SIZE - 1
///
/// The left shift value to convert a byte array index to a array index.
///
public const int SHIFT = 2;
uint _data;
///
/// A convenience accessor for reading/writing individual bytes within this .
///
///
public byte this[int offset]
{
get
{
var i = (offset & MASK) << 3;
return (byte)(_data >> i);
}
set
{
var i = (offset & MASK) << 3;
var d = (uint)value << i;
var di = (uint)0xff << i;
_data = _data & ~di | d;
}
}
///
/// Zeros out all bytes of this .
///
public void ClearAll()
{
_data = 0;
}
}
}