namespace VirtualNes.Core
{
public struct RAMSTAT : IStateBufferObject
{
/// Internal NES RAM
public byte[] RAM;
/// BG Palette
public byte[] BGPAL;
/// SP Palette
public byte[] SPPAL;
/// Sprite RAM
public byte[] SPRAM;
public static RAMSTAT GetDefault()
{
var res = new RAMSTAT();
res.RAM = new byte[2 * 1024];
res.BGPAL = new byte[16];
res.SPPAL = new byte[16];
res.SPRAM = new byte[256];
return res;
}
public uint GetSize()
{
return (uint)(RAM.Length + BGPAL.Length + SPPAL.Length + SPRAM.Length);
}
public void SaveState(StateBuffer buffer)
{
buffer.Write(RAM);
buffer.Write(BGPAL);
buffer.Write(SPPAL);
buffer.Write(SPRAM);
}
public void LoadState(StateReader buffer)
{
RAM = buffer.Read_bytes(2 * 1024);
BGPAL = buffer.Read_bytes(16);
SPPAL = buffer.Read_bytes(16);
SPRAM = buffer.Read_bytes(256);
}
}
}